Skip to content

Commit

Permalink
fix(anta.tests): Fix VerifySSHStatus to support 4.32 text output (#874)
Browse files Browse the repository at this point in the history
Co-authored-by: Guillaume Mulocher <[email protected]>
  • Loading branch information
carl-baillargeon and gmuloc authored Oct 10, 2024
1 parent 86e8602 commit 387c281
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion anta/tests/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test(self) -> None:
except StopIteration:
self.result.is_failure("Could not find SSH status in returned output.")
return
status = line.split("is ")[1]
status = line.split()[-1]

if status == "disabled":
self.result.is_success()
Expand Down
22 changes: 21 additions & 1 deletion tests/units/anta_tests/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,32 @@
"expected": {"result": "failure", "messages": ["Could not find SSH status in returned output."]},
},
{
"name": "failure-ssh-disabled",
"name": "failure-ssh-enabled",
"test": VerifySSHStatus,
"eos_data": ["SSHD status for Default VRF is enabled\nSSH connection limit is 50\nSSH per host connection limit is 20\nFIPS status: disabled\n\n"],
"inputs": None,
"expected": {"result": "failure", "messages": ["SSHD status for Default VRF is enabled"]},
},
{
"name": "success-4.32",
"test": VerifySSHStatus,
"eos_data": [
"User certificate authentication methods: none (neither trusted CA nor SSL profile configured)\n"
"SSHD status for Default VRF: disabled\nSSH connection limit: 50\nSSH per host connection limit: 20\nFIPS status: disabled\n\n"
],
"inputs": None,
"expected": {"result": "success"},
},
{
"name": "failure-ssh-enabled-4.32",
"test": VerifySSHStatus,
"eos_data": [
"User certificate authentication methods: none (neither trusted CA nor SSL profile configured)\n"
"SSHD status for Default VRF: enabled\nSSH connection limit: 50\nSSH per host connection limit: 20\nFIPS status: disabled\n\n"
],
"inputs": None,
"expected": {"result": "failure", "messages": ["SSHD status for Default VRF: enabled"]},
},
{
"name": "success",
"test": VerifySSHIPv4Acl,
Expand Down

0 comments on commit 387c281

Please sign in to comment.