forked from p15670423/monkey
UT: Use from_dict() and from_json() in tests
This commit is contained in:
parent
28250daffe
commit
e4eee6a5eb
|
@ -1,4 +1,4 @@
|
|||
from common.configuration import AgentConfigurationSchema
|
||||
from common.configuration import AgentConfiguration
|
||||
|
||||
flat_config = {
|
||||
"keep_tunnel_open_time": 30,
|
||||
|
@ -116,4 +116,4 @@ flat_config = {
|
|||
},
|
||||
}
|
||||
|
||||
DEFAULT_CONFIG = AgentConfigurationSchema().load(flat_config)
|
||||
DEFAULT_CONFIG = AgentConfiguration.from_dict(flat_config)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
from tests.common.example_agent_configuration import AGENT_CONFIGURATION
|
||||
|
||||
from common.configuration.agent_configuration import AgentConfigurationSchema
|
||||
from common.configuration.agent_configuration import AgentConfiguration
|
||||
from monkey_island.cc.repository import IAgentConfigurationRepository
|
||||
|
||||
|
||||
class InMemoryAgentConfigurationRepository(IAgentConfigurationRepository):
|
||||
def __init__(self):
|
||||
self._configuration = AgentConfigurationSchema().load(AGENT_CONFIGURATION)
|
||||
self._configuration = AgentConfiguration.from_dict(AGENT_CONFIGURATION)
|
||||
|
||||
def get_configuration(self):
|
||||
return self._configuration
|
||||
|
|
|
@ -161,7 +161,7 @@ def test_propagation_configuration():
|
|||
def test_agent_configuration():
|
||||
schema = AgentConfigurationSchema()
|
||||
|
||||
config = schema.load(AGENT_CONFIGURATION)
|
||||
config = AgentConfiguration.from_dict(AGENT_CONFIGURATION)
|
||||
config_dict = schema.dump(config)
|
||||
|
||||
assert isinstance(config, AgentConfiguration)
|
||||
|
@ -175,9 +175,7 @@ def test_agent_configuration():
|
|||
|
||||
|
||||
def test_default_agent_configuration():
|
||||
schema = AgentConfigurationSchema()
|
||||
|
||||
config = schema.loads(DEFAULT_AGENT_CONFIGURATION_JSON)
|
||||
config = AgentConfiguration.from_json(DEFAULT_AGENT_CONFIGURATION_JSON)
|
||||
|
||||
assert isinstance(config, AgentConfiguration)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import pytest
|
|||
from tests.common.example_agent_configuration import AGENT_CONFIGURATION
|
||||
from tests.monkey_island import OpenErrorFileRepository, SingleFileRepository
|
||||
|
||||
from common.configuration import AgentConfigurationSchema
|
||||
from common.configuration import AgentConfiguration
|
||||
from monkey_island.cc.repository import FileAgentConfigurationRepository, RetrievalError
|
||||
|
||||
|
||||
|
@ -12,8 +12,7 @@ def repository(default_agent_configuration):
|
|||
|
||||
|
||||
def test_store_agent_config(repository):
|
||||
schema = AgentConfigurationSchema()
|
||||
agent_configuration = schema.load(AGENT_CONFIGURATION)
|
||||
agent_configuration = AgentConfiguration.from_dict(AGENT_CONFIGURATION)
|
||||
|
||||
repository.store_configuration(agent_configuration)
|
||||
retrieved_agent_configuration = repository.get_configuration()
|
||||
|
|
Loading…
Reference in New Issue