extended tests covering unban tuple IDs

pull/3533/head
sebres 2023-06-22 19:35:09 +02:00
parent 6afdf239c4
commit 34390b3fe1
2 changed files with 12 additions and 3 deletions

View File

@ -1408,8 +1408,12 @@ class Fail2banServerTest(Fail2banClientServerBase):
all=True, wait=MID_WAITTIME
)
# unban 1, 2 and 5:
self.execCmd(SUCCESS, startparams, 'unban', '125-000-001', '125-000-002', '125-000-005')
# unban 1, 2 and 5 (as expr):
self.execCmd(SUCCESS, startparams, 'unban', '125-000-001', '125-000-002')
self.execCmd(SUCCESS, startparams, 'unban', '--expr', '"125-000-005"')
# check tuple IDs don't consider as a list of IDs to unban:
self.execCmd(SUCCESS, startparams, 'unban', '--expr', '("125-000-003","125-000-004")')
self.assertLogged('%r is not banned' % (('125-000-003', '125-000-004'),))
_out_file(mpfn)
# check really unbanned but other sessions are still present (blacklisted in map-file):
mp = _read_file(mpfn)

View File

@ -372,8 +372,13 @@ class Transmitter(TransmitterBase):
# ... (no error, IPs logged only):
self.assertEqual(
self.transm.proceed(
["set", self.jailName, "unbanip", "192.0.2.255", "192.0.2.254"]),(0, 0))
["set", self.jailName, "unbanip", "--", "192.0.2.255", "192.0.2.254"]),(0, 0))
self.assertLogged("192.0.2.255 is not banned", "192.0.2.254 is not banned", all=True, wait=True)
# tuple ID:
self.assertEqual(
self.transm.proceed(
["set", self.jailName, "unbanip", "--expr", "(1,2,3)"]),(0, 0))
self.assertLogged("%r is not banned" % ((1,2,3),), wait=True)
def testJailAttemptIP(self):
self.server.startJail(self.jailName) # Jail must be started