From 344effb4374b70c20cb07027569966718e30a75f Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 7 Oct 2011 15:25:11 -0400 Subject: [PATCH] ENH: minor unittest to see if tickets carry correct 'matches' --- testcases/filtertestcase.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/testcases/filtertestcase.py b/testcases/filtertestcase.py index 273dc8aad..f18cb2783 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) ") @@ -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 ") @@ -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)