Commit Graph

32 Commits

Author SHA1 Message Date
Rebecca Law
08dcc920a2 Updated notifications-util to the latest version.
There has been an update to the email validation code.
Added an extra test for email validation.
2018-07-02 13:48:40 +01:00
Katie Smith
43c63a1644 Add new virus scan statuses
Added the following new notification statuses:
* pending_virus_check
* virus_scan_failed

If we decide to remove these statuses in future, we will need to replace
them with a different status in the notifications and
Notification_history tables where they are referenced, so
pending-virus-check will be replaced with sending, and virus-scan-failed
will be replaced with permanent-failure.
2018-03-13 12:03:14 +00:00
Rebecca Law
52bf6dabcd The regex to validate uuids was not rejecting uuids with a space at the end.
Switched to using a isinstance check on the string.
Added an order by clause to dao_get_template_usage_stats_by_service, it was causing an itermitten failure in the tests.
2018-02-15 13:34:06 +00:00
Rebecca Law
d779751bae Set reply_to_text for letter notifications posted to /notifications/letter 2017-11-24 16:17:25 +00:00
Ken Tsang
df98f0dec1 Update schema to allow include_jobs on get_notis 2017-11-16 14:44:28 +00:00
Ken Tsang
8bdc999818 Update notification schema to include received letter status 2017-10-25 10:48:35 +01:00
Leo Hemsted
4174c72f21 allow 'accepted' as a proxy for created + sending as well as 'failed' for the three failure types when querying the api 2017-09-20 15:30:14 +01:00
Rebecca Law
0a21f1f3e8 Small refactor to how notification_schemas are tested.
My local build was not always getting the optional requirement for the jsonschema uri format checker (rfc3987).
The requirement has been added to the requirements_for_test file.
I changed the tests to validate the response schema from the post_notifications tests, this way we can tell if we are breaking the contract.
This showed that the email_from was not returning the entire email address but just the username, that has been corrected here.
Removed the response schema validation tests since they are not being testing in the post notification tests.
2017-09-11 11:10:45 +01:00
Leo Hemsted
11f8603319 Remove custom error message from personalisation validation
There's no longer a single err msg that fits all problems with
personalisation - since letters expect specific fields there
2017-07-27 16:49:37 +01:00
Rebecca Law
9f6c037530 Use iso8601 to validate scheduled_for datetime.
Added a validation method that always fails for scheduled notifications.
Comment out config for scheduled task.
The schedule notifications will be turned on once we can invite services to use it.
Waiting for the service permission story, must commit this in order to keep things from going stale.
2017-05-24 16:27:15 +01:00
Rebecca Law
a57dc18895 Add validation for scheduled_for where the date can not be in the past or more than 24 hours in the future. 2017-05-22 14:39:30 +01:00
Rebecca Law
751abb4b99 Update dateformat for scheduled_for to include minutes. 2017-05-22 14:15:35 +01:00
Rebecca Law
973cc2c4c9 Changed the scheduled_for datetime to only send and hour of a day to send.
Also expect the date being passed in is BST. The date is converted to UTC before saving. And converted to BST when returning a notification.
2017-05-17 15:06:15 +01:00
Rebecca Law
38e5b31e9a Update notification schemas with optional schedule_for element 2017-05-15 15:02:38 +01:00
Leo Hemsted
5ec4829d00 fix v2 schema phone/email validation when non-str passed in
jsonschema states:

> A format attribute can generally only validate a given set of
> instance types. If the type of the instance to validate is not in
> this set, validation for this format attribute and instance SHOULD
> succeed.

We were not checking for the type of the input, and our validators were
behaving in unexpected manners (throwing TypeErrors etc etc). Despite
us declaring that the phone_number field is of type `str`, we still
need to make sure the validator passes gracefully, so that the inbuilt
type check can be the bit that catches if someone passes in a non-str
value. We've seen this with people passing in integers instead of strs
for phone numbers. This'll make them receive a nice 400 error
(e.g. "phone_number 12345 is not of type string"), rather than us
having a 500 internal server error
2017-05-10 11:04:12 +01:00
Leo Hemsted
02e8f454e1 add new notification status 'sent'
for international text messages, when we may not ever receive callback info,
so we need a separate status that doesn't get timed out etc
2017-04-25 17:08:29 +01:00
Leo Hemsted
501187a9f4 bump utils to 13.0.1
brings in a fix to InvalidEmail/Phone/AddressExceptions not being
instantiated correctly. `exception.message` is not a python standard,
so we shouldn't be relying on it to transmit exception reasons -
rather we should be using `str(exception)` instead. This involved a
handful of small changes to the schema validation
2017-01-09 16:37:58 +00:00
Rebecca Law
7f9111fd90 Removed the oneOf validation in the get_notification_response schema. 2017-01-04 11:00:47 +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
Paul Craig
2ca675eb73 Test invalid statuses and template_types
Run through a few scenarios in the `test_schema_notifications.py`
test file, calling `.validate()` on some data instead of actually
calling the route.
2016-11-28 15:10:13 +00:00
Paul Craig
9758b96a2b Create 'v2' get notification route
The new 'v2' API wants to return less data than the previous one,
which was sending back tons of fields the clients never used.

This new route returns only useful information, with the JSON
response dict being built up in the model's `.serialize()` method.

Note that writing the test for this was a bit painful because of
having to treat loads of keys differently. Hopefully we think this
is a good way to write this test, because if we don't, we should
start thinking of a better way to check the values are what we
expect.
2016-11-21 15:41:49 +00:00
Paul Craig
fddb1653ac Add .cost() to notification model
In the V2 API, the GET response for an individual notification
returns a 'cost' value, which we can get by multiplying the
billable units by the per-message rate of the supplier who
sent the message.
Any notifications with billable units > 0 but without a
corresponding `ProviderRates` entry will blow up the application,
so make sure you've got one.
2016-11-18 17:50:39 +00:00
Rebecca Law
f5e3c6f63b Remove print stmt and added assert error content 2016-11-17 14:02:44 +00:00
Rebecca Law
df62be421f Make email_from and subject required attributes of the email_content schema.
Update the format_checkers to raise the specific exception that why the validator can handle multiple messages.
Which led to a refactor of build_error_message.
2016-11-16 17:25:00 +00:00
Rebecca Law
b0ee09a9f6 Implemented the post email notifications endpoint for v2 2016-11-14 13:56:09 +00:00
Rebecca Law
c758694b98 Change validation error message to a string from a dict. 2016-11-10 16:30:51 +00:00
Rebecca Law
346d90e319 update V2 error response to
{status_code: 403,
 errors: [error: AuthError, message: token has expired}]
}
2016-11-09 14:56:54 +00:00
Rebecca Law
4cb38e2d12 Use status_code in error response.
Remove code.
2016-11-02 14:58:39 +00:00
Rebecca Law
db91a87fb2 Remove link from v2 error response 2016-11-02 14:48:15 +00:00
Rebecca Law
36ac00811d Create dict for the fields in the error response. 2016-11-02 09:13:48 +00:00
Rebecca Law
482d10545b Improvements to the tests.
Update AuthError with a to_dict_v2 method.
2016-11-01 10:33:34 +00:00
Rebecca Law
a5e07d8aff V2 schemas for post sms notifications, post_sms_request and post_sms_response 2016-10-25 14:53:31 +01:00