Skip to content

Commit 6b3ec5d

Browse files
committed
test: empty db-anon-role lacks role in logs
1 parent 6804ce3 commit 6b3ec5d

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

test/io/test_io.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,28 @@ def test_expired_jwt_log_lacks_role(defaultenv):
10471047
)
10481048

10491049

1050+
def test_log_lacks_role_with_empty_anon_role(defaultenv):
1051+
"Requests are logged without a role when db-anon-role is empty."
1052+
1053+
env = {
1054+
**defaultenv,
1055+
"PGRST_DB_CONFIG": "false",
1056+
"PGRST_DB_ANON_ROLE": "",
1057+
}
1058+
1059+
with run(env=env) as postgrest:
1060+
response = postgrest.session.get("/projects")
1061+
assert response.status_code == 401
1062+
1063+
output = postgrest.read_stdout(nlines=1)
1064+
1065+
assert len(output) == 1
1066+
assert re.match(
1067+
r'- - - \[.+\] "GET /projects HTTP/1.1" 401 \d+ "" "python-requests/.+"',
1068+
output[0],
1069+
)
1070+
1071+
10501072
def test_invalid_rpc_method_log_contains_role(defaultenv):
10511073
"Invalid RPC method requests are logged with the anonymous role."
10521074

0 commit comments

Comments
 (0)