Commit Graph

60 Commits

Author SHA1 Message Date
Nicholas Staples
327f169575 Filtering added and tests working. 2016-03-21 12:37:34 +00:00
Nicholas Staples
c3a15f9f30 Fix pagination bug and swapped file name with original file name. 2016-03-16 16:47:18 +00:00
Nicholas Staples
356083e8ac Update schemas to return more details about the job and template for notifications. 2016-03-15 14:24:10 +00:00
Nicholas Staples
b409e4459d Duplicate service name check added and all tests passing. 2016-03-10 10:34:46 +00:00
Rebecca Law
49198b26e7 Merge branch 'master' into reset-password
Conflicts:
	app/schemas.py
	tests/app/celery/test_tasks.py
2016-03-09 09:36:57 +00:00
NIcholas Staples
528f570ab6 Merge pull request #141 from alphagov/capture-aggregate-data
Capture aggregate data
2016-03-08 17:54:39 +00:00
Rebecca Law
114cfa6b17 Use the validation error message from the InvalidEmailError 2016-03-08 17:46:00 +00:00
Martyn Inglis
67c4bd2263 Build rest endpoint to read service stats
- get stats by service id
- returns a list of stats objects

Not paginated - have 1 row per day.
2016-03-08 16:34:03 +00:00
Rebecca Law
29a7289d1e Use new email validation.
Use logger.exception where it makes sense, not for SqlAlchemy errors as it give too much information away.
2016-03-08 15:47:35 +00:00
Rebecca Law
cbc585a1b1 Merge branch 'master' into reset-password 2016-03-08 15:40:20 +00:00
Rebecca Law
ba337374fd - Remove password_changed_at from the update_dict in users_dao
- Format dates in UserSchema
- Properly formatted subject and message body for the password reset email
- Add name to the message for reset password
2016-03-08 14:33:06 +00:00
Chris Hill-Scott
8323757441 Accept phone numbers in any valid format
This uses the `format_phone_number` method from utils to output phone numbers
in a consistent format. It is added to the schemas, so will be applied before
the API tries to do anything with a provided phone number.

So now the API will accept any of the following:
- 07123456789
- 07123 456789
- 07123-456-789
- 00447123456789
- 00 44 7123456789
- +447123456789
- +44 7123 456 789
- +44 (0)7123 456 789

…but the API will always hand off phone numbers to 3rd party APIs in the format
- +447123456789

The test for this is slightly convoluted, because template IDs are still
database IDs, and can’t consistently be mocked, therefore we have to ignore that
part of the call to `encrypt()`.
2016-03-08 09:47:21 +00:00
Chris Hill-Scott
157b385327 Use validation of recipients from utils
This was added to utils in 5914da74f1

This means that:
- we are doing the exact same validation in the API and admin app
- we are actually validating phone numbers for the correct format (hence all the
  changes to the tests)
2016-03-08 09:47:21 +00:00
Rebecca Law
10296f0cc2 Send email address in the data rather than the user_id as a path param.
Remove unused OldRequestVerifyCodeSchema.
2016-03-07 15:21:05 +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
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
Nicholas Staples
918d40cc9d Functionality added and all tests working. 2016-03-01 14:21:28 +00:00
Adam Shimali
59aec1939c [WIP] invited user now has comma separated permission values
stored against it so that user can be created with correct
permissions.
2016-02-29 14:05:02 +00:00
Nicholas Staples
75b9f77f92 user permissions now returned with the user object and all tests passing. 2016-02-26 15:57:24 +00:00
Nicholas Staples
16e1ecb134 Working permissions and all tests passing.
Remove print statements.

Fix for review comments.
2016-02-26 15:00:29 +00:00
Martyn Inglis
a3a9d673a6 Merge branch 'master' into celery-jobs 2016-02-25 12:06:53 +00:00
Martyn Inglis
0b63477e49 Removed now unused notification for job endpoints
- this is now handled in the tasks
2016-02-25 11:35:32 +00:00
Adam Shimali
e6fe10cbdc [WIP] added endpoint and dao to create invites for users.
Droped token as later code to send email invite can generate
timebased url to send to user. That can then be checked
against configurable time threshold for expiry. Therefore
no need to store a token.
2016-02-24 14:18:56 +00:00
Martyn Inglis
b0609b1813 More refactors
- single base method to send notifications
- knows about service id (present if job based)
- knows about jobs - if needed
- knows about type

Does the right thing

Was lots of shared code around error checking now in one place.
2016-02-24 09:55:05 +00:00
Martyn Inglis
635debb5a6 Moved the sending sms for a job into celery tasks 2016-02-23 17:30:50 +00:00
Martyn Inglis
b01782bbe6 Send Email via the API
- uses the new subject/email from fields present on the templates / service tables
- brings the send email api call into line with the sms one.
- same fields (to/template_id)
- same rules regarding restricted services
- wired in as a task into celery

