@not_github_ci
@pytest.mark.parametrize('test_name,identifier,username,roles,allowed_actions,requested_actions,expected', TEST_AUTHZ_DATA)
def test_authorized_user(monkeypatch, app_request, jwt, test_name, identifier, username, roles, allowed_actions, requested_actions, expected):
    'Assert that the type of user authorization is correct, based on the expected outcome.'
    from requests import Response
    print(test_name)

    def mock_get(*args, **kwargs):
        resp = Response()
        resp.status_code = 200
        return resp

    def mock_json(self, **kwargs):
        return {'roles': allowed_actions}
    monkeypatch.setattr('requests.sessions.Session.get', mock_get)
    monkeypatch.setattr('requests.Response.json', mock_json)

    @app_request.route('/fake_jwt_route/<string:identifier>')
    @jwt.requires_auth
    def get_fake(identifier: str):
        if (not authorized(identifier, jwt, ['view'])):
            return (jsonify(message='failed'), HTTPStatus.METHOD_NOT_ALLOWED)
        return (jsonify(message='success'), HTTPStatus.OK)
    token = helper_create_jwt(jwt, roles=roles, username=username)
    headers = {'Authorization': ('Bearer ' + token)}
    rv = app_request.test_client().get(f'/fake_jwt_route/{identifier}', headers=headers)
    assert (rv.status_code == expected)
Assert that the type of user authorization is correct, based on the expected outcome.
@not_github_ci
@pytest.mark.parametrize('test_name,identifier,username,roles,allowed_actions,requested_actions,expected', TEST_AUTHZ_DATA)
def test_authorized_user(monkeypatch, app_request, jwt, test_name, identifier, username, roles, allowed_actions, requested_actions, expected):
    
    from requests import Response
    print(test_name)

    def mock_get(*args, **kwargs):
        resp = Response()
        resp.status_code = 200
        return resp

    def mock_json(self, **kwargs):
        return {'roles': allowed_actions}
    monkeypatch.setattr('requests.sessions.Session.get', mock_get)
    monkeypatch.setattr('requests.Response.json', mock_json)

    @app_request.route('/fake_jwt_route/<string:identifier>')
    @jwt.requires_auth
    def get_fake(identifier: str):
        if (not authorized(identifier, jwt, ['view'])):
            return (jsonify(message='failed'), HTTPStatus.METHOD_NOT_ALLOWED)
        return (jsonify(message='success'), HTTPStatus.OK)
    token = helper_create_jwt(jwt, roles=roles, username=username)
    headers = {'Authorization': ('Bearer ' + token)}
    rv = app_request.test_client().get(f'/fake_jwt_route/{identifier}', headers=headers)
    assert (rv.status_code == expected)