Commit Graph

155 Commits

Author SHA1 Message Date
Leo Hemsted
f371c393a2 rename renew_api_key to create_api_key 2016-06-23 16:44:57 +01:00
Rebecca Law
acee87fc63 Refactor the api_key_dao.
The only update we should be doing to an api key is to expire/revoke the api key.
Removed the update_dict from the the save method.
Added an expire_api_key method that only updates the api key with an expiry date.
2016-06-22 15:27:28 +01:00
Adam Shimali
b33312b855 Change endpoint responses where there are marshalling, unmarshalling
or param errors to raise invalid data exception. That will cause
those responses to be handled in by errors.py, which will log
the errors.

Set most of schemas to strict mode so that marshmallow will raise
exception rather than checking for errors in return tuple from load.

Added handler to errors.py for marshmallow validation errors.
2016-06-15 14:37:51 +01:00
Adam Shimali
e28ef237e4 When adding a user new with permissions to a service, the permissions
dao was deleting all permissions for that user (regardless of service
id) as the last filter on the permissions dao get_query method won.

I've added a replace flag to the set_user_service_permission method
so that it can handle adding new users + permissions and editing
of existing users' permissions.

Also by pass the get_query method until it can be refactored to work
correctly.

For now execute the filter query directly on the model.
2016-06-07 16:35:26 +01:00
Adam Shimali
63c29a3a3d API recieves full set of permissions names on create of user
invite. This is instead of mapping from permission groups to individual
permissions on user creation.
2016-06-06 12:37:06 +01:00
Adam Shimali
682ea55d9e [WIP] save reply to email address on service 2016-05-17 10:56:02 +01:00
Nicholas Staples
bedc20d0ff Fragment count endpoint added and all tests working. 2016-04-28 12:01:57 +01:00
Adam Shimali
078756919d Add events to temporary history view for story sign off. 2016-04-27 17:30:15 +01:00
Nicholas Staples
b56e324a4c Working tests and provider stats table.
Fix for tests and import error.

Added tests and updated for code review comments.
2016-04-25 12:20:06 +01:00
Adam Shimali
7378352c26 This is a temporary endpoint to get history of service and api key
updates. This will be surfaced on a simple log page on admin app
until product team work out who/how/when etc. of viewing history
data.
2016-04-21 16:32:20 +01:00
Adam Shimali
74ac5b5f30 Added version history to api keys. This needed a bit of change
to create history to handle foreign keys better. There may yet
be a better way of doing this that I have not found yet in sqlalchemy
docs.
2016-04-21 14:47:58 +01:00
Adam Shimali
a6a18c1a6f This approach uses part of sqlalchemy example history_meta code
adapted to recording inserts and updates.

This removes need to manually create history tables.

Our code still remains in control of when history records are
created.
2016-04-19 17:13:26 +01:00
Nicholas Staples
c4b316bde6 Rebased migrations, all tests working. 2016-04-08 13:34:54 +01:00
Rebecca Law
8df4919029 The admin app now sends the email from when creating a service and when updating the service name.
This PR removes the need for the email_safe function. The api does not create the email_from field for the service.
Tests were updated to reflect this change.
2016-03-31 17:46:18 +01:00
Rebecca Law
376a074f5f Add view_activity permission so that users can have the default permission to see activity.
Add view_activity to default permissions when adding a new user.
Add view_activity as a permission group, used when inviting a user.
2016-03-29 15:35:34 +01:00
Nicholas Staples
3a59c75257 Transaction management added for one example. All tests passing. 2016-03-23 16:30:47 +00:00
Nicholas Staples
090babaaeb Added endpoint for removing user from service, all tests passing. 2016-03-22 13:14:23 +00:00
Rebecca Law
123b0ead3a Replaced first queries with one queries, which throws a NoResultFound.
Able to remove many of the None checks as a result of this.
Fixed the tests were needed.
2016-03-11 15:34:20 +00:00
Rebecca Law
e055590b07 Changed db queries to use one, which throws NoResultFound exception, this exception is dealt with in our error handlers.
Now a lot of the if none checks can be removed.
2016-03-11 12:39:55 +00:00
Nicholas Staples
b409e4459d Duplicate service name check added and all tests passing. 2016-03-10 10:34:46 +00:00
Martyn Inglis
4a880af8ef Drop all services sending limits to 50. 2016-03-09 14:03:44 +00:00
Adam Shimali
f945253596 [WIP] Changed add user to service to take list of permissions instead
of invite.
2016-03-03 17:36:21 +00:00
Adam Shimali
fc8e27e582 [WIP] When user is added to a service a list of permissions groups are
used to assign the correct permissions to the user.

