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 11import pytest
22from httpx import AsyncClient
33from 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
You can’t perform that action at this time.
0 commit comments