MCPcopy Create free account
hub / github.com/fastapi-users/fastapi-users / test_inactive_user

Method test_inactive_user

tests/test_router_oauth.py:255–282  ·  view source on GitHub ↗
(
        self,
        async_method_mocker: AsyncMethodMocker,
        test_app_client: httpx.AsyncClient,
        oauth_client: BaseOAuth2,
        inactive_user_oauth: UserOAuthModel,
        user_manager_oauth: UserManagerMock,
        access_token: str,
    )

Source from the content-addressed store, hash-verified

253 assert user_manager_oauth.on_after_login.called is True
254
255 async def test_inactive_user(
256 self,
257 async_method_mocker: AsyncMethodMocker,
258 test_app_client: httpx.AsyncClient,
259 oauth_client: BaseOAuth2,
260 inactive_user_oauth: UserOAuthModel,
261 user_manager_oauth: UserManagerMock,
262 access_token: str,
263 ):
264 state_jwt = generate_state_token({"csrftoken": "CSRFTOKEN"}, JWT_SECRET)
265 async_method_mocker(oauth_client, "get_access_token", return_value=access_token)
266 async_method_mocker(
267 oauth_client,
268 "get_id_email",
269 return_value=("user_oauth1", inactive_user_oauth.email),
270 )
271 async_method_mocker(
272 user_manager_oauth, "oauth_callback", return_value=inactive_user_oauth
273 )
274
275 test_app_client.cookies.set("fastapiusersoauthcsrf", "CSRFTOKEN")
276 response = await test_app_client.get(
277 "/oauth/callback",
278 params={"code": "CODE", "state": state_jwt},
279 )
280
281 assert response.status_code == status.HTTP_400_BAD_REQUEST
282 assert user_manager_oauth.on_after_login.called is False
283
284 async def test_redirect_url_router(
285 self,

Callers

nothing calls this directly

Calls 4

generate_state_tokenFunction · 0.90
async_method_mockerFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected