mirror of https://github.com/fail2ban/fail2ban
ENH+TST: Ticket -- drop unused/bogus get|setFile + enh __str__ + basic testing
parent
149a83545f
commit
3b52eca608
|
@ -47,7 +47,7 @@ class Ticket:
|
|||
|
||||
def __str__(self):
|
||||
return "%s: ip=%s time=%s #attempts=%d" % \
|
||||
(self.__class__, self.__ip, self.__time, self.__attempt)
|
||||
(self.__class__.__name__.split('.')[-1], self.__ip, self.__time, self.__attempt)
|
||||
|
||||
|
||||
def setIP(self, value):
|
||||
|
@ -59,12 +59,6 @@ class Ticket:
|
|||
def getIP(self):
|
||||
return self.__ip
|
||||
|
||||
def setFile(self, value):
|
||||
self.__file = value
|
||||
|
||||
def getFile(self):
|
||||
return self.__file
|
||||
|
||||
def setTime(self, value):
|
||||
self.__time = value
|
||||
|
||||
|
|
|
@ -78,6 +78,20 @@ class AddFailure(unittest.TestCase):
|
|||
ticket = self.__failManager.toBan()
|
||||
self.assertEqual(ticket.getIP(), "193.168.0.128")
|
||||
self.assertTrue(isinstance(ticket.getIP(), str))
|
||||
|
||||
# finish with rudimentary tests of the ticket
|
||||
# verify consistent str
|
||||
ticket_str = str(ticket)
|
||||
self.assertEqual(
|
||||
ticket_str,
|
||||
'FailTicket: ip=193.168.0.128 time=1167605999.0 #attempts=5')
|
||||
# and some get/set-ers otherwise not tested
|
||||
ticket.setTime(1000002000.0)
|
||||
self.assertEqual(ticket.getTime(), 1000002000.0)
|
||||
# and str() adjusted correspondingly
|
||||
self.assertEqual(
|
||||
str(ticket),
|
||||
'FailTicket: ip=193.168.0.128 time=1000002000.0 #attempts=5')
|
||||
|
||||
def testbanNOK(self):
|
||||
self.__failManager.setMaxRetry(10)
|
||||
|
|
Loading…
Reference in New Issue