Skip to content

Commit 6804ce3

Browse files
committed
test: empty schema cache error has role in logs
1 parent 42e53e8 commit 6804ce3

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

test/io/test_io.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,33 @@ def test_invalid_rpc_method_log_contains_role(defaultenv):
10631063
)
10641064

10651065

1066+
def test_empty_schema_cache_log_contains_jwt_role(defaultenv):
1067+
"Requests are logged with the role when the schema cache is empty on startup"
1068+
1069+
env = {
1070+
**defaultenv,
1071+
"PGRST_INTERNAL_SCHEMA_CACHE_QUERY_SLEEP": "1000",
1072+
"PGRST_JWT_SECRET": SECRET,
1073+
}
1074+
headers = jwtauthheader({"role": "postgrest_test_author"}, SECRET)
1075+
1076+
with run(env=env, wait_for_readiness=False) as postgrest:
1077+
postgrest.wait_until_scache_starts_loading()
1078+
1079+
response = postgrest.session.get("/authors_only", headers=headers)
1080+
assert response.status_code == 503
1081+
1082+
output = drain_stdout(postgrest)
1083+
1084+
assert any(
1085+
re.match(
1086+
r'- - postgrest_test_author \[.+\] "GET /authors_only HTTP/1.1" 503 \d+ "" "python-requests/.+"',
1087+
line,
1088+
)
1089+
for line in output
1090+
)
1091+
1092+
10661093
def test_no_pool_connection_required_on_bad_http_logic(defaultenv):
10671094
"no pool connection should be consumed for failing on invalid http logic"
10681095

0 commit comments

Comments
 (0)