mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
feat(test): added more tests
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user