

def test_usertokens(standard_graph, session, users, groups, permissions):
    user = users['zorkian@a.co']
    assert (len(user.tokens) == 0)
    (tok, secret) = add_new_user_token(session, UserToken(user=user, name='Foo'))
    assert (len(user.tokens) == 1)
    assert tok.check_secret(secret)
    assert (tok.check_secret('invalid') == False)
    assert (tok.enabled == True)
    disable_user_token(session, tok)
    assert (tok.enabled == False)
    assert (user.tokens[0].enabled == False)
    assert (UserToken.get(session, name='Foo', user=user).enabled == False)
    assert (tok.check_secret(secret) == False)

dataset/ETHPy150Open dropbox/grouper/tests/test_users.py test_usertokens/original