mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-14 10:58:58 -04:00
Remove existing whitespace stripping code
Since we’re doing this globally, we don’t need to handle it in a custom way for the sign in form (and it’s much nicer encapsulated like this). Also added some more extensive tests in this commit.
This commit is contained in:
@@ -30,8 +30,6 @@ def sign_in():
|
||||
return redirect(url_for('main.choose_service'))
|
||||
|
||||
form = LoginForm()
|
||||
if form.email_address.data:
|
||||
form.email_address.data = form.email_address.data.strip()
|
||||
|
||||
if form.validate_on_submit():
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ def test_logged_in_user_redirects_to_choose_service(
|
||||
'+4407700900460',
|
||||
'+1800-555-555',
|
||||
])
|
||||
@pytest.mark.parametrize('password', [
|
||||
'the quick brown fox',
|
||||
' the quick brown fox ',
|
||||
])
|
||||
def test_register_creates_new_user_and_redirects_to_continue_page(
|
||||
client,
|
||||
mock_send_verify_code,
|
||||
@@ -48,11 +52,12 @@ def test_register_creates_new_user_and_redirects_to_continue_page(
|
||||
mock_send_verify_email,
|
||||
mock_login,
|
||||
phone_number_to_register_with,
|
||||
password,
|
||||
):
|
||||
user_data = {'name': 'Some One Valid',
|
||||
'email_address': 'notfound@example.gov.uk',
|
||||
'mobile_number': phone_number_to_register_with,
|
||||
'password': 'validPassword!',
|
||||
'password': password,
|
||||
'auth_type': 'sms_auth'
|
||||
}
|
||||
|
||||
|
||||
@@ -77,9 +77,9 @@ def test_logged_in_user_redirects_to_choose_service(
|
||||
assert response.location == url_for('main.choose_service', _external=True)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('email_address', [
|
||||
'valid@example.gov.uk',
|
||||
' valid@example.gov.uk ',
|
||||
@pytest.mark.parametrize('email_address, password', [
|
||||
('valid@example.gov.uk', 'val1dPassw0rd!'),
|
||||
(' valid@example.gov.uk ', ' val1dPassw0rd! '),
|
||||
])
|
||||
def test_process_sms_auth_sign_in_return_2fa_template(
|
||||
client,
|
||||
@@ -89,14 +89,15 @@ def test_process_sms_auth_sign_in_return_2fa_template(
|
||||
mock_get_user_by_email,
|
||||
mock_verify_password,
|
||||
email_address,
|
||||
password,
|
||||
):
|
||||
response = client.post(
|
||||
url_for('main.sign_in'), data={
|
||||
'email_address': email_address,
|
||||
'password': 'val1dPassw0rd!'})
|
||||
'password': password})
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('.two_factor', _external=True)
|
||||
mock_verify_password.assert_called_with(api_user_active.id, 'val1dPassw0rd!')
|
||||
mock_verify_password.assert_called_with(api_user_active.id, password)
|
||||
mock_get_user_by_email.assert_called_with('valid@example.gov.uk')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user