mirror of https://github.com/fail2ban/fail2ban
BF: (python 2.[45]) store backends names in a list to use .index later on (Closes gh-83)
.index() got into tuple's API only in 2.6pull/68/merge
parent
9510619b7b
commit
5becaf8ef2
|
@ -125,6 +125,7 @@ tests.addTest(unittest.makeSuite(filtertestcase.LogFile))
|
|||
tests.addTest(unittest.makeSuite(filtertestcase.LogFileMonitor))
|
||||
tests.addTest(unittest.makeSuite(filtertestcase.GetFailures))
|
||||
tests.addTest(unittest.makeSuite(filtertestcase.DNSUtilsTests))
|
||||
tests.addTest(unittest.makeSuite(filtertestcase.JailTests))
|
||||
|
||||
# DateDetector
|
||||
tests.addTest(unittest.makeSuite(datedetectortestcase.DateDetectorTest))
|
||||
|
|
|
@ -33,7 +33,9 @@ logSys = logging.getLogger("fail2ban.jail")
|
|||
class Jail:
|
||||
|
||||
#Known backends. Each backend should have corresponding __initBackend method
|
||||
_BACKENDS = ('pyinotify', 'gamin', 'polling')
|
||||
# yoh: stored in a list instead of a tuple since only
|
||||
# list had .index until 2.6
|
||||
_BACKENDS = ['pyinotify', 'gamin', 'polling']
|
||||
|
||||
def __init__(self, name, backend = "auto"):
|
||||
self.__name = name
|
||||
|
|
|
@ -28,6 +28,7 @@ import sys
|
|||
import time
|
||||
import tempfile
|
||||
|
||||
from server.jail import Jail
|
||||
from server.filterpoll import FilterPoll
|
||||
from server.filter import FileFilter, DNSUtils
|
||||
from server.failmanager import FailManager
|
||||
|
@ -626,3 +627,10 @@ class DNSUtilsTests(unittest.TestCase):
|
|||
self.assertEqual(res, ['192.0.43.10'])
|
||||
else:
|
||||
self.assertEqual(res, [])
|
||||
|
||||
class JailTests(unittest.TestCase):
|
||||
|
||||
def testSetBackend_gh83(self):
|
||||
# smoke test
|
||||
jail = Jail('test', backend='polling') # Must not fail to initiate
|
||||
|
||||
|
|
Loading…
Reference in New Issue