From 09c7540e7badc758e419c885c848ab577354e2ab Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 19 Jan 2023 11:49:32 -0500 Subject: [PATCH] UT: Add a test to verify exploiter order preservation --- .../test_agent_sub_configurations.py | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/monkey/tests/unit_tests/common/agent_configuration/test_agent_sub_configurations.py b/monkey/tests/unit_tests/common/agent_configuration/test_agent_sub_configurations.py index f09033da264..488b31c508f 100644 --- a/monkey/tests/unit_tests/common/agent_configuration/test_agent_sub_configurations.py +++ b/monkey/tests/unit_tests/common/agent_configuration/test_agent_sub_configurations.py @@ -1,4 +1,4 @@ -from common.agent_configuration import TCPScanConfiguration +from common.agent_configuration import ExploitationConfiguration, TCPScanConfiguration expected_tcp_schema = { "type": "object", @@ -30,3 +30,28 @@ def test_sub_config_to_json_schema(): del tcp_schema["description"] assert tcp_schema == expected_tcp_schema + + +raw_exploitation_configuration = { + "exploiters": { + "Exploiter1": {}, + "SSHExploiter": {}, + "Exploiter2": {}, + "WmiExploiter": {"smb_download_timeout": 30}, + "Exploiter3": {}, + "Exploiter4": {}, + "Exploiter5": {}, + "Exploiter6": {}, + }, + "options": {"http_ports": []}, +} + + +def test_exploitation_sub_configurations__preserve_exploiter_order(): + parsed_exploiter_config = ExploitationConfiguration(**raw_exploitation_configuration) + + for actual, expected in zip( + parsed_exploiter_config.exploiters.keys(), + raw_exploitation_configuration["exploiters"].keys(), + ): + assert actual == expected