Ejemplo 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)
Ejemplo n.º 2
0
def login():
    form = LoginForm()
    no_username = None
    not_match = None

    if form.validate_on_submit():
        try:
            user = service.get_user(form.user_name.data.lower(),
                                    repo.repo_instance)
            service.check_username_password(user.user_name, form.password.data,
                                            repo.repo_instance)
            session.clear()
            session['username'] = user.user_name

            return redirect(url_for('home_bp.home'))

        except service.NoUserNameException:
            no_username = '******'

        except service.NotMatchException:
            not_match = 'Password does not match supplied username'
    return render_template('authentication/user_information.html',
                           title='Login',
                           form=form,
                           username_error_message=no_username,
                           password_error_message=not_match)
Ejemplo n.º 3
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