Commit Graph

126 Commits

Author SHA1 Message Date
Chris Hill-Scott
a8a556d02a Use PassThrough renderer
Implements and depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/49
2016-07-07 22:48:07 +01:00
Leo Hemsted
96513442fe notifications from test api keys dont send for real - a la research_mode
also added a bunch more tests around api keys to help ensure we're behaving in at least a consistent way
2016-07-05 16:29:53 +01:00
Leo Hemsted
eee98e3e52 move callback tests into separate file
also fix syntax errors
2016-07-05 16:20:03 +01:00
Leo Hemsted
011afa4b16 make tests parametrized for all three key types 2016-07-05 16:20:02 +01:00
Leo Hemsted
2cf1d22748 add filters to GET /notifications endpoints to only return for provided key_type
if api_key used to access endpoint is type team, endpoints only return that type -
will 404 if you provide a different ID. Same applies for normal (normal api keys
cannot see team notifications)
also, for convenience, set sample_notification to supply key_type of KEY_TYPE_NORMAL
by default
2016-07-01 14:35:02 +01:00
Leo Hemsted
2b645f490a move get_all_notifications_for_service and get_all_notifications_for_job
moved from notifications/rest -> service/rest and job/rest respectively
endpoint routes not affected
removed requires_admin decorator - that should be set by nginx config
as opposed to python code
2016-06-30 10:44:21 +01:00
Rebecca Law
8435217808 Fix new test for the default status of a notification 2016-06-27 15:02:53 +01:00
Rebecca Law
48e64abd81 Merge branch 'master' into notification-created-status 2016-06-27 14:59:56 +01:00
Rebecca Law
8a0211b3eb Only send to the provider if the notification has a created status.
If the notification ends up in the retry queue and the delivery app is restarted the notification will get sent twice.
This is because when the app is restarted another message will be in the retry queue as message available which is a
duplicate of the one in the queue that is a  message in flight.

This should complete https://www.pivotaltracker.com/story/show/121844427
2016-06-27 14:47:20 +01:00
Adam Shimali
3423c0c44d Added subject for email templates 2016-06-23 15:21:03 +01:00
Adam Shimali
f65b86cfc9 Body of notification without placeholder should have been present. 2016-06-23 10:25:07 +01:00
Adam Shimali
ed5bdb7be8 Merge pull request #467 from alphagov/notification-created-status
Notification created status for send_sms
2016-06-23 10:21:43 +01:00
Leo Hemsted
c92138d5ab return replaced subject back from get notifications API 2016-06-22 16:24:34 +01:00
Rebecca Law
fcb5ca9ef4 The send_sms task will created the notification with a status = created.
The encrypted_notification for the send_sms_to_provider task has been made optional.
2016-06-22 13:32:27 +01:00
Adam Shimali
731bb19a9c Template and personalisation content is now merged and returned with
notifications, when retrieved by notification id, or service id (i.e.
all notifications for service).

There is a new element returned at top level of notification json called
body, which is the template content merged with personalisation. This
is consistent with api to endpoint to create notification which returns
what was sent as 'body' in json response.

Merging of template with personalisation is done in the
NotificationStatusSchema.

Personalisation data in encrypted before storing in db.
2016-06-20 16:49:17 +01:00
Leo Hemsted
d0eca79417 move all send_notification tests to separate file 2016-06-15 12:27:57 +01:00
Rebecca Law
470bf7281a Merge pull request #420 from alphagov/use-notify-to-send-email-verification-links
Use notify to send email verification links
2016-06-14 17:00:28 +01:00
Rebecca Law
4c34238a88 Fix send_email task requested from notifications endpoint. 2016-06-14 16:53:52 +01:00
Chris Hill-Scott
7f7743b389 Test for filtering a job by notification status
It’s going to be useful to see all the notifications for a job that are
failed/delivered/etc.

The API seems to support this behaviour already, but it doesn’t seem to
be tested.

