5032 Commits
Author SHA1 Message Date
Rebecca Law b2da3f563b Merge branch 'master' into email-registered-users 2016-07-08 14:53:38 +01:00
Chris Hill-Scott aa12c88551 Add a test for sending email to provider
We had a test like this for sending sms, but not email. This meant that,
for example, we weren’t checking that the provider was getting passed
the HTML and plain text versions of the email.
2016-07-08 11:16:45 +01:00
Chris Hill-Scott bb3c55ca6c Make send sms test use a template with a newline 2016-07-08 11:16:45 +01:00
Rebecca Law f4976539e4 Make email a required field for the email_data_schema. 2016-07-08 10:57:20 +01:00
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
Rebecca Law 36ecdca04c Add new email template for the GOV.UK Notify service, to send an email to users that register with the same email address.
Add a new endpoint to send the email.
2016-07-07 17:23:07 +01:00
Rebecca Law 16eb20371f Fix import 2016-07-06 15:07:09 +01:00
Rebecca Law a1209ed9a4 Merge branch 'master' into fix-count 2016-07-06 14:45:10 +01:00
Rebecca Law 8bea8b6a8f Fix bug where all notifications were getting a type = email.
Includes a fix to notification and notification_statistics data.
2016-07-06 14:31:52 +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 242be97bfa remove reply_to_addresses from task kwargs
also added a test for aws_ses.send_email to prove it handles reply_to_address correctly
2016-07-04 17:29:41 +01:00
Leo Hemsted f5e14f043d dont pass reply-to-addresses about
dont send reply_to_addresses around from process_job and send_email -
take it from the service in send_email_to_provider. also clean up
the kwarg in aws_ses.send_email to more accurately reflect what we
might pass in
2016-07-04 15:04:43 +01:00
Adam Shimali 19f2ccb594 Merge pull request #498 from alphagov/set-sms-sender-api
Set sms sender on service
2016-07-04 10:32:04 +01:00
Leo Hemsted 4e2a14ed28 Merge branch 'master' into notifications-get-api-key-filter 2016-07-01 17:12:03 +01:00
Adam Shimali b32f0ab2cd Resolve conflicts 2016-07-01 16:53:12 +01:00
Leo Hemsted f992240192 make notification.key_type not nullable
set to 'normal' for all existing notifications, and all job notifications also created as 'normal' - so if your eg reporting service hits notify, it gets notifications created from both API calls and front-end csv jobs.
2016-07-01 16:36:11 +01:00
Adam Shimali c29dd23702 Add sms sender to service to be used in sms templates
in place of default numeric short code.

If not present default short code is used.
2016-07-01 15:27:54 +01:00
Rebecca Law 4a321497fc Remove print 2016-07-01 15:03:28 +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 01419e7894 store api_key_id and key_type on notification
pass through from POST /notification/<type> to the celery task
also removed a couple of asserts that can fail (based on unfrozen time comparisons)
2016-07-01 14:35:02 +01:00
Leo Hemsted 5ae7ed1acb only send to team emails/phones if POST /notificaiton/<type> with team api_key
uses same restriction as a service in trial mode
2016-07-01 14:33:25 +01:00
Rebecca Law f52755742c Split send_email task into one task to create the notification and one to send it to the provider.
Is there is an exception the task will go to the retry queue.
2016-07-01 14:14:28 +01:00
Leo Hemsted 11093530f9 Merge pull request #485 from alphagov/api_user-cleanup
Api user cleanup
2016-07-01 10:58:18 +01:00
Chris Hill-Scott a26d2a2551 Merge pull request #482 from alphagov/swagger-spike
Publish a Swagger specification
2016-06-30 13:41:33 +01:00
Leo Hemsted 3838715077 refactored the requires_auth handler to raise exceptions
hopefully cleans up code flow and readability [a tiny bit].
raise an AuthException in auth.py, and catch it in errors.py to
save on returning error_repsonse values throughout the function
2016-06-30 10:44:21 +01:00
Leo Hemsted 39519e3f36 attach api_key to app
we previously attached the service id and the key's secret
also more refactoring of auth.py
2016-06-30 10:44:21 +01:00
Leo Hemsted adbe02783d refactor authentication code
moved api_key secret manipulation (generating and getting) into
authentiation/utils, and added a property on the model, to facilitate
easier matching of authenticated requests and the api keys they used
2016-06-30 10:44:21 +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
Chris Hill-Scott 7c3d25a87a Publish a Swagger specification
Adds a new endpoint (`/spec`) which returns a the specification of the
API in Swagger-formatted JSON.

This means we will have something to point frontends at, so we can
evaluate which ones we like.

Right now it’s all hand-defined. If we were consistent about our use of
Marshmallow we could generated the spec from the Marshmallow schemas.
2016-06-29 12:07:32 +01:00
Rebecca Law 60e159e3c0 Add notification_type to notification table.
It seems like an oversight not to include the notification type in the notifcation.
When updating statistics a query to the template table is required to get the type, this update will mean that query does not have to happen.
2016-06-29 11:23:02 +01:00
Rebecca Law 340abae82c Merge pull request #478 from alphagov/make-password_changed_at-not-null
Users.password_changed_at not nullable
2016-06-28 17:00:22 +01:00
Rebecca Law abb9135e35 Password changed at is defaulted to the current date when the user is created.
This PR set the users.password_changed_at column to not be nullable.
2016-06-28 11:24:08 +01:00
Leo Hemsted 4c44f0c9e9 remove default key_type 2016-06-27 17:00:02 +01:00
Rebecca Law b3fabae958 Merge and codestyle 2016-06-27 15:38:25 +01:00
Rebecca Law 6626771335 Merge branch 'master' into notification-created-status 2016-06-27 15:36:42 +01:00
Rebecca Law 3346582634 Fix codestyle 2016-06-27 15:32:26 +01:00
Rebecca Law 90e8154700 Added a test that the message is not sent if the status of the notification is not created. 2016-06-27 15:23:23 +01:00
Rebecca Law 8435217808 Fix new test for the default status of a notification 2016-06-27 15:02:53 +01:00
Leo Hemsted 523215c8fa Merge pull request #473 from alphagov/api-key-type
key_types table
2016-06-27 15:02:52 +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
Leo Hemsted 9eedb19fd4 default to KEY_TYPE_NORMAL to ensure backwards compatibility
also cleaned up tests around api_keys - fixed imports, reduced fixture usage
and added an additional (temporary) test for default test type
2016-06-24 16:33:51 +01:00
Leo Hemsted e9482c7fe1 add new key_type table
* single-column static data table that currently contains two types: 'normal' and 'team'
* key_type foreign-keyed from api_keys
  - must be not null
  - existing rows set to 'normal'
* key_type foreign-keyed from notifications
  - nullable
  - existing rows set to null
* api_key foreign-keyed from notifications
  - nullable
  - existing rows set to null
2016-06-24 15:56:54 +01:00
Leo Hemsted f371c393a2 rename renew_api_key to create_api_key 2016-06-23 16:44:57 +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
Rebecca Law 8f19ad19f8 Stop sending the encrypted message to the send_sms_to_provider task.
Everything the task needs is now stored in the db.
2016-06-23 09:41:21 +01:00