We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b3ce107 commit 8c93004Copy full SHA for 8c93004
tests/test_middleware.py
@@ -1,7 +1,7 @@
1
import pytest
2
from httpx import AsyncClient
3
from fastapi.responses import JSONResponse
4
-from fastapi_oauth2.exceptions import OAuth2AuthenticationError
+from starlette.authentication import AuthenticationError
5
6
7
@pytest.mark.anyio
@@ -81,6 +81,7 @@ async def test_middleware_reports_invalid_jwt(get_app):
81
badtoken=jwt.encode({"bad": "token"}, 'badsecret', 'HS256')
82
client.cookies.update(dict(Authorization=f"Bearer: {badtoken}"))
83
84
- with pytest.raises(OAuth2AuthenticationError, match="401: Signature verification failed.") as ctx:
85
- response = await client.get("/user")
+ response = await client.get("/user")
+ assert response.status_code == 401 # Not authenticated
86
+ assert response.text == "Signature verification failed."
87
0 commit comments