Commit Graph

815 Commits

Author SHA1 Message Date
Martyn Inglis
c44aaf0fdc Capture the count of sent notifications for a job 2016-03-04 14:25:28 +00:00
Martyn Inglis
024e390c2f Merge branch 'master' into aggregate-data 2016-03-04 13:43:22 +00:00
Martyn Inglis
a186e277d7 Sent count on jobs 2016-03-04 13:42:55 +00:00
Chris Hill-Scott
f7a1cfac50 Revert "Strip HTML from template content" 2016-03-04 13:23:44 +00:00
Rebecca Law
7e1f3f6180 Merge pull request #130 from alphagov/strip-html-from-templates
Strip HTML from template content
2016-03-04 11:46:52 +00:00
Chris Hill-Scott
703e513ddf Strip HTML from template content
Templates are created in the admin app and persisted in the API.

They are consumed:
- in the admin app, by requesting them from the API
- in the API, by loading them from the database

There are two potential places where unescaped HTML could be sent to a user:
- when the admin app is previewing a template (it has to render the template as
  markup in order to show the placeholders)
- in the body of an email

For all consumers to have confidence that the templates are safe, it makes sense
to santitise them at the point of creation (and modification). This also avoids
any performance issues that could come from doing it at the point of requesting
a template.

In the future they could be created by a direct API call, bypassing the admin
app. Therefore it makes sense for the API to sanitise them.

The commit sanitises templates using an XML parser. It extracts the text content
of the template, minus any HTML tags, because of this famous StackOverflow
answer:
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
2016-03-04 07:03:15 +00:00
Adam Shimali
f945253596 [WIP] Changed add user to service to take list of permissions instead
of invite.
2016-03-03 17:36:21 +00:00
Adam Shimali
fc8e27e582 [WIP] When user is added to a service a list of permissions groups are
used to assign the correct permissions to the user.

Last slice will be to update invite status.
2016-03-03 16:38:12 +00:00
Martyn Inglis
9b28a6d4ad Fixed version file to use new names 2016-03-03 16:27:13 +00:00
Martyn Inglis
5a2cf1baca Appeased pep8 2016-03-03 15:38:22 +00:00
Martyn Inglis
13320cbed0 Updated to populate on dev 2016-03-03 15:32:22 +00:00
Martyn Inglis
24a9487a20 Updated status page
- include travis build number
- renamed properties
- ELB version
- moved code all into health check
- changed health check to be on same URL for admin and api
2016-03-03 15:18:12 +00:00
Martyn Inglis
b818e1a535 Populate version data with build number and fixed date 2016-03-03 15:06:10 +00:00
Martyn Inglis
aaedd4d054 Removed unused notifcation status 2016-03-03 12:19:56 +00:00
Rebecca Law
2d142287c2 Merge pull request #125 from alphagov/check-restricted-services-on-tasks
Ensure restricted service are respected by tasks:
2016-03-03 12:17:52 +00:00
Martyn Inglis
800afc9e44 Ensure restricted service are respected by tasks:
This is checked on 3rd party API calls, but jobs (CSV files) were able expected to only allow valid files.

Change in tack means we want to have restricted notification failures reported in the UI.
2016-03-03 12:05:18 +00:00
Nicholas Staples
c80753bb75 Fix url for user service permissions. 2016-03-03 09:59:21 +00:00
Nicholas Staples
ebec54cb80 Permission enums corrected, all tests passing. 2016-03-02 15:34:26 +00:00
Rebecca Law
3fd3aa5b3e Merge pull request #119 from alphagov/update_permission_endpoints
Update permission endpoints
2016-03-02 14:33:18 +00:00
Rebecca Law
0c4b34d65a Merge branch 'master' into revert-queue-config 2016-03-02 13:20:55 +00:00
Rebecca Law
6a739d5ec9 Remove celery_queues from config.
Removed unused endpoint.
2016-03-02 13:15:23 +00:00
Chris Hill-Scott
b202af716d Fix bug where sending messages failed
When building the template it was looking for a placeholder called
((phone number)). This caused it to fail because the template it had did not
match the personalisation it was being given.

`Template` has an optional parameter for specifying personalisation values that
should be ignored. The recipient of a message is an example of such a value.

