summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Sušnik <jodlajodla@gmail.com>2018-05-08 14:07:57 +0200
committersebres <serg.brester@sebres.de>2018-07-06 17:32:32 +0200
commitdf33322f9fb3fdf8d2fc42f635ad64f65a70f458 (patch)
treef6fc3120452634255c051d3b999e6bbebd77f05e
parent75330568d97c8d40c67e30dc514a90e0d1bc4c51 (diff)
downloadfail2ban-df33322f9fb3fdf8d2fc42f635ad64f65a70f458.tar.gz
Added test to prove bug when specifying journal flags to systemd backend
-rw-r--r--fail2ban/tests/servertestcase.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/fail2ban/tests/servertestcase.py b/fail2ban/tests/servertestcase.py
index 59dfef50..295b2d31 100644
--- a/fail2ban/tests/servertestcase.py
+++ b/fail2ban/tests/servertestcase.py
@@ -803,6 +803,28 @@ class Transmitter(TransmitterBase):
result = self.transm.proceed(
["set", jailName, "deljournalmatch", value])
self.assertTrue(isinstance(result[1], ValueError))
+
+ def testJournalFlagsMatch(self):
+ if not filtersystemd: # pragma: no cover
+ raise unittest.SkipTest("systemd python interface not available")
+ self.assertTrue(True)
+ jailName = "TestJail3"
+ self.server.addJail(jailName, "systemd[journalflags=2]")
+ values = [
+ "_SYSTEMD_UNIT=sshd.service",
+ "TEST_FIELD1=ABC",
+ "_HOSTNAME=example.com",
+ ]
+ for n, value in enumerate(values):
+ self.assertEqual(
+ self.transm.proceed(
+ ["set", jailName, "addjournalmatch", value]),
+ (0, [[val] for val in values[:n+1]]))
+ for n, value in enumerate(values):
+ self.assertEqual(
+ self.transm.proceed(
+ ["set", jailName, "deljournalmatch", value]),
+ (0, [[val] for val in values[n+1:]]))
class TransmitterLogging(TransmitterBase):