mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-31 11:49:58 -04:00
Fix for duplicate email registration that meant flash error not being
displayed. The error message does not specify the error is a duplicate email address so as not to reveal which emails are current user accounts.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from flask import url_for
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
def test_render_register_returns_template_with_form(app_):
|
||||
@@ -106,3 +107,24 @@ def test_should_return_400_if_password_is_blacklisted(app_,
|
||||
|
||||
response.status_code == 200
|
||||
assert 'That password is blacklisted, too common' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_register_with_existing_email_returns_error(app_,
|
||||
api_user_active,
|
||||
mock_get_user_by_email):
|
||||
user_data = {
|
||||
'name': 'Already Hasaccount',
|
||||
'email_address': api_user_active.email_address,
|
||||
'mobile_number': '+4407700900460',
|
||||
'password': 'validPassword!'
|
||||
}
|
||||
|
||||
with app_.test_request_context():
|
||||
response = app_.test_client().post(url_for('main.register'),
|
||||
data=user_data)
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
element = page.find('h1')
|
||||
assert element.text == 'Create an account'
|
||||
flash_banner = page.find('div', class_='banner-dangerous').string.strip()
|
||||
assert flash_banner == 'There was an error registering your account'
|
||||
|
||||
Reference in New Issue
Block a user