From 2c74027e0d501f5e8183b0ed23c104e428d8b37f Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Fri, 3 Nov 2017 11:56:15 +0000 Subject: [PATCH 1/9] Adding a route for 'callbacks' page Gone with callbacks as this page may be extended for delivery receipts in the future. --- app/main/views/index.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/main/views/index.py b/app/main/views/index.py index 412a8dbe4..24061b3cc 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -135,3 +135,8 @@ def using_notify(): @main.route('/information-risk-management') def information_risk_management(): return render_template('views/information-risk-management.html') + + +@main.route('/callbacks') +def callbacks(): + return render_template('views/callbacks.html') From 9eb83792cf1f84cbeb9e11b85c0b6a34ab5598f5 Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Fri, 3 Nov 2017 11:57:29 +0000 Subject: [PATCH 2/9] Added test for new callbacks static page --- tests/app/main/views/test_index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/app/main/views/test_index.py b/tests/app/main/views/test_index.py index 46dd31da7..2e46706e9 100644 --- a/tests/app/main/views/test_index.py +++ b/tests/app/main/views/test_index.py @@ -18,7 +18,7 @@ def test_logged_in_user_redirects_to_choose_service( @pytest.mark.parametrize('view', [ 'cookies', 'using_notify', 'pricing', 'terms', 'integration_testing', 'roadmap', - 'features', 'information_risk_management' + 'features', 'information_risk_management', 'callbacks' ]) def test_static_pages( client, From bc7af49b5694fa2b66b78ec86a0ff906bcce173e Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Fri, 3 Nov 2017 14:24:10 +0000 Subject: [PATCH 3/9] New page explaining the format of callback messages --- app/templates/views/callbacks.html | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 app/templates/views/callbacks.html diff --git a/app/templates/views/callbacks.html b/app/templates/views/callbacks.html new file mode 100644 index 000000000..935667280 --- /dev/null +++ b/app/templates/views/callbacks.html @@ -0,0 +1,63 @@ +{% from "components/table.html" import mapping_table, row, text_field, edit_field, field %} +{% extends "withoutnav_template.html" %} + +{% block per_page_title %} + Callbacks +{% endblock %} + +{% block maincolumn_content %} + +
+
+

Callbacks for received text messages

+ +

+ Text messages you receive can be forwarded to a URL that you specify, using our callback feature. +

+ +

+ Messages are forwarded as they are received. +

+ +

+ To protect your service, we require you to provide a bearer token. We put this token in the authorisation header of the callback requests. +

+ +

+ Once you have ‘receive text messages’ enabled, you can set up your callback on the settings page of your service. +

+ +

+ If you don’t have ‘receive text messages’ enabled for your service, get in touch and we can turn it on for you. +

+ +

Format of the callback

+ +

+ The format of the callback message you receive is JSON. +

+ +
+ {% call mapping_table( + caption='Callback message format', + field_headings=['Key', 'Description', 'Format'], + field_headings_visible=True, + caption_visible=False + ) %} + {% for key, description, format in [ + ('id', 'Notify’s id for the received message', 'UUID'), + ('source_number', 'The phone number the message was sent from', '447700912345'), + ('destination_number', 'The number the message was sent to (your number)', '07700987654'), + ('message', 'The received message', 'Hello Notify!'), + ('date_received', 'The UTC datetime that the message was received by Notify', '2017-05-14T12:15:30.000000Z') + ] %} + {% call row() %} + {% call row_heading() %} {{ key }} {% endcall %} + {{ text_field(description) }} + {{ text_field(format) }} + {% endcall %} + {% endfor %} + {% endcall %} +
+ +{% endblock %} From 4b2ba34d685eacca66c28c50726ffd08ba080ef0 Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Fri, 3 Nov 2017 14:25:31 +0000 Subject: [PATCH 4/9] Updated the label to set the callback URL on the settings page --- app/templates/views/service-settings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/views/service-settings.html b/app/templates/views/service-settings.html index 4e279f043..b31854876 100644 --- a/app/templates/views/service-settings.html +++ b/app/templates/views/service-settings.html @@ -106,7 +106,7 @@ {% if can_receive_inbound %} {% call row() %} - {{ text_field('API endpoint for received text messages') }} + {{ text_field('Callback URL for received text messages') }} {{ optional_text_field(inbound_api_url) }} {{ edit_field('Change', url_for('.service_set_inbound_api', service_id=current_service.id)) }} {% endcall %} From 431e269cf94c6cff0c23d221732bee7723052516 Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Fri, 3 Nov 2017 16:02:43 +0000 Subject: [PATCH 5/9] Updated the field label for the callback URL --- app/main/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index 75d15fb16..1d2a65b67 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -693,10 +693,10 @@ class ServiceInboundNumberForm(Form): class ServiceInboundApiForm(Form): - url = StringField("Inbound sms url", + url = StringField("Callback URL", validators=[DataRequired(message='Can’t be empty'), Regexp(regex="^https.*", - message='Must be a valid https url')] + message='Must be a valid https URL')] ) bearer_token = PasswordFieldShowHasContent("Bearer token", validators=[DataRequired(message='Can’t be empty'), From 55093691f12f053135d85b8766dd39d77f97e220 Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Fri, 3 Nov 2017 16:05:10 +0000 Subject: [PATCH 6/9] Updated test to reflect new label on callback URL field --- tests/app/main/views/test_service_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 998b32243..cea7c6a7c 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -1272,7 +1272,7 @@ def test_does_not_show_research_mode_indicator( @pytest.mark.parametrize('url, bearer_token, expected_errors', [ ("", "", "Can’t be empty Can’t be empty"), - ("http://not_https.com", "1234567890", "Must be a valid https url"), + ("http://not_https.com", "1234567890", "Must be a valid https URL"), ("https://test.com", "123456789", "Must be at least 10 characters"), ]) def test_set_inbound_api_validation( From 60a39b2e493f99ccc835ddb5145516fc00ab4fc8 Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Fri, 3 Nov 2017 16:10:26 +0000 Subject: [PATCH 7/9] Updated the callbacks page to add the link to new documentation. --- .../views/service-settings/set-inbound-api.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/templates/views/service-settings/set-inbound-api.html b/app/templates/views/service-settings/set-inbound-api.html index 0609ff126..9530b36d5 100644 --- a/app/templates/views/service-settings/set-inbound-api.html +++ b/app/templates/views/service-settings/set-inbound-api.html @@ -3,27 +3,27 @@ {% from "components/page-footer.html" import page_footer %} {% block service_page_title %} - Inbound api + Callback URL {% endblock %} {% block maincolumn_content %}
-

API endpoint for received text messages

+

Callback URL for received text messages

- This is the https url that the inbound SMS messages will be posted to - and the bearer token used in the authorisation header of the request. + Text messages you receive can be forwarded to your systems with our callback feature. + See our documentation on the format of the callback.

{{ textbox( form.url, width='2-3', - hint='Valid https url' + hint='Valid https URL' ) }} {{ textbox( form.bearer_token, - width='1-4', + width='2-3', hint='At least 10 characters' ) }} {{ page_footer( @@ -35,4 +35,4 @@
-{% endblock %} \ No newline at end of file +{% endblock %} From c19855c0b0d1b78c3b2d1979c3f61615a86c62d0 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 3 Nov 2017 16:12:37 +0000 Subject: [PATCH 8/9] Fix missing import --- app/templates/views/callbacks.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/views/callbacks.html b/app/templates/views/callbacks.html index 935667280..38ec51669 100644 --- a/app/templates/views/callbacks.html +++ b/app/templates/views/callbacks.html @@ -1,4 +1,4 @@ -{% from "components/table.html" import mapping_table, row, text_field, edit_field, field %} +{% from "components/table.html" import mapping_table, row, text_field, edit_field, field, row_heading%} {% extends "withoutnav_template.html" %} {% block per_page_title %} @@ -12,7 +12,7 @@

Callbacks for received text messages

- Text messages you receive can be forwarded to a URL that you specify, using our callback feature. + Text messages you receive can be forwarded to a URL that you specify, using our callback feature.

From 240f25eaf97bd65b9b9dab6f31bea614dd248528 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 3 Nov 2017 16:15:39 +0000 Subject: [PATCH 9/9] Fix failing tests --- tests/app/main/views/test_service_settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index cea7c6a7c..27080aaee 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -121,7 +121,7 @@ def test_should_show_overview( 'Text message sender GOVUK Manage', 'International text messages On Change', 'Receive text messages On Change', - 'API endpoint for received text messages Not set Change', + 'Callback URL for received text messages Not set Change', 'Label Value Action', 'Send letters Off Change', @@ -207,7 +207,7 @@ def test_service_settings_show_elided_api_url_if_needed( non_empty_trs = [tr.find_all('td') for tr in page.find_all('tr') if tr.find_all('td')] api_url = [api_setting[1].text.strip() for api_setting in non_empty_trs - if api_setting[0].text.strip() == 'API endpoint for received text messages'][0] + if api_setting[0].text.strip() == 'Callback URL for received text messages'][0] assert api_url == elided_url assert mocked_get_fn.called is True