Requires
- new celery queue
- new env property (NOTIFY_EMAIL_DOMAIN)
2016-02-22 17:17:29 +00:00
Rebecca Law
17d14f291e Refactor user/<user_id>/code into two endpoints.
- Created new endpoint user/<user_id>/sms-code to send the sms verification code to the user.
- Create new endpoirtn user/<user_id>/email-code to send the email verifcation code to the user.
- Marked the old methods, schema, tests with a TODO to be deleted when the admin app is no longer sending messages to /user/<user_id>/code
- Added error handlers for DataError and NoResultFound. Data error catches invalid input errors.
- Added error handler for SqlAlchemyError which catches any other database errors.
- Removed the need for the try catches around the db calls in the user endpoints with the addition of the db error handlers.
- We may want to wrap db excpetions in the dao, if we want the No results found message to be more specific and say no result found for user.
2016-02-19 11:37:35 +00:00
Martyn Inglis
cb265896a7 Merge branch 'master' into move-sms-notifications-into-celery
Conflicts:
	app/__init__.py
	tests/conftest.py
2016-02-17 09:14:37 +00:00
Martyn Inglis
e42da7dd54 Fixing up tests to validate the call to the celery tasks.
- mocker used to test call or otherwise of the task
- no new tests just a spring clean
2016-02-16 14:06:56 +00:00
Martyn Inglis
655beddba6 Fixed up the get_notitication endpoint
- returns a notification
2016-02-16 11:22:44 +00:00
Rebecca Law
fcaed04918 Fix validation of template for service.
When the delivery app creates the sms on behalf of the service,
the validation was failing.
2016-02-15 15:02:19 +00:00
Nicholas Staples
1eb18e7f07 Code review fix. 2016-02-12 14:08:48 +00:00
Nicholas Staples
918c561726 Code added to now check service id matches the authorization token service for sending an sms. 2016-02-12 11:13:54 +00:00
Adam Shimali
17e5e70f6c [WIP] Added endpoints under /job for creating, updating and reading
notification status.
2016-02-09 14:17:42 +00:00
Adam Shimali
0580f5ab06 New endpoint for delivery app to use.
Once removal of code that uses existing alpha is done, then
duplicated code from /notifications/sms and the new endpoint
can be merged.

Job id is now avaiable in notificaiton but is not used yet.
2016-02-08 14:54:15 +00:00
Nicholas Staples
6286646d7f Fix for review comments. 2016-02-03 15:53:16 +00:00
Nicholas Staples
aba1cd2ed5 Sqs queues now populated from all create_notification api calls. Marshmallow schemas added for notification. 2016-02-03 13:16:19 +00:00
Rebecca Law
b5c662eca8 Change services.id to a UUID
Ideally all the primary keys in the db would be UUID in order to guarantee unique ids across distributed dbs.
This updates the services.id to a UUID. All the tables with a foreign key to the services.id are also updated.
The endpoints no longer state a data type of the <service_id> path param.
All the tests are updated to reflect this update.

The thing to pay attention to is the 0011_uuid_service_id.py migration script.
This commit must go with a commit on the notifications_admin app to keep things working.
There will be a small outage until both deploys have happened.
2016-02-02 14:22:22 +00:00
Rebecca Law
0b62005983 Move VERIFY_CODE_TYPES outside the class and use it in the schema 2016-02-01 10:54:32 +00:00
Rebecca Law
cec0d40e5b Create schema for RequestVerifyCodeSchema
Previously we were using a schema that mapped onto db.Model. However, the json
in the request did not reflect the VerfiyCode db Model.
I did not add validation on the to field, we did not have that previously.
2016-02-01 10:48:33 +00:00
Nicholas Staples
2451f7e53d Added support for validation only of put requests. 2016-01-29 11:11:00 +00:00
Adam Shimali
9bf11b3d40 Merge pull request #39 from alphagov/add_password_update
Added support for allowing password to updated from the PUT request t…
2016-01-28 11:54:26 +00:00
Nicholas Staples
66c1d858ac Added support for allowing password to updated from the PUT request to the user rest endpoint. 2016-01-28 11:41:21 +00:00
Rebecca Law
42a4c8b0b1 Add sms notifications from a service to a queue. 2016-01-27 17:42:05 +00:00
Nicholas Staples
6b035cd324 All tests working, second time around. 2016-01-21 17:29:24 +00:00
Rebecca Law
9eb856b86e Get api_keys for service endpoint 2016-01-20 15:24:13 +00:00
Rebecca Law
15b2d414cc Updates from review comments:
Update api_key relationship.
Check that id in dict exists before deleting it
2016-01-19 13:11:22 +00:00
Rebecca Law
4fc5c34320 Change Tokens to ApiKey
Added name to ApiKey model
2016-01-19 12:13:47 +00:00
Adam Shimali
f839bae1f5 Add rest of user model fields to api.
First step to moving user interactions to api.
2016-01-19 11:39:59 +00:00
Adam Shimali
834801d19b Added endpoints for creating job, and getting job/jobs. 2016-01-15 15:48:05 +00:00