Example #1
0
async def _(
    internalapi_graphql_client=internalapi_graphql_client,
    db=db,
    user_factory=user_factory,
):
    internalapi_graphql_client.force_service_login(issuer="pycon-backend")

    user_1 = await user_factory(email="*****@*****.**",
                                fullname="Name",
                                is_staff=False)
    await user_factory(email="*****@*****.**",
                       fullname="Another",
                       is_staff=False)
    user_3 = await user_factory(email="*****@*****.**",
                                fullname="Name",
                                is_staff=False)

    query = """query($query: String!) {
        searchUsers(query: $query) {
            id
        }
    }"""

    response = await internalapi_graphql_client.query(
        query, variables={"query": "name"})
    assert not response.errors
    assert len(response.data["searchUsers"]) == 2
    assert {"id": str(user_1.id)} in response.data["searchUsers"]
    assert {"id": str(user_3.id)} in response.data["searchUsers"]
Example #2
0
async def _(
    internalapi_graphql_client=internalapi_graphql_client,
    db=db,
    user_factory=user_factory,
):
    internalapi_graphql_client.force_service_login(
        issuer="not-allowed-service")

    await user_factory(email="*****@*****.**",
                       fullname="Name",
                       is_staff=False)
    await user_factory(email="*****@*****.**",
                       fullname="Another",
                       is_staff=False)
    await user_factory(email="*****@*****.**",
                       fullname="Name",
                       is_staff=False)

    query = """query($query: String!) {
        searchUsers(query: $query) {
            id
        }
    }"""

    response = await internalapi_graphql_client.query(
        query, variables={"query": "name"})
    assert response.errors[0]["message"] == "Forbidden"
    assert not response.data
Example #3
0
async def _(
    internalapi_graphql_client=internalapi_graphql_client,
    db=db,
    user_factory=user_factory,
):
    internalapi_graphql_client.force_service_login(issuer="pycon-backend")

    user_1 = await user_factory(email="*****@*****.**",
                                fullname="Name",
                                is_staff=False)
    user_2 = await user_factory(email="*****@*****.**",
                                fullname="Another",
                                is_staff=False)
    await user_factory(email="*****@*****.**",
                       fullname="Name",
                       is_staff=False)

    query = """query($ids: [ID!]!) {
        usersByIds(ids: $ids) {
            id
        }
    }"""

    response = await internalapi_graphql_client.query(
        query, variables={"ids": [user_1.id, user_2.id]})
    assert not response.errors
    assert len(response.data["usersByIds"]) == 2
    assert {"id": str(user_1.id)} in response.data["usersByIds"]
    assert {"id": str(user_2.id)} in response.data["usersByIds"]
Example #4
0
async def _(
    internalapi_graphql_client=internalapi_graphql_client,
    db=db,
    user_factory=user_factory,
):
    internalapi_graphql_client.force_service_login(
        issuer="not-allowed-service")

    user_1 = await user_factory(email="*****@*****.**",
                                fullname="Name",
                                is_staff=False)
    user_2 = await user_factory(email="*****@*****.**",
                                fullname="Another",
                                is_staff=False)
    await user_factory(email="*****@*****.**",
                       fullname="Name",
                       is_staff=False)

    query = """query($ids: [ID!]!) {
        usersByIds(ids: $ids) {
            id
        }
    }"""

    response = await internalapi_graphql_client.query(
        query, variables={"ids": [user_1.id, user_2.id]})
    assert response.errors[0]["message"] == "Forbidden"
    assert not response.data
Example #5
0
async def _(
    internalapi_graphql_client=internalapi_graphql_client,
    db=db,
    user_factory=user_factory,
):
    internalapi_graphql_client.force_service_login(
        issuer="association-backend")

    user_1 = await user_factory(email="*****@*****.**",
                                fullname="Name",
                                is_staff=False)
    await user_factory(email="*****@*****.**",
                       fullname="Another",
                       is_staff=False)
    await user_factory(email="*****@*****.**",
                       fullname="Name",
                       is_staff=False)

    query = """query($email: String!) {
        userByEmail(email: $email) {
            id
        }
    }"""

    response = await internalapi_graphql_client.query(
        query, variables={"email": user_1.email})
    assert not response.errors
    assert response.data["userByEmail"]["id"] == str(user_1.id)
Example #6
0
async def _(
    internalapi_graphql_client=internalapi_graphql_client,
    db=db,
    user_factory=user_factory,
):
    internalapi_graphql_client.force_service_login()

    user = await user_factory(email="*****@*****.**", is_staff=False)

    query = """query($id: ID!) {
        user(id: $id) {
            id
            email
            isStaff
        }
    }"""

    response = await internalapi_graphql_client.query(
        query, variables={"id": user.id})
    assert not response.errors
    assert {
        "id": str(user.id),
        "email": user.email,
        "isStaff": False
    } == response.data["user"]