mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 13:39:41 -04:00
Integrate with the API for adding and getting webauthn creds
This links up the `get_webauthn_credentials_for_user` and
`create_webauthn_credential_for_user` methods of the user api client to
notifications-api.
To send data to the API we need strings to be unicode, so we call
decode('utf-8') on base64 objects.
Co-authored-by: Leo Hemsted <leo.hemsted@digital.cabinet-office.gov.uk>
This commit is contained in:
@@ -19,8 +19,10 @@ def test_should_show_overview_page(
|
||||
|
||||
def test_overview_page_shows_disable_for_platform_admin(
|
||||
client_request,
|
||||
platform_admin_user
|
||||
platform_admin_user,
|
||||
mocker
|
||||
):
|
||||
mocker.patch('app.user_api_client.get_webauthn_credentials_for_user')
|
||||
client_request.login(platform_admin_user)
|
||||
page = client_request.get('main.user_profile')
|
||||
assert page.select_one('h1').text.strip() == 'Your profile'
|
||||
|
||||
@@ -27,6 +27,7 @@ def test_begin_register_returns_encoded_options(
|
||||
values={'ADMIN_BASE_URL': 'http://localhost:6012'}
|
||||
)
|
||||
webauthn_server.init_app(app_)
|
||||
mocker.patch('app.user_api_client.get_webauthn_credentials_for_user', return_value=[])
|
||||
|
||||
response = platform_admin_client.get(
|
||||
url_for('main.webauthn_begin_register')
|
||||
@@ -71,11 +72,18 @@ def test_begin_register_includes_existing_credentials(
|
||||
|
||||
def test_begin_register_stores_state_in_session(
|
||||
platform_admin_client,
|
||||
mocker,
|
||||
):
|
||||
platform_admin_client.get(
|
||||
mocker.patch(
|
||||
'app.user_api_client.get_webauthn_credentials_for_user',
|
||||
return_value=[])
|
||||
|
||||
response = platform_admin_client.get(
|
||||
url_for('main.webauthn_begin_register')
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
with platform_admin_client.session_transaction() as session:
|
||||
assert session['webauthn_registration_state'] is not None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user