From eb207de9194e69d7c7aa15f8006d76dc60a4c383 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 30 Aug 2022 14:24:43 +0530 Subject: [PATCH] UT: Convert lists to tuples before comparing values in configuration tests Probably not the best way to do this --- .../common/agent_configuration/test_agent_configuration.py | 7 ++++--- .../monkey_island/cc/resources/test_agent_configuration.py | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/monkey/tests/unit_tests/common/agent_configuration/test_agent_configuration.py b/monkey/tests/unit_tests/common/agent_configuration/test_agent_configuration.py index ed1f1bfa3..cb561aac5 100644 --- a/monkey/tests/unit_tests/common/agent_configuration/test_agent_configuration.py +++ b/monkey/tests/unit_tests/common/agent_configuration/test_agent_configuration.py @@ -23,6 +23,7 @@ from tests.common.example_agent_configuration import ( WINDOWS_COMMAND, WINDOWS_FILENAME, ) +from tests.utils import convert_lists_to_tuples from common.agent_configuration.agent_configuration import AgentConfiguration from common.agent_configuration.agent_sub_configurations import ( @@ -180,7 +181,7 @@ def test_exploitation_configuration(): config_dict = config.dict() assert isinstance(config, ExploitationConfiguration) - assert config_dict == EXPLOITATION_CONFIGURATION + assert config_dict == convert_lists_to_tuples(EXPLOITATION_CONFIGURATION.copy()) def test_propagation_configuration(): @@ -191,7 +192,7 @@ def test_propagation_configuration(): assert isinstance(config.network_scan, NetworkScanConfiguration) assert isinstance(config.exploitation, ExploitationConfiguration) assert config.maximum_depth == 5 - assert config_dict == PROPAGATION_CONFIGURATION + assert config_dict == convert_lists_to_tuples(PROPAGATION_CONFIGURATION.copy()) def test_propagation_configuration__invalid_maximum_depth(): @@ -213,7 +214,7 @@ def test_agent_configuration(): assert isinstance(config.credential_collectors[0], PluginConfiguration) assert isinstance(config.payloads[0], PluginConfiguration) assert isinstance(config.propagation, PropagationConfiguration) - assert config_dict == AGENT_CONFIGURATION + assert config_dict == convert_lists_to_tuples(AGENT_CONFIGURATION.copy()) def test_agent_configuration__negative_keep_tunnel_open_time(): diff --git a/monkey/tests/unit_tests/monkey_island/cc/resources/test_agent_configuration.py b/monkey/tests/unit_tests/monkey_island/cc/resources/test_agent_configuration.py index f2010a59e..9845405c8 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/resources/test_agent_configuration.py +++ b/monkey/tests/unit_tests/monkey_island/cc/resources/test_agent_configuration.py @@ -5,6 +5,7 @@ from tests.common import StubDIContainer from tests.common.example_agent_configuration import AGENT_CONFIGURATION from tests.monkey_island import InMemoryAgentConfigurationRepository from tests.unit_tests.monkey_island.conftest import get_url_for_resource +from tests.utils import convert_lists_to_tuples from common.agent_configuration import AgentConfiguration from monkey_island.cc.repository import IAgentConfigurationRepository @@ -33,7 +34,10 @@ def test_agent_configuration_endpoint(flask_client): resp = flask_client.get(AGENT_CONFIGURATION_URL) assert resp.status_code == 200 - assert json.loads(resp.data) == AGENT_CONFIGURATION + + assert convert_lists_to_tuples(json.loads(resp.data)) == convert_lists_to_tuples( + AGENT_CONFIGURATION.copy() + ) def test_agent_configuration_invalid_config(flask_client):