From d52e919b6667c8d9f70c381939181ca952f8c02e Mon Sep 17 00:00:00 2001 From: Alyssa Dai Date: Tue, 16 Jul 2024 20:08:39 -0400 Subject: [PATCH] test empty query succeeds when auth is disabled --- tests/test_query.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_query.py b/tests/test_query.py index a3fb12a..752b5a3 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -495,3 +495,17 @@ def test_aggregate_query_response_structure( assert all( dataset["subject_data"] == "protected" for dataset in response.json() ) + + +def test_query_without_token_succeeds_when_auth_disabled( + test_app, + mock_successful_get, + monkeypatch, + disable_auth, +): + """ + Test that when authentication is disabled, a request to the /query route without a token succeeds. + """ + monkeypatch.setattr(crud, "get", mock_successful_get) + response = test_app.get("/query/") + assert response.status_code == 200