mirror of https://github.com/fail2ban/fail2ban
TST/BF: more changes to make sure testcases can be run on live install
parent
64d1502d48
commit
c7f4c48090
|
@ -32,10 +32,8 @@ from ..client.configurator import Configurator
|
||||||
from .utils import LogCaptureTestCase
|
from .utils import LogCaptureTestCase
|
||||||
|
|
||||||
TEST_FILES_DIR = os.path.join(os.path.dirname(__file__), "files")
|
TEST_FILES_DIR = os.path.join(os.path.dirname(__file__), "files")
|
||||||
if os.path.exists(os.path.join('config','fail2ban.conf')):
|
STOCK = os.path.exists(os.path.join('config','fail2ban.conf'))
|
||||||
CONFIG_DIR='config'
|
CONFIG_DIR='config' if STOCK else '/etc/fail2ban'
|
||||||
else:
|
|
||||||
CONFIG_DIR='/etc/fail2ban'
|
|
||||||
|
|
||||||
IMPERFECT_CONFIG = os.path.join(os.path.dirname(__file__), 'config')
|
IMPERFECT_CONFIG = os.path.join(os.path.dirname(__file__), 'config')
|
||||||
|
|
||||||
|
@ -185,6 +183,7 @@ class JailReaderTest(LogCaptureTestCase):
|
||||||
self.assertTrue(self._is_logged('Caught exception: While reading action joho[foo we should have got 1 or 2 groups. Got: 0'))
|
self.assertTrue(self._is_logged('Caught exception: While reading action joho[foo we should have got 1 or 2 groups. Got: 0'))
|
||||||
|
|
||||||
|
|
||||||
|
if STOCK:
|
||||||
def testStockSSHJail(self):
|
def testStockSSHJail(self):
|
||||||
jail = JailReader('sshd', basedir=CONFIG_DIR) # we are running tests from root project dir atm
|
jail = JailReader('sshd', basedir=CONFIG_DIR) # we are running tests from root project dir atm
|
||||||
self.assertTrue(jail.read())
|
self.assertTrue(jail.read())
|
||||||
|
@ -407,7 +406,7 @@ class JailsReaderTest(LogCaptureTestCase):
|
||||||
self.assertTrue(self._is_logged("Errors in jail 'missingbitsjail'. Skipping..."))
|
self.assertTrue(self._is_logged("Errors in jail 'missingbitsjail'. Skipping..."))
|
||||||
self.assertTrue(self._is_logged("No file(s) found for glob /weapons/of/mass/destruction"))
|
self.assertTrue(self._is_logged("No file(s) found for glob /weapons/of/mass/destruction"))
|
||||||
|
|
||||||
|
if STOCK:
|
||||||
def testReadStockJailConf(self):
|
def testReadStockJailConf(self):
|
||||||
jails = JailsReader(basedir=CONFIG_DIR) # we are running tests from root project dir atm
|
jails = JailsReader(basedir=CONFIG_DIR) # we are running tests from root project dir atm
|
||||||
self.assertTrue(jails.read()) # opens fine
|
self.assertTrue(jails.read()) # opens fine
|
||||||
|
@ -535,7 +534,7 @@ class JailsReaderTest(LogCaptureTestCase):
|
||||||
% (target_command, str(commands)) )
|
% (target_command, str(commands)) )
|
||||||
|
|
||||||
|
|
||||||
def testConfigurator(self):
|
def testStockConfigurator(self):
|
||||||
configurator = Configurator()
|
configurator = Configurator()
|
||||||
configurator.setBaseDir(CONFIG_DIR)
|
configurator.setBaseDir(CONFIG_DIR)
|
||||||
self.assertEqual(configurator.getBaseDir(), CONFIG_DIR)
|
self.assertEqual(configurator.getBaseDir(), CONFIG_DIR)
|
||||||
|
|
Loading…
Reference in New Issue