Commit Graph

518 Commits

Author SHA1 Message Date
minglis
ff97d0b064 Merge pull request #143 from alphagov/rate-limit
Rate limit
2016-03-09 15:08:49 +00:00
Martyn Inglis
593d753ed5 Updated tests 2016-03-09 14:52:07 +00:00
Martyn Inglis
45b19a49a4 Updated tests 2016-03-09 14:49:14 +00:00
Martyn Inglis
2a13fe4a54 Merge branch 'master' into rate-limit
Conflicts:
	app/celery/tasks.py
	tests/app/celery/test_tasks.py
2016-03-09 14:16:59 +00:00
Martyn Inglis
4a880af8ef Drop all services sending limits to 50. 2016-03-09 14:03:44 +00:00
Martyn Inglis
b0074449bd Adds another job state to account for when sending limits have been exceeded. 2016-03-09 13:57:53 +00:00
Martyn Inglis
61af70a392 Some more tests around edge cases 2016-03-09 11:35:12 +00:00
Martyn Inglis
14d621d243 Job processing respects sendlimits
- If a job starts it MUST be able to fit into the days sending limits
- So if service limit is 10, and we've sent 5 messages and the current job is 4 then it's OK.
- If the job is 6 then it's over the limit and it should fail
- Job should NOT start if can't complete in the limit
2016-03-09 11:28:52 +00:00
Chris Hill-Scott
03f5f01a51 Merge pull request #142 from alphagov/allow-csvs-with-extra-personalisation
Accept CSV files with additional columns
2016-03-09 11:13:18 +00:00
Martyn Inglis
61a0cf32c8 Ensure clients have rate limit enforced
- rate limiting is a hard number per day
- not limited in terms of rate of request
- limit is a single number held against the service
- every notification counts against the limit, regardless of type
- return a 429 if limit exceeded.
2016-03-09 11:06:37 +00:00
Rebecca Law
63fa6ddbbb Merge pull request #139 from alphagov/reset-password
Reset password
2016-03-09 10:42:38 +00:00
Rebecca Law
d0c5977b9d Fix extra space in test 2016-03-09 09:57:14 +00:00
Chris Hill-Scott
589b4de5f9 Accept CSV files with additional columns
Currently when the Celery task processes a CSV it will call the API with the
values for all the non-recipient columns in the `personalisation` field. This
means that those API calls would fail, even though the CSV has been processed
‘successfully’.

This was not being caught by the tests, so this commit adds extra tests to check
what data the task is passing to the API call.

It then updates utils to version 2.0.1 which brings in this fix:
https://github.com/alphagov/notifications-utils/pull/10
2016-03-09 09:52:39 +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
e07d16e8c6 Fixed up dates so that we respect mills 2016-03-08 17:45:37 +00:00
Chris Hill-Scott
6308a5b2ca Merge pull request #140 from alphagov/remove_delivery_config
Removed DELIVERY_CLIENT_USER_NAME and DELIVERY_CLIENT_SECRET
2016-03-08 17:10:44 +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
fde4b646f6 Merge pull request #134 from alphagov/use-updated-csv-util
Use utils to validate and iterate over recipients
2016-03-08 15:39:37 +00:00
Rebecca Law
5d7b1bc786 Removed DELIVERY_CLIENT_USER_NAME and DELIVERY_CLIENT_SECRET from configs and auth module 2016-03-08 15:27:12 +00:00
Martyn Inglis
f5f50e00ff New notification stats table
- to capture the counts of things that we do
- initial commit captures when we create an email or sms

DOES NOT know about ultimate success only that we asked our partners to ship the notification

Requires some updates when we retry sending in event of error.
2016-03-08 15:23:19 +00:00
Rebecca Law
6e17a015e8 Add missing import 2016-03-08 15:20:34 +00:00
Rebecca Law
d840b8d689 Merge branch 'master' into reset-password 2016-03-08 15:05:18 +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
Chris Hill-Scott
7cb8450839 Use RecipientCSV from utils for processing CSVs
See https://github.com/alphagov/notifications-utils/pull/9 for details of the
changes.
2016-03-08 09:43:48 +00:00
NIcholas Staples
e99331315e Merge pull request #138 from alphagov/fix-not-null-notifications-sent
Add script to set notifications sent count on jobs table.
2016-03-08 09:17:05 +00:00
Martyn Inglis
8d8abb524d Add script to set notifications sent count on jobs table. 2016-03-08 09:12:33 +00:00
NIcholas Staples
f931e3fca6 Merge pull request #133 from alphagov/aggregate-data
Aggregate data
2016-03-08 08:55:04 +00:00
NIcholas Staples
bcca510a2d Merge pull request #137 from alphagov/fix-logged-in-at
Capture logged in at when password is verified
2016-03-08 08:49:44 +00:00
Rebecca Law
5c4ac9d938 Include token creation date in the url token. 2016-03-07 18:20:20 +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
Martyn Inglis
4f8c2d31a5 Capture logged in at when password is verified 2016-03-07 15:01:40 +00:00
Rebecca Law
b15d3434c3 Added an endpoint and celery task to email a reset password url. 2016-03-07 14:34:53 +00:00
minglis
7665ec7213 Merge pull request #135 from alphagov/strip-html-from-templates
Strip HTML from template content
2016-03-07 12:40:29 +00:00
Chris Hill-Scott
b3f4e40421 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 a Mozilla’s Bleach library[1]. It is
configured to get the text content of the template, minus any HTML tags. It is
not using a regex because[2].

1. https://github.com/mozilla/bleach
2. http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
2016-03-04 22:07:10 +00:00
Martyn Inglis
ae395b490e Fixed bug where I forgot to update only the right job :-( 2016-03-04 15:54:43 +00:00
Rebecca Law
fa87f9c7b3 Merge pull request #129 from alphagov/add-user-with-permissions
[WIP] Changed add user to service to take list
2016-03-04 15:52:58 +00:00
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
065e81697b Merge pull request #132 from alphagov/revert-130-strip-html-from-templates
Revert "Strip HTML from template content"
2016-03-04 13:41:10 +00:00
Chris Hill-Scott
f7a1cfac50 Revert "Strip HTML from template content" 2016-03-04 13:23:44 +00:00
Rebecca Law
9f6f1f791a Merge pull request #131 from alphagov/revert-strip-html
Reverting the use of lxml until we can fix the ubuntu dependencies
2016-03-04 12:56:35 +00:00
Rebecca Law
49a51a8d87 Reverting the use of lxml until we can fix the ubuntu dependencies 2016-03-04 12:40:02 +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