diff --git a/fail2ban/tests/files/logs/sshd b/fail2ban/tests/files/logs/sshd index f465c9a7..fb3defea 100644 --- a/fail2ban/tests/files/logs/sshd +++ b/fail2ban/tests/files/logs/sshd @@ -239,5 +239,5 @@ Nov 26 13:03:30 srv sshd[45]: fatal: Unable to negotiate with 192.0.2.2 port 554 Nov 26 15:03:30 host sshd[22440]: Connection from 192.0.2.3 port 39678 on 192.168.1.9 port 22 # failJSON: { "time": "2004-11-26T15:03:31", "match": true , "host": "192.0.2.3", "desc": "Multiline - no matching key exchange method" } Nov 26 15:03:31 host sshd[22440]: fatal: Unable to negotiate a key exchange method [preauth] -# failJSON: { "time": "2004-11-26T15:03:32", "match": true , "host": "192.0.2.3", "desc": "Second attempt within the same connect" } -Nov 26 15:03:32 host sshd[22440]: fatal: Unable to negotiate a key exchange method [preauth] \ No newline at end of file +# failJSON: { "time": "2004-11-26T15:03:32", "match": true , "host": "192.0.2.3", "filter": "sshd", "desc": "Second attempt within the same connect" } +Nov 26 15:03:32 host sshd[22440]: fatal: Unable to negotiate a key exchange method [preauth] diff --git a/fail2ban/tests/samplestestcase.py b/fail2ban/tests/samplestestcase.py index 5c45e729..0ba11c2e 100644 --- a/fail2ban/tests/samplestestcase.py +++ b/fail2ban/tests/samplestestcase.py @@ -182,6 +182,9 @@ def testSampleRegexsFactory(name, basedir): try: ret = self.filter.processLine(line) if not ret: + # Bypass if filter constraint specified: + if faildata.get('filter') and name != faildata.get('filter'): + continue # Check line is flagged as none match self.assertFalse(faildata.get('match', True), "Line not matched when should have") @@ -202,7 +205,7 @@ def testSampleRegexsFactory(name, basedir): # Verify match captures (at least fid/host) and timestamp as expected for k, v in faildata.iteritems(): - if k not in ("time", "match", "desc"): + if k not in ("time", "match", "desc", "filter"): fv = fail.get(k, None) # Fallback for backwards compatibility (previously no fid, was host only): if k == "host" and fv is None: