mirror of https://github.com/fail2ban/fail2ban
fulfill getIP with getID replacement; added simple tests for ticket
parent
cf2695a253
commit
8eb521694e
|
@ -295,7 +295,7 @@ class Jail(object):
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
#logSys.debug('restored ticket: %s', ticket)
|
#logSys.debug('restored ticket: %s', ticket)
|
||||||
if self.filter.inIgnoreIPList(ticket.getIP(), log_ignore=True): continue
|
if self.filter.inIgnoreIPList(ticket.getID(), log_ignore=True): continue
|
||||||
# mark ticked was restored from database - does not put it again into db:
|
# mark ticked was restored from database - does not put it again into db:
|
||||||
ticket.restored = True
|
ticket.restored = True
|
||||||
# correct start time / ban time (by the same end of ban):
|
# correct start time / ban time (by the same end of ban):
|
||||||
|
|
|
@ -118,6 +118,17 @@ class TicketTests(unittest.TestCase):
|
||||||
self.assertEqual(ft2.getTime(), ft.getTime())
|
self.assertEqual(ft2.getTime(), ft.getTime())
|
||||||
self.assertEqual(ft2.getBanTime(), ft.getBanTime())
|
self.assertEqual(ft2.getBanTime(), ft.getBanTime())
|
||||||
|
|
||||||
|
def testDiffIDAndIPTicket(self):
|
||||||
|
tm = MyTime.time()
|
||||||
|
# different ID (string) and IP:
|
||||||
|
t = Ticket('123-456-678', tm, data={'ip':'192.0.2.1'})
|
||||||
|
self.assertEqual(t.getID(), '123-456-678')
|
||||||
|
self.assertEqual(t.getIP(), '192.0.2.1')
|
||||||
|
# different ID (tuple) and IP:
|
||||||
|
t = Ticket(('192.0.2.1', '5000'), tm, data={'ip':'192.0.2.1'})
|
||||||
|
self.assertEqual(t.getID(), ('192.0.2.1', '5000'))
|
||||||
|
self.assertEqual(t.getIP(), '192.0.2.1')
|
||||||
|
|
||||||
def testTicketFlags(self):
|
def testTicketFlags(self):
|
||||||
flags = ('restored', 'banned')
|
flags = ('restored', 'banned')
|
||||||
ticket = Ticket('test', 0)
|
ticket = Ticket('test', 0)
|
||||||
|
|
Loading…
Reference in New Issue