Commit Graph

1716 Commits

Author SHA1 Message Date
Leo Hemsted
9ae6e14140 move deactivate functionality into one database transactions
this means that any errors will cause the entire thing to roll back

unfortunately, to do this we have to circumvent our regular code, which calls commit a lot, and lazily loads a lot of things, which will flush, and cause the version decorators to fail. so we have to write a lot of stuff by hand and re-select the service (even though it's already been queried) just to populate the api_keys and templates relationship on it
2016-11-11 11:20:41 +00:00
Leo Hemsted
17cf582502 Merge branch 'master' into active-service 2016-11-10 13:54:02 +00:00
Leo Hemsted
abecb5ff98 Merge pull request #726 from alphagov/auth-500
update python client to 2.0.0
2016-11-10 13:47:34 +00:00
Leo Hemsted
dd004a6154 Merge pull request #727 from alphagov/exc-handl
remove 500/unplanned exception handlers in test
2016-11-10 13:47:13 +00:00
Leo Hemsted
e8c3a5cdde add check for inactive services to auth handler
cleaned up some auth code to marginally improve efficiency of error checking
and hopefully make it easier to read

fixed some incorrect auth headers in the deactivate tests
2016-11-10 11:07:12 +00:00
Leo Hemsted
b2149bf02a undo unnecessary change to models 2016-11-10 10:38:36 +00:00
Leo Hemsted
b0e240267a add only_active flag to get services functionality 2016-11-09 15:07:23 +00:00
Leo Hemsted
d4a300ec7a add only_active flag to GET /services/
does what it says on the tin
2016-11-09 11:45:39 +00:00
Leo Hemsted
3cbacecf19 fix non-functional/overengineered existing tests 2016-11-09 11:32:07 +00:00
Leo Hemsted
efd2be9acb set service to active on creation 2016-11-08 17:10:28 +00:00
Leo Hemsted
f6de17d6b7 dont let people accidentally delete their local database by forcing it to run against a different DB (ie test_notifications_api) 2016-11-08 17:10:28 +00:00
Leo Hemsted
089ac099f3 POST /service/{id}/deactivate deactivates a service:
* set active=False on the service
* renames service to "_archived_{old_name}"
* archives all templates for the service
* revokes all api keys for the service
2016-11-08 17:10:28 +00:00
Leo Hemsted
da2fa5b4bc move sqlalchemy defaults from booleans to SQL constructs
booleans aren't actually allowed, and quietly do nothing

also default Services.active to true
2016-11-08 17:10:28 +00:00
Chris Hill-Scott
bec20d3854 Merge pull request #728 from alphagov/case-insensitive-auth-header
Make bearer prefix on auth header case insensitive
2016-11-07 14:59:09 +01:00
imdadahad
273984a629 Merge pull request #729 from alphagov/logging-around-jobs-and-tasks
Added job id to logger
2016-11-07 12:00:48 +00:00
Martyn Inglis
15ba0a3eb1 Added job id to logger 2016-11-07 11:59:46 +00:00
Chris Hill-Scott
9248e72c50 Make bearer prefix on auth header case insensitive
From a support ticket:

> the "Bearer" prefix on the auth header is case sensitive. Can this be
> made case-insensitive?

Sure can 🙃
2016-11-07 10:49:05 +00:00
Leo Hemsted
f842a8c893 update test to pytest.raises instaed of assert response == 500 2016-11-04 17:04:51 +00:00
Leo Hemsted
ed187f7fad remove 500/unplanned exception handlers in test
this means if your code throws an exception, in the test you'll see the full stack trace to help debugging
2016-11-04 16:37:55 +00:00
Leo Hemsted
f089b75129 update python client to 2.0.0
this is to prevent 500 errors because <2.0.0 raised AssertionError
if supplied JWT tokens were incorrectly formatted

tests added
2016-11-03 17:05:25 +00:00
bandesz
edf22860e1 Bump boto version to 2.43.0-patch3 2016-11-02 17:59:09 +00:00
Rebecca Law
9f9ec28e2c Merge pull request #724 from alphagov/post-sms-v2
Move jsonschema to requirements.txt to missing dependency
2016-11-02 14:16:27 +00:00
Rebecca Law
83f3c92c24 Move jsonschema to requirements.txt to missing dependency 2016-11-02 14:02:06 +00:00
Rebecca Law
58a010ae77 Merge pull request #721 from alphagov/post-sms-v2
Post sms v2
2016-11-02 13:38:42 +00:00
Rebecca Law
36ac00811d Create dict for the fields in the error response. 2016-11-02 09:13:48 +00:00
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