Skip to content

Commit

Permalink
Updated test name and model name
Browse files Browse the repository at this point in the history
  • Loading branch information
vitthalmagadum committed Dec 2, 2024
1 parent 6fb100f commit fe4d354
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions anta/input_models/stun.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from anta.custom_types import Port


class ClientAddress(BaseModel):
"""STUN (Session Traversal Utilities for NAT) model represents the configuration of an IPv4-based client."""
class StunClientTranslation(BaseModel):
"""STUN (Session Traversal Utilities for NAT) model represents the configuration of an IPv4-based client translations."""

model_config = ConfigDict(extra="forbid")
source_address: IPv4Address
Expand All @@ -26,7 +26,7 @@ class ClientAddress(BaseModel):
"""The public-facing port number of the STUN client, discovered via the STUN server."""

def __str__(self) -> str:
"""Return a human-readable string representation of the ClientAddress for reporting.
"""Return a human-readable string representation of the StunClientTranslation for reporting.
Examples
--------
Expand Down
14 changes: 7 additions & 7 deletions anta/tests/stun.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

from typing import ClassVar

from anta.input_models.stun import ClientAddress
from anta.input_models.stun import StunClientTranslation
from anta.models import AntaCommand, AntaTemplate, AntaTest
from anta.tools import get_value


class VerifyStunClient(AntaTest):
class VerifyStunClientTranslation(AntaTest):
"""Verifies the translation for a source address on a STUN client.
This test performs the following checks for each specified address family:
Expand All @@ -35,7 +35,7 @@ class VerifyStunClient(AntaTest):
--------
```yaml
anta.tests.stun:
- VerifyStunClient:
- VerifyStunClientTranslation:
stun_clients:
- source_address: 172.18.3.2
public_address: 172.18.3.21
Expand All @@ -52,19 +52,19 @@ class VerifyStunClient(AntaTest):
commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show stun client translations {source_address} {source_port}", revision=1)]

class Input(AntaTest.Input):
"""Input model for the VerifyStunClient test."""
"""Input model for the VerifyStunClientTranslation test."""

stun_clients: list[ClientAddress]
stun_clients: list[StunClientTranslation]
"""List of STUN clients."""
ClientAddress: ClassVar[type[ClientAddress]] = ClientAddress
StunClientTranslation: ClassVar[type[StunClientTranslation]] = StunClientTranslation

def render(self, template: AntaTemplate) -> list[AntaCommand]:
"""Render the template for each STUN translation."""
return [template.render(source_address=client.source_address, source_port=client.source_port) for client in self.inputs.stun_clients]

@AntaTest.anta_test
def test(self) -> None:
"""Main test function for VerifyStunClient."""
"""Main test function for VerifyStunClientTranslation."""
self.result.is_success()

# Iterate over each command output and corresponding client input
Expand Down
2 changes: 1 addition & 1 deletion examples/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ anta.tests.stp:
threshold: 10

anta.tests.stun:
- VerifyStunClient:
- VerifyStunClientTranslation:
stun_clients:
- source_address: 172.18.3.2
public_address: 172.18.3.21
Expand Down
12 changes: 6 additions & 6 deletions tests/units/anta_tests/test_stun.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

from typing import Any

from anta.tests.stun import VerifyStunClient, VerifyStunServer
from anta.tests.stun import VerifyStunClientTranslation, VerifyStunServer
from tests.units.anta_tests import test

DATA: list[dict[str, Any]] = [
{
"name": "success",
"test": VerifyStunClient,
"test": VerifyStunClientTranslation,
"eos_data": [
{
"bindings": {
Expand Down Expand Up @@ -60,7 +60,7 @@
},
{
"name": "failure-incorrect-public-ip",
"test": VerifyStunClient,
"test": VerifyStunClientTranslation,
"eos_data": [
{
"bindings": {
Expand Down Expand Up @@ -95,7 +95,7 @@
},
{
"name": "failure-no-client",
"test": VerifyStunClient,
"test": VerifyStunClientTranslation,
"eos_data": [
{"bindings": {}},
{"bindings": {}},
Expand All @@ -113,7 +113,7 @@
},
{
"name": "failure-incorrect-public-port",
"test": VerifyStunClient,
"test": VerifyStunClientTranslation,
"eos_data": [
{"bindings": {}},
{
Expand Down Expand Up @@ -142,7 +142,7 @@
},
{
"name": "failure-all-type",
"test": VerifyStunClient,
"test": VerifyStunClientTranslation,
"eos_data": [
{"bindings": {}},
{
Expand Down

0 comments on commit fe4d354

Please sign in to comment.