Exemplo n.º 1
0
def test_authentication_with_invalid_credentials(in_memory_repo):
    new_username = '******'
    new_password = '******'

    service.add_user(new_username, new_password, in_memory_repo)
    with pytest.raises(service.NotMatchException):
        service.check_username_password(new_username, '0987654321', in_memory_repo)
Exemplo n.º 2
0
def test_cannot_add_user_with_existing_name(in_memory_repo):
    service.add_user('piggyyo', 'abcd1A23', in_memory_repo)
    username = '******'
    password = '******'

    with pytest.raises(service.NameNotUniqueException):
        service.add_user(username, password, in_memory_repo)
Exemplo n.º 3
0
def test_can_add_user(in_memory_repo):
    new_username = '******'
    new_password = '******'

    service.add_user(new_username, new_password, in_memory_repo)

    assert in_memory_repo.get_user(new_username).user_name == 'suzuha'
    assert in_memory_repo.get_user(new_username).password[0:14] =='pbkdf2:sha256:'
Exemplo n.º 4
0
def test_authentication_with_valid_credentials(in_memory_repo):
    new_username = '******'
    new_password = '******'

    service.add_user(new_username, new_password, in_memory_repo)

    try:
        service.check_username_password(new_username, new_password, in_memory_repo)
    except service.NotMatchException:
        assert False
Exemplo n.º 5
0
def register():
    form = RegistrationForm()
    username_not_unique = None

    if form.validate_on_submit():
        try:
            service.add_user(form.user_name.data, form.password.data,
                             repo.repo_instance)
            return redirect(url_for('authentication_bp.login'))
        except service.NameNotUniqueException:
            username_not_unique = 'Your username is already taken - please supply another'
    return render_template(
        'authentication/user_information.html',
        title='Register',
        form=form,
        username_error_message=username_not_unique,
        password_error_message=None,
        handler_url=url_for('authentication_bp.register'),
    )