-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(anta.tests): Added testcase to verify IPv4 ACL sequence entries #544
Conversation
anta/tests/security.py
Outdated
@@ -377,3 +378,73 @@ def test(self) -> None: | |||
failed_log = f"SSL certificate `{certificate.certificate_name}` is not configured properly:" | |||
failed_log += get_failed_logs(expected_certificate_details, actual_certificate_details) | |||
self.result.is_failure(f"{failed_log}\n") | |||
|
|||
|
|||
class VerifyIpv4ACL(AntaTest): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class VerifyIpv4ACL(AntaTest): | |
class VerifyIPv4ACL(AntaTest): |
anta/tests/security.py
Outdated
"""List of IPv4 ACL to verify""" | ||
|
||
class Ipv4Acl(BaseModel): | ||
"""Detail of IPv4 ACl""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Detail of IPv4 ACl""" | |
"""Detail of IPv4 ACL""" |
anta/tests/security.py
Outdated
* failure: The test will fail if an IPv4 ACL is not configured or entries are not in sequence. | ||
""" | ||
|
||
name = "VerifyIpv4ACL" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name = "VerifyIpv4ACL" | |
name = "VerifyIPv4ACL" |
anta/tests/security.py
Outdated
commands = [AntaTemplate(template="show ip access-lists {acl}")] | ||
|
||
class Input(AntaTest.Input): | ||
"""Inputs for the VerifyIpv4ACL test.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Inputs for the VerifyIpv4ACL test.""" | |
"""Inputs for the VerifyIPv4ACL test.""" |
anta/tests/security.py
Outdated
ipv4_access_list: List[Ipv4Acl] | ||
"""List of IPv4 ACL to verify""" | ||
|
||
class Ipv4Acl(BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class Ipv4Acl(BaseModel): | |
class IPv4ACL(BaseModel): |
anta/tests/security.py
Outdated
name: str | ||
"""Name of IPv4 ACL""" | ||
|
||
entries: List[Ipv4AclEntries] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entries: List[Ipv4AclEntries] | |
entries: List[IPv4ACLEntries] |
anta/tests/security.py
Outdated
entries: List[Ipv4AclEntries] | ||
"""List of IPv4 ACL entries""" | ||
|
||
class Ipv4AclEntries(BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class Ipv4AclEntries(BaseModel): | |
class IPv4ACLEntries(BaseModel): |
anta/tests/security.py
Outdated
class Input(AntaTest.Input): | ||
"""Inputs for the VerifyIpv4ACL test.""" | ||
|
||
ipv4_access_list: List[Ipv4Acl] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ipv4_access_list: List[Ipv4Acl] | |
ipv4_access_lists: List[IPv4ACL] |
anta/tests/security.py
Outdated
"""Action of an ACL entry""" | ||
|
||
def render(self, template: AntaTemplate) -> list[AntaCommand]: | ||
return [template.render(acl=acl.name, entries=acl.entries) for acl in self.inputs.ipv4_access_list] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return [template.render(acl=acl.name, entries=acl.entries) for acl in self.inputs.ipv4_access_list] | |
return [template.render(acl=acl.name, entries=acl.entries) for acl in self.inputs.ipv4_access_lists] |
examples/tests.yaml
Outdated
@@ -205,6 +205,22 @@ anta.tests.security: | |||
common_name: Arista Networks Internal IT Root Cert Authority | |||
encryption_algorithm: RSA | |||
key_size: 4096 | |||
- VerifyIpv4ACL: | |||
ipv4_access_list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ipv4_access_list: | |
ipv4_access_lists: |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Description
Added testcase to verify IPv4 ACL sequence entries.
Note: This test only check if a acl is configured and input entries sequence are same in actual output. It will not fail if we have 2 entries of a acl in input but in actual output there are more then 2 entries. If input two entries sequence is match with actual output then testcase will pass. @carl-baillargeon
Fixes #543
Checklist:
pre-commit run
)tox -e testenv
)