def example( self, info, **kwargs ) -> typing.List[typing.Union[Edge[int], Edge[str]]]: return [ Edge(cursor=strawberry.ID("1"), node=1), Edge(cursor=strawberry.ID("2"), node="string"), ]
async def parse_id_token(self, token: str) -> User: """Verify that the id token generated is correct and return the payload.""" issuer = f"https://{self.settings.domain}/".format( self.settings.domain) tv = TokenVerifier( signature_verifier=self.signature_verifier, issuer=issuer, audience=self.settings.client_id, ) await asyncio.to_thread(tv.verify, token) payload = jwt.decode(token, verify=False) return User(id=strawberry.ID(str(payload["sub"])), name=payload["name"])
def person_edge(self) -> Edge[Person]: return Edge(cursor=strawberry.ID("1"), node=Person(name="Example"))
def person_edge(self) -> EdgeWithCursor[SpecialPerson]: return EdgeWithCursor(cursor=strawberry.ID("1"), node=SpecialPerson(name="Example"))
def example(self) -> typing.Union[Fallback, Edge[int]]: return Edge(cursor=strawberry.ID("1"), node=1)
def int_edge(self) -> Edge[int]: return Edge(cursor=strawberry.ID("1"), node_field=1)
authenticator.send_login_code.side_effect = Exception() result = await send_login_code(email, info) assert isinstance(result, AuthError) assert result.reason == AuthErrorReason.INTERNAL_ERROR @pytest.mark.parametrize( "result", [ Result(error=AuthError.internal_error("Something happened")), Result(error=AuthError.temporary_failure("Something happened")), Result(error=AuthError.invalid_request("Something happened")), Result(error=AuthError.invalid_token("Something happened")), Result(value=Authentication( user=User(id=strawberry.ID("foo"), name="Someone's Name"), access_token="foo", refresh_token="bar", expires_in=0, )), ], ) @pytest.mark.asyncio async def test_login_with_code_calls_authenticator( info: Info, authenticator: MockAuthenticator, result: Result): """Check that send_login_code resolver uses authenticator and passes the result through.""" authenticator.login_with_code.return_value = result assert (await login_with_code("InR5cCI6", "*****@*****.**", info)) == result.collapse()
def int_edge(self, info, **kwargs) -> Edge: return Edge(cursor=strawberry.ID("1"), node=1)
} } """, variables={"email": email}, ) assert result.get("errors") is None assert result["data"] == {"sendLoginCode": {"emailAddress": email}} @pytest.mark.parametrize( "authentication", [ Authentication( access_token="foo", refresh_token="bar", user=User(id=strawberry.ID("id-1"), name="Foo Name"), expires_in=1000, ) ], ) @pytest.mark.parametrize("code", ["e78bc7a"]) @pytest.mark.parametrize("email", ["*****@*****.**"]) def test_login_with_code( client: GraphQLClient, email: str, code: str, authentication: Authentication, mocker: MockerFixture, ): """ Check that loginWithCode() endpoint returns Authentication from