From ff8c8bd0a0c2ee5224751f42610a6d940c86eef7 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 28 Sep 2022 15:22:44 -0400 Subject: [PATCH] Agent: Use PUT instead of POST to send agent logs --- .../island_api_client/http_island_api_client.py | 2 +- .../island_api_client/test_http_island_api_client.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/island_api_client/http_island_api_client.py b/monkey/infection_monkey/island_api_client/http_island_api_client.py index 2c0e2319a..eb2420c95 100644 --- a/monkey/infection_monkey/island_api_client/http_island_api_client.py +++ b/monkey/infection_monkey/island_api_client/http_island_api_client.py @@ -93,7 +93,7 @@ class HTTPIslandAPIClient(IIslandAPIClient): @handle_island_errors def send_log(self, agent_id: AgentID, log_contents: str): - response = requests.post( # noqa: DUO123 + response = requests.put( # noqa: DUO123 f"{self._api_url}/agent-logs/{agent_id}", json=log_contents, verify=False, diff --git a/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py b/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py index 2eb013d9a..e65ba4eba 100644 --- a/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py +++ b/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py @@ -119,7 +119,7 @@ def test_island_api_client__send_log(island_api_client, actual_error, expected_e island_api_client.connect(SERVER) with pytest.raises(expected_error): - m.post(ISLAND_SEND_LOG_URI, exc=actual_error) + m.put(ISLAND_SEND_LOG_URI, exc=actual_error) island_api_client.send_log(agent_id=AGENT_ID, log_contents="some_data") @@ -136,7 +136,7 @@ def test_island_api_client_send_log__status_code(island_api_client, status_code, island_api_client.connect(SERVER) with pytest.raises(expected_error): - m.post(ISLAND_SEND_LOG_URI, status_code=status_code) + m.put(ISLAND_SEND_LOG_URI, status_code=status_code) island_api_client.send_log(agent_id=AGENT_ID, log_contents="some_data")