Exemplo n.º 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)
Exemplo n.º 2
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)
Exemplo n.º 3
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))
    eq_(json.loads(res.data), {'result': usr_json})
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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})
Exemplo n.º 10
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))
    assert_result(res.data, usr_json)