From 018a8ce24886256996d7eccd606db747dd3d6910 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Fri, 29 Sep 2023 16:50:16 +0000 Subject: [PATCH] test(service): an unauthorized query --- tests/test_graphql/test_services.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/test_graphql/test_services.py b/tests/test_graphql/test_services.py index 4a170cf..fcd2b85 100644 --- a/tests/test_graphql/test_services.py +++ b/tests/test_graphql/test_services.py @@ -164,16 +164,20 @@ def api_stop_by_name(client, service_id: str) -> dict: def api_all_services(authorized_client): - response = authorized_client.post( - "/graphql", - json={"query": generate_service_query([API_SERVICES_QUERY])}, - ) + response = api_all_services_raw(authorized_client) data = get_data(response) result = data["services"]["allServices"] assert result is not None return result +def api_all_services_raw(client): + return client.post( + "/graphql", + json={"query": generate_service_query([API_SERVICES_QUERY])}, + ) + + def api_service(authorized_client, service: Service): id = service.get_id() for _service in api_all_services(authorized_client): @@ -231,6 +235,14 @@ def test_stop_return_value(authorized_client, only_dummy_service): assert service["status"] == ServiceStatus.INACTIVE.value +def test_allservices_unauthorized(client, only_dummy_service): + dummy_service = only_dummy_service + response = api_all_services_raw(client) + + assert response.status_code == 200 + assert response.json().get("data") is None + + def test_start_unauthorized(client, only_dummy_service): dummy_service = only_dummy_service mutation_response = api_start(client, dummy_service)