From 6b3ec5d9e07cc9efbb3f2762956767ffae173d46 Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Tue, 5 May 2026 19:09:45 -0500 Subject: [PATCH] test: empty db-anon-role lacks role in logs --- test/io/test_io.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/io/test_io.py b/test/io/test_io.py index a1bbfaf93..4bf0e4fb2 100644 --- a/test/io/test_io.py +++ b/test/io/test_io.py @@ -1047,6 +1047,28 @@ def test_expired_jwt_log_lacks_role(defaultenv): ) +def test_log_lacks_role_with_empty_anon_role(defaultenv): + "Requests are logged without a role when db-anon-role is empty." + + env = { + **defaultenv, + "PGRST_DB_CONFIG": "false", + "PGRST_DB_ANON_ROLE": "", + } + + with run(env=env) as postgrest: + response = postgrest.session.get("/projects") + assert response.status_code == 401 + + output = postgrest.read_stdout(nlines=1) + + assert len(output) == 1 + assert re.match( + r'- - - \[.+\] "GET /projects HTTP/1.1" 401 \d+ "" "python-requests/.+"', + output[0], + ) + + def test_invalid_rpc_method_log_contains_role(defaultenv): "Invalid RPC method requests are logged with the anonymous role."