CPI Ordering System (the old version)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

64 lines
1.9 KiB

''' 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'
7 years ago
# 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
7 years ago
# 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 '<!-- user is logged in -->' 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 '<!-- user is logged in -->' in response