Skip to content

Commit 8c93004

Browse files
committed
GB-42: Tests adapted to new error handling
1 parent b3ce107 commit 8c93004

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/test_middleware.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from httpx import AsyncClient
33
from fastapi.responses import JSONResponse
4-
from fastapi_oauth2.exceptions import OAuth2AuthenticationError
4+
from starlette.authentication import AuthenticationError
55

66

77
@pytest.mark.anyio
@@ -81,6 +81,7 @@ async def test_middleware_reports_invalid_jwt(get_app):
8181
badtoken=jwt.encode({"bad": "token"}, 'badsecret', 'HS256')
8282
client.cookies.update(dict(Authorization=f"Bearer: {badtoken}"))
8383

84-
with pytest.raises(OAuth2AuthenticationError, match="401: Signature verification failed.") as ctx:
85-
response = await client.get("/user")
84+
response = await client.get("/user")
85+
assert response.status_code == 401 # Not authenticated
86+
assert response.text == "Signature verification failed."
8687

0 commit comments

Comments
 (0)