diff --git a/testcases/clientreadertestcase.py b/testcases/clientreadertestcase.py index 96f9134f..f55be051 100644 --- a/testcases/clientreadertestcase.py +++ b/testcases/clientreadertestcase.py @@ -188,6 +188,38 @@ class JailsReaderTest(LogCaptureTestCase): reader = JailsReader(basedir='/XXX') self.assertRaises(ValueError, reader.read) + def testReadTestJailConf(self): + jails = JailsReader(basedir=os.path.join('testcases','config')) + self.assertTrue(jails.read()) # opens fine + self.assertFalse(jails.getOptions()) # reads not sof ine + self.assertRaises(ValueError, jails.convert) + comm_commands = jails.convert(allow_no_files=True) + self.maxDiff = None + self.assertEqual(comm_commands, + [['add', 'emptyaction', 'auto'], + ['set', 'emptyaction', 'usedns', 'warn'], + ['set', 'emptyaction', 'addlogpath', '/var/log/messages'], + ['set', 'emptyaction', 'maxretry', 3], + ['set', 'emptyaction', 'findtime', 600], + ['set', 'emptyaction', 'bantime', 600], + ['add', 'special', 'auto'], + ['set', 'special', 'usedns', 'warn'], + ['set', 'special', 'addlogpath', '/var/log/messages'], + ['set', 'special', 'maxretry', 3], + ['set', 'special', 'addfailregex', ''], + ['set', 'special', 'findtime', 600], + ['set', 'special', 'bantime', 600], + ['add', 'missinglogfiles', 'auto'], + ['set', 'missinglogfiles', 'usedns', 'warn'], + ['set', 'missinglogfiles', 'maxretry', 3], + ['set', 'missinglogfiles', 'findtime', 600], + ['set', 'missinglogfiles', 'bantime', 600], + ['set', 'missinglogfiles', 'addfailregex', ''], + ['start', 'emptyaction'], + ['start', 'special'], + ['start', 'missinglogfiles']]) + + def testReadStockJailConf(self): jails = JailsReader(basedir='config') # we are running tests from root project dir atm self.assertTrue(jails.read()) # opens fine diff --git a/testcases/config/jail.conf b/testcases/config/jail.conf index 4bdd74cf..ab791451 100644 --- a/testcases/config/jail.conf +++ b/testcases/config/jail.conf @@ -7,6 +7,14 @@ enabled = true filter = action = +[special] +failregex = +ignoreregex = +ignoreip = + +[missinglogfiles] +logpath = /weapons/of/mass/destruction + [brokenactiondef] enabled = true action = joho[foo @@ -18,3 +26,7 @@ action = brokenaction [missingbitsjail] filter = catchallthebadies action = thefunkychickendance + +[parse_to_end_of_jail.conf] +enabled = true +action =