test: adjust jwt claims error test to avoid failure

The JWT claims IO test fails too often. This breaks our
workflows. This commit adjusts the edge cases in test to
prevent flakiness.
This commit is contained in:
Taimoor Zaeem
2025-07-19 12:16:29 +00:00
committed by Wolfgang Walther
parent 161f37f1f1
commit 96bbbe35e1
+6 -6
View File
@@ -102,20 +102,20 @@ def test_jwt_errors(defaultenv):
assert response.status_code == 401 assert response.status_code == 401
assert response.json()["message"] == 'role "not_existing" does not exist' assert response.json()["message"] == 'role "not_existing" does not exist'
# -31 seconds, because we allow clock skew of 30 seconds # -35 seconds, because we allow clock skew of 30 seconds
headers = jwtauthheader({"exp": relativeSeconds(-31)}, SECRET) headers = jwtauthheader({"exp": relativeSeconds(-35)}, SECRET)
response = postgrest.session.get("/", headers=headers) response = postgrest.session.get("/", headers=headers)
assert response.status_code == 401 assert response.status_code == 401
assert response.json()["message"] == "JWT expired" assert response.json()["message"] == "JWT expired"
# 31 seconds, because we allow clock skew of 30 seconds # 35 seconds, because we allow clock skew of 30 seconds
headers = jwtauthheader({"nbf": relativeSeconds(31)}, SECRET) headers = jwtauthheader({"nbf": relativeSeconds(35)}, SECRET)
response = postgrest.session.get("/", headers=headers) response = postgrest.session.get("/", headers=headers)
assert response.status_code == 401 assert response.status_code == 401
assert response.json()["message"] == "JWT not yet valid" assert response.json()["message"] == "JWT not yet valid"
# 31 seconds, because we allow clock skew of 30 seconds # 35 seconds, because we allow clock skew of 35 seconds
headers = jwtauthheader({"iat": relativeSeconds(31)}, SECRET) headers = jwtauthheader({"iat": relativeSeconds(35)}, SECRET)
response = postgrest.session.get("/", headers=headers) response = postgrest.session.get("/", headers=headers)
assert response.status_code == 401 assert response.status_code == 401
assert response.json()["message"] == "JWT issued at future" assert response.json()["message"] == "JWT issued at future"