Commit Graph

1691 Commits

Author SHA1 Message Date
Rebecca Law
e32978b72a Merge branch 'master' into post-sms-v2 2016-11-02 09:08:26 +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
a358f3cb3a Error handler for schema validation errors 2016-10-31 15:43:11 +00:00
Chris Hill-Scott
5485252b85 Merge pull request #720 from alphagov/utils-bump-email-newline
Bump utils
2016-10-31 16:05:37 +01:00
Leo Hemsted
11cebb295c Merge pull request #718 from alphagov/letters-flag
add can_send_letters flag to services
2016-10-31 14:46:25 +00:00
Rebecca Law
fc298367c5 Updated test_validators to test the contents of the error messages.
Added some tests to the test_post_notifications.
Added a errorhandler for AuthErrors.

This endpoint is not being used anywhere, however there is some common code being used in the v1 post endpoint. The only thing that may be affected is the error response, hopefully they are the same.
2016-10-31 12:22:26 +00:00
Chris Hill-Scott
9192ff137f Bump utils
Includes:
- [ ] https://github.com/alphagov/notifications-utils/pull/75
2016-10-31 09:21:18 +00:00
imdadahad
250a14092c Merge pull request #719 from alphagov/use-wheels-to-speed-as-deployment
Move wheel dependency installation to docker build
2016-10-28 17:54:39 +01:00
Imdad Ahad
ebe2ec4341 Install pip wheel in the dockerfile 2016-10-28 17:48:31 +01:00
Imdad Ahad
c8be8db742 Use venv for installation 2016-10-28 17:43:27 +01:00
Imdad Ahad
497f56bc81 Move wheel dependency installation to docker build 2016-10-28 17:27:37 +01:00
imdadahad
62303571ce Merge pull request #717 from alphagov/use-wheels-to-speed-as-deployment
Use python wheels to speed up AS deployment
2016-10-28 17:15:23 +01:00
Rebecca Law
8cf2fc72a8 - Refactor version 1 of post notificaitons to use the common persist_notificaiton and send_notification_to_queue methods.
- It would be nice to refactor the send_sms and send_email tasks to use these common functions as well, that way I can get rid of the new Notifications.from_v2_api_request method.
- Still not happy with the format of the errors. Would like to find a happy place, where the message is descript enough that we do not need external documentation to explain the error. Perhaps we still only need documentation to explain the trial mode concept.
2016-10-28 17:10:00 +01:00
Rebecca Law
6e4bad135a - Implemented persist_notification and send_notification_to_queue in the process_notifications module
- Not sure I want to create a new classmethod on Notifications to create from v2 request. Will take another look at that.
2016-10-27 17:34:54 +01:00
Rebecca Law
c2eecdae36 - Add validation methods for post notification.
- Use these validation methods in post_sms_notification and the version 1 of post_notification.
- Create a v2 error handlers.
- InvalidRequest has a to_dict method for private and v1 error responses and a to_dict_v2 method to create the v2 of the error responses.
- Each validation method has extensive unit tests, so the unit test for the endpoint do not need to check every error case, but check that the error handle formats the message correctly.
- The format of the error messages is still a work on progress.
- This version of the api could be deployed without causing a problem to the application.
- The new endpoing is still a work in progress and is not being used yet.
2016-10-27 11:46:37 +01:00
Leo Hemsted
a45c62d41d add can_send_letters flag to services
defaults to false
2016-10-26 13:01:40 +01:00
Rebecca Law
23a4f00e56 New package structure for the version 2 of the public api.
Start building up the validators required for post notificaiton.
The app/v2/errors.py is a rough sketch, will be passed a code, the error can look up the message and link for the error message.
2016-10-25 18:04:03 +01: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
Imdad Ahad
72993311b3 Install wheel when building artifact 2016-10-24 16:23:18 +01:00
Imdad Ahad
177515de8f Use python wheels to speed up AS deployment:
* Create wheels from python dependencies on building codedeploy artifact
* Update script to install wheels and default to pypi if not found
2016-10-21 16:16:10 +01:00
Leo Hemsted
e5bedbd789 Merge pull request #716 from alphagov/error-handling
Error handling
2016-10-19 10:24:18 +01:00
Andras Ferencz-Szabo
5d840bfab0 Merge pull request #715 from alphagov/use_patched_boto
Bump up boto version to 2.42.0-patch2
2016-10-18 09:58:20 +01:00
bandesz
a675509b5e Bump up boto version to 2.42.0-patch2 2016-10-17 18:10:16 +01:00
Leo Hemsted
a1cc092d3b fix logger.exception syntax
when given any log function with multiple parameters, the python logging utils
assume the first param is a format string and the rest are arguments to pass
in - we were passing in the exception object to `logger.exception`, however,
the purpose of .exception is to add the exception object itself - so we didn't
need to
2016-10-17 17:44:17 +01:00
Leo Hemsted
65197a6c91 handle Exception and remove duplication in errors.py
ensure that if unexpected Exceptions are thrown, we handle them correctly
(log and then return JSON)

