From f4dee02874d9f11628539b1c6b6c8f79981fcc7b Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 22 Jul 2022 13:22:13 -0400 Subject: [PATCH] Island: Properly handle Credentials JSON in resource --- .../monkey_island/cc/resources/propagation_credentials.py | 2 +- .../cc/resources/test_propagation_credentials.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/monkey/monkey_island/cc/resources/propagation_credentials.py b/monkey/monkey_island/cc/resources/propagation_credentials.py index 2342d0f37..f3cd05132 100644 --- a/monkey/monkey_island/cc/resources/propagation_credentials.py +++ b/monkey/monkey_island/cc/resources/propagation_credentials.py @@ -29,7 +29,7 @@ class PropagationCredentials(AbstractResource): return propagation_credentials, HTTPStatus.OK def post(self, collection=None): - credentials = [Credentials.from_json(c) for c in request.json] + credentials = [Credentials.from_mapping(c) for c in request.json] if collection == _configured_collection: self._credentials_repository.save_configured_credentials(credentials) diff --git a/monkey/tests/unit_tests/monkey_island/cc/resources/test_propagation_credentials.py b/monkey/tests/unit_tests/monkey_island/cc/resources/test_propagation_credentials.py index e613d85b5..37fdb131b 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/resources/test_propagation_credentials.py +++ b/monkey/tests/unit_tests/monkey_island/cc/resources/test_propagation_credentials.py @@ -89,8 +89,8 @@ def test_propagation_credentials_endpoint__post_stolen(flask_client, credentials resp = flask_client.post( url, json=[ - Credentials.to_json(LM_HASH_CREDENTIALS), - Credentials.to_json(NT_HASH_CREDENTIALS), + Credentials.to_mapping(LM_HASH_CREDENTIALS), + Credentials.to_mapping(NT_HASH_CREDENTIALS), ], ) assert resp.status_code == HTTPStatus.NO_CONTENT @@ -134,8 +134,8 @@ def test_propagation_credentials_endpoint__post_not_found(flask_client): resp = flask_client.post( NON_EXISTENT_COLLECTION_URL, json=[ - Credentials.to_json(LM_HASH_CREDENTIALS), - Credentials.to_json(NT_HASH_CREDENTIALS), + Credentials.to_mapping(LM_HASH_CREDENTIALS), + Credentials.to_mapping(NT_HASH_CREDENTIALS), ], ) assert resp.status_code == HTTPStatus.NOT_FOUND