def testJailActionBrokenDef(self):
		jail = JailReader('brokenactiondef', basedir=os.path.join('testcases','config'))
		self.assertTrue(jail.read())
		self.assertFalse(jail.getOptions())
		self.assertTrue(jail.isEnabled())
		self.assertTrue(self._is_logged('Error in action definition joho[foo'))
		self.assertTrue(self._is_logged('Caught exception: While reading action joho[foo we should have got 1 or 2 groups. Got: 0'))
	def testJailActionFilterMissing(self):
		jail = JailReader('missingbitsjail', basedir=os.path.join('testcases','config'))
		self.assertTrue(jail.read())
		self.assertFalse(jail.getOptions())
		self.assertTrue(jail.isEnabled())
		self.assertTrue(self._is_logged("Found no accessible config files for 'filter.d/catchallthebadies' under testcases/config"))
		self.assertTrue(self._is_logged('Unable to read the filter'))
	def testJailActionEmpty(self):
		jail = JailReader('emptyaction', basedir=os.path.join('testcases','config'))
		self.assertTrue(jail.read())
		self.assertTrue(jail.getOptions())
		self.assertTrue(jail.isEnabled())
		self.assertTrue(self._is_logged('No filter set for jail emptyaction'))
		self.assertTrue(self._is_logged('No actions were defined for emptyaction'))
	def testFailModelRead(self):
		"""
		Test that the client can successfully read a fail model and
		send it to the server
		"""
		#Naive way to reach "testcases/files"
		#TODO: Look at other tests and see how thay do that. I suspect
		#that it all happens in fail2ban-testcases
		from os.path import dirname
		test_dir  = dirname(__file__)

		
		fail_model_jail = JailReader("ats-ddos-model")
		fail_model_jail.setBaseDir(test_dir + "/files")
		fail_model_jail.read()
		fail_model_jail.getOptions()
Exemple #5
0
 def testStockSSHJail(self):
     jail = JailReader(
         'ssh-iptables',
         basedir='config')  # we are running tests from root project dir atm
     self.assertTrue(jail.read())
     self.assertTrue(jail.getOptions())
     self.assertFalse(jail.isEnabled())
     self.assertEqual(jail.getName(), 'ssh-iptables')
	def testStockSSHJail(self):
		jail = JailReader('ssh-iptables', basedir='config') # we are running tests from root project dir atm
		self.assertTrue(jail.read())
		self.assertTrue(jail.getOptions())
		self.assertFalse(jail.isEnabled())
		self.assertEqual(jail.getName(), 'ssh-iptables')
		jail.setName('ssh-funky-blocker')
		self.assertEqual(jail.getName(), 'ssh-funky-blocker')