Browse Source

coverage and code review

pull/2402/head
sebres 6 years ago
parent
commit
4629e4320f
  1. 4
      fail2ban/server/transmitter.py
  2. 8
      fail2ban/tests/servertestcase.py

4
fail2ban/server/transmitter.py

@ -186,7 +186,7 @@ class Transmitter:
elif name == "dbmaxmatches":
db = self.__server.getDatabase()
if db is None:
logSys.msg("dbmaxmatches setting was not in effect since no db yet")
logSys.log(logging.MSG, "dbmaxmatches setting was not in effect since no db yet")
return None
else:
db.maxMatches = int(command[1])
@ -195,7 +195,7 @@ class Transmitter:
elif name == "dbpurgeage":
db = self.__server.getDatabase()
if db is None:
logSys.warning("dbpurgeage setting was not in effect since no db yet")
logSys.log(logging.MSG, "dbpurgeage setting was not in effect since no db yet")
return None
else:
db.purgeage = command[1]

8
fail2ban/tests/servertestcase.py

@ -197,6 +197,8 @@ class Transmitter(TransmitterBase):
self.setGetTest("dbfile", tmpFilename)
# the same file name (again no jails / not changed):
self.setGetTest("dbfile", tmpFilename)
self.setGetTest("dbmaxmatches", "100", 100)
self.setGetTestNOK("dbmaxmatches", "LIZARD")
self.setGetTest("dbpurgeage", "600", 600)
self.setGetTestNOK("dbpurgeage", "LIZARD")
# the same file name (again with jails / not changed):
@ -211,6 +213,12 @@ class Transmitter(TransmitterBase):
self.assertEqual(self.transm.proceed(
["get", "dbfile"]),
(0, None))
self.assertEqual(self.transm.proceed(
["set", "dbmaxmatches", "100"]),
(0, None))
self.assertEqual(self.transm.proceed(
["get", "dbmaxmatches"]),
(0, None))
self.assertEqual(self.transm.proceed(
["set", "dbpurgeage", "500"]),
(0, None))

Loading…
Cancel
Save