Skip to content
Snippets Groups Projects
Commit e1ed8a76 authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

fix(test_fail2ban): int comparison & output

parent d5e42ce2
No related branches found
No related tags found
No related merge requests found
...@@ -69,8 +69,10 @@ def get_jails() -> list: ...@@ -69,8 +69,10 @@ def get_jails() -> list:
:rtype: list :rtype: list
""" """
_, output = u.exec_cmd(["fail2ban-client status | grep 'Jail list'"]) _, output = u.exec_cmd(
jails = output.split(":")[1].replace(" ", "").split(",") "fail2ban-client status | grep 'Jail list'", log_output=False
)
jails = output.split(":")[1].strip().replace(" ", "").split(",")
return jails return jails
...@@ -85,12 +87,13 @@ def check_jail_banned(name: str) -> int: ...@@ -85,12 +87,13 @@ def check_jail_banned(name: str) -> int:
""" """
_, output = u.exec_cmd( _, output = u.exec_cmd(
"fail2ban-client status {} | grep 'Currently banned'".format(name) "fail2ban-client status {} | grep 'Currently banned'".format(name),
log_output=False,
) )
banned = output.split(":")[1].replace(" ", "") banned = output.split(":")[1].strip()
if banned: if banned:
return banned return int(banned)
return 0 return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment