feat(test): added more tests

This commit is contained in:
ribardej
2025-11-06 11:20:10 +01:00
parent 733e7a8918
commit 8b301c386e
2 changed files with 1 additions and 41 deletions

View File

@@ -113,25 +113,6 @@ async def test_register_then_login_and_fetch_me(fastapi_app):
assert me.status_code == status.HTTP_200_OK
assert me.json()["email"] == email
@pytest.mark.asyncio
async def test_revoked_token_blocked_everywhere(fastapi_app, test_user):
transport = ASGITransport(app=fastapi_app, raise_app_exceptions=True)
async with AsyncClient(transport=transport, base_url="http://testserver") as ac:
login = await ac.post("/auth/jwt/login", data=test_user)
token = login.json()["access_token"]
headers = {"Authorization": f"Bearer {token}"}
# Sanity check works before logout
ok = await ac.get("/authenticated-route", headers=headers)
assert ok.status_code == status.HTTP_200_OK
# Logout revokes token
lo = await ac.post("/auth/jwt/logout", headers=headers)
assert lo.status_code in (status.HTTP_200_OK, status.HTTP_204_NO_CONTENT)
# Token should be rejected on any protected endpoint
blocked = await ac.get("/authenticated-route", headers=headers)
assert blocked.status_code == status.HTTP_401_UNAUTHORIZED
@pytest.mark.asyncio
async def test_delete_current_user_revokes_access(fastapi_app):