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.
51 lines
1.4 KiB
51 lines
1.4 KiB
7 years ago
|
''' 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
|
||
|
|
||
|
|
||
|
@pytest.mark.xfail
|
||
|
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'
|
||
|
|
||
|
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
|
||
|
|
||
|
form = response.forms[1]
|
||
|
form['username'] = 'TerryGilliam'
|
||
|
form['password'] = 'Nudge Nudge'
|
||
|
response = form.submit().follow()
|
||
|
assert '<!-- user is logged in -->' in response
|
||
|
|
||
|
|
||
|
|
||
|
|