mirror of https://github.com/fail2ban/fail2ban
TST: complete coverage of splitAction
parent
b18ce122dd
commit
c6d14dcf0e
|
@ -180,7 +180,7 @@ class JailReader(ConfigReader):
|
|||
"2 groups. Got: 0" % action)
|
||||
if len(mgroups) == 2:
|
||||
action_name, action_opts = mgroups
|
||||
elif len(mgroups) == 1:
|
||||
elif len(mgroups) == 1: # pragma: nocover - unreachable - .* on second group always matches
|
||||
action_name, action_opts = mgroups[0], None
|
||||
else: # pragma: nocover - unreachable - regex only can capture 2 groups
|
||||
raise ValueError("While reading action %s we should have got up to "
|
||||
|
|
|
@ -124,6 +124,18 @@ class JailReaderTest(LogCaptureTestCase):
|
|||
result = JailReader.splitAction(action)
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
self.assertEqual(['mail.who_is', {}], JailReader.splitAction("mail.who_is"))
|
||||
self.assertEqual(['mail.who_is', {'a':'cat', 'b':'dog'}], JailReader.splitAction("mail.who_is[a=cat,b=dog]"))
|
||||
self.assertEqual(['mail--ho_is', {}], JailReader.splitAction("mail--ho_is"))
|
||||
|
||||
self.assertEqual(['mail--ho_is', {}], JailReader.splitAction("mail--ho_is['s']"))
|
||||
self.assertTrue(self._is_logged("Invalid argument ['s'] in ''s''"))
|
||||
|
||||
self.assertEqual(['mail', {'a': ','}], JailReader.splitAction("mail[a=',']"))
|
||||
|
||||
self.assertRaises(ValueError, JailReader.splitAction ,'mail-how[')
|
||||
|
||||
|
||||
def testGlob(self):
|
||||
d = tempfile.mkdtemp(prefix="f2b-temp")
|
||||
# Generate few files
|
||||
|
|
Loading…
Reference in New Issue