def test_jsonrpc_user_auth(live_server, john_doe, common_pwd):

    c = HTTPClient(live_server.url + '/all-rpc/')
    c.session.auth = (john_doe.username, common_pwd)

    assert c.logged_user_required(5) == 5
    assert c.logged_user_required_alt(5) == 5

    assert raises(ReceivedErrorResponse, c.request,
                  'logged_superuser_required',
                  5).value.code == RPC_INTERNAL_ERROR
    assert raises(ReceivedErrorResponse, c.request,
                  'logged_superuser_required_alt',
                  5).value.code == RPC_INTERNAL_ERROR
    assert raises(ReceivedErrorResponse, c.request,
                  'delete_user_perm_required',
                  5).value.code == RPC_INTERNAL_ERROR
    assert raises(ReceivedErrorResponse, c.request, 'any_permission_required',
                  5).value.code == RPC_INTERNAL_ERROR
    assert raises(ReceivedErrorResponse, c.request, 'all_permissions_required',
                  5).value.code == RPC_INTERNAL_ERROR
    assert raises(ReceivedErrorResponse, c.request, 'in_group_A_required',
                  5).value.code == RPC_INTERNAL_ERROR
    assert raises(ReceivedErrorResponse, c.request,
                  'in_groups_A_and_B_required',
                  5).value.code == RPC_INTERNAL_ERROR
    e = raises(ReceivedErrorResponse, c.request,
               'in_groups_A_and_B_required_alt', 5)
    assert e.value.code == RPC_INTERNAL_ERROR
    assert raises(ReceivedErrorResponse, c.request, 'in_group_A_or_B_required',
                  5).value.code == RPC_INTERNAL_ERROR
def test_jsonrpc_superuser_auth(live_server, superuser, common_pwd):

    c = HTTPClient(live_server.url + '/all-rpc/')
    c.session.auth = (superuser.username, common_pwd)

    assert c.logged_user_required(5) == 5
    assert c.logged_user_required_alt(5) == 5
    assert c.logged_superuser_required(5) == 5
    assert c.logged_superuser_required_alt(5) == 5
    assert c.delete_user_perm_required(5) == 5
    assert c.any_permission_required(5) == 5
    assert c.all_permissions_required(5) == 5
    assert c.in_group_A_required(5) == 5
    assert c.in_groups_A_and_B_required(5) == 5
    assert c.in_groups_A_and_B_required_alt(5) == 5
    assert c.in_group_A_or_B_required(5) == 5