''' tests for the login, logout, registration and account settings''' import pytest from pyramid_mailer import get_mailer from . import testapp, get_token_url from .. import get_user def test_reset_password(testapp): ''' test the complete reset password process ''' # submit the registration form response = testapp.get('/account/forgot-password') form = response.forms[1] form['username_or_email'] = 'TerryGilliam' response = form.submit() assert response.location == 'http://localhost/account/forgot-password-email' response = response.follow() assert 'Password Reset Link' in response # click the email verification token mailer = get_mailer(testapp.app.registry) email = mailer.outbox[-1] assert email.subject == '[ordr] Password Reset' # set a new password token_link = get_token_url(email) response = testapp.get(token_link) form = response.forms[1] form['password'] = 'Nudge Nudge' form['password-confirm'] = 'Nudge Nudge' response = form.submit() assert response.location == 'http://localhost/account/login' response = response.follow() assert 'consider a longer password' in response assert 'Your password was changed' in response # logging in with the old password should not work response = testapp.get('/account/logout') response = testapp.get('/account/login') form = response.forms[1] form['username'] = 'TerryGilliam' form['password'] = 'Terry' response = form.submit() assert '' not in response # logging in with the old password should work response = testapp.get('/account/logout') response = testapp.get('/account/login') form = response.forms[1] form['username'] = 'TerryGilliam' form['password'] = 'Nudge Nudge' response = form.submit() response = testapp.get('/faq') assert '' in response