Exemple #1
0
def test_create_other_user(capsys):
    assert len(users.get_users()) == 0
    name = 'username'
    email = '*****@*****.**'

    scripts.main([scripts.__file__, 'create_other_user', name, email])
    output = capsys.readouterr()[0]
    assert 'Success' in output
    password = output.split("'")[1]
    assert len(password) == 32
    assert all((c in '0123456789abcdef') for c in password)

    assert len(users.get_users()) == 1
    user = users.get_users()[0]
    assert user.name == name
    assert user.email == email
    assert user.type == users.UserType.OTHER
    assert not authentication.login(name, "password")
    assert authentication.login(name, password)
def verify_password(username, password):
    if not username:
        return None
    flask.g.user = login(username, password)
    return flask.g.user