From ae2f8f988749305e26a532c316830a81aa9bb03b Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 4 May 2020 12:37:05 +0100 Subject: [PATCH] Add a second URL for the email auth endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We’re going to add an interstitial page that redirects to this new URL. But we don’t want that redirect to 404 while the change is deploying, because some boxes will have the new URL and some won’t. So let’s deploy the new URL to all the boxes first, then the redirect page can safely take over the new one. The new URL is going to be `post` not `get` because that feels more HTTP-y, so we need to make sure that’s part of this change too. --- app/main/views/two_factor.py | 2 +- tests/app/main/views/test_two_factor.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/main/views/two_factor.py b/app/main/views/two_factor.py index 00e2a3b53..1e2aadcad 100644 --- a/app/main/views/two_factor.py +++ b/app/main/views/two_factor.py @@ -28,7 +28,7 @@ def two_factor_email_sent(): ) -@main.route('/email-auth/', methods=['GET']) +@main.route('/email-auth/', methods=['GET', 'POST']) def two_factor_email(token): if current_user.is_authenticated: return redirect_when_logged_in(platform_admin=current_user.platform_admin) diff --git a/tests/app/main/views/test_two_factor.py b/tests/app/main/views/test_two_factor.py index 6b0e4d9d3..5b4dd45b3 100644 --- a/tests/app/main/views/test_two_factor.py +++ b/tests/app/main/views/test_two_factor.py @@ -253,6 +253,9 @@ def test_two_factor_should_activate_pending_user( assert mock_activate_user.called +@pytest.mark.parametrize('http_method', ( + 'get', 'post', +)) def test_valid_two_factor_email_link_logs_in_user( client, valid_token, @@ -260,10 +263,11 @@ def test_valid_two_factor_email_link_logs_in_user( mock_get_services_with_one_service, mocker, mock_create_event, + http_method, ): mocker.patch('app.user_api_client.check_verify_code', return_value=(True, '')) - response = client.get( + response = getattr(client, http_method)( url_for_endpoint_with_token('main.two_factor_email', token=valid_token), )