|
|
@ -22,6 +22,13 @@ REGISTRATION_FORM_DATA = MultiDict([ |
|
|
|
('__end__', 'password:mapping'), |
|
|
|
('__end__', 'password:mapping'), |
|
|
|
]) |
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PASSWORD_RESET_FORM_DATA = MultiDict([ |
|
|
|
|
|
|
|
('__start__', 'password:mapping'), |
|
|
|
|
|
|
|
('password', 'Nudge'), |
|
|
|
|
|
|
|
('password-confirm', 'Nudge'), |
|
|
|
|
|
|
|
('__end__', 'password:mapping'), |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('rolename', ['user', 'purchaser', 'admin']) |
|
|
|
@pytest.mark.parametrize('rolename', ['user', 'purchaser', 'admin']) |
|
|
|
def test_account_login_active_users(dbsession, rolename): |
|
|
|
def test_account_login_active_users(dbsession, rolename): |
|
|
@ -297,30 +304,28 @@ def test_reset_password_form(): |
|
|
|
assert isinstance(result['form'], deform.Form) |
|
|
|
assert isinstance(result['form'], deform.Form) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reset_password_form_processing_ok(): |
|
|
|
def test_reset_password_form_processing_ok(dbsession): |
|
|
|
''' reset password form processing is ok ''' |
|
|
|
''' reset password form processing is ok ''' |
|
|
|
from ordr2.models.account import TokenSubject |
|
|
|
from ordr2.models.account import Token, TokenSubject, User |
|
|
|
from ordr2.views.account import reset_password_form_processing |
|
|
|
from ordr2.views.account import reset_password_form_processing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
request = DummyRequest(dbsession=dbsession) |
|
|
|
|
|
|
|
set_deform_data(request, REGISTRATION_FORM_DATA) |
|
|
|
account = get_user('user') |
|
|
|
account = get_user('user') |
|
|
|
token = user.issue_token(request, TokenSubject.RESET_PASSWORD) |
|
|
|
token = account.issue_token(request, TokenSubject.RESET_PASSWORD) |
|
|
|
dbsession.add(account) |
|
|
|
dbsession.add(account) |
|
|
|
dbsession.flush() |
|
|
|
dbsession.flush() |
|
|
|
context = DummyResource(model=token) |
|
|
|
context = DummyResource(model=token) |
|
|
|
request = DummyRequest( |
|
|
|
|
|
|
|
dbsession=dbsession, |
|
|
|
|
|
|
|
POST={'password': 'Nudge', 'password-confirmation': 'Nudge'} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
result = reset_password_form_processing(context, request) |
|
|
|
result = reset_password_form_processing(context, request) |
|
|
|
|
|
|
|
|
|
|
|
assert isinstance(result, HTTPFound) |
|
|
|
assert isinstance(result, HTTPFound) |
|
|
|
assert result.location == 'http://example.com/account/login' |
|
|
|
assert result.location == 'http://example.com//login' |
|
|
|
assert account.check_password('Nudge') |
|
|
|
assert account.check_password(REGISTRATION_FORM_DATA['password']) |
|
|
|
assert dbsession.query(Token).count() == 0 |
|
|
|
assert dbsession.query(Token).count() == 0 |
|
|
|
assert dbsession.query(User).count() == 1 |
|
|
|
assert dbsession.query(User).count() == 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reset_password_form_processing_cancel(): |
|
|
|
def test_reset_password_form_processing_cancel(): |
|
|
|
''' reset password form processing is canceled ''' |
|
|
|
''' reset password form processing is canceled ''' |
|
|
|
from ordr2.views.account import reset_password_form_processing |
|
|
|
from ordr2.views.account import reset_password_form_processing |
|
|
|
|
|
|
|
|
|
|
@ -339,14 +344,13 @@ def reset_password_form_processing_cancel(): |
|
|
|
('', 'one is empty'), |
|
|
|
('', 'one is empty'), |
|
|
|
] |
|
|
|
] |
|
|
|
) |
|
|
|
) |
|
|
|
def reset_password_form_processing_invalid(pw, confirm): |
|
|
|
def test_reset_password_form_processing_invalid(pw, confirm): |
|
|
|
''' validation error in reset password form ''' |
|
|
|
''' validation error in reset password form ''' |
|
|
|
from ordr2.views.account import reset_password_form_processing |
|
|
|
from ordr2.views.account import reset_password_form_processing |
|
|
|
|
|
|
|
|
|
|
|
request = DummyRequest( |
|
|
|
request = DummyRequest(dbsession=dbsession) |
|
|
|
dbsession=dbsession, |
|
|
|
modifier = {'password': pw, 'password-confim': confirm} |
|
|
|
POST={'password': pw, 'password-confirmation': confirm} |
|
|
|
set_deform_data(request, REGISTRATION_FORM_DATA, modifier) |
|
|
|
) |
|
|
|
result = reset_password_form_processing(None, request) |
|
|
|
result = reset_password_form_processing(context, request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert isinstance(result['form'], deform.Form) |
|
|
|
assert isinstance(result['form'], deform.Form) |
|
|
|