(
self,
async_method_mocker: AsyncMethodMocker,
test_app_client: httpx.AsyncClient,
oauth_client: BaseOAuth2,
user_oauth: UserOAuthModel,
user_manager_oauth: UserManagerMock,
access_token: str,
)
| 222 | assert user_manager_oauth.on_after_login.called is False |
| 223 | |
| 224 | async def test_active_user( |
| 225 | self, |
| 226 | async_method_mocker: AsyncMethodMocker, |
| 227 | test_app_client: httpx.AsyncClient, |
| 228 | oauth_client: BaseOAuth2, |
| 229 | user_oauth: UserOAuthModel, |
| 230 | user_manager_oauth: UserManagerMock, |
| 231 | access_token: str, |
| 232 | ): |
| 233 | state_jwt = generate_state_token({"csrftoken": "CSRFTOKEN"}, JWT_SECRET) |
| 234 | async_method_mocker(oauth_client, "get_access_token", return_value=access_token) |
| 235 | async_method_mocker( |
| 236 | oauth_client, "get_id_email", return_value=("user_oauth1", user_oauth.email) |
| 237 | ) |
| 238 | async_method_mocker( |
| 239 | user_manager_oauth, "oauth_callback", return_value=user_oauth |
| 240 | ) |
| 241 | |
| 242 | test_app_client.cookies.set("fastapiusersoauthcsrf", "CSRFTOKEN") |
| 243 | response = await test_app_client.get( |
| 244 | "/oauth/callback", |
| 245 | params={"code": "CODE", "state": state_jwt}, |
| 246 | ) |
| 247 | |
| 248 | assert response.status_code == status.HTTP_200_OK |
| 249 | |
| 250 | data = cast(dict[str, Any], response.json()) |
| 251 | assert data["access_token"] == str(user_oauth.id) |
| 252 | |
| 253 | assert user_manager_oauth.on_after_login.called is True |
| 254 | |
| 255 | async def test_inactive_user( |
| 256 | self, |
nothing calls this directly
no test coverage detected