forked from p15670423/monkey
UT: Pass headers in PUT requests in test_island_mode.py
This commit is contained in:
parent
d56951f152
commit
9c17cf44b1
|
@ -38,14 +38,20 @@ def flask_client(build_flask_client):
|
||||||
)
|
)
|
||||||
def test_island_mode_post(flask_client, mode):
|
def test_island_mode_post(flask_client, mode):
|
||||||
resp = flask_client.put(
|
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
|
assert resp.status_code == HTTPStatus.NO_CONTENT
|
||||||
|
|
||||||
|
|
||||||
def test_island_mode_post__invalid_mode(flask_client):
|
def test_island_mode_post__invalid_mode(flask_client):
|
||||||
resp = flask_client.put(
|
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
|
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(
|
resp = flask_client.put(
|
||||||
IslandModeResource.urls[0],
|
IslandModeResource.urls[0],
|
||||||
data=json.dumps(IslandMode.RANSOMWARE.value),
|
data=json.dumps(IslandMode.RANSOMWARE.value),
|
||||||
|
headers={"Content-Type": "application/json"},
|
||||||
follow_redirects=True,
|
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])
|
@pytest.mark.parametrize("mode", [IslandMode.RANSOMWARE.value, IslandMode.ADVANCED.value])
|
||||||
def test_island_mode_endpoint(flask_client, mode):
|
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)
|
resp = flask_client.get(IslandModeResource.urls[0], follow_redirects=True)
|
||||||
assert resp.status_code == HTTPStatus.OK
|
assert resp.status_code == HTTPStatus.OK
|
||||||
assert json.loads(resp.data) == mode
|
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):
|
def test_island_mode_endpoint__invalid_mode(flask_client):
|
||||||
resp_post = flask_client.put(
|
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)
|
resp_get = flask_client.get(IslandModeResource.urls[0], follow_redirects=True)
|
||||||
assert resp_post.status_code == HTTPStatus.UNPROCESSABLE_ENTITY
|
assert resp_post.status_code == HTTPStatus.UNPROCESSABLE_ENTITY
|
||||||
|
|
Loading…
Reference in New Issue