also remove some branches that will never trip, and combine a couple of
identical functions
2016-10-17 17:41:39 +01:00
Andras Ferencz-Szabo
7ff373723d Merge pull request #714 from alphagov/use_patched_boto
Use custom patched boto: 2.42.0-patch1
2016-10-17 16:55:10 +01:00
bandesz
cffedb1a05 Use custom patched boto: 2.42.0-patch1 2016-10-17 16:42:41 +01:00
Leo Hemsted
6e015b5a7a Merge pull request #713 from alphagov/email-exception
Don't retry invalid emails
2016-10-17 11:26:50 +01:00
Chris Hill-Scott
2a65bf3bb5 Merge pull request #711 from alphagov/extend-scheduling-to-96-hours
Let jobs be scheduled up to 96 hours in the future
2016-10-14 15:33:44 +01:00
Leo Hemsted
c69d2aa778 add tests for ses client 2016-10-13 16:07:32 +01:00
Leo Hemsted
a2c3d265de remove unused former send_sms_to_provider and send_sms_to_email functions
they were superceded by deliver_sms and deliver_email in the same file 3 wks ago
2016-10-13 15:53:01 +01:00
Leo Hemsted
a095aa41f3 don't retry task if InvalidEmailError
just record it as a technical error - retrying wont fix a bad email
2016-10-13 15:27:47 +01:00
Leo Hemsted
c0c62e02b7 move statsd call out of generic tryexcept
we shouldn't try and use statsd to log an error if they fail, for example

[we also shouldn't retry sending the message but that's a problem for another time]
2016-10-13 14:17:17 +01:00
Rebecca Law
d9ced9f912 Merge pull request #712 from alphagov/change-email-confirmation
Change email confirmation
2016-10-13 14:01:23 +01:00
Rebecca Law
9ffdf66c49 Rename the endpoints.
Increase test coverage to include the encrypted message sent to the task.
2016-10-13 11:59:47 +01:00
Chris Hill-Scott
9f36b363f2 Let jobs be scheduled up to 96 hours in the future
If you want to send a job on Monday morning, you should be able to
schedule it on Friday. You shouldn’t need to work on the weekend.

96 hours is a full 4 days, so you can schedule a job at any time on
Friday for any time on Monday.

We’ve checked with the information assurance people, and they’re OK with
us holding the data for this extra amount of time.
2016-10-12 13:38:12 +01:00
Rebecca Law
b37eef974c Change email confirmation
- New endpoint to send a user an email to verify the email address when they want to change it.
2016-10-12 13:06:39 +01:00
Chris Hill-Scott
2f12ad987d Merge pull request #710 from alphagov/email-regex
bump notification-utils to 9.0.5
2016-10-12 11:24:00 +01:00
Leo Hemsted
8aaa444489 bump notification-utils to 9.0.5
includes improved email validation regex
2016-10-11 17:04:42 +01:00
Leo Hemsted
9ade3ee767 Merge pull request #709 from alphagov/test-message-filtering
Test message filtering
2016-10-11 15:55:57 +01:00
Leo Hemsted
487554c025 use partial to make tests more legible 2016-10-11 14:40:23 +01:00
Leo Hemsted
d8467bfc3c filter out test jobs from the GET /service/{}/job endpoint
this is so that the filtering, which we do on the admin side, is applied
before pagination - so that the pages returned are all valid displayable
jobs. unfortunately this means that another config value has to be copied
to the server side but it's not the end of the world
2016-10-11 14:30:40 +01:00
Rebecca Law
153e9c3f3a Merge pull request #708 from alphagov/change-email-template
Confirm new email address template.
2016-10-11 13:44:37 +01:00
Rebecca Law
c17f0b9b91 Confirm new email address template.
Creation of a new template for the GOV.UK Notify service to send to users to confirm the change of their email address.
2016-10-11 13:28:46 +01:00
Chris Hill-Scott
2bdbc4d788 Merge pull request #707 from alphagov/loosen-get-notification-key-restriction
Loosen key restriction on get notification
2016-10-11 10:40:02 +01:00
Chris Hill-Scott
717e73a9f7 Loosen key restriction on get notification
Currently getting a single notification by ID is restricted to
notifications created with the same key type.

This makes things awkward for the functional tests now we’ve removed the
ability to create live keys in trial mode. So this commit removes the
restriction, so that any key can get any notification, no matter how it
was created.

And you’re never going to guess a UUID, so the chances of this giving
you privileged access to someone’s personal information is none.

This does not change the get all notifications endpoint, which
absolutely should be restricted by key type.
2016-10-10 17:29:38 +01:00
Chris Hill-Scott
88362cb075 Merge pull request #706 from alphagov/sort-jobs-by-processed-time-first
Sort jobs by processed time first
2016-10-10 14:03:27 +01:00
Chris Hill-Scott
ac1f5fcc91 Fix impossible test notification
No way a notification can be processed before it’s created.
2016-10-10 13:12:50 +01:00
Chris Hill-Scott
a2ea0db393 Make test easier to read
Explicity labelling what the numbers mean makes it easier to understand
what’s going on rather than having to refer back to the function call.
2016-10-10 13:12:40 +01:00
Chris Hill-Scott
df0504ddda Refactor job order test
- uses 4 rather than 8 entries to test the sort (2 notifications × 2
  columns on which we’re sorting)
- makes sure we test for when a scheduled job was created before a job
  that’s been processed already
- removes any relative datetimes so the tests are independant of
  database speed
2016-10-10 12:45:48 +01:00