mirror of https://github.com/fail2ban/fail2ban
TST: test all stock jails to have actions and correctly specifying blocktype
parent
d2b1c73b92
commit
8a57ffd2fb
|
@ -144,10 +144,38 @@ class JailsReaderTest(unittest.TestCase):
|
||||||
# and warn on useDNS
|
# and warn on useDNS
|
||||||
self.assertTrue(['set', j, 'usedns', 'warn'] in comm_commands)
|
self.assertTrue(['set', j, 'usedns', 'warn'] in comm_commands)
|
||||||
self.assertTrue(['start', j] in comm_commands)
|
self.assertTrue(['start', j] in comm_commands)
|
||||||
|
|
||||||
# last commands should be the 'start' commands
|
# last commands should be the 'start' commands
|
||||||
self.assertEqual(comm_commands[-1][0], 'start')
|
self.assertEqual(comm_commands[-1][0], 'start')
|
||||||
# TODO: make sure that all of the jails have actions assigned,
|
|
||||||
# otherwise it makes little to no sense
|
for j in jails._JailsReader__jails:
|
||||||
|
actions = j._JailReader__actions
|
||||||
|
jail_name = j.getName()
|
||||||
|
# make sure that all of the jails have actions assigned,
|
||||||
|
# otherwise it makes little to no sense
|
||||||
|
self.assertTrue(len(actions),
|
||||||
|
msg="No actions found for jail %s" % jail_name)
|
||||||
|
|
||||||
|
# Test for presence of blocktype (in relation to gh-232)
|
||||||
|
for action in actions:
|
||||||
|
commands = action.convert()
|
||||||
|
file_ = action.getFile()
|
||||||
|
if '<blocktype>' in str(commands):
|
||||||
|
# Verify that it is among cInfo
|
||||||
|
self.assertTrue('blocktype' in action._ActionReader__cInfo)
|
||||||
|
# Verify that we have a call to set it up
|
||||||
|
blocktype_present = False
|
||||||
|
target_command = [ 'set', jail_name, 'setcinfo', file_, 'blocktype' ]
|
||||||
|
for command in commands:
|
||||||
|
if (len(command) > 5 and
|
||||||
|
command[:5] == target_command):
|
||||||
|
blocktype_present = True
|
||||||
|
continue
|
||||||
|
self.assertTrue(
|
||||||
|
blocktype_present,
|
||||||
|
msg="Found no %s command among %s"
|
||||||
|
% (target_command, str(commands)) )
|
||||||
|
|
||||||
|
|
||||||
def testConfigurator(self):
|
def testConfigurator(self):
|
||||||
configurator = Configurator()
|
configurator = Configurator()
|
||||||
|
|
Loading…
Reference in New Issue