forked from p15670423/monkey
UT: Fix false negative in test_agent_configuration_endpoint()
This commit is contained in:
parent
f321d72dc5
commit
1b1bc85804
|
@ -6,8 +6,13 @@ from tests.common.example_agent_configuration import AGENT_CONFIGURATION
|
||||||
from tests.monkey_island import InMemoryAgentConfigurationRepository
|
from tests.monkey_island import InMemoryAgentConfigurationRepository
|
||||||
from tests.unit_tests.monkey_island.conftest import get_url_for_resource
|
from tests.unit_tests.monkey_island.conftest import get_url_for_resource
|
||||||
|
|
||||||
|
from common.configuration import AgentConfiguration
|
||||||
from monkey_island.cc.repository import IAgentConfigurationRepository
|
from monkey_island.cc.repository import IAgentConfigurationRepository
|
||||||
from monkey_island.cc.resources.agent_configuration import AgentConfiguration
|
from monkey_island.cc.resources.agent_configuration import (
|
||||||
|
AgentConfiguration as AgentConfigurationResource,
|
||||||
|
)
|
||||||
|
|
||||||
|
AGENT_CONFIGURATION_URL = get_url_for_resource(AgentConfigurationResource)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -21,30 +26,27 @@ def flask_client(build_flask_client):
|
||||||
|
|
||||||
|
|
||||||
def test_agent_configuration_endpoint(flask_client):
|
def test_agent_configuration_endpoint(flask_client):
|
||||||
agent_configuration_url = get_url_for_resource(AgentConfiguration)
|
resp = flask_client.post(
|
||||||
|
AGENT_CONFIGURATION_URL,
|
||||||
flask_client.post(
|
data=AgentConfiguration.to_json(AGENT_CONFIGURATION),
|
||||||
agent_configuration_url, data=json.dumps(AGENT_CONFIGURATION), follow_redirects=True
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
resp = flask_client.get(agent_configuration_url)
|
assert resp.status_code == 200
|
||||||
|
resp = flask_client.get(AGENT_CONFIGURATION_URL)
|
||||||
|
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert json.loads(resp.data) == AGENT_CONFIGURATION
|
assert json.loads(resp.data) == AGENT_CONFIGURATION
|
||||||
|
|
||||||
|
|
||||||
def test_agent_configuration_invalid_config(flask_client):
|
def test_agent_configuration_invalid_config(flask_client):
|
||||||
agent_configuration_url = get_url_for_resource(AgentConfiguration)
|
|
||||||
|
|
||||||
resp = flask_client.post(
|
resp = flask_client.post(
|
||||||
agent_configuration_url, data=json.dumps({"invalid_config": "invalid_stuff"})
|
AGENT_CONFIGURATION_URL, data=json.dumps({"invalid_config": "invalid_stuff"})
|
||||||
)
|
)
|
||||||
|
|
||||||
assert resp.status_code == 400
|
assert resp.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
def test_agent_configuration_invalid_json(flask_client):
|
def test_agent_configuration_invalid_json(flask_client):
|
||||||
agent_configuration_url = get_url_for_resource(AgentConfiguration)
|
resp = flask_client.post(AGENT_CONFIGURATION_URL, data="InvalidJson!")
|
||||||
|
|
||||||
resp = flask_client.post(agent_configuration_url, data="InvalidJson!")
|
|
||||||
|
|
||||||
assert resp.status_code == 400
|
assert resp.status_code == 400
|
||||||
|
|
Loading…
Reference in New Issue