From 5a6173163bc06e45559649652d55ba3b66392205 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 27 Jul 2022 16:06:37 +0530 Subject: [PATCH] UT: Add test for TCPScanConfigurationSchema port validation --- .../common/configuration/test_agent_configuration.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py b/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py index d7e4bebd4..3eb90b525 100644 --- a/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py +++ b/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py @@ -135,6 +135,17 @@ def test_tcp_scan_configuration_schema(): assert config.ports == tuple(PORTS) +@pytest.mark.parametrize("ports", [[-1, 1, 2], [1, 2, 99999]]) +def test_tcp_scan_configuration_schema__ports_out_of_range(ports): + schema = TCPScanConfigurationSchema() + + invalid_ports_configuration = TCP_SCAN_CONFIGURATION.copy() + invalid_ports_configuration["ports"] = ports + + with pytest.raises(ValidationError): + schema.load(invalid_ports_configuration) + + def test_network_scan_configuration(): schema = NetworkScanConfigurationSchema()