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

Method test_invalid_state

tests/test_router_oauth.py:146–165  ·  view source on GitHub ↗
(
        self,
        async_method_mocker: AsyncMethodMocker,
        test_app_client: httpx.AsyncClient,
        oauth_client: BaseOAuth2,
        user_oauth: UserOAuthModel,
        access_token: str,
    )

Source from the content-addressed store, hash-verified

144)
145class TestCallback:
146 async def test_invalid_state(
147 self,
148 async_method_mocker: AsyncMethodMocker,
149 test_app_client: httpx.AsyncClient,
150 oauth_client: BaseOAuth2,
151 user_oauth: UserOAuthModel,
152 access_token: str,
153 ):
154 async_method_mocker(oauth_client, "get_access_token", return_value=access_token)
155 get_id_email_mock = async_method_mocker(
156 oauth_client, "get_id_email", return_value=("user_oauth1", user_oauth.email)
157 )
158
159 response = await test_app_client.get(
160 "/oauth/callback",
161 params={"code": "CODE", "state": "STATE"},
162 )
163 assert response.status_code == status.HTTP_400_BAD_REQUEST
164
165 get_id_email_mock.assert_not_called()
166
167 @pytest.mark.parametrize("csrf_token", [None, "invalid_csrf_token"])
168 async def test_invalid_csrf_state(

Callers

nothing calls this directly

Calls 2

async_method_mockerFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected