From 95a6c143346399044cdbbab58b1ba74377bdb48b Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 27 Jul 2022 17:48:36 +0530 Subject: [PATCH] UT: Add test for ExploitationOptionsConfigurationSchema port validation --- .../common/configuration/test_agent_configuration.py | 10 ++++++++++ 1 file changed, 10 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 95539b9c7..9b2f1ba47 100644 --- a/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py +++ b/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py @@ -191,6 +191,16 @@ def test_exploitation_options_configuration_schema(): assert config.http_ports == tuple(ports) +@pytest.mark.parametrize("ports", [[-1, 1, 2], [1, 2, 99999]]) +def test_exploitation_options_configuration_schema__ports_out_of_range(ports): + schema = ExploitationOptionsConfigurationSchema() + + invalid_ports_configuration = {"http_ports": ports} + + with pytest.raises(ValidationError): + schema.load(invalid_ports_configuration) + + def test_exploiter_configuration_schema(): name = "bond" options = {"gun": "Walther PPK", "car": "Aston Martin DB5"}