mirror of https://github.com/fail2ban/fail2ban
extends samples test-case factory to see the matched regex number and expression in assert message (helps if some similar regexp's available in filter)
parent
d92381aaa9
commit
64d9e164cf
|
@ -201,6 +201,7 @@ def testSampleRegexsFactory(name, basedir):
|
||||||
flt, regexsUsedIdx = flt
|
flt, regexsUsedIdx = flt
|
||||||
regexList = flt.getFailRegex()
|
regexList = flt.getFailRegex()
|
||||||
|
|
||||||
|
failregex = -1
|
||||||
try:
|
try:
|
||||||
fail = {}
|
fail = {}
|
||||||
ret = flt.processLine(line)
|
ret = flt.processLine(line)
|
||||||
|
@ -263,9 +264,10 @@ def testSampleRegexsFactory(name, basedir):
|
||||||
regexsUsedRe.add(regexList[failregex])
|
regexsUsedRe.add(regexList[failregex])
|
||||||
except AssertionError as e: # pragma: no cover
|
except AssertionError as e: # pragma: no cover
|
||||||
import pprint
|
import pprint
|
||||||
raise AssertionError("%s: %s on: %s:%i, line:\n%s\n"
|
raise AssertionError("%s: %s on: %s:%i, line:\n %sregex (%s):\n %s\n"
|
||||||
"faildata: %s\nfail: %s" % (
|
"faildata: %s\nfail: %s" % (
|
||||||
fltName, e, logFile.filename(), logFile.filelineno(), line,
|
fltName, e, logFile.filename(), logFile.filelineno(),
|
||||||
|
line, failregex, regexList[failregex] if failregex != -1 else None,
|
||||||
'\n'.join(pprint.pformat(faildata).splitlines()),
|
'\n'.join(pprint.pformat(faildata).splitlines()),
|
||||||
'\n'.join(pprint.pformat(fail).splitlines())))
|
'\n'.join(pprint.pformat(fail).splitlines())))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue