Commit Graph

284 Commits

Author SHA1 Message Date
Martyn Inglis
a9539d892c Merge branch 'master' into rate-limit-api-calls
Conflicts:
	requirements.txt
	tests/app/notifications/rest/test_send_notification.py
	tests/app/notifications/test_validators.py
	tests/app/v2/notifications/test_post_notifications.py
2017-05-02 10:56:56 +01:00
Martyn Inglis
2a0f8c8808 Validate International phone numbers
- uses new utils methods to validate phone numbers
- defaults to International=True on validation. This ensures the validator works on all numbers
- Then check if the user can send this message to the number internationally if needed.
2017-04-26 15:56:45 +01:00
Martyn Inglis
926b8a60f9 Adds in call to new rate limit method in the redis client
- both V1 and V2 APIs
- Rate limiting wrapped into a new method - check_rate_limiting
	- delegates to the previous daily limit and the new though put limit
- Rate limiting done on key type. Each key has it's own limit (number of requests) and interval (time period of requests)
- Configured in the config. Not done on a per-env basis though could be in the future.
2017-04-24 14:15:08 +01:00
Ken Tsang
4a63a337b2 Removed slash from v2 get all templates route 2017-04-19 12:38:58 +01:00
Ken Tsang
fc0cfa5dbf Corrected code to handle template types 2017-04-19 10:51:12 +01:00
Ken Tsang
c33b876c66 Remove get all template print 2017-04-19 10:51:12 +01:00
Ken Tsang
a5e514c356 Refactored to use template response as template 2017-04-19 10:51:12 +01:00
Ken Tsang
d290a2e0ad Removed paging from get all templates 2017-04-19 10:51:12 +01:00
Ken Tsang
cb7cd233d1 Rrefactored schema 2017-04-19 10:51:12 +01:00
Ken Tsang
89e244ccd2 First commit 2017-04-19 10:51:12 +01:00
Ken Tsang
f5da3574b5 Add get all templates schema 2017-04-19 10:51:12 +01:00
Martyn Inglis
81f0942f57 Merge branch 'master' into update-the-notification-with-dvla-id
Conflicts:
	requirements.txt
2017-04-18 11:21:26 +01:00
Martyn Inglis
b0e5062df2 Added the random string reference to the letter
- uses the reference field on the notifications table to store a 16char random string used to cross reference DVLA letters back to the notification
- used as letter barcode does not have space for a UUID notification id

Depends on https://github.com/alphagov/notifications-utils/pull/149

Renamed the numeric_id to notification_reference in utils and changed validation rules to match this

Note also the persist_notification method set "reference" to be "client_reference" which is confusing and they are different things, so fixed this too.
2017-04-12 17:56:55 +01:00
Ken Tsang
ccd25382ea Refactored post template 2017-04-11 16:37:30 +01:00
Ken Tsang
7c0aeca66e Removed unused imports 2017-04-11 16:19:43 +01:00
Ken Tsang
06ec7a59a6 Refactored code to personalise subject 2017-04-11 16:19:43 +01:00
Ken Tsang
eba88b08c5 Removed URI from preview response 2017-04-11 16:19:43 +01:00
Martyn Inglis
ac445114c7 When using a priority template put the notification in the priority queue.
- there is now a dedicated worker to handle priority queues. We don't now bundle this in the default worker.
2017-04-04 13:44:11 +01:00
Martyn Inglis
7dcd3164e2 Revert "Reinstating the 2 task model for API submitted notifications."
This reverts commit 1c154c4113.
2017-03-30 10:46:23 +01:00
Martyn Inglis
385a73da2b Revert "ensure we're passing through api keys and key types from notifications"
This reverts commit 25d1777937.
2017-03-30 10:38:41 +01:00
kentsanggds
79025e54b0 Merge pull request #865 from alphagov/add-v2-template-preview
Add v2 template preview endpoint and schema
2017-03-28 18:40:32 +01:00
Leo Hemsted
25d1777937 ensure we're passing through api keys and key types from notifications
when we made the change to async persist notifications, we forgot to
pass through api_key_id and key_type. in send_sms/email, for legacy
reasons, they default to None/KEY_TYPE_NORMAL, so regardless of what
your api key was set up as, we would send real messages!

TODO: Once the PaaS transition is complete and the task changes are
reverted, remove the api_key_id and key_type params from the send_*
tasks entirely, as those are only called from the csv job flow, and
don't need them
2017-03-28 13:14:46 +01:00
Ken Tsang
dfaf38269b Refactored get template 2017-03-23 15:02:21 +00:00
Martyn Inglis
1c154c4113 Reinstating the 2 task model for API submitted notifications.
This is being done for the PaaS migration to allow us to keep traffic coming in whilst we migrate the database.

