Add patch to fix failing test

i9ce
Orion Poplawski 8 years ago
parent f918a8706c
commit c12a4ed538

@ -0,0 +1,60 @@
From c49fe12f701807a8d89bfe57c9f7f492375a0a53 Mon Sep 17 00:00:00 2001
From: sebres <serg.brester@sebres.de>
Date: Mon, 15 Aug 2016 12:53:40 +0200
Subject: [PATCH] fix fail2banregextestcase using setUpMyTime/tearDownMyTime:
always use correct static time as base-time (using mock up MyTime), correct
datetimes inside test
---
fail2ban/tests/fail2banregextestcase.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fail2ban/tests/fail2banregextestcase.py b/fail2ban/tests/fail2banregextestcase.py
index 3321ffd..1119efd 100644
--- a/fail2ban/tests/fail2banregextestcase.py
+++ b/fail2ban/tests/fail2banregextestcase.py
@@ -39,7 +39,7 @@
from ..client import fail2banregex
from ..client.fail2banregex import Fail2banRegex, get_opt_parser, output
-from .utils import LogCaptureTestCase, logSys
+from .utils import setUpMyTime, tearDownMyTime, LogCaptureTestCase, logSys
from .utils import CONFIG_DIR
@@ -70,10 +70,12 @@ class Fail2banRegexTest(LogCaptureTestCase):
def setUp(self):
"""Call before every test case."""
LogCaptureTestCase.setUp(self)
+ setUpMyTime()
def tearDown(self):
"""Call after every test case."""
LogCaptureTestCase.tearDown(self)
+ tearDownMyTime()
def testWrongRE(self):
(opts, args, fail2banRegex) = _Fail2banRegex(
@@ -159,8 +161,8 @@ def testVerbose(self):
self.assertTrue(fail2banRegex.start(opts, args))
self.assertLogged('Lines: 13 lines, 0 ignored, 5 matched, 8 missed')
- self.assertLogged('141.3.81.106 Fri Aug 14 11:53:59 2015')
- self.assertLogged('141.3.81.106 Fri Aug 14 11:54:59 2015')
+ self.assertLogged('141.3.81.106 Sun Aug 14 11:53:59 2005')
+ self.assertLogged('141.3.81.106 Sun Aug 14 11:54:59 2005')
def testWronChar(self):
(opts, args, fail2banRegex) = _Fail2banRegex(
@@ -169,9 +171,8 @@ def testWronChar(self):
self.assertTrue(fail2banRegex.start(opts, args))
self.assertLogged('Lines: 4 lines, 0 ignored, 2 matched, 2 missed')
- self.assertLogged('Error decoding line');
- self.assertLogged('Continuing to process line ignoring invalid characters:', '2015-01-14 20:00:58 user ');
- self.assertLogged('Continuing to process line ignoring invalid characters:', '2015-01-14 20:00:59 user ');
+ self.assertLogged('Error decoding line')
+ self.assertLogged('Continuing to process line ignoring invalid characters:')
self.assertLogged('Nov 8 00:16:12 main sshd[32548]: input_userauth_request: invalid user llinco')
self.assertLogged('Nov 8 00:16:12 main sshd[32547]: pam_succeed_if(sshd:auth): error retrieving information about user llinco')

@ -9,6 +9,9 @@ Source0: https://github.com/%{name}/%{name}/archive/%{version}.tar.gz#/%{name}-%
# Fix failing test
# https://github.com/fail2ban/fail2ban/issues/1353
Patch0: fail2ban-test.patch
# Upstream patch to fix failing tests
# https://github.com/fail2ban/fail2ban/commit/c49fe12f701807a8d89bfe57c9f7f492375a0a53
Patch1: https://github.com/fail2ban/fail2ban/commit/c49fe12f701807a8d89bfe57c9f7f492375a0a53.patch
BuildRequires: python3-devel
# For 2to3
@ -146,6 +149,7 @@ by default.
%prep
%setup -q
%patch0 -p1 -b .test
%patch1 -p1
# Use Fedora paths
sed -i -e 's/^before = paths-.*/before = paths-fedora.conf/' config/jail.conf
2to3 --write --nobackups .
@ -275,6 +279,9 @@ fi
%changelog
* Mon Oct 3 2016 Orion Poplawski <orion@cora.nwra.com> - 0.9.5-1
- Add patch to fix failing test
* Sun Sep 25 2016 Orion Poplawski <orion@cora.nwra.com> - 0.9.5-1
- Update to 0.9.5
- Drop mysql patch applied upstream

Loading…
Cancel
Save