This commit adds some testsfor the DAO and REST layers.
2016-06-14 14:07:54 +01:00
Rebecca Law
a6ce109c62 Rename first send_email to send_email_v1.
Fix the tests
2016-06-13 16:16:56 +01:00
Rebecca Law
cd2627e5ed Create a new task called send_email_v2 so that I can get rid of the from_address in the signature.
This is done to make sure we do not lose any messages in the queue during deployment.
2016-06-13 15:31:45 +01:00
Rebecca Law
c9f1eb65a7 Build the from address in the task instead of the rest call. 2016-06-13 14:57:59 +01:00
Leo Hemsted
a487931323 python 34 compatibility 2016-06-02 16:49:34 +01:00
Leo Hemsted
54a1adfe8b fix copypasta error with ses test 2016-06-02 16:30:40 +01:00
Leo Hemsted
d41048f4aa statsd counters for callback statuses
also for the 'code' param from firetext
2016-06-02 15:53:04 +01:00
Rebecca Law
25a1b7f31c Firetext does not have a status code for temporary-failure.
In order to set a message as temporary-failure, we check if it is in pending status first.
Otherwise a delivery receipt for failure is set to permanent failure.
2016-05-26 16:46:00 +01:00
Rebecca Law
fa152c4431 Mark a declined message from Firetext as permanent-failure rather than failed. 2016-05-24 15:32:48 +01:00
Leo Hemsted
24625a44f3 prevent public api from sending archived templates 2016-05-24 13:08:38 +01:00
Rebecca Law
cf2723bdc9 If the sms client provider sends more than one delivery receipt only take the update for the the first one.
Only update the notification.status if status = sending.
2016-05-20 17:04:56 +01:00
NIcholas Staples
e0f6b4e571 Merge pull request #327 from alphagov/add_job_row_number
Added job row number to the notification for csv jobs. All tests pass…
2016-05-19 14:33:21 +01:00
Adam Shimali
955005d7fe Added additional outcome status codes to mmg responses. 2016-05-19 11:27:22 +01:00
Nicholas Staples
0fe0c1d2b4 Added job row number to the notification for csv jobs. All tests passing. 2016-05-19 10:46:03 +01:00
Nicholas Staples
c46216dd96 Fix test to check for decrypted dictionary value. 2016-05-18 14:28:19 +01:00
Rebecca Law
281a93b32d Update ses callback to interpret hard and soft bounces.
If the notification has a status == sending then update the status otherwise do not update the status.
In other words do not change the status more than once.
2016-05-17 15:38:49 +01:00
minglis
3c751d94a4 Merge pull request #309 from alphagov/statsd-integration
Statsd integration
2016-05-16 12:29:14 +01:00
Martyn Inglis
a60e11a1b6 Fixed test bug due to pluralisation typo 2016-05-13 17:25:34 +01:00
Martyn Inglis
829d862739 Fixed pep8 issues and hostname in the test environment. 2016-05-13 17:20:29 +01:00
Martyn Inglis
3f7559b286 Added statsd integration into the API
- new client for statsd, follows conventions used elsewhere for configuration
- client wraps underlying library so we can use a config property to send/not send statsd

Added statsd metrics for:
- count of API successful calls SMS/Email
- count of successful task execution for SMS/Email
- count of errors from Client libraries
- timing of API calls to third party clients
- timing of how long messages live on the SQS queue
2016-05-13 17:15:39 +01:00
Rebecca Law
917110870d Use the template version at the time the notification is created or at the time the job is created.
Update notifications/sms|email endpoint to send the template version to the queue.
Update the process_job celery talk to send the template version to the queue.
When the send_sms|send_email task runs it will get the template by id and version.

Created a data migration script to add the template_vesion column for jobs and notifications.
The existing jobs and notifications are given the template_version of the current template.
There is a chance this is the wrong template version, but deemed okay since the application is not live.

Create unit test for the dao_get_template_versions method.
Rename /template/<id>/version to /template/<id>/versions which returns all versions for that template id and service id.
2016-05-13 16:25:05 +01:00
Nicholas Staples
f465066a69 Group by Notification Statistics added and all tests working.
Fixed tests for upgraded client.
2016-05-05 11:04:20 +01:00
Rebecca Law
b53fdf1f3f Update python client to version 1.0.0.
This version of the client removed the request method, path and body from the encode and decode methods.
The biggest changes here is to the unit tests.
2016-05-04 16:08:23 +01:00
Nicholas Staples
f71dbe9c0f Message limit added and all tests passing. 2016-04-29 10:36:59 +01:00
Chris Hill-Scott
ac0fa5b211 Send emails with a friendly from name
It’s nicer to have emails with a sender name, as well as the raw email
address.

Amazon SES can acheive this by using the format
```
"Sender name" <sender.name@domain.com>
```
— http://docs.aws.amazon.com/ses/latest/DeveloperGuide/email-format.html
We also have to remove all non-ASCII characters from the sender name,
because SMTP only supports 7-bit ASCII:

> A field name MUST be composed of printable US-ASCII characters (i.e.,
> characters that have values between 33 and 126, inclusive), except
> colon.

— http://www.ietf.org/rfc/rfc5322.txt

We use the service name as the sender name when:
- sending emails from the API
- sending emails from a CSV file

We use GOV.UK Notify as the sender name when:
- sending invitation emails
- sending password reset emails
2016-04-25 16:57:17 +01:00
Nicholas Staples
b56e324a4c Working tests and provider stats table.
Fix for tests and import error.

Added tests and updated for code review comments.
2016-04-25 12:20:06 +01:00
Rebecca Law
794e922d94 Merge pull request #248 from alphagov/mmg-client-fix
Update MMG responses so that 3 is success.
2016-04-20 14:45:08 +01:00
Rebecca Law
9a25062943 Update mmg responses so that 3 is success.
Status codes from mmg are:
2: UNDELIVERABLE Message is undeliverable.
3: DELIVERED Message is delivered.
4: EXPIRED Message is expired.
5: REJECTED Message is rejected.
2016-04-20 14:29:31 +01:00
Rebecca Law
7187ba6dc7 Merge pull request #242 from alphagov/mmg-client-fix
Update to processing the the response from MMG
2016-04-20 11:27:37 +01:00
Rebecca Law
f283379646 Defend against status code 00 or 0 from mmg 2016-04-20 11:07:21 +01:00
Chris Hill-Scott
425cc8340e Fix missing import on notification stats endpoint
The response import was missing, which broke things.

There was no test to catch this.

This commit adds a rudimentary test to make sure that the endpoint
doesn’t 500, at the very least.
2016-04-20 10:33:41 +01:00
Rebecca Law
41ce691704 Update to processing the the response from MMG
MMG changed the datatype and the status codes they send us for the delivery receipts.
This PR accounts for that change.
2016-04-20 09:45:13 +01:00