uses the same tasks as the CSV uploaded notifications. Simple changes to not persist the notification, and call into a different task.
2017-03-23 14:41:00 +00:00
Ken Tsang
50db538df7 Updated schema to remove redundant 'content' 2017-03-23 11:50:15 +00:00
Ken Tsang
22239deb90 Removed redundant try block 2017-03-22 14:01:04 +00:00
Ken Tsang
8e5266e89b Refactor and fix auth errors 2017-03-22 10:54:15 +00:00
Ken Tsang
b81d789307 Add preview endpoint and tests 2017-03-22 10:11:31 +00:00
Ken Tsang
fad67e1bdd Added schemas + tests & updated get template tests 2017-03-22 10:10:05 +00:00
Rebecca Law
e4e7a99f40 Merge branch 'master' into secure-endpoints
Conflicts:
	app/__init__.py
2017-03-17 10:24:12 +00:00
Rebecca Law
78242812ef Register a before_request event for all blueprints, that defines the authentication requirement.
There are three authentication methods:
 - requires_no_auth - public endpoint that does not require an Authorisation header
 - requires_auth - public endpoints that need an API key in the Authorisation header
 - requires_admin_auth - private endpoint that requires an Authorisation header which contains the API key for the defined as the client admin user
2017-03-16 18:15:49 +00:00
Ken Tsang
ea8a3754a0 Updated schema to handle null updated_at 2017-03-15 15:48:28 +00:00
Ken Tsang
7558a7661a Updated schema description 2017-03-15 09:19:56 +00:00
Ken Tsang
a596a1bb87 Refactored tests and get template endpoint 2017-03-14 17:51:30 +00:00
Ken Tsang
9e4b1b2bfc Add schemas, endpoints and supporting tests 2017-03-14 15:40:38 +00:00
Rebecca Law
8ed0979251 increase page size for API calls to 250 2017-01-20 12:26:55 +00:00
Rebecca Law
f66670c558 - Added logging to indicate that we created the notification and that we sent the notification to a delivery queue.
- Small updates as recommended by review comments.
2017-01-18 09:56:26 +00:00
Rebecca Law
b34c5f0bcd If the template.process_type = PRIROITY send the message to the notify queue.
We are using the notify queue in this iteration because that queue is a low volume queue with it's own dedicated workers. This just saves us from building a new queue at this point, and a new queue may not be necessary.
2017-01-17 13:16:26 +00:00
Rebecca Law
a8cdabcecd - Refactor v2 post_notification to use a single method for sms and email.
- Added the `simulate` notification logic to version 2. We have 3 email addresses and phone numbers that are used
to simulate a successful post to /notifications. This was missed out of the version 2 endpoint.
- Added a test to template_dao to check for the default value of normal for new templates
- in v2 get_notifications, casted the path param to a uuid, if not uuid abort(404)
2017-01-17 12:08:24 +00:00
minglis
0c6193e2e9 Merge pull request #775 from alphagov/do-not-write-test-data-to-the-history-table
Do not write test data to the history table
2017-01-10 13:05:06 +00:00
Rebecca Law
bbdbb9079e Fixed the template uri for the post notification responses.
It was optimistic to think the v2 templates would be complete.
2017-01-04 11:22:50 +00:00
Rebecca Law
7f9111fd90 Removed the oneOf validation in the get_notification_response schema. 2017-01-04 11:00:47 +00:00
Martyn Inglis
0f37824b0c Ensure updates on a research mode service or test key don't touch the history table
- note this is an unexpectedly big change.
- When we create a service we pass the service id to the persist method. This means that we don't have the service available to check if in research mode.
- All calling methods (expecting the one where we use the notify service) have the service available. So rather than reload it I changed the method signature to pass the service, not the ID to persist.
- Touches a few places.

Note this means that the update or create methods will fall over on a null service. But this seems correct.

Goes back to the story which we need to play to make the service available as the API user so that the need to load and pass around services is minimised.
2016-12-19 16:45:18 +00:00
imdadahad
fb114f4c80 Merge pull request #772 from alphagov/fix-v2-uri
Fix uri validation in v2 responses
2016-12-16 15:53:26 +00:00
Imdad Ahad
243c4e481f Add uri validation to response schemas:
* Add to root uri and template.uri in responses
* Add tests to validate invalid or missing uri
* General refactoring for clarity
2016-12-15 16:39:15 +00:00
Rebecca Law
7a623de171 Added boby and subject to the get_notifications schema 2016-12-15 16:19:55 +00:00
Chris Hill-Scott
2c9a3f6f57 Merge pull request #764 from alphagov/more-breaking-utils-changes
Update utils to 12.1.1
2016-12-14 17:46:15 +01:00
Chris Hill-Scott
59af44d7ab Update utils to 12.0.0
Includes:

- [x] https://github.com/alphagov/notifications-utils/pull/94 (breaking
      changes which are responsible for all the changes to the API in
      this PR)

The test for `get_sms_fragment_count` has been removed because this
method is already tested in utils here:

ac20f7e99e/tests/test_base_template.py (L140-L159)
2016-12-13 10:57:01 +00:00
Imdad Ahad
431ec8acad Retrieve notifications by reference:
* Use get_notifications instead (references may not be unique)
2016-12-12 18:04:20 +00:00
Rebecca Law
4f9b295a5b Merge pull request #766 from alphagov/fix-sms-sender
Fix the from number in the post_sms_response.
2016-12-12 16:46:00 +00:00