Skip to content
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): Added test case to verify isis interface authentication mode #1064

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

geetanjalimanegslab
Copy link
Collaborator

Description

Verifies IS-IS interfaces are running in the correct authentication mode.

Expected Results

* Success: The test will pass if all provided IS-IS interfaces are running in the correct authentication mode.
* Failure: The test will fail if any of the provided IS-IS interfaces are not configured or running in the incorrect authentication mode.
* Skipped: The test will be skipped if IS-IS is not configured.

Fixes #881

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have run pre-commit for code linting and typing (pre-commit run)
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (tox -e testenv)

Copy link

codspeed-hq bot commented Mar 5, 2025

CodSpeed Performance Report

Merging #1064 will not alter performance

Comparing geetanjalimanegslab:issue_881_isis_auth (68f128c) with main (2672570)

Summary

✅ 22 untouched benchmarks

interfaces: list[ISISInterface] | None = None
"""IS-IS interfaces detail. Required field in the `VerifyISISInterfaceAuthMode` test."""

# TODO: Need to review this in ANTA 2.0 as VRF is used in both ISISInterface model.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# TODO: Need to review this in ANTA 2.0 as VRF is used in both ISISInterface model.
# TODO: Need to review this model in ANTA 2.0 as VRF is used in ISISInterface model as well.

@@ -64,6 +68,12 @@ class ISISInterface(BaseModel):
"""Expected number of IS-IS neighbors on this interface. Required field in the `VerifyISISNeighborCount` test."""
mode: Literal["point-to-point", "broadcast", "passive"] | None = None
"""IS-IS network type of the interface. Required field in the `VerifyISISInterfaceMode` test."""
authentication_mode: Literal["MD5", "Text", "SHA", "shared-secret"] | None = None
"""IS-IS authentication mode. Required field in the `VerifyISISInterfaceAuthMode` test."""
auth_key_id: int | None = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be constrained.

anta.tests.routing:
isis:
- VerifyISISInterfaceAuthMode:
instances:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will not affect but please take care of indentation

raise ValueError(msg)
return instances

def _validate_isis_auth_mode(self, instance_data: str, act_interface_detail: dict[str, Any], interface_data: dict[str, Any]) -> str | None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _validate_isis_auth_mode(self, instance_data: str, act_interface_detail: dict[str, Any], interface_data: dict[str, Any]) -> str | None:
def _validate_isis_auth_mode(self, instance_data: ISISInstance, interface_data: ISISInterface, act_interface_detail: dict[str, Any]) -> str | None:


# If authentication mode is not configured, test fails.
if not (act_interface_detail.get("authenticationMode") or act_interface_detail["sharedSecretProfile"]):
return f"{instance_data} Interface: {interface_data.name} Level: {interface_data.level} - Authentication mode not configured"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may have this details in str()

Applicable to all this place

{
"name": "success",
"test": VerifyISISInterfaceAuthMode,
"eos_data": [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want these details in eos date.

},
},
{
"name": "failure-is-is-not-configured",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"name": "failure-is-is-not-configured",
"name": "skipped-ISIS-not-configured",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the test case to verify ISIS authentication modes
2 participants