Exemplo n.º 1
0
 def testBan(self):
     ban = BanEntry(BAN_IP, datetime.datetime.now())
     ban.ban(INTERFACE)
     status, output = commands.getstatusoutput("/sbin/iptables -L -n")
     ban.unban()
     self.assertIn(BAN_IP, output, msg="IP address not banned")
     status, output = commands.getstatusoutput("/sbin/iptables -L -n")
     self.assertNotIn(BAN_IP, output, msg="IP address was not unbanned")
Exemplo n.º 2
0
    def testClean(self): 

        ban_len = 1
        bantime = datetime.timedelta(minutes=(ban_len*2))
        ban = BanEntry(BAN_IP, datetime.datetime.now() - bantime)
        session.add(ban)
        session.commit()

        ban.ban(INTERFACE)
        cleaner = BanCleaner(db_conn, ban_len)
        cleaner.cleanBans()
        
        status, output = commands.getstatusoutput("/sbin/iptables -L -n")
        self.assertNotIn(BAN_IP, output, msg="Ban was not reset by cleaner")