mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
make sure error message flashes work properly
flashes are consumed by the jinja template calling get_flashed_messages in flash_messages.html. When you call `abort(403)` the 403 error page is rendered, with the flashed message on it. However, the webauthn endpoints just return that page to the ajax `fetch`, which ignores the response and just reloads the page. Instead of calling abort, we can just return an empty response body and the 403 error code, so that the flashed messages stay in the session and will be rendered when the `GET /two-factor-webauthn` request happens after the js reloads the page.
This commit is contained in:
@@ -292,6 +292,8 @@ def test_complete_authentication_403s_if_key_isnt_in_users_credentials(
|
||||
assert 'user_id' not in session
|
||||
# webauthn state reset so can't replay
|
||||
assert 'webauthn_authentication_state' not in session
|
||||
# make sure there's an error message to show when the page reloads
|
||||
assert '_flashes' in session
|
||||
|
||||
assert mock_verify_webauthn_login.called is False
|
||||
# make sure we incremented the failed login count
|
||||
@@ -362,6 +364,10 @@ def test_verify_webauthn_login_signs_user_in_doesnt_sign_user_in_if_api_rejects(
|
||||
|
||||
resp = client.post(url_for('main.webauthn_complete_authentication'))
|
||||
|
||||
with client.session_transaction() as session:
|
||||
# make sure there's an error message to show when the page reloads
|
||||
assert '_flashes' in session
|
||||
|
||||
assert resp.status_code == 403
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user