예제 #1
0
def test_mutation_refresh_jwt_token_required(flask_app: Flask):
    test_cli = flask_app.test_client()

    with flask_app.test_request_context():
        refresh_token = create_refresh_token('username')

    response = request(test_cli, "mutation",
                       'refresh(refreshToken:"{0}")'.format(refresh_token),
                       """newToken""")

    with flask_app.test_request_context():
        assert get_jwt_data(response['refresh']["newToken"],
                            "access")["identity"] == "username"
예제 #2
0
def test_query_jwt_required(flask_app: Flask):
    test_cli = flask_app.test_client()

    with flask_app.test_request_context():
        access_token = create_access_token('username')

    response = request(
        test_cli, "query", 'protected(token:"{0}")'.format(access_token),
        """... on AuthInfoField{
                                message
                            }
                            ... on MessageField{
                                message
                            }""")

    assert response['protected']["message"] == "Hello World!"
예제 #3
0
def test_mutation_jwt_required(flask_app: Flask):
    test_cli = flask_app.test_client()

    with flask_app.test_request_context():
        access_token = create_access_token('username')

    response = request(
        test_cli, "mutation", 'protected(token:"{0}")'.format(access_token),
        """message {
                        ... on MessageField {
                                message
                            }
                        ... on AuthInfoField {
                                message
                            }
                        }""")

    assert response['protected']["message"][
        "message"] == "Protected mutation works"