forked from p15670423/monkey
Merge pull request #2158 from guardicore/2071-POST-to-PUT
Change POST to PUT in /api/agent-configuration
This commit is contained in:
commit
efec473b08
|
@ -24,7 +24,7 @@ class AgentConfiguration(AbstractResource):
|
|||
return make_response(configuration_json, 200)
|
||||
|
||||
@jwt_required
|
||||
def post(self):
|
||||
def put(self):
|
||||
try:
|
||||
configuration_object = AgentConfigurationObject.from_mapping(request.json)
|
||||
self._agent_configuration_repository.store_configuration(configuration_object)
|
||||
|
|
|
@ -97,7 +97,7 @@ const ConfigImportModal = (props: Props) => {
|
|||
delete config['advanced'];
|
||||
authComponent.authFetch(configImportEndpoint,
|
||||
{
|
||||
method: 'POST',
|
||||
method: 'PUT',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(config)
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ const ConfigImportModal = (props: Props) => {
|
|||
props.onClose(true);
|
||||
} else {
|
||||
setUploadStatus(UploadStatuses.error);
|
||||
setErrorMessage("Configuration file is corrupt or in an outdated format.");
|
||||
setErrorMessage("Configuration file is corrupt or in an outdated format");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -142,9 +142,20 @@ const ConfigImportModal = (props: Props) => {
|
|||
setErrorMessage('File is not in a valid json format');
|
||||
return
|
||||
}
|
||||
setConfigEncrypted(importContents['metadata']['encrypted']);
|
||||
setConfigContents(importContents['configuration']);
|
||||
setConfigCredentials(importContents['credentials']);
|
||||
|
||||
try {
|
||||
setConfigEncrypted(importContents['metadata']['encrypted']);
|
||||
setConfigContents(importContents['configuration']);
|
||||
setConfigCredentials(importContents['credentials']);
|
||||
} catch (e) {
|
||||
if (e instanceof TypeError) {
|
||||
setErrorMessage('Missing required fields; configuration file is most '
|
||||
+ 'likely from an older version of Infection Monkey.')
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
reader.readAsText(event.target.files[0]);
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ class ConfigurePageComponent extends AuthComponent {
|
|||
return (
|
||||
this.authFetch(CONFIG_URL,
|
||||
{
|
||||
method: 'POST',
|
||||
method: 'PUT',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(config)
|
||||
})
|
||||
|
|
|
@ -26,7 +26,7 @@ def flask_client(build_flask_client):
|
|||
|
||||
|
||||
def test_agent_configuration_endpoint(flask_client):
|
||||
resp = flask_client.post(
|
||||
resp = flask_client.put(
|
||||
AGENT_CONFIGURATION_URL,
|
||||
json=AgentConfiguration.to_mapping(AGENT_CONFIGURATION),
|
||||
follow_redirects=True,
|
||||
|
@ -39,12 +39,12 @@ def test_agent_configuration_endpoint(flask_client):
|
|||
|
||||
|
||||
def test_agent_configuration_invalid_config(flask_client):
|
||||
resp = flask_client.post(AGENT_CONFIGURATION_URL, json={"invalid_config": "invalid_stuff"})
|
||||
resp = flask_client.put(AGENT_CONFIGURATION_URL, json={"invalid_config": "invalid_stuff"})
|
||||
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
def test_agent_configuration_invalid_json(flask_client):
|
||||
resp = flask_client.post(AGENT_CONFIGURATION_URL, data="InvalidJson!")
|
||||
resp = flask_client.put(AGENT_CONFIGURATION_URL, data="InvalidJson!")
|
||||
|
||||
assert resp.status_code == 400
|
||||
|
|
Loading…
Reference in New Issue