mirror of https://github.com/fail2ban/fail2ban
TST: Update travis coverage config to exempt systemd related code
parent
c08bd67f50
commit
90de5aa568
|
@ -17,4 +17,6 @@ script:
|
|||
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then export PYTHONPATH="$PYTHONPATH:/usr/share/pyshared:/usr/lib/pyshared/python2.7"; fi
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then coverage run --rcfile=.travis_coveragerc setup.py test; else python setup.py test; fi
|
||||
after_success:
|
||||
# Coverage config file must be .coveragerc for coveralls
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then cp -v .travis_coveragerc .coveragerc; fi
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then coveralls; fi
|
||||
|
|
|
@ -5,3 +5,11 @@ omit =
|
|||
/usr/*
|
||||
/home/travis/virtualenv/*
|
||||
fail2ban/server/filtersystemd.py
|
||||
|
||||
[report]
|
||||
exclude_lines =
|
||||
# Have to re-enable the standard pragma
|
||||
pragma: no cover
|
||||
|
||||
# systemd backend related
|
||||
pragma: systemd no cover
|
||||
|
|
|
@ -648,7 +648,7 @@ class FileContainer:
|
|||
#
|
||||
# Base interface class for systemd journal filters
|
||||
|
||||
class JournalFilter(Filter):
|
||||
class JournalFilter(Filter): # pragma: systemd no cover
|
||||
|
||||
def addJournalMatch(self, match):
|
||||
pass
|
||||
|
|
|
@ -45,7 +45,7 @@ logSys = logging.getLogger("fail2ban.filter")
|
|||
# else that matches a given regular expression. This class is instantiated by
|
||||
# a Jail object.
|
||||
|
||||
class FilterSystemd(JournalFilter):
|
||||
class FilterSystemd(JournalFilter): # pragma: systemd no cover
|
||||
##
|
||||
# Constructor.
|
||||
#
|
||||
|
|
|
@ -101,7 +101,7 @@ class Jail:
|
|||
from filterpyinotify import FilterPyinotify
|
||||
self.__filter = FilterPyinotify(self)
|
||||
|
||||
def _initSystemd(self):
|
||||
def _initSystemd(self): # pragma: systemd no cover
|
||||
# Try to import systemd
|
||||
import systemd
|
||||
logSys.info("Jail '%s' uses systemd" % self.__name)
|
||||
|
|
|
@ -184,21 +184,21 @@ class Server:
|
|||
if isinstance(filter_, FileFilter):
|
||||
return [m.getFileName()
|
||||
for m in filter_.getLogPath()]
|
||||
else:
|
||||
else: # pragma: systemd no cover
|
||||
logSys.info("Jail %s is not a FileFilter instance" % name)
|
||||
return []
|
||||
|
||||
def addJournalMatch(self, name, match):
|
||||
def addJournalMatch(self, name, match): # pragma: systemd no cover
|
||||
filter_ = self.__jails.getFilter(name)
|
||||
if isinstance(filter_, JournalFilter):
|
||||
filter_.addJournalMatch(match)
|
||||
|
||||
def delJournalMatch(self, name, match):
|
||||
def delJournalMatch(self, name, match): # pragma: systemd no cover
|
||||
filter_ = self.__jails.getFilter(name)
|
||||
if isinstance(filter_, JournalFilter):
|
||||
filter_.delJournalMatch(match)
|
||||
|
||||
def getJournalMatch(self, name):
|
||||
def getJournalMatch(self, name): # pragma: systemd no cover
|
||||
filter_ = self.__jails.getFilter(name)
|
||||
if isinstance(filter_, JournalFilter):
|
||||
return filter_.getJournalMatch()
|
||||
|
|
|
@ -144,11 +144,11 @@ class Transmitter:
|
|||
value = command[2]
|
||||
self.__server.setLogEncoding(name, value)
|
||||
return self.__server.getLogEncoding(name)
|
||||
elif command[1] == "addjournalmatch":
|
||||
elif command[1] == "addjournalmatch": # pragma: systemd no cover
|
||||
value = ' '.join(command[2:])
|
||||
self.__server.addJournalMatch(name, value)
|
||||
return self.__server.getJournalMatch(name)
|
||||
elif command[1] == "deljournalmatch":
|
||||
elif command[1] == "deljournalmatch": # pragma: systemd no cover
|
||||
value = ' '.join(command[2:])
|
||||
self.__server.delJournalMatch(name, value)
|
||||
return self.__server.getJournalMatch(name)
|
||||
|
@ -258,7 +258,7 @@ class Transmitter:
|
|||
return self.__server.getLogPath(name)
|
||||
elif command[1] == "logencoding":
|
||||
return self.__server.getLogEncoding(name)
|
||||
elif command[1] == "journalmatch":
|
||||
elif command[1] == "journalmatch": # pragma: systemd no cover
|
||||
return self.__server.getJournalMatch(name)
|
||||
elif command[1] == "ignoreip":
|
||||
return self.__server.getIgnoreIP(name)
|
||||
|
|
|
@ -165,7 +165,7 @@ def _copy_lines_between_files(in_, fout, n=None, skip=0, mode='a', terminal_line
|
|||
time.sleep(0.1)
|
||||
return fout
|
||||
|
||||
def _copy_lines_to_journal(in_, fields={},n=None, skip=0, terminal_line=""):
|
||||
def _copy_lines_to_journal(in_, fields={},n=None, skip=0, terminal_line=""): # pragma: systemd no cover
|
||||
"""Copy lines from one file to systemd journal
|
||||
|
||||
Returns None
|
||||
|
@ -607,7 +607,7 @@ def get_monitor_failures_testcase(Filter_):
|
|||
% (Filter_.__name__, testclass_name) # 'tempfile')
|
||||
return MonitorFailures
|
||||
|
||||
def get_monitor_failures_journal_testcase(Filter_):
|
||||
def get_monitor_failures_journal_testcase(Filter_): # pragma: systemd no cover
|
||||
"""Generator of TestCase's for journal based filters/backends
|
||||
"""
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ def gatherTests(regexps=None, no_network=False):
|
|||
for Filter_ in filters:
|
||||
tests.addTest(unittest.makeSuite(
|
||||
filtertestcase.get_monitor_failures_testcase(Filter_)))
|
||||
try:
|
||||
try: # pragma: systemd no cover
|
||||
from fail2ban.server.filtersystemd import FilterSystemd
|
||||
tests.addTest(unittest.makeSuite(filtertestcase.get_monitor_failures_journal_testcase(FilterSystemd)))
|
||||
except Exception, e: # pragma: no cover
|
||||
|
|
Loading…
Reference in New Issue