fix: stabilize auth tests and mailu service

This commit is contained in:
Brad Stein 2026-01-19 19:20:42 -03:00
parent 1bed2d9294
commit 248177dedd
4 changed files with 7 additions and 2 deletions

View File

@ -30,11 +30,11 @@ class KeycloakOIDC:
def verify(self, token: str) -> dict[str, Any]:
if not token:
raise ValueError("missing token")
jwks = self._get_jwks()
header = jwt.get_unverified_header(token)
kid = header.get("kid")
if not isinstance(kid, str):
raise ValueError("token missing kid")
jwks = self._get_jwks()
key = None
for candidate in jwks.get("keys", []) if isinstance(jwks, dict) else []:
if isinstance(candidate, dict) and candidate.get("kid") == kid:

View File

@ -61,3 +61,6 @@ class MailuService:
if isinstance(raw, str) and raw.strip():
return raw.strip()
return f"{username}@{settings.mailu_domain}"
mailu = MailuService()

2
pytest.ini Normal file
View File

@ -0,0 +1,2 @@
[pytest]
pythonpath = .

View File

@ -1,7 +1,7 @@
fastapi==0.115.11
uvicorn[standard]==0.30.6
httpx==0.27.2
PyJWT==2.10.1
PyJWT[crypto]==2.10.1
psycopg[binary]==3.2.6
psycopg-pool==3.2.6
croniter==2.0.7