mirror of https://github.com/fail2ban/fail2ban
tests: define CONFIG_DIR in utils.
parent
8f521b8551
commit
270ea363d3
|
@ -22,11 +22,7 @@ import unittest
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ..dummyjail import DummyJail
|
from ..dummyjail import DummyJail
|
||||||
|
from ..utils import CONFIG_DIR
|
||||||
if os.path.exists('config/fail2ban.conf'):
|
|
||||||
CONFIG_DIR = "config"
|
|
||||||
else:
|
|
||||||
CONFIG_DIR='/etc/fail2ban'
|
|
||||||
|
|
||||||
if sys.version_info >= (2,7):
|
if sys.version_info >= (2,7):
|
||||||
class BadIPsActionTest(unittest.TestCase):
|
class BadIPsActionTest(unittest.TestCase):
|
||||||
|
|
|
@ -30,10 +30,7 @@ else:
|
||||||
|
|
||||||
from ..dummyjail import DummyJail
|
from ..dummyjail import DummyJail
|
||||||
|
|
||||||
if os.path.exists('config/fail2ban.conf'):
|
from ..utils import CONFIG_DIR
|
||||||
CONFIG_DIR = "config"
|
|
||||||
else:
|
|
||||||
CONFIG_DIR='/etc/fail2ban'
|
|
||||||
|
|
||||||
class TestSMTPServer(smtpd.SMTPServer):
|
class TestSMTPServer(smtpd.SMTPServer):
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,10 @@ 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")
|
||||||
|
|
||||||
|
from .utils import CONFIG_DIR
|
||||||
|
|
||||||
STOCK = os.path.exists(os.path.join('config','fail2ban.conf'))
|
STOCK = os.path.exists(os.path.join('config','fail2ban.conf'))
|
||||||
CONFIG_DIR='config' if STOCK else '/etc/fail2ban'
|
|
||||||
|
|
||||||
IMPERFECT_CONFIG = os.path.join(os.path.dirname(__file__), 'config')
|
IMPERFECT_CONFIG = os.path.join(os.path.dirname(__file__), 'config')
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,9 @@ else:
|
||||||
|
|
||||||
from ..server.filter import Filter
|
from ..server.filter import Filter
|
||||||
from ..client.filterreader import FilterReader
|
from ..client.filterreader import FilterReader
|
||||||
from .utils import setUpMyTime, tearDownMyTime
|
from .utils import setUpMyTime, tearDownMyTime, CONFIG_DIR
|
||||||
|
|
||||||
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('config/fail2ban.conf'):
|
|
||||||
CONFIG_DIR = "config"
|
|
||||||
else:
|
|
||||||
CONFIG_DIR='/etc/fail2ban'
|
|
||||||
|
|
||||||
class FilterSamplesRegex(unittest.TestCase):
|
class FilterSamplesRegex(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,15 @@ from ..helpers import getLogger
|
||||||
|
|
||||||
logSys = getLogger(__name__)
|
logSys = getLogger(__name__)
|
||||||
|
|
||||||
|
CONFIG_DIR = os.environ.get('FAIL2BAN_CONFIG_DIR', None)
|
||||||
|
|
||||||
|
if not CONFIG_DIR:
|
||||||
|
# Use heuristic to figure out where configuration files are
|
||||||
|
if os.path.exists(os.path.join('config','fail2ban.conf')):
|
||||||
|
CONFIG_DIR = 'config'
|
||||||
|
else:
|
||||||
|
CONFIG_DIR = '/etc/fail2ban'
|
||||||
|
|
||||||
def mtimesleep():
|
def mtimesleep():
|
||||||
# no sleep now should be necessary since polling tracks now not only
|
# no sleep now should be necessary since polling tracks now not only
|
||||||
# mtime but also ino and size
|
# mtime but also ino and size
|
||||||
|
|
Loading…
Reference in New Issue