Leo Hemsted
4bfcfcd2fb
clean up test imports
2016-09-21 15:45:26 +01:00
Leo Hemsted
29abd4c382
make dao_get_jobs_by_service_id paginated
...
it can return a pretty long list, especially when we run lots of
smoke tests, so make it accept pagination parameters, and return
a pagination object
2016-09-21 14:35:23 +01:00
Leo Hemsted
94b280af63
ensure conftest sets up datetimes within function bodies
...
this makes sure it respects any freezegun.freeze_times that might
be in place
2016-09-21 14:34:38 +01:00
minglis
ffdf3272fb
Merge pull request #679 from alphagov/remove-test-keys-from-admin-app
...
Remove test keys from admin app
2016-09-19 12:31:12 +01:00
minglis
1d28f09c22
Merge pull request #677 from alphagov/no-jobs-on-api-get
...
No jobs on api get
2016-09-19 12:31:04 +01:00
Martyn Inglis
7c16294b75
Exclude test key notifications from:
...
- get all notifications by service
- template usage
- most recently used templates
Ensures that the dashboard shows no test key data. Supplements: https://github.com/alphagov/notifications-api/pull/677 which excludes CSV data. This branches from that so is dependant.
2016-09-16 13:47:09 +01:00
Chris Hill-Scott
d44a0b72bb
Rewrite authentication error messages more English
2016-09-16 08:57:55 +01:00
Chris Hill-Scott
1ce91997e8
Give specifc error when service doesn’t exist
...
If you sign a token with a service ID that doesn’t exist (say, for
example, that you get service ID and API key mixed up) then you get
an error saying that “no API keys exist for the service”. This is wrong
because the service doesn’t even exist.
This commit adds:
- code to check if the service does exist
- a specific error message for this case
The check does mean an extra database call to look up the service.
However this only happens _after_ looping through all the API keys. So
it shouldn’t have a performance implication for anyone using a valid API
key.
2016-09-16 08:49:49 +01:00
Chris Hill-Scott
6b3c899127
Add a test for auth-ing with non-existant service
...
If you create a token signed with a service ID that doesn’t exist, you
will get an error (as you should).
However we didn’t have a test that explicitly checks for this. This
commit adds one.
2016-09-16 08:46:32 +01:00
Martyn Inglis
d4971cc45f
Ensure GET /notifications returns JOB or API data correctly, using new boolean query param "include_jobs"
2016-09-15 16:01:26 +01:00
Martyn Inglis
fe5d53bd70
Ensure GET /notifications/ by service ID returns CSV and API data - used by ADMIN console.
...
- this is existing functionality mimicked.
2016-09-15 16:00:46 +01:00
Martyn Inglis
23062233b6
Setup code for various key types and separated notifications made by CSV and by API into separate fixtures.
2016-09-15 16:00:04 +01:00
Martyn Inglis
803820d9aa
New field on GET /notifications to allow users to request CSV data
2016-09-15 15:59:34 +01:00
Martyn Inglis
9f02e94f38
Ensure that querying for notifications does not return CSV data unless:
...
- It's explicitly asked for AND
- you are using a LIVE key
Team and Test keys CANNOT retrieve CSV/Job derived notifications
2016-09-15 15:59:02 +01:00
imdadahad
b07bbbbe16
Merge pull request #673 from alphagov/provide-simulated-numbers-live-keys
...
Add capability for simulated numbers and email addresses
2016-09-14 15:23:12 +01:00
minglis
c67c819f0a
Merge pull request #671 from alphagov/statsd-time-taken-to-be-delivered
...
Statsd time taken to be delivered
2016-09-14 14:53:01 +01:00
Imdad Ahad
98ef340bc6
Refactor to use .count() method instead of mocking fake UUID
2016-09-14 13:07:57 +01:00
Imdad Ahad
af8cfbe78c
Add checks to ensure simulated notifications are not persisted to database
2016-09-14 11:12:57 +01:00
Imdad Ahad
d4b0f68a69
Refactor to re-use existing contract-dependent method
2016-09-14 10:25:09 +01:00
Imdad Ahad
9df24b39ce
Add capability for simulated numbers and email addresses
2016-09-13 17:00:28 +01:00
Rebecca Law
cb51c69503
Update the timeout_notifications scheduled tasks.
...
We found that if the notifications were in created or pending they are not purged from notifications.
- New bulk update method to set all notificaitons with:
- a status = created|sending|pending to temporary-failure
- and is older then today minus SENDING_NOTIFICATIONS_TIMEOUT_PERIOD (in seconds)
- the scheduled task to timeout notifications use the new bulk update query.
- the task will be more efficient
2016-09-13 16:42:53 +01:00
Martyn Inglis
1a4b303c43
Only record the elapsed time at provider for notifications with a sent_at date,
...
could be that have a problem with state, misaligned tasks, we should just not record as edge case and this is aggregate.
2016-09-13 13:57:06 +01:00
Martyn Inglis
517cec173b
Logs time between sent_at and the provider callback into statsd
2016-09-13 13:04:44 +01:00
Martyn Inglis
8541f6adcd
Change DAO to return the notification from an update, not Boolean
...
- tests reflect this
2016-09-13 12:29:40 +01:00
minglis
d2b936e631
Merge pull request #667 from alphagov/delete-csv-file-after-7-days
...
Delete csv file after 7 days
2016-09-13 09:03:48 +01:00
Rebecca Law
f1b9702dfb
Fix codestyle
2016-09-12 16:41:48 +01:00
Martyn Inglis
e0d46d821d
Merge branch 'master' into delete-csv-file-after-7-days
...
Conflicts:
app/notifications/rest.py
2016-09-12 16:33:01 +01:00
Rebecca Law
bab9360519
Fix a bug in the accept invitation that was throwing a 500.
...
- If the token for invitation was expired, the method would throw a 500 while creating the erorr message.
- Added unit tests.
2016-09-12 16:16:02 +01:00
Martyn Inglis
a6bfc48478
Merge branch 'master' into write-to-postgres-not-sqs
2016-09-08 16:00:31 +01:00
Martyn Inglis
dde22bc58b
Implemented deleted notification if SQS write fails
2016-09-08 16:00:18 +01:00
minglis
c50a0200d4
Merge pull request #664 from alphagov/rationalise-config
...
Simplified the config. Aim is to get the actual secrets in credstash …
2016-09-08 10:27:31 +01:00
Martyn Inglis
b4d40dcd18
Merge branch 'master' into write-to-postgres-not-sqs
...
Conflicts:
app/notifications/rest.py
tests/app/notifications/rest/test_send_notification.py
2016-09-08 09:15:07 +01:00
Martyn Inglis
852e207478
Adds new scheduled task to delete CSV files.
...
Deletes files for jobs older than 7 days, matching delete process for the actual notifications
Runs 1 minutes past the hour at midnight, 1 and 2 am.
2016-09-07 15:36:59 +01:00
Martyn Inglis
c3657839e4
New jobs dao method to get jobs that are older than a certain number of days.
...
Used in deleting CSV files scheduled task
2016-09-07 15:36:07 +01:00
Martyn Inglis
0ecd6f2737
Removed the 'delete job' tasks from the tasks.py file
...
- this was called after processing a job.
- now to be called on a schedule.
2016-09-07 15:35:12 +01:00
imdadahad
6cbd5396ea
Merge pull request #662 from alphagov/remove-send-notification-tests
...
Remove rate limiting tests
2016-09-07 15:18:44 +01:00
Martyn Inglis
cf107d649f
Merge branch 'master' into write-to-postgres-not-sqs
...
Conflicts:
app/celery/tasks.py
2016-09-07 13:51:21 +01:00
Martyn Inglis
770b0c2838
Update rest end point to wrote to the DB not the queue.
...
We wrote to the queue as a performance optimisation , however dev found it confusing to not have immediate access to the notification as it may be perished some minutes later under periods of load. Additionally we had a couple of DB issues which led to us dropping notifications.
Pushing the DB write to earlier in the flow makes the system a little more robust in the early days, we may want to change this when the traffic increases.
2016-09-07 13:47:22 +01:00
Martyn Inglis
99250b2248
Adds a builder method to the notification object.
...
This is used to construct a notification from the sorts of data an API call provides. This is used in both the db-email / db-sms tasks and the notifications rest endpoint to construct the notification DB object.
2016-09-07 13:44:56 +01:00
Imdad Ahad
41681ac001
Fix mocker syntax issue
2016-09-07 11:17:27 +01:00
Imdad Ahad
840b99b277
Fix issue where test key cannot send messages to external numbers
2016-09-07 09:57:20 +01:00
Martyn Inglis
c1b00a5f0c
Simplified the config. Aim is to get the actual secrets in credstash to be env specific, and not the random collection of things we have at the moment.
...
Secret definition also includes env specific things such as URLs / Queue prefixes / URLs for providers and so on.
2016-09-07 09:35:31 +01:00
Martyn Inglis
259fb0cb62
Slightly changed to only unlimited the live services.
...
Logic:
- live services don't check days limit for now
- restricted services check limits
(caveat) simulate keys aren't checking day limit even in restricted mode.
2016-09-06 14:21:36 +01:00
Rebecca Law
727c00af21
Merge pull request #659 from alphagov/update-requirements
...
Update requirements
2016-09-06 14:16:31 +01:00
Chris Hill-Scott
be9fd96d03
Merge pull request #656 from alphagov/add-cancel-job-endpoint
...
Add an endpoint to cancel a job
2016-09-06 12:11:32 +01:00
Imdad Ahad
d6a8780515
Remove send notification test
2016-09-06 11:39:22 +01:00
Rebecca Law
4d1c34fcce
A little bit of clean up.
...
- Remove the deploy to staging | live links in the README
- Update most of the outdated requirements. Left Flask update out for now.
2016-09-05 16:45:54 +01:00
minglis
64bb12c866
Merge pull request #640 from alphagov/scheduled-delivery-of-jobs-cleanup
...
Scheduled delivery of jobs cleanup
2016-09-05 12:29:10 +01:00
Leo Hemsted
6ceb80d32f
Merge pull request #651 from alphagov/contract-tests
...
Contract tests
2016-09-05 11:31:29 +01:00
Chris Hill-Scott
e28ce50d17
Don’t pass notify_db or notify_db_session to test
...
They get set up by the `sample_scheduled_job` fixture.
2016-09-03 08:48:03 +01:00