Skip to content

Commit

Permalink
Added deprecation to maintain backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vitthalmagadum committed Dec 3, 2024
1 parent 2520a0f commit 8e1e49b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
33 changes: 32 additions & 1 deletion anta/tests/stun.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
# mypy: disable-error-code=attr-defined
from __future__ import annotations

from typing import ClassVar
from typing import Any, ClassVar
from warnings import warn

from anta.decorators import deprecated_test
from anta.input_models.stun import StunClientTranslation
from anta.models import AntaCommand, AntaTemplate, AntaTest
from anta.tools import get_value
Expand Down Expand Up @@ -90,6 +92,35 @@ def test(self) -> None:
self.result.is_failure(f"{client_input} - Incorrect public-facing port - Expected: {input_public_port} Actual: {actual_public_port}")


class VerifyStunClient(VerifyStunClientTranslation):
"""[deprecated] Verifies the translation for a source address on a STUN client.
Alias for the VerifyStunClientTranslation test to maintain backward compatibility.
When initialized, it will emit a deprecation warning and call the VerifyStunClientTranslation test.
TODO: Remove this class in ANTA v2.0.0.
Examples
--------
```yaml
anta.tests.stun:
- VerifyStunClient:
stun_clients:
- source_address: 172.18.3.2
public_address: 172.18.3.21
source_port: 4500
public_port: 6006
```
"""

name = "VerifyStunClient"
description = "[deprecated] Verifies the translation for a source address on a STUN client."

@deprecated_test("VerifyStunClientTranslation")
def test(self):
super.test()


class VerifyStunServer(AntaTest):
"""Verifies the STUN server status is enabled and running.
Expand Down
8 changes: 8 additions & 0 deletions examples/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,15 @@ anta.tests.stp:
# Verifies the number of changes across all interfaces in the Spanning Tree Protocol (STP) topology is below a threshold.
threshold: 10
anta.tests.stun:
- VerifyStunClient:
# Verifies the translation for a source address on a STUN client.
stun_clients:
- source_address: 172.18.3.2
public_address: 172.18.3.21
source_port: 4500
public_port: 6006
- VerifyStunClientTranslation:
# Verifies the translation for a source address on a STUN client.
stun_clients:
- source_address: 172.18.3.2
public_address: 172.18.3.21
Expand Down

0 comments on commit 8e1e49b

Please sign in to comment.