From 8e1e49bc272632f55bae4e884a558c727522b202 Mon Sep 17 00:00:00 2001 From: vitthalmagadum Date: Tue, 3 Dec 2024 08:02:37 -0500 Subject: [PATCH] Added deprecation to maintain backward compatibility --- anta/tests/stun.py | 33 ++++++++++++++++++++++++++++++++- examples/tests.yaml | 8 ++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/anta/tests/stun.py b/anta/tests/stun.py index b6ae4127e..b050ea7d5 100644 --- a/anta/tests/stun.py +++ b/anta/tests/stun.py @@ -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 @@ -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. diff --git a/examples/tests.yaml b/examples/tests.yaml index ed9772108..acba8a456 100644 --- a/examples/tests.yaml +++ b/examples/tests.yaml @@ -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