commit
e2fc2a5023
@ -0,0 +1,41 @@
|
|||||||
|
commit b2a1032f5738575f1c368360ba93fc7da5991225
|
||||||
|
Author: Yaroslav Halchenko <debian@onerussian.com>
|
||||||
|
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)
|
Loading…
Reference in new issue