mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 20:43:12 -04:00
Make email addresses case insensitive when inviting users to services
Email addresses in invites should be case insensitive. This is to stop the bug where a user creates their account using a lower case email address (e.g. user1@gov.uk), but is then invited to a service using their email address in a different case (e.g. USER1.gov.uk) and sees an error message telling them that they can't accept an invite for a different email address.
This commit is contained in:
@@ -170,3 +170,30 @@ def test_should_attempt_redirect_when_user_is_pending(
|
||||
'password': 'val1dPassw0rd!'})
|
||||
assert response.location == url_for('main.resend_email_verification', _external=True)
|
||||
assert response.status_code == 302
|
||||
|
||||
|
||||
def test_email_address_is_treated_case_insensitively_when_signing_in_as_invited_user(
|
||||
client,
|
||||
mocker,
|
||||
mock_verify_password,
|
||||
api_user_active,
|
||||
sample_invite,
|
||||
mock_accept_invite,
|
||||
mock_send_verify_code
|
||||
):
|
||||
sample_invite['email_address'] = 'TEST@user.gov.uk'
|
||||
|
||||
mocker.patch('app.user_api_client.get_user_by_email_or_none', return_value=api_user_active)
|
||||
mocker.patch('app.main.views.sign_in._get_and_verify_user', return_value=api_user_active)
|
||||
|
||||
with client.session_transaction() as session:
|
||||
session['invited_user'] = sample_invite
|
||||
|
||||
response = client.post(
|
||||
url_for('main.sign_in'), data={
|
||||
'email_address': 'test@user.gov.uk',
|
||||
'password': 'val1dPassw0rd!'})
|
||||
|
||||
assert mock_accept_invite.called
|
||||
assert response.status_code == 302
|
||||
assert mock_send_verify_code.called
|
||||
|
||||
Reference in New Issue
Block a user