mirror of https://github.com/fail2ban/fail2ban
TST: fail2ban-testcases to be able to be run on installed fail2ban
parent
fe582e67e3
commit
51403fec50
|
@ -35,13 +35,9 @@ TEST_FILES_DIR = os.path.join(os.path.dirname(__file__), "files")
|
||||||
if os.path.exists(os.path.join('config','fail2ban.conf')):
|
if os.path.exists(os.path.join('config','fail2ban.conf')):
|
||||||
CONFIG_DIR='config'
|
CONFIG_DIR='config'
|
||||||
else:
|
else:
|
||||||
CONFIG_DIR=os.path.join('etc','fail2ban')
|
CONFIG_DIR='/etc/fail2ban'
|
||||||
|
|
||||||
IMPERFECT_CONFIG = os.path.join('fail2ban', 'tests','config')
|
|
||||||
|
|
||||||
|
|
||||||
IMPERFECT_CONFIG = os.path.join('fail2ban', 'tests','config')
|
|
||||||
|
|
||||||
|
IMPERFECT_CONFIG = os.path.join(os.path.dirname(__file__), 'config')
|
||||||
|
|
||||||
class ConfigReaderTest(unittest.TestCase):
|
class ConfigReaderTest(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ from ..server.mytime import MyTime
|
||||||
from ..server.ticket import FailTicket
|
from ..server.ticket import FailTicket
|
||||||
from .dummyjail import DummyJail
|
from .dummyjail import DummyJail
|
||||||
|
|
||||||
|
TEST_FILES_DIR = os.path.join(os.path.dirname(__file__), "files")
|
||||||
|
|
||||||
class DatabaseTest(unittest.TestCase):
|
class DatabaseTest(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -65,7 +67,8 @@ class DatabaseTest(unittest.TestCase):
|
||||||
"Jail not retained in Db after disconnect reconnect.")
|
"Jail not retained in Db after disconnect reconnect.")
|
||||||
|
|
||||||
def testUpdateDb(self):
|
def testUpdateDb(self):
|
||||||
shutil.copyfile('fail2ban/tests/files/database_v1.db', self.dbFilename)
|
shutil.copyfile(
|
||||||
|
os.path.join(TEST_FILES_DIR, 'database_v1.db'), self.dbFilename)
|
||||||
self.db = Fail2BanDb(self.dbFilename)
|
self.db = Fail2BanDb(self.dbFilename)
|
||||||
self.assertEqual(self.db.getJailNames(), set(['DummyJail #29162448 with 0 tickets']))
|
self.assertEqual(self.db.getJailNames(), set(['DummyJail #29162448 with 0 tickets']))
|
||||||
self.assertEqual(self.db.getLogPaths(), set(['/tmp/Fail2BanDb_pUlZJh.log']))
|
self.assertEqual(self.db.getLogPaths(), set(['/tmp/Fail2BanDb_pUlZJh.log']))
|
||||||
|
|
Loading…
Reference in New Issue