fixes beautifier `get` `ignoreip` (explicit convert to string)

pull/3598/merge
sebres 2025-08-12 23:26:42 +02:00
parent bf4903538d
commit 3ce6f344e3
2 changed files with 10 additions and 3 deletions

View File

@ -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:

View File

@ -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"