From 8cebd782b2e2d0c79539c04498d824d8ba60615c Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Fri, 15 Aug 2014 10:54:28 -0600 Subject: [PATCH] Add patch to fix tests --- fail2ban-tests.patch | 41 +++++++++++++++++++++++++++++++++++++++++ fail2ban.spec | 9 ++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 fail2ban-tests.patch diff --git a/fail2ban-tests.patch b/fail2ban-tests.patch new file mode 100644 index 0000000..b4dc47a --- /dev/null +++ b/fail2ban-tests.patch @@ -0,0 +1,41 @@ +commit b2a1032f5738575f1c368360ba93fc7da5991225 +Author: Yaroslav Halchenko +Date: Tue Aug 12 11:31:42 2014 -0400 + + ENH/BF(TST): making permissions restrictive is not sufficient -- really remove file to test + +diff --git a/fail2ban/tests/filtertestcase.py b/fail2ban/tests/filtertestcase.py +index c02e861..1fa3116 100644 +--- a/fail2ban/tests/filtertestcase.py ++++ b/fail2ban/tests/filtertestcase.py +@@ -24,6 +24,7 @@ __license__ = "GPL" + + from __builtin__ import open as fopen + import unittest ++import getpass + import os + import sys + import time +@@ -349,10 +350,20 @@ class LogFileMonitor(LogCaptureTestCase): + # shorter wait time for not modified status + return not self.isModified(0.4) + +- def testNoLogFile(self): ++ def testUnaccessibleLogFile(self): + os.chmod(self.name, 0) + self.filter.getFailures(self.name) +- self.assertTrue(self._is_logged('Unable to open %s' % self.name)) ++ failure_was_logged = self._is_logged('Unable to open %s' % self.name) ++ is_root = getpass.getuser() == 'root' ++ # If ran as root, those restrictive permissions would not ++ # forbid log to be read. ++ self.assertTrue(failure_was_logged != is_root) ++ ++ def testNoLogFile(self): ++ _killfile(self.file, self.name) ++ self.filter.getFailures(self.name) ++ failure_was_logged = self._is_logged('Unable to open %s' % self.name) ++ self.assertTrue(failure_was_logged) + + def testRemovingFailRegex(self): + self.filter.delFailRegex(0) diff --git a/fail2ban.spec b/fail2ban.spec index 2f5c67e..6d58c3a 100644 --- a/fail2ban.spec +++ b/fail2ban.spec @@ -1,7 +1,7 @@ Summary: Daemon to ban hosts that cause multiple authentication errors Name: fail2ban Version: 0.9 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv2+ URL: http://fail2ban.sourceforge.net/ Source0: https://github.com/%{name}/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz @@ -18,6 +18,9 @@ Patch2: fail2ban-tests-syslog.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1128152 # https://github.com/fail2ban/fail2ban/pull/780 Patch3: fail2ban-logpath.patch +# Fix test failure +# https://github.com/fail2ban/fail2ban/pull/784 +Patch4: fail2ban-tests.patch BuildRequires: python2-devel # For testcases @@ -153,6 +156,7 @@ by default. %patch1 -p1 -b .tests-nonet %patch2 -p1 -b .tests-syslog %patch3 -p1 -b .logpath +%patch4 -p1 -b .tests # Use Fedora paths sed -i -e 's/^before = paths-.*/before = paths-fedora.conf/' config/jail.conf # Start after firewalld (https://bugzilla.redhat.com/show_bug.cgi?id=1067147) @@ -279,6 +283,9 @@ fi %changelog +* Fri Aug 15 2014 Orion Poplawski - 0.9-8 +- Add patch to fix tests + * Fri Aug 8 2014 Orion Poplawski - 0.9-8 - Fix log paths for some jails (bug #1128152)