From 9e6d07d928d1016be8195613aac2c0a2b53b9342 Mon Sep 17 00:00:00 2001 From: sebres Date: Wed, 22 Jan 2020 17:19:35 +0100 Subject: [PATCH] testSampleRegexsFactory: `time` is not mandatory anymore (check time only if set in json), allows usage of same line(s) matching different `logtype` option: `# filterOptions: [{"logtype": "file"}, {"logtype": "short"}, {"logtype": "journal"}]` --- fail2ban/tests/samplestestcase.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fail2ban/tests/samplestestcase.py b/fail2ban/tests/samplestestcase.py index 1039b65e..0bbd05f5 100644 --- a/fail2ban/tests/samplestestcase.py +++ b/fail2ban/tests/samplestestcase.py @@ -223,11 +223,9 @@ def testSampleRegexsFactory(name, basedir): try: fail = {} # for logtype "journal" we don't need parse timestamp (simulate real systemd-backend handling): - checktime = True if opts.get('logtype') != 'journal': ret = flt.processLine(line) else: # simulate journal processing, time is known from journal (formatJournalEntry): - checktime = False if opts.get('test.prefix-line'): # journal backends creates common prefix-line: line = opts.get('test.prefix-line') + line ret = flt.processLine(('', TEST_NOW_STR, line.rstrip('\r\n')), TEST_NOW) @@ -271,7 +269,7 @@ def testSampleRegexsFactory(name, basedir): self.assertEqual(fv, v) t = faildata.get("time", None) - if checktime or t is not None: + if t is not None: try: jsonTimeLocal = datetime.datetime.strptime(t, "%Y-%m-%dT%H:%M:%S") except ValueError: