Adding upstream version 1.4.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
dc7df702ea
commit
7996c81031
166 changed files with 13787 additions and 11959 deletions
|
@ -5,48 +5,24 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
import sys
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from anta.models import AntaTest
|
||||
from anta.result_manager.models import AntaTestStatus
|
||||
from anta.tests.stun import VerifyStunClientTranslation, VerifyStunServer
|
||||
from tests.units.anta_tests import test
|
||||
|
||||
DATA: list[dict[str, Any]] = [
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyStunClientTranslation,
|
||||
if TYPE_CHECKING:
|
||||
from tests.units.anta_tests import AntaUnitTestDataDict
|
||||
|
||||
DATA: AntaUnitTestDataDict = {
|
||||
(VerifyStunClientTranslation, "success"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"bindings": {
|
||||
"000000010a64ff0100000000": {
|
||||
"sourceAddress": {"ip": "100.64.3.2", "port": 4500},
|
||||
"publicAddress": {"ip": "192.64.3.2", "port": 6006},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"bindings": {
|
||||
"000000040a64ff0100000000": {
|
||||
"sourceAddress": {"ip": "172.18.3.2", "port": 4500},
|
||||
"publicAddress": {"ip": "192.18.3.2", "port": 6006},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"bindings": {
|
||||
"000000040a64ff0100000000": {
|
||||
"sourceAddress": {"ip": "172.18.4.2", "port": 4500},
|
||||
"publicAddress": {"ip": "192.18.4.2", "port": 6006},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"bindings": {
|
||||
"000000040a64ff0100000000": {
|
||||
"sourceAddress": {"ip": "172.18.6.2", "port": 4500},
|
||||
"publicAddress": {"ip": "192.18.6.2", "port": 6006},
|
||||
}
|
||||
}
|
||||
},
|
||||
{"bindings": {"000000010a64ff0100000000": {"sourceAddress": {"ip": "100.64.3.2", "port": 4500}, "publicAddress": {"ip": "192.64.3.2", "port": 6006}}}},
|
||||
{"bindings": {"000000040a64ff0100000000": {"sourceAddress": {"ip": "172.18.3.2", "port": 4500}, "publicAddress": {"ip": "192.18.3.2", "port": 6006}}}},
|
||||
{"bindings": {"000000040a64ff0100000000": {"sourceAddress": {"ip": "172.18.4.2", "port": 4500}, "publicAddress": {"ip": "192.18.4.2", "port": 6006}}}},
|
||||
{"bindings": {"000000040a64ff0100000000": {"sourceAddress": {"ip": "172.18.6.2", "port": 4500}, "publicAddress": {"ip": "192.18.6.2", "port": 6006}}}},
|
||||
],
|
||||
"inputs": {
|
||||
"stun_clients": [
|
||||
|
@ -56,28 +32,12 @@ DATA: list[dict[str, Any]] = [
|
|||
{"source_address": "172.18.6.2", "source_port": 4500, "public_port": 6006},
|
||||
]
|
||||
},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure-incorrect-public-ip",
|
||||
"test": VerifyStunClientTranslation,
|
||||
(VerifyStunClientTranslation, "failure-incorrect-public-ip"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"bindings": {
|
||||
"000000010a64ff0100000000": {
|
||||
"sourceAddress": {"ip": "100.64.3.2", "port": 4500},
|
||||
"publicAddress": {"ip": "192.64.3.2", "port": 6006},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"bindings": {
|
||||
"000000040a64ff0100000000": {
|
||||
"sourceAddress": {"ip": "172.18.3.2", "port": 4500},
|
||||
"publicAddress": {"ip": "192.18.3.2", "port": 6006},
|
||||
}
|
||||
}
|
||||
},
|
||||
{"bindings": {"000000010a64ff0100000000": {"sourceAddress": {"ip": "100.64.3.2", "port": 4500}, "publicAddress": {"ip": "192.64.3.2", "port": 6006}}}},
|
||||
{"bindings": {"000000040a64ff0100000000": {"sourceAddress": {"ip": "172.18.3.2", "port": 4500}, "publicAddress": {"ip": "192.18.3.2", "port": 6006}}}},
|
||||
],
|
||||
"inputs": {
|
||||
"stun_clients": [
|
||||
|
@ -86,20 +46,15 @@ DATA: list[dict[str, Any]] = [
|
|||
]
|
||||
},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.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",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "failure-no-client",
|
||||
"test": VerifyStunClientTranslation,
|
||||
"eos_data": [
|
||||
{"bindings": {}},
|
||||
{"bindings": {}},
|
||||
],
|
||||
(VerifyStunClientTranslation, "failure-no-client"): {
|
||||
"eos_data": [{"bindings": {}}, {"bindings": {}}],
|
||||
"inputs": {
|
||||
"stun_clients": [
|
||||
{"source_address": "100.64.3.2", "public_address": "192.164.3.2", "source_port": 4500, "public_port": 6006},
|
||||
|
@ -107,23 +62,14 @@ DATA: list[dict[str, Any]] = [
|
|||
]
|
||||
},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"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"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "failure-incorrect-public-port",
|
||||
"test": VerifyStunClientTranslation,
|
||||
(VerifyStunClientTranslation, "failure-incorrect-public-port"): {
|
||||
"eos_data": [
|
||||
{"bindings": {}},
|
||||
{
|
||||
"bindings": {
|
||||
"000000040a64ff0100000000": {
|
||||
"sourceAddress": {"ip": "172.18.3.2", "port": 4500},
|
||||
"publicAddress": {"ip": "192.18.3.2", "port": 4800},
|
||||
}
|
||||
}
|
||||
},
|
||||
{"bindings": {"000000040a64ff0100000000": {"sourceAddress": {"ip": "172.18.3.2", "port": 4500}, "publicAddress": {"ip": "192.18.3.2", "port": 4800}}}},
|
||||
],
|
||||
"inputs": {
|
||||
"stun_clients": [
|
||||
|
@ -132,7 +78,7 @@ DATA: list[dict[str, Any]] = [
|
|||
]
|
||||
},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": [
|
||||
"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",
|
||||
|
@ -140,19 +86,10 @@ DATA: list[dict[str, Any]] = [
|
|||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "failure-all-type",
|
||||
"test": VerifyStunClientTranslation,
|
||||
(VerifyStunClientTranslation, "failure-all-type"): {
|
||||
"eos_data": [
|
||||
{"bindings": {}},
|
||||
{
|
||||
"bindings": {
|
||||
"000000040a64ff0100000000": {
|
||||
"sourceAddress": {"ip": "172.18.3.2", "port": 4500},
|
||||
"publicAddress": {"ip": "192.18.3.2", "port": 4800},
|
||||
}
|
||||
}
|
||||
},
|
||||
{"bindings": {"000000040a64ff0100000000": {"sourceAddress": {"ip": "172.18.3.2", "port": 4500}, "publicAddress": {"ip": "192.18.3.2", "port": 4800}}}},
|
||||
],
|
||||
"inputs": {
|
||||
"stun_clients": [
|
||||
|
@ -161,7 +98,7 @@ DATA: list[dict[str, Any]] = [
|
|||
]
|
||||
},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": [
|
||||
"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",
|
||||
|
@ -169,61 +106,20 @@ DATA: list[dict[str, Any]] = [
|
|||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyStunServer,
|
||||
"eos_data": [
|
||||
{
|
||||
"enabled": True,
|
||||
"pid": 1895,
|
||||
}
|
||||
],
|
||||
(VerifyStunServer, "success"): {"eos_data": [{"enabled": True, "pid": 1895}], "inputs": {}, "expected": {"result": AntaTestStatus.SUCCESS}},
|
||||
(VerifyStunServer, "failure-disabled"): {
|
||||
"eos_data": [{"enabled": False, "pid": 1895}],
|
||||
"inputs": {},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["STUN server status is disabled"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-disabled",
|
||||
"test": VerifyStunServer,
|
||||
"eos_data": [
|
||||
{
|
||||
"enabled": False,
|
||||
"pid": 1895,
|
||||
}
|
||||
],
|
||||
(VerifyStunServer, "failure-not-running"): {
|
||||
"eos_data": [{"enabled": True, "pid": 0}],
|
||||
"inputs": {},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["STUN server status is disabled"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["STUN server is not running"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-not-running",
|
||||
"test": VerifyStunServer,
|
||||
"eos_data": [
|
||||
{
|
||||
"enabled": True,
|
||||
"pid": 0,
|
||||
}
|
||||
],
|
||||
(VerifyStunServer, "failure-not-running-disabled"): {
|
||||
"eos_data": [{"enabled": False, "pid": 0}],
|
||||
"inputs": {},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["STUN server is not running"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["STUN server status is disabled and not running"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-not-running-disabled",
|
||||
"test": VerifyStunServer,
|
||||
"eos_data": [
|
||||
{
|
||||
"enabled": False,
|
||||
"pid": 0,
|
||||
}
|
||||
],
|
||||
"inputs": {},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["STUN server status is disabled and not running"],
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue