From 6804ce3cbe12cfc47a9bd2a6f51de008d792d579 Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Tue, 5 May 2026 18:37:20 -0500 Subject: [PATCH] test: empty schema cache error has role in logs --- test/io/test_io.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/io/test_io.py b/test/io/test_io.py index f56346e97..a1bbfaf93 100644 --- a/test/io/test_io.py +++ b/test/io/test_io.py @@ -1063,6 +1063,33 @@ def test_invalid_rpc_method_log_contains_role(defaultenv): ) +def test_empty_schema_cache_log_contains_jwt_role(defaultenv): + "Requests are logged with the role when the schema cache is empty on startup" + + env = { + **defaultenv, + "PGRST_INTERNAL_SCHEMA_CACHE_QUERY_SLEEP": "1000", + "PGRST_JWT_SECRET": SECRET, + } + headers = jwtauthheader({"role": "postgrest_test_author"}, SECRET) + + with run(env=env, wait_for_readiness=False) as postgrest: + postgrest.wait_until_scache_starts_loading() + + response = postgrest.session.get("/authors_only", headers=headers) + assert response.status_code == 503 + + output = drain_stdout(postgrest) + + assert any( + re.match( + r'- - postgrest_test_author \[.+\] "GET /authors_only HTTP/1.1" 503 \d+ "" "python-requests/.+"', + line, + ) + for line in output + ) + + def test_no_pool_connection_required_on_bad_http_logic(defaultenv): "no pool connection should be consumed for failing on invalid http logic"