From 9c17cf44b18a8f1fe1484745636fb2e7e079a3dc Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 3 Aug 2022 13:35:02 +0530 Subject: [PATCH] UT: Pass headers in PUT requests in test_island_mode.py --- .../cc/resources/test_island_mode.py | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/resources/test_island_mode.py b/monkey/tests/unit_tests/monkey_island/cc/resources/test_island_mode.py index 97aa300e0..c0321394a 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/resources/test_island_mode.py +++ b/monkey/tests/unit_tests/monkey_island/cc/resources/test_island_mode.py @@ -38,14 +38,20 @@ def flask_client(build_flask_client): ) def test_island_mode_post(flask_client, mode): resp = flask_client.put( - IslandModeResource.urls[0], data=json.dumps(mode), follow_redirects=True + IslandModeResource.urls[0], + data=json.dumps(mode), + headers={"Content-Type": "application/json"}, + follow_redirects=True, ) assert resp.status_code == HTTPStatus.NO_CONTENT def test_island_mode_post__invalid_mode(flask_client): resp = flask_client.put( - IslandModeResource.urls[0], data=json.dumps("bogus mode"), follow_redirects=True + IslandModeResource.urls[0], + data=json.dumps("bogus mode"), + headers={"Content-Type": "application/json"}, + follow_redirects=True, ) assert resp.status_code == HTTPStatus.UNPROCESSABLE_ENTITY @@ -61,6 +67,7 @@ def test_island_mode_post__internal_server_error(build_flask_client): resp = flask_client.put( IslandModeResource.urls[0], data=json.dumps(IslandMode.RANSOMWARE.value), + headers={"Content-Type": "application/json"}, follow_redirects=True, ) @@ -69,7 +76,12 @@ def test_island_mode_post__internal_server_error(build_flask_client): @pytest.mark.parametrize("mode", [IslandMode.RANSOMWARE.value, IslandMode.ADVANCED.value]) def test_island_mode_endpoint(flask_client, mode): - flask_client.put(IslandModeResource.urls[0], data=json.dumps(mode), follow_redirects=True) + flask_client.put( + IslandModeResource.urls[0], + data=json.dumps(mode), + headers={"Content-Type": "application/json"}, + follow_redirects=True, + ) resp = flask_client.get(IslandModeResource.urls[0], follow_redirects=True) assert resp.status_code == HTTPStatus.OK assert json.loads(resp.data) == mode @@ -77,7 +89,10 @@ def test_island_mode_endpoint(flask_client, mode): def test_island_mode_endpoint__invalid_mode(flask_client): resp_post = flask_client.put( - IslandModeResource.urls[0], data=json.dumps("bogus_mode"), follow_redirects=True + IslandModeResource.urls[0], + data=json.dumps("bogus_mode"), + headers={"Content-Type": "application/json"}, + follow_redirects=True, ) resp_get = flask_client.get(IslandModeResource.urls[0], follow_redirects=True) assert resp_post.status_code == HTTPStatus.UNPROCESSABLE_ENTITY