mirror of https://github.com/fail2ban/fail2ban
TST: dummyjail in own class
parent
6224d761ab
commit
8a458b45bc
|
@ -306,36 +306,7 @@ class LogFileMonitor(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
class DummyJail(object):
|
from dummyjail import DummyJail
|
||||||
"""A simple 'jail' to suck in all the tickets generated by Filter's
|
|
||||||
"""
|
|
||||||
def __init__(self):
|
|
||||||
self.lock = Lock()
|
|
||||||
self.queue = []
|
|
||||||
|
|
||||||
def __len__(self):
|
|
||||||
try:
|
|
||||||
self.lock.acquire()
|
|
||||||
return len(self.queue)
|
|
||||||
finally:
|
|
||||||
self.lock.release()
|
|
||||||
|
|
||||||
def putFailTicket(self, ticket):
|
|
||||||
try:
|
|
||||||
self.lock.acquire()
|
|
||||||
self.queue.append(ticket)
|
|
||||||
finally:
|
|
||||||
self.lock.release()
|
|
||||||
|
|
||||||
def getFailTicket(self):
|
|
||||||
try:
|
|
||||||
self.lock.acquire()
|
|
||||||
return self.queue.pop()
|
|
||||||
finally:
|
|
||||||
self.lock.release()
|
|
||||||
|
|
||||||
def getName(self):
|
|
||||||
return "DummyJail #%s with %d tickets" % (id(self), len(self))
|
|
||||||
|
|
||||||
def get_monitor_failures_testcase(Filter_):
|
def get_monitor_failures_testcase(Filter_):
|
||||||
"""Generator of TestCase's for different filters/backends
|
"""Generator of TestCase's for different filters/backends
|
||||||
|
|
Loading…
Reference in New Issue