diff options
author | Yaroslav Halchenko <debian@onerussian.com> | 2011-10-07 15:25:11 -0400 |
---|---|---|
committer | Yaroslav Halchenko <debian@onerussian.com> | 2011-10-07 15:49:47 -0400 |
commit | 344effb4374b70c20cb07027569966718e30a75f (patch) | |
tree | 53096b46f1508c47afc2e5b1c3b72c51e1ca9bc0 | |
parent | de8786dd1d81a9d42cef56f0c7a23d5f140c8e7e (diff) | |
download | fail2ban-344effb4374b70c20cb07027569966718e30a75f.tar.gz |
ENH: minor unittest to see if tickets carry correct 'matches'
-rw-r--r-- | testcases/filtertestcase.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/testcases/filtertestcase.py b/testcases/filtertestcase.py index 273dc8aa..f18cb278 100644 --- a/testcases/filtertestcase.py +++ b/testcases/filtertestcase.py @@ -110,9 +110,13 @@ class GetFailures(unittest.TestCase): time.localtime(found[2]),\ time.localtime(output[2]) self.assertEqual(found_time, output_time) + if len(found) > 3: # match matches + self.assertEqual(found[3], output[3]) + def testGetFailures01(self): - output = ('193.168.0.128', 3, 1124013599.0) + output = ('193.168.0.128', 3, 1124013599.0, + ['Aug 14 11:59:59 [sshd] error: PAM: Authentication failure for kevin from 193.168.0.128\n']*3) self.__filter.addLogPath(GetFailures.FILENAME_01) self.__filter.addFailRegex("(?:(?:Authentication failure|Failed [-/\w+]+) for(?: [iI](?:llegal|nvalid) user)?|[Ii](?:llegal|nvalid) user|ROOT LOGIN REFUSED) .*(?: from|FROM) <HOST>") @@ -124,12 +128,15 @@ class GetFailures(unittest.TestCase): attempts = ticket.getAttempt() date = ticket.getTime() ip = ticket.getIP() - found = (ip, attempts, date) + matches = ticket.getMatches() + found = (ip, attempts, date, matches) self._assertEqualEntries(found, output) def testGetFailures02(self): - output = ('141.3.81.106', 4, 1124013539.0) + output = ('141.3.81.106', 4, 1124013539.0, + ['Aug 14 11:%d:59 i60p295 sshd[12365]: Failed publickey for roehl from ::ffff:141.3.81.106 port 51332 ssh2\n' + % m for m in 53, 54, 57, 58]) self.__filter.addLogPath(GetFailures.FILENAME_02) self.__filter.addFailRegex("Failed .* from <HOST>") @@ -141,7 +148,8 @@ class GetFailures(unittest.TestCase): attempts = ticket.getAttempt() date = ticket.getTime() ip = ticket.getIP() - found = (ip, attempts, date) + matches = ticket.getMatches() + found = (ip, attempts, date, matches) self._assertEqualEntries(found, output) |