This commit passes that extra parameter, which fixes that bug.
2016-03-02 12:27:50 +00:00
NIcholas Staples
62f66329a9 Merge pull request #117 from alphagov/time-3rd-party-calls
Add logging around 3rd party delivery calls
2016-03-02 11:27:00 +00:00
Chris Hill-Scott
cc741003c0 Log FireText exceptions as exceptions 2016-03-02 11:14:32 +00:00
Chris Hill-Scott
0e5d72494e Prefix all SMS messages with service name
Implements https://github.com/alphagov/notifications-utils/pull/4
2016-03-02 11:14:32 +00:00
Nicholas Staples
01f616eeac Fix all tests. 2016-03-02 11:10:52 +00:00
Nicholas Staples
6f689a187e Merge remote-tracking branch 'origin/master' into update_permission_endpoints 2016-03-02 10:44:38 +00:00
Martyn Inglis
35b7b884f8 Add logging around 3rd party delivery calls
- time SES, Twilio, fire text calls
- use monotonic for accuracy
2016-03-02 09:33:20 +00:00
Chris Hill-Scott
fa4b2e16e7 Remove CSV utils
These are in the utils repo since https://github.com/alphagov/notifications-utils/releases/tag/0.2.1
2016-03-02 08:59:34 +00:00
Chris Hill-Scott
d6f7c7d1c9 Replace placeholders before sending a message
This commit replaces placeholders in a template with the user’s data, using
the Template class from utils
(https://github.com/alphagov/notifications-utils/tree/master/utils#template)

It also extracts the personalisation data from the CSV, taking account of the
different column headings that SMS and email CSVs will have.

At the point of creating the task to send an individual messages, validation of
the placeholders matching the template is assumed to have been done either:
- in processing the CSV in the admin app
- in the endpoint for the API call

No exceptions should be raised at this point.
2016-03-02 08:59:34 +00:00
Chris Hill-Scott
68eaacaafb Accept and validate personalisation
This commit allows the send notification endpoint to accept an extra parameter,
`personalisation`, the contents of which will be used (later) to replace the
placeholders in the template.

It does validation in the following places:
- at the schema level, to validate the type and (optional) presence of
  personalisation
- at the endpoint, to check whether the personalisation provided matches exactly
  the placeholders in the template

It does not do validation when processing CSV files, as these are assumed to
already have been validated by the admin app.

It explicitly does not persist either the names of the placeholders (these
should always be derived from the template contents unless it really becomes a
performance concern) or the values of the placeholders (because they might be
personal data).
2016-03-02 08:59:34 +00:00
Chris Hill-Scott
68f31c6f84 Refactor send notification into one route
Using a URL parameter means that sending a notification can be done in one
route, rather than two separate routes and an extra method.

This commit also refactors that one remaining method to be shorter/cleaner/more
readable (or I think so anyway).

No functional changes in this commit.
2016-03-02 08:59:34 +00:00
Nicholas Staples
47c4368007 Merge with master. 2016-03-01 17:18:46 +00:00
Rebecca Law
a2b1dc0432 Merge pull request #115 from alphagov/accept-invite
[WIP] Start of api for accepting invite.
2016-03-01 15:57:52 +00:00
Adam Shimali
ac9adc292b [WIP] Change status code to 404 rather than 400. 2016-03-01 15:51:22 +00:00
Adam Shimali
993bdc8055 [WIP] use correct dao function for adding user to service.
Check for no user returned from user dao and return correct
error message.
2016-03-01 15:36:31 +00:00
Adam Shimali
9fe08d480c Merge pull request #114 from alphagov/cancel-invited-user
New endpoint to update invited user.
2016-03-01 15:17:03 +00:00
Rebecca Law
dd503e7f14 Merge pull request #113 from alphagov/fetch-notifications-endpoints
Fetch endpoints for notifications
2016-03-01 15:16:54 +00:00
Martyn Inglis
dd67b84f6d Merge branch 'fetch-notifications-endpoints' of github.com:alphagov/notifications-api into fetch-notifications-endpoints
Conflicts:
	app/dao/notifications_dao.py
2016-03-01 14:59:21 +00:00
Martyn Inglis
6d345c1dfc Fixed ordering of the notifications test
- was backwards
2016-03-01 14:58:27 +00:00
minglis
57d8aa2bfd Removed print statement 2016-03-01 14:38:54 +00:00
Nicholas Staples
918d40cc9d Functionality added and all tests working. 2016-03-01 14:21:28 +00:00
Adam Shimali
3b66745677 [WIP] Start of api for accepting invite. 2016-03-01 14:13:38 +00:00
Rebecca Law
98c9ba14f7 New endpoint to update invited user.
Can be used to update status on invited user.
2016-03-01 13:33:20 +00:00
Martyn Inglis
c5a993ead1 Fetch endpoints for notifications
- includes check on token type to ensure clients can perform admin style fetches
2016-03-01 13:30:10 +00:00
Nicholas Staples
7d43b4265f Merge and fix conflicts. 2016-03-01 11:59:50 +00:00
Rebecca Law
ecbfbbc6b0 Fix bug in PermissionDAO
Refactor user/test_rest
Remove conftest/sample_admin_service
2016-03-01 10:34:27 +00:00
Nicholas Staples
47ac0b8a98 Fixed some tests. 2016-02-29 18:32:25 +00:00
Rebecca Law
6f338f17ac Merge branch 'master' into invitation
Conflicts:
	scripts/run_celery.sh
2016-02-29 16:14:35 +00:00
Rebecca Law
9f6255ac94 Add subject line to the invitation email. 2016-02-29 16:12:12 +00:00