mirror of https://github.com/fail2ban/fail2ban
fixes beautifier `get` `ignoreip` (explicit convert to string)
parent
bf4903538d
commit
3ce6f344e3
|
@ -212,8 +212,8 @@ class Beautifier:
|
||||||
else:
|
else:
|
||||||
msg = "These IP addresses/networks are ignored:\n"
|
msg = "These IP addresses/networks are ignored:\n"
|
||||||
for ip in response[:-1]:
|
for ip in response[:-1]:
|
||||||
msg += "|- " + ip + "\n"
|
msg += "|- " + str(ip) + "\n"
|
||||||
msg += "`- " + response[-1]
|
msg += "`- " + str(response[-1])
|
||||||
elif inC[2] in ("failregex", "addfailregex", "delfailregex",
|
elif inC[2] in ("failregex", "addfailregex", "delfailregex",
|
||||||
"ignoreregex", "addignoreregex", "delignoreregex"):
|
"ignoreregex", "addignoreregex", "delignoreregex"):
|
||||||
if len(response) == 0:
|
if len(response) == 0:
|
||||||
|
|
|
@ -25,7 +25,7 @@ import unittest
|
||||||
|
|
||||||
from ..client.beautifier import Beautifier
|
from ..client.beautifier import Beautifier
|
||||||
from ..version import version
|
from ..version import version
|
||||||
from ..server.ipdns import IPAddr
|
from ..server.ipdns import IPAddr, FileIPAddrSet
|
||||||
from ..exceptions import UnknownJailException, DuplicateJailException
|
from ..exceptions import UnknownJailException, DuplicateJailException
|
||||||
|
|
||||||
class BeautifierTest(unittest.TestCase):
|
class BeautifierTest(unittest.TestCase):
|
||||||
|
@ -297,6 +297,13 @@ class BeautifierTest(unittest.TestCase):
|
||||||
output += "`- 10.0.2.1"
|
output += "`- 10.0.2.1"
|
||||||
self.assertEqual(self.b.beautify(response), output)
|
self.assertEqual(self.b.beautify(response), output)
|
||||||
|
|
||||||
|
def testIgnoreIPFile(self):
|
||||||
|
self.b.setInputCmd(["set", "sshd", "addignoreip"])
|
||||||
|
response = [FileIPAddrSet("/test/file-ipaddr-set")]
|
||||||
|
output = ("These IP addresses/networks are ignored:\n"
|
||||||
|
"`- file://test/file-ipaddr-set")
|
||||||
|
self.assertEqual(self.b.beautify(response), output)
|
||||||
|
|
||||||
def testFailRegex(self):
|
def testFailRegex(self):
|
||||||
self.b.setInputCmd(["get", "sshd", "failregex"])
|
self.b.setInputCmd(["get", "sshd", "failregex"])
|
||||||
output = "No regular expression is defined"
|
output = "No regular expression is defined"
|
||||||
|
|
Loading…
Reference in New Issue