File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 1
1
import pytest
2
2
from httpx import AsyncClient
3
3
from fastapi .responses import JSONResponse
4
- from fastapi_oauth2 . exceptions import OAuth2AuthenticationError
4
+ from starlette . authentication import AuthenticationError
5
5
6
6
7
7
@pytest .mark .anyio
@@ -81,6 +81,7 @@ async def test_middleware_reports_invalid_jwt(get_app):
81
81
badtoken = jwt .encode ({"bad" : "token" }, 'badsecret' , 'HS256' )
82
82
client .cookies .update (dict (Authorization = f"Bearer: { badtoken } " ))
83
83
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."
86
87
You can’t perform that action at this time.
0 commit comments