File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
10661093def test_no_pool_connection_required_on_bad_http_logic (defaultenv ):
10671094 "no pool connection should be consumed for failing on invalid http logic"
10681095
You can’t perform that action at this time.
0 commit comments