From f946b022e8276c73172630fd741f8302875dd69d Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Wed, 7 Dec 2016 13:05:38 +0000 Subject: [PATCH 1/4] Update the invitation expiry error message so that it is nicer to read. --- app/accept_invite/rest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/accept_invite/rest.py b/app/accept_invite/rest.py index 25855ecc8..f8f3bc9d0 100644 --- a/app/accept_invite/rest.py +++ b/app/accept_invite/rest.py @@ -33,7 +33,9 @@ def get_invited_user_by_token(token): current_app.config['DANGEROUS_SALT'], max_age_seconds) except SignatureExpired: - errors = {'invitation': ['Invitation has expired']} + errors = {'invitation': + ['This invitation has expired please contact the person that invited you to invite you again']} + print(errors) raise InvalidRequest(errors, status_code=400) invited_user = get_invited_user_by_id(invited_user_id) From eedc2fb43e3216e77d1ce0b1ff5a8bd85cbb8eba Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Wed, 7 Dec 2016 13:29:19 +0000 Subject: [PATCH 2/4] Fix test and style --- app/accept_invite/rest.py | 3 +-- tests/app/accept_invite/test_accept_invite_rest.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/accept_invite/rest.py b/app/accept_invite/rest.py index f8f3bc9d0..e62de8079 100644 --- a/app/accept_invite/rest.py +++ b/app/accept_invite/rest.py @@ -34,8 +34,7 @@ def get_invited_user_by_token(token): max_age_seconds) except SignatureExpired: errors = {'invitation': - ['This invitation has expired please contact the person that invited you to invite you again']} - print(errors) + ['This invitation has expired please contact the person that invited you to invite you again']} raise InvalidRequest(errors, status_code=400) invited_user = get_invited_user_by_id(invited_user_id) diff --git a/tests/app/accept_invite/test_accept_invite_rest.py b/tests/app/accept_invite/test_accept_invite_rest.py index 2df8c185f..94603bb69 100644 --- a/tests/app/accept_invite/test_accept_invite_rest.py +++ b/tests/app/accept_invite/test_accept_invite_rest.py @@ -1,6 +1,5 @@ import uuid -import pytest from flask import json from freezegun import freeze_time from notifications_utils.url_safe_token import generate_token @@ -20,7 +19,8 @@ def test_accept_invite_for_expired_token_returns_400(notify_api, sample_invited_ assert response.status_code == 400 json_resp = json.loads(response.get_data(as_text=True)) assert json_resp['result'] == 'error' - assert json_resp['message'] == {'invitation': ['Invitation has expired']} + assert json_resp['message'] == {'invitation': [ + 'This invitation has expired please contact the person that invited you to invite you again']} def test_accept_invite_returns_200_when_token_valid(notify_api, sample_invited_user): From e97c3bcc73637fe6597b2183d4132197860db991 Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Fri, 9 Dec 2016 12:20:03 +0000 Subject: [PATCH 3/4] Tweaked the wording of the expired invitation message. --- app/accept_invite/rest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/accept_invite/rest.py b/app/accept_invite/rest.py index e62de8079..bebc41b76 100644 --- a/app/accept_invite/rest.py +++ b/app/accept_invite/rest.py @@ -34,7 +34,7 @@ def get_invited_user_by_token(token): max_age_seconds) except SignatureExpired: errors = {'invitation': - ['This invitation has expired please contact the person that invited you to invite you again']} + ['Your invitation to GOV.UK Notify has expired. Please ask the person that invited you to send you another one']} raise InvalidRequest(errors, status_code=400) invited_user = get_invited_user_by_id(invited_user_id) From 8c9e7b2d68fc1e5682bcd7d16f4733f9c6ddb662 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Fri, 9 Dec 2016 12:28:28 +0000 Subject: [PATCH 4/4] Update the tests for the new text --- app/accept_invite/rest.py | 3 ++- tests/app/accept_invite/test_accept_invite_rest.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/accept_invite/rest.py b/app/accept_invite/rest.py index bebc41b76..f7c552d34 100644 --- a/app/accept_invite/rest.py +++ b/app/accept_invite/rest.py @@ -34,7 +34,8 @@ def get_invited_user_by_token(token): max_age_seconds) except SignatureExpired: errors = {'invitation': - ['Your invitation to GOV.UK Notify has expired. Please ask the person that invited you to send you another one']} + ['Your invitation to GOV.UK Notify has expired. ' + 'Please ask the person that invited you to send you another one']} raise InvalidRequest(errors, status_code=400) invited_user = get_invited_user_by_id(invited_user_id) diff --git a/tests/app/accept_invite/test_accept_invite_rest.py b/tests/app/accept_invite/test_accept_invite_rest.py index 94603bb69..3fbc80079 100644 --- a/tests/app/accept_invite/test_accept_invite_rest.py +++ b/tests/app/accept_invite/test_accept_invite_rest.py @@ -20,7 +20,8 @@ def test_accept_invite_for_expired_token_returns_400(notify_api, sample_invited_ json_resp = json.loads(response.get_data(as_text=True)) assert json_resp['result'] == 'error' assert json_resp['message'] == {'invitation': [ - 'This invitation has expired please contact the person that invited you to invite you again']} + 'Your invitation to GOV.UK Notify has expired. ' + 'Please ask the person that invited you to send you another one']} def test_accept_invite_returns_200_when_token_valid(notify_api, sample_invited_user):