mirror of https://github.com/fail2ban/fail2ban
DOC: minor PEP8ing and comments enhancements
parent
ec6032d934
commit
14c31d8c58
|
@ -45,7 +45,7 @@ TEST_FILES_DIR_SHARE_CFG = {}
|
||||||
from .utils import CONFIG_DIR
|
from .utils import CONFIG_DIR
|
||||||
CONFIG_DIR_SHARE_CFG = unittest.F2B.share_config
|
CONFIG_DIR_SHARE_CFG = unittest.F2B.share_config
|
||||||
|
|
||||||
STOCK = os.path.exists(os.path.join('config','fail2ban.conf'))
|
STOCK = os.path.exists(os.path.join('config', 'fail2ban.conf'))
|
||||||
|
|
||||||
IMPERFECT_CONFIG = os.path.join(os.path.dirname(__file__), 'config')
|
IMPERFECT_CONFIG = os.path.join(os.path.dirname(__file__), 'config')
|
||||||
IMPERFECT_CONFIG_SHARE_CFG = {}
|
IMPERFECT_CONFIG_SHARE_CFG = {}
|
||||||
|
|
|
@ -1001,7 +1001,8 @@ class ServerConfigReaderTests(LogCaptureTestCase):
|
||||||
if STOCK:
|
if STOCK:
|
||||||
|
|
||||||
def testCheckStockJailActions(self):
|
def testCheckStockJailActions(self):
|
||||||
jails = JailsReader(basedir=CONFIG_DIR, force_enable=True, share_config=self.__share_cfg) # we are running tests from root project dir atm
|
# we are running tests from root project dir atm
|
||||||
|
jails = JailsReader(basedir=CONFIG_DIR, force_enable=True, share_config=self.__share_cfg)
|
||||||
self.assertTrue(jails.read()) # opens fine
|
self.assertTrue(jails.read()) # opens fine
|
||||||
self.assertTrue(jails.getOptions()) # reads fine
|
self.assertTrue(jails.getOptions()) # reads fine
|
||||||
stream = jails.convert(allow_no_files=True)
|
stream = jails.convert(allow_no_files=True)
|
||||||
|
@ -1019,14 +1020,17 @@ class ServerConfigReaderTests(LogCaptureTestCase):
|
||||||
# change to the fast init backend:
|
# change to the fast init backend:
|
||||||
if cmd[0] == 'add':
|
if cmd[0] == 'add':
|
||||||
cmd[2] = 'polling'
|
cmd[2] = 'polling'
|
||||||
# change log path to test log of jail (to prevent "Permission denied" on /var/logs/ for test-user):
|
# change log path to test log of the jail
|
||||||
|
# (to prevent "Permission denied" on /var/logs/ for test-user):
|
||||||
elif len(cmd) > 3 and cmd[0] == 'set' and cmd[2] == 'addlogpath':
|
elif len(cmd) > 3 and cmd[0] == 'set' and cmd[2] == 'addlogpath':
|
||||||
fn = os.path.join(TEST_FILES_DIR, 'logs', cmd[1])
|
fn = os.path.join(TEST_FILES_DIR, 'logs', cmd[1])
|
||||||
# fallback to testcase01 if jail has not an own test log-file (currently should be no matter):
|
# fallback to testcase01 if jail has no its own test log-file
|
||||||
|
# (should not matter really):
|
||||||
if not os.path.exists(fn): # pragma: no cover
|
if not os.path.exists(fn): # pragma: no cover
|
||||||
fn = os.path.join(TEST_FILES_DIR, 'testcase01.log')
|
fn = os.path.join(TEST_FILES_DIR, 'testcase01.log')
|
||||||
cmd[3] = fn
|
cmd[3] = fn
|
||||||
# if fast add dummy regex to prevent too long compile of all regexp (we don't use it in this test at all):
|
# if fast add dummy regex to prevent too long compile of all regexp
|
||||||
|
# (we don't use it in this test at all):
|
||||||
elif unittest.F2B.fast and (
|
elif unittest.F2B.fast and (
|
||||||
len(cmd) > 3 and cmd[0] in ('set', 'multi-set') and cmd[2] == 'addfailregex'
|
len(cmd) > 3 and cmd[0] in ('set', 'multi-set') and cmd[2] == 'addfailregex'
|
||||||
):
|
):
|
||||||
|
|
Loading…
Reference in New Issue