mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
Strip spaces from email addresses when signing in
If you copy and paste an email address into the sign in box, there’s a chance you’ll also copy some leading or trailing spaces. This is especially likely to happen if you’re doing this while using your computer upside down. If this happens, it never even gets as far as looking up the user, because the form validation doesn’t consider a string with a leading space to be a valid email address. This commit makes sure that accidental spaces are handled, by removing them before doing any validation or hitting the API to look up the user.
This commit is contained in:
@@ -77,6 +77,10 @@ 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 ',
|
||||
])
|
||||
def test_process_sms_auth_sign_in_return_2fa_template(
|
||||
client,
|
||||
api_user_active,
|
||||
@@ -84,14 +88,16 @@ def test_process_sms_auth_sign_in_return_2fa_template(
|
||||
mock_get_user,
|
||||
mock_get_user_by_email,
|
||||
mock_verify_password,
|
||||
email_address,
|
||||
):
|
||||
response = client.post(
|
||||
url_for('main.sign_in'), data={
|
||||
'email_address': 'valid@example.gov.uk',
|
||||
'email_address': email_address,
|
||||
'password': 'val1dPassw0rd!'})
|
||||
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_get_user_by_email.assert_called_with('valid@example.gov.uk')
|
||||
|
||||
|
||||
def test_process_email_auth_sign_in_return_2fa_template(
|
||||
|
||||
Reference in New Issue
Block a user