Exemple #1
0
def assert_usr_token(data, **attrs):
    token = _get_token(data)
    attrs['typ'] = 'usr'
    attrs['id'] = id = token.id
    attrs['token'] = FakeSerializer.usr(id)
    attrs['disabled'] = False
    _eq_token(token, attrs)
def assert_usr_token(data, **attrs):
    token = _get_token(data)
    attrs['typ'] = 'usr'
    attrs['id'] = id = token.id
    attrs['token'] = FakeSerializer.usr(id)
    attrs['disabled'] = False
    _eq_token(token, attrs)
def test_query_usr_token_success_all(client):
    """Querying a user token with base.tokens.usr.view.all returns the token."""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.usr(2))
    eq_(json.loads(res.data), {'result': usr_json})
def test_query_usr_token_forbidden_not_mine(client):
    """Querying a user token with base.tokens.usr.view.my gives 403
    if the token email doesn't match the request email"""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.usr(2))
    eq_(res.status_code, 403)
def test_query_usr_token_forbidden(client):
    """Querying a user token without permission results in a 403"""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.usr(2))
    eq_(res.status_code, 403)
Exemple #6
0
def test_query_usr_token_success_all(client):
    """Querying a user token with base.tokens.usr.view.all returns the token."""
    res = client.post_json('/tokenauth/tokens/query', FakeSerializer.usr(2))
    assert_result(res.data, usr_json)
Exemple #7
0
def test_query_usr_token_forbidden_not_mine(client):
    """Querying a user token with base.tokens.usr.view.my gives 403
    if the token email doesn't match the request email"""
    res = client.post_json('/tokenauth/tokens/query', FakeSerializer.usr(2))
    eq_(res.status_code, 403)
Exemple #8
0
def test_query_usr_token_forbidden(client):
    """Querying a user token without permission results in a 403"""
    res = client.post_json('/tokenauth/tokens/query', FakeSerializer.usr(2))
    eq_(res.status_code, 403)
Exemple #9
0
def test_query_usr_token_success_mine(client):
    """Querying a user token with base.tokens.usr.view.my returns the
    token if the emails match"""
    res = client.post_json('/tokenauth/tokens/query', FakeSerializer.usr(2))
    eq_(json.loads(res.data), {'result': usr_json})
def test_query_usr_token_success_mine(client):
    """Querying a user token with base.tokens.usr.view.my returns the
    token if the emails match"""
    res = client.post_json('/tokenauth/tokens/query',
                           FakeSerializer.usr(2))
    assert_result(res.data, usr_json)