mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-13 01:44:08 -04:00
Add missing tests for authentication radios
Previously we only had one test for SMS auth not being disabled on the invite version of the form. This modifies that test to fully check what's displayed, and adds two more for the edit version of the form.
This commit is contained in:
@@ -453,8 +453,11 @@ def test_invite_user_allows_to_choose_auth(
|
||||
service_one['permissions'].append('email_auth')
|
||||
page = client_request.get('main.invite_user', service_id=SERVICE_ONE_ID)
|
||||
|
||||
sms_auth_radio_button = page.select_one('input[value="sms_auth"]')
|
||||
assert sms_auth_radio_button.has_attr("disabled") is False
|
||||
radio_buttons = page.select("input[name=login_authentication]")
|
||||
values = {button["value"] for button in radio_buttons}
|
||||
|
||||
assert values == {'sms_auth', 'email_auth'}
|
||||
assert not any(button.has_attr("disabled") for button in radio_buttons)
|
||||
|
||||
|
||||
def test_invite_user_has_correct_email_field(
|
||||
@@ -794,6 +797,48 @@ def test_edit_user_permissions_including_authentication_with_email_auth_service(
|
||||
)
|
||||
|
||||
|
||||
def test_edit_user_permissions_shows_authentication_for_email_auth_service(
|
||||
client_request,
|
||||
service_one,
|
||||
mock_get_users_by_service,
|
||||
mock_get_template_folders,
|
||||
active_user_with_permissions,
|
||||
):
|
||||
service_one['permissions'].append('email_auth')
|
||||
|
||||
page = client_request.get(
|
||||
'main.edit_user_permissions',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
user_id=active_user_with_permissions['id'],
|
||||
)
|
||||
|
||||
radio_buttons = page.select("input[name=login_authentication]")
|
||||
values = {button["value"] for button in radio_buttons}
|
||||
|
||||
assert values == {'sms_auth', 'email_auth'}
|
||||
assert not any(button.has_attr("disabled") for button in radio_buttons)
|
||||
|
||||
|
||||
def test_edit_user_permissions_hides_authentication_for_webauthn_user(
|
||||
client_request,
|
||||
service_one,
|
||||
mock_get_users_by_service,
|
||||
mock_get_template_folders,
|
||||
active_user_with_permissions,
|
||||
):
|
||||
active_user_with_permissions['auth_type'] = 'webauthn_auth'
|
||||
service_one['permissions'].append('email_auth')
|
||||
|
||||
page = client_request.get(
|
||||
'main.edit_user_permissions',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
user_id=active_user_with_permissions['id'],
|
||||
)
|
||||
|
||||
assert 'This user will login with a security key' in str(page)
|
||||
assert page.select_one('#login_authentication') is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize('new_auth_type', ['sms_auth', 'email_auth'])
|
||||
def test_edit_user_permissions_preserves_auth_type_for_webauthn_user(
|
||||
client_request,
|
||||
|
||||
Reference in New Issue
Block a user