Last slice will be to update invite status.
2016-03-03 16:38:12 +00:00
Adam Shimali
ac9adc292b [WIP] Change status code to 404 rather than 400. 2016-03-01 15:51:22 +00:00
Adam Shimali
993bdc8055 [WIP] use correct dao function for adding user to service.
Check for no user returned from user dao and return correct
error message.
2016-03-01 15:36:31 +00:00
Adam Shimali
3b66745677 [WIP] Start of api for accepting invite. 2016-03-01 14:13:38 +00:00
Rebecca Law
df278a8e6e Email invitation to an invited user.
New celery task to send the email.
2016-02-29 13:21:12 +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
Rebecca Law
67af351f26 Fix get_users_by_service to return 404 if service does not exist.
Refactored service/rest.py so that all methods are returning a properly formatted error message so that the error message can deal with the response.
Refactoed errors.py to properly format the error message.
2016-02-25 12:11:51 +00:00
Rebecca Law
f1fdfbb308 Return empty list when there are no users for the service.
Added a test for when there are no users for the service.
Added a test_url_for - do we want to add this test and use url_for in our tests?
Or explictly write the url in the test?
2016-02-24 10:30:00 +00:00
Rebecca Law
12a2d8db0a New endpoint to get users for service id.
/service/<service_id>/users returns a list of all users associated with the service
2016-02-23 17:53:54 +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
Martyn Inglis
9bb95a53ec Updates to template endpoints:
- moved into templates rest class
- updated dao
- removed delete methods
- constraint on subject line
2016-02-22 12:55:18 +00:00
Martyn Inglis
98314485d3 Generate the email_from from the service name. 2016-02-19 17:07:59 +00:00
Martyn Inglis
1a136885c3 Update service rest class to handle new fields and updated dao 2016-02-19 15:53:45 +00:00
Adam Shimali
4f33b6f406 Wire up error handlers.
Replace some 400s with more appropriate 500s.

DAO methods that cause unexpected exceptions get caught and
logged by errors.py 500 error handler.
2016-02-17 17:04:50 +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
Nicholas Staples
2451f7e53d Added support for validation only of put requests. 2016-01-29 11:11:00 +00:00
Rebecca Law
5a937d6e71 Added user_id as a query param for get_services.
Need to add this query param for the services page on the admin app.
Do not add the query param to path in the token.
2016-01-22 12:47:59 +00:00
Nicholas Staples
e657958af4 Templates fix with tests working. 2016-01-22 10:44:34 +00:00
Rebecca Law
0027b62224 Updated get_api_keys endpoint to return one or many given key_id or not. 2016-01-21 12:13:17 +00:00
Rebecca Law
98c73e5bff Correction to url name 2016-01-20 16:34:30 +00:00
Rebecca Law
3e141e05cb Added tests for get api endpoint 2016-01-20 15:41:19 +00:00
Rebecca Law
9eb856b86e Get api_keys for service endpoint 2016-01-20 15:24:13 +00:00
Rebecca Law
2689d908c1 Update api-key/revoke endpoint to expire the key for the service.
Previously we assumed there was only one api key that was valid.
2016-01-20 14:48:44 +00:00
NIcholas Staples
4a3fae7580 Merge pull request #23 from alphagov/allow-multiple-api-keys
Allow multiple api keys
2016-01-20 14:13:29 +00:00
Nicholas Staples
4739f3fbd2 Added send_email endpoint. 2016-01-20 13:14:23 +00:00
Rebecca Law
27a381c3e9 Allow services to have multiple api keys.
/service/<service_id>/api-key/renew has been renamed to /service/<service_id>/api-key
/service/<service_id>/api-key now creates a token and no longer expires the existing api key.
Moved test for this endpoint to it's own file.
2016-01-20 10:57:46 +00:00
Rebecca Law
1db57dca8c Allow for multiple api keys for a service. 2016-01-19 18:25:21 +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