mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-26 17:24:23 -04:00
Merge pull request #3559 from alphagov/hidden-email-on-register
Put hidden email field on register from invite page
This commit is contained in:
@@ -17,6 +17,14 @@ Create an account
|
|||||||
<span class="nowrap">{{invited_user.email_address}}</span>
|
<span class="nowrap">{{invited_user.email_address}}</span>
|
||||||
</p>
|
</p>
|
||||||
{% call form_wrapper() %}
|
{% call form_wrapper() %}
|
||||||
|
{#
|
||||||
|
This field is to enable password managers to capture the username as
|
||||||
|
well as the password, but should not be visible to users, nor should
|
||||||
|
the view process the input.
|
||||||
|
#}
|
||||||
|
<div class="visually-hidden">
|
||||||
|
<input type="email" name="username" id="username" value="{{ invited_user.email_address }}" disabled="disabled" tabindex="-1" aria-hidden="true" autocomplete="username" />
|
||||||
|
</div>
|
||||||
{{ textbox(form.name, width='3-4') }}
|
{{ textbox(form.name, width='3-4') }}
|
||||||
{% if invited_user.auth_type == 'sms_auth' %}
|
{% if invited_user.auth_type == 'sms_auth' %}
|
||||||
<div class="extra-tracking">
|
<div class="extra-tracking">
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ def test_register_with_existing_email_sends_emails(
|
|||||||
("f.last@example.com", ""),
|
("f.last@example.com", ""),
|
||||||
("f.m.last@example.com", ""),
|
("f.m.last@example.com", ""),
|
||||||
])
|
])
|
||||||
def test_shows_registration_page_from_invite(
|
def test_shows_name_on_registration_page_from_invite(
|
||||||
client_request,
|
client_request,
|
||||||
fake_uuid,
|
fake_uuid,
|
||||||
email_address,
|
email_address,
|
||||||
@@ -226,6 +226,48 @@ def test_shows_registration_page_from_invite(
|
|||||||
assert page.select_one('input[name=name]')['value'] == expected_value
|
assert page.select_one('input[name=name]')['value'] == expected_value
|
||||||
|
|
||||||
|
|
||||||
|
def test_shows_hidden_email_address_on_registration_page_from_invite(
|
||||||
|
client_request,
|
||||||
|
fake_uuid,
|
||||||
|
):
|
||||||
|
with client_request.session_transaction() as session:
|
||||||
|
session['invited_user'] = {
|
||||||
|
'id': fake_uuid,
|
||||||
|
'service': fake_uuid,
|
||||||
|
'from_user': "",
|
||||||
|
'email_address': "test@example.com",
|
||||||
|
'permissions': ["manage_users"],
|
||||||
|
'status': "pending",
|
||||||
|
'created_at': datetime.utcnow(),
|
||||||
|
'auth_type': 'sms_auth',
|
||||||
|
'folder_permissions': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
page = client_request.get('main.register_from_invite')
|
||||||
|
assert normalize_spaces(page.select_one('main p').text) == (
|
||||||
|
'Your account will be created with this email address: test@example.com'
|
||||||
|
)
|
||||||
|
hidden_input = page.select_one('form .visually-hidden input')
|
||||||
|
for attr, value in (
|
||||||
|
('type', 'email'),
|
||||||
|
('name', 'username'),
|
||||||
|
('id', 'username'),
|
||||||
|
('value', 'test@example.com'),
|
||||||
|
('disabled', "disabled"),
|
||||||
|
('tabindex', '-1'),
|
||||||
|
('aria-hidden', 'true'),
|
||||||
|
('autocomplete', 'username'),
|
||||||
|
):
|
||||||
|
assert hidden_input[attr] == value
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('extra_data', (
|
||||||
|
{},
|
||||||
|
# The username field is present in the page but the POST request
|
||||||
|
# should ignore it
|
||||||
|
{'username': 'invited@user.com'},
|
||||||
|
{'username': 'anythingelse@example.com'},
|
||||||
|
))
|
||||||
def test_register_from_invite(
|
def test_register_from_invite(
|
||||||
client,
|
client,
|
||||||
fake_uuid,
|
fake_uuid,
|
||||||
@@ -233,6 +275,7 @@ def test_register_from_invite(
|
|||||||
mock_register_user,
|
mock_register_user,
|
||||||
mock_send_verify_code,
|
mock_send_verify_code,
|
||||||
mock_accept_invite,
|
mock_accept_invite,
|
||||||
|
extra_data,
|
||||||
):
|
):
|
||||||
invited_user = InvitedUser(
|
invited_user = InvitedUser(
|
||||||
{
|
{
|
||||||
@@ -251,14 +294,15 @@ def test_register_from_invite(
|
|||||||
session['invited_user'] = invited_user.serialize()
|
session['invited_user'] = invited_user.serialize()
|
||||||
response = client.post(
|
response = client.post(
|
||||||
url_for('main.register_from_invite'),
|
url_for('main.register_from_invite'),
|
||||||
data={
|
data=dict(
|
||||||
'name': 'Registered in another Browser',
|
name='Registered in another Browser',
|
||||||
'email_address': invited_user.email_address,
|
email_address=invited_user.email_address,
|
||||||
'mobile_number': '+4407700900460',
|
mobile_number='+4407700900460',
|
||||||
'service': str(invited_user.id),
|
service=str(invited_user.id),
|
||||||
'password': 'somreallyhardthingtoguess',
|
password='somreallyhardthingtoguess',
|
||||||
'auth_type': 'sms_auth'
|
auth_type='sms_auth',
|
||||||
}
|
**extra_data
|
||||||
|
),
|
||||||
)
|
)
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
assert response.location == url_for('main.verify', _external=True)
|
assert response.location == url_for('main.verify', _external=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user