Changed registration flow to first send email verification link that

when visited sends sms code for second step of account verification.

At that second step user enters just sms code sent to users mobile
number.

Also moved dao calls that simply proxied calls to client to calling
client directly.

There is still a place where a user will be a sent a code for
verification to their email namely if they update email address.
This commit is contained in:
Adam Shimali
2016-03-17 13:07:52 +00:00
parent dcc253bf61
commit 2792bece54
23 changed files with 363 additions and 481 deletions

View File

@@ -1,39 +1,30 @@
import pytest
from flask import url_for
from bs4 import BeautifulSoup
def test_should_render_email_verification_resent_show_email_address_and_resend_verify_email(app_,
mocker,
api_user_active,
mock_get_user_by_email,
mock_send_verify_email):
def test_should_render_email_code_not_received_template_and_populate_email_address(app_,
api_user_active,
mock_get_user_by_email,
mock_send_verify_code):
with app_.test_request_context():
with app_.test_client() as client:
with client.session_transaction() as session:
session['user_details'] = {
'id': api_user_active.id,
'email': api_user_active.email_address}
response = client.get(url_for('main.check_and_resend_email_code'))
response = client.get(url_for('main.resend_email_verification'))
assert response.status_code == 200
assert 'Check your email address is correct and then resend the confirmation code' \
in response.get_data(as_text=True)
assert 'value="test@user.gov.uk"' in response.get_data(as_text=True)
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
def test_should_check_and_resend_email_code_redirect_to_verify(app_,
api_user_active,
mock_get_user_by_email,
mock_update_user,
mock_send_verify_code):
with app_.test_request_context():
with app_.test_client() as client:
with client.session_transaction() as session:
session['user_details'] = {
'id': api_user_active.id,
'email': api_user_active.email_address}
response = client.post(url_for('main.check_and_resend_email_code'),
data={'email_address': 'test@user.gov.uk'})
assert response.status_code == 302
assert response.location == url_for('main.verify', _external=True)
assert page.h1.string == 'Check your email'
expected = "In order to verify your email address we've sent a new confirmation link to {}".format(api_user_active.email_address) # noqa
assert page.p.string == expected
mock_send_verify_email.assert_called_with(api_user_active.id, api_user_active.email_address)
def test_should_render_text_code_not_received_template(app_,
@@ -70,23 +61,6 @@ def test_should_check_and_redirect_to_verify(app_,
assert response.location == url_for('main.verify', _external=True)
def test_should_update_email_address_resend_code(app_,
api_user_active,
mock_get_user_by_email,
mock_update_user,
mock_send_verify_code):
with app_.test_request_context():
with app_.test_client() as client:
with client.session_transaction() as session:
session['user_details'] = {
'id': api_user_active.id,
'email': api_user_active.email_address}
response = client.post(url_for('main.check_and_resend_email_code'),
data={'email_address': 'new@address.gov.uk'})
assert response.status_code == 302
assert response.location == url_for('main.verify', _external=True)
def test_should_update_mobile_number_resend_code(app_,
api_user_active,
mock_get_user_by_email,