rename two_factor to two_factor_sms

it's a bit confusing now that there are three endpoints. the other two
are already renamed two_factor_email and two_factor_webauthn
This commit is contained in:
Leo Hemsted
2021-05-14 19:15:12 +01:00
parent 907a7dc363
commit c203f624ca
12 changed files with 26 additions and 23 deletions

View File

@@ -138,7 +138,7 @@ def test_check_and_redirect_to_two_factor_if_user_active(
'email': api_user_active['email_address']}
response = client.get(url_for('main.check_and_resend_verification_code', next=redirect_url))
assert response.status_code == 302
assert response.location == url_for('main.two_factor', _external=True, next=redirect_url)
assert response.location == url_for('main.two_factor_sms', _external=True, next=redirect_url)
@pytest.mark.parametrize('redirect_url', [

View File

@@ -56,7 +56,7 @@ def test_should_redirect_to_two_factor_when_password_reset_is_successful(
response = client.post(url_for_endpoint_with_token('.new_password', token=token, next=redirect_url),
data={'new_password': 'a-new_password'})
assert response.status_code == 302
assert response.location == url_for('.two_factor', _external=True, next=redirect_url)
assert response.location == url_for('.two_factor_sms', _external=True, next=redirect_url)
mock_get_user_by_email_request_password_reset.assert_called_once_with(user['email_address'])

View File

@@ -130,7 +130,9 @@ def test_process_sms_auth_sign_in_return_2fa_template(
'email_address': email_address,
'password': password})
assert response.status_code == 302
assert response.location == url_for('.two_factor', next=redirect_url, _external=True)
# TODO: remove this assert once we start defaulting to returning two_factor_sms first
assert '/two-factor-sms' not in response.location
assert response.location == url_for('.two_factor_sms', next=redirect_url, _external=True)
mock_verify_password.assert_called_with(api_user_active['id'], password)
mock_get_user_by_email.assert_called_with('valid@example.gov.uk')

View File

@@ -54,7 +54,7 @@ def test_should_render_two_factor_page(
'id': api_user_active['id'],
'email': api_user_active['email_address']}
mocker.patch('app.user_api_client.get_user', return_value=api_user_active)
response = client.get(url_for('main.two_factor', next=redirect_url))
response = client.get(url_for('main.two_factor_sms', next=redirect_url))
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert page.select_one('main p').text.strip() == (
@@ -86,7 +86,7 @@ def test_should_login_user_and_should_redirect_to_next_url(
'email': api_user_active['email_address']}
api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z'
response = client.post(url_for('main.two_factor', next='/services/{}'.format(SERVICE_ONE_ID)),
response = client.post(url_for('main.two_factor_sms', next='/services/{}'.format(SERVICE_ONE_ID)),
data={'sms_code': '12345'})
assert response.status_code == 302
assert response.location == url_for(
@@ -112,7 +112,7 @@ def test_should_send_email_and_redirect_to_info_page_if_user_needs_to_revalidate
session['user_details'] = {
'id': api_user_active['id'],
'email': api_user_active['email_address']}
response = client.post(url_for('main.two_factor', next=f'/services/{SERVICE_ONE_ID}'),
response = client.post(url_for('main.two_factor_sms', next=f'/services/{SERVICE_ONE_ID}'),
data={'sms_code': '12345'})
assert response.status_code == 302
@@ -140,7 +140,7 @@ def test_should_login_user_and_not_redirect_to_external_url(
'email': api_user_active['email_address']}
api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z'
response = client.post(url_for('main.two_factor', next='http://www.google.com'),
response = client.post(url_for('main.two_factor_sms', next='http://www.google.com'),
data={'sms_code': '12345'})
assert response.status_code == 302
assert response.location == url_for('main.show_accounts_or_dashboard', _external=True)
@@ -166,7 +166,7 @@ def test_should_login_user_and_redirect_to_show_accounts(
api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z'
api_user_active['platform_admin'] = platform_admin
response = client.post(url_for('main.two_factor'),
response = client.post(url_for('main.two_factor_sms'),
data={'sms_code': '12345'})
assert response.status_code == 302
@@ -186,7 +186,7 @@ def test_should_return_200_with_sms_code_error_when_sms_code_is_wrong(
'email': api_user_active['email_address']}
mocker.patch('app.user_api_client.get_user', return_value=api_user_active)
response = client.post(url_for('main.two_factor'),
response = client.post(url_for('main.two_factor_sms'),
data={'sms_code': '23456'})
assert response.status_code == 200
assert 'Code not found' in response.get_data(as_text=True)
@@ -208,7 +208,7 @@ def test_should_login_user_when_multiple_valid_codes_exist(
'email': api_user_active['email_address']}
api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z'
response = client.post(url_for('main.two_factor'),
response = client.post(url_for('main.two_factor_sms'),
data={'sms_code': '23456'})
assert response.status_code == 302
@@ -230,7 +230,7 @@ def test_two_factor_should_set_password_when_new_password_exists_in_session(
'password': 'changedpassword'}
api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z'
response = client.post(url_for('main.two_factor'),
response = client.post(url_for('main.two_factor_sms'),
data={'sms_code': '12345'})
assert response.status_code == 302
assert response.location == url_for('main.show_accounts_or_dashboard', _external=True)
@@ -252,7 +252,7 @@ def test_two_factor_returns_error_when_user_is_locked(
'id': api_user_locked['id'],
'email': api_user_locked['email_address'],
}
response = client.post(url_for('main.two_factor'),
response = client.post(url_for('main.two_factor_sms'),
data={'sms_code': '12345'})
assert response.status_code == 200
assert 'Code not found' in response.get_data(as_text=True)
@@ -262,13 +262,13 @@ def test_two_factor_post_should_redirect_to_sign_in_if_user_not_in_session(
client_request,
):
client_request.post(
'main.two_factor',
'main.two_factor_sms',
_data={'sms_code': '12345'},
_expected_redirect=url_for('main.sign_in', _external=True)
)
@pytest.mark.parametrize('endpoint', ['main.two_factor_webauthn', 'main.two_factor'])
@pytest.mark.parametrize('endpoint', ['main.two_factor_webauthn', 'main.two_factor_sms'])
def test_two_factor_get_should_redirect_to_sign_in_if_user_not_in_session(
client_request,
endpoint,
@@ -296,7 +296,7 @@ def test_two_factor_should_activate_pending_user(
'id': api_user_pending['id'],
'email_address': api_user_pending['email_address']
}
client.post(url_for('main.two_factor'), data={'sms_code': '12345'})
client.post(url_for('main.two_factor_sms'), data={'sms_code': '12345'})
assert mock_activate_user.called

View File

@@ -289,7 +289,7 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, {
'trial_mode',
'trial_mode_new',
'trial_services',
'two_factor',
'two_factor_sms',
'two_factor_email',
'two_factor_email_interstitial',
'two_factor_email_sent',