UT: Convert lists to tuples before comparing values in configuration tests

Probably not the best way to do this
This commit is contained in:
Shreya Malviya 2022-08-30 14:24:43 +05:30
parent 1f77fd468a
commit eb207de919
2 changed files with 9 additions and 4 deletions

View File

@ -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():

View File

@ -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):