Skip to content

Commit

Permalink
addressed review commets: updated inline comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vitthalmagadum committed Dec 2, 2024
1 parent 1c8d295 commit e5088e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions anta/tests/stun.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class VerifyStunClient(AntaTest):
This test performs the following checks for each specified address family:
1. Validates that the STUN client is configured.
1. Validates that there is a translation for the STUN client.
2. If public IP and port details are provided, validates their correctness against the configuration.
Expected Results
Expand Down Expand Up @@ -75,19 +75,19 @@ def test(self) -> None:

# If no bindings are found for the STUN client, mark the test as a failure and continue with the next client
if not bindings:
self.result.is_failure(f"{client_input} - STUN client transaction not found.")
self.result.is_failure(f"{client_input} - STUN client translation not found.")
continue

# Extract the transaction ID from the bindings
transaction_id = next(iter(bindings.keys()))

# If public address is provided, add it to the actual and expected STUN data
# Verifying the public address if provided
if input_public_address and str(input_public_address) != (actual_public_address := get_value(bindings, f"{transaction_id}.publicAddress.ip")):
self.result.is_failure(f"{client_input} - Incorrect public-facing address; Expected: {input_public_address} Actual: {actual_public_address}")
self.result.is_failure(f"{client_input} - Incorrect public-facing address - Expected: {input_public_address} Actual: {actual_public_address}")

# If public port is provided, add it to the actual and expected STUN data
# Verifying the public port if provided
if input_public_port and input_public_port != (actual_public_port := get_value(bindings, f"{transaction_id}.publicAddress.port")):
self.result.is_failure(f"{client_input} - Incorrect public-facing port; Expected: {input_public_port} Actual: {actual_public_port}")
self.result.is_failure(f"{client_input} - Incorrect public-facing port - Expected: {input_public_port} Actual: {actual_public_port}")


class VerifyStunServer(AntaTest):
Expand Down
18 changes: 9 additions & 9 deletions tests/units/anta_tests/test_stun.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
"expected": {
"result": "failure",
"messages": [
"Client 100.64.3.2 Port: 4500 - Incorrect public-facing address; Expected: 192.164.3.2 Actual: 192.64.3.2",
"Client 172.18.3.2 Port: 4500 - Incorrect public-facing address; Expected: 192.118.3.2 Actual: 192.18.3.2",
"Client 100.64.3.2 Port: 4500 - Incorrect public-facing address - Expected: 192.164.3.2 Actual: 192.64.3.2",
"Client 172.18.3.2 Port: 4500 - Incorrect public-facing address - Expected: 192.118.3.2 Actual: 192.18.3.2",
],
},
},
Expand All @@ -108,7 +108,7 @@
},
"expected": {
"result": "failure",
"messages": ["Client 100.64.3.2 Port: 4500 - STUN client transaction not found.", "Client 172.18.3.2 Port: 4500 - STUN client transaction not found."],
"messages": ["Client 100.64.3.2 Port: 4500 - STUN client translation not found.", "Client 172.18.3.2 Port: 4500 - STUN client translation not found."],
},
},
{
Expand All @@ -134,9 +134,9 @@
"expected": {
"result": "failure",
"messages": [
"Client 100.64.3.2 Port: 4500 - STUN client transaction not found.",
"Client 172.18.3.2 Port: 4500 - Incorrect public-facing address; Expected: 192.118.3.2 Actual: 192.18.3.2",
"Client 172.18.3.2 Port: 4500 - Incorrect public-facing port; Expected: 6006 Actual: 4800",
"Client 100.64.3.2 Port: 4500 - STUN client translation not found.",
"Client 172.18.3.2 Port: 4500 - Incorrect public-facing address - Expected: 192.118.3.2 Actual: 192.18.3.2",
"Client 172.18.3.2 Port: 4500 - Incorrect public-facing port - Expected: 6006 Actual: 4800",
],
},
},
Expand All @@ -163,9 +163,9 @@
"expected": {
"result": "failure",
"messages": [
"Client 100.64.3.2 Port: 4500 - STUN client transaction not found.",
"Client 172.18.4.2 Port: 4800 - Incorrect public-facing address; Expected: 192.118.3.2 Actual: 192.18.3.2",
"Client 172.18.4.2 Port: 4800 - Incorrect public-facing port; Expected: 6006 Actual: 4800",
"Client 100.64.3.2 Port: 4500 - STUN client translation not found.",
"Client 172.18.4.2 Port: 4800 - Incorrect public-facing address - Expected: 192.118.3.2 Actual: 192.18.3.2",
"Client 172.18.4.2 Port: 4800 - Incorrect public-facing port - Expected: 6006 Actual: 4800",
],
},
},
Expand Down

0 comments on commit e5088e1

Please sign in to comment.