Commit Graph

1133 Commits

Author SHA1 Message Date
Rebecca Law
ed4b9d34a6 Changes as per code review comments.
Fix my backward date math :P
2017-02-15 17:41:07 +00:00
Rebecca Law
52342afe3f Add a limit to the number of active 2fa codes that we create. At the moment that is set to 10. 2017-02-15 16:18:05 +00:00
Rebecca Law
9de88c50ba Remove test for resetting the failed_login_count, the admin app will request that. 2017-02-15 15:24:42 +00:00
Rebecca Law
c4bf7a1331 Merge branch 'master' into stronger-2fa-security 2017-02-15 14:20:32 +00:00
Rebecca Law
07fc71cc4c Fix codestyle 2017-02-15 11:59:31 +00:00
Rebecca Law
74e29708f9 Fix bug where the increment calls set count to 1 if the cache does not exist. 2017-02-15 11:49:19 +00:00
Rebecca Law
53b7ad0961 Moved the cache key to the utils module.
Renamed the dao method.
2017-02-14 14:22:52 +00:00
Rebecca Law
5f48367ee5 Set the expiry time on a verify code (2fa) to 10 minutes.
When the verify code is wrong or expired increment the failed to login count for the user.
When the verify code is successfully used reset the failed login count to 0.
2017-02-14 14:04:11 +00:00
Rebecca Law
458adefcb8 Added a redis cache for the template usage stats.
Cache expires every 10 minutes, but will help with the every 2 second query, especially when a job is running.
There is some clean up and qa to do for this yet
2017-02-13 18:47:29 +00:00
imdadahad
7417662fc1 Merge pull request #819 from alphagov/fix-auto-provider-switch-update-history
Fix: Update history when auto switching provider
2017-02-09 10:50:01 +00:00
Imdad Ahad
41a689f4be Update test to assert that the provider history table has been updated 2017-02-08 17:14:46 +00:00
Imdad Ahad
42bb2f14da Add test to check version is updated after switch 2017-02-08 14:15:45 +00:00
Chris Hill-Scott
8cefe6a71b Merge pull request #820 from alphagov/fix-monthly-miscount
Fix miscount with monthly totals
2017-02-08 13:05:43 +00:00
imdadahad
cdc693fae5 Merge pull request #818 from alphagov/feat-add-update-user-password-endpoint
Add separate endpoint to update a user's password
2017-02-08 09:44:29 +00:00
Rebecca Law
08e39d4b93 Merge pull request #816 from alphagov/refactor-send_to_providers
Small refactor to reuse code.
2017-02-07 17:27:51 +00:00
Chris Hill-Scott
0dfa4a93d5 Make sure status dictionary is assinged each time
The status dictionary was being assigned once, and then subsequent
uses of it were by reference. This meant that each template type was
pointing at the same dictionary, and updating one meant updating all.

This commit adds a dictionary comprehension, which gets evaluated once
for each template type, so each template type has its own `dict` of
statuses.

Before
--
```
Email     SMS       Letter
  |        |           |
{'sending':, 'failed', …}
```

After
--
```
Email                SMS                   Letter
   |                  |                      |
{'sending':,      {'sending':,            {'sending':,
'failed',          'failed',               'failed',
…}                 …}                      …}
```
2017-02-07 13:14:58 +00:00
Chris Hill-Scott
4805ccdeed Check email and letter count in monthly stats test
Before we were only checking counts for SMS, because we’d only created
SMS notifications.

This commit also checks the counts for email and letter, which should be
0. But they’re not. So this commit is adding the test case which
demonstrates the bug.
2017-02-07 13:13:06 +00:00
Chris Hill-Scott
dd2e754730 Refactor test into loop
This makes it less repetitive, and will let us add more assertions for
each month that we’re checking.
2017-02-07 13:12:23 +00:00
Imdad Ahad
c512b31afd Update provider history when auto switching provider 2017-02-07 12:38:56 +00:00
Imdad Ahad
a764ba8451 Rename update password test 2017-02-07 11:32:03 +00:00
Imdad Ahad
69b1007c33 Add schema and separate endpoint to update a user password 2017-02-07 11:27:13 +00:00
Imdad Ahad
ac48e4c944 Add separate method to update user password 2017-02-07 11:05:15 +00:00
Rebecca Law
c36d61c071 Update as per comments on review 2017-02-06 16:20:44 +00:00
imdadahad
be24bfe147 Merge pull request #815 from alphagov/fix-perf-platform-stats-job
Fix perf platform stats job
2017-02-03 14:01:25 +00:00
Imdad Ahad
e75b618c6e Use datetime in other test for consistency 2017-02-03 13:35:50 +00:00
Imdad Ahad
99cc2f5897 Format date correctly for upload + refactor tests 2017-02-03 13:32:19 +00:00
Rebecca Law
30ca9e7e78 Merge pull request #811 from alphagov/check-service-is-active
Check service is active
2017-02-02 11:59:28 +00:00
Rebecca Law
f56824adde Cancel job if the service is inactive.
Update the PermissionsDao.get_permissions_by_user_id to only return permissions for active services,
this will make the admin app return a 403 if someone (otherthan platform admin) tries to look at an inactive service.
Removed the active flag in sample_service the dao_create_service overiddes this attribute.
2017-02-02 11:34:00 +00:00
Leo Hemsted
855a412c90 Merge pull request #812 from alphagov/plat-adm-dates
make sure we convert strings to dates before we use them
2017-01-31 16:24:30 +00:00
Leo Hemsted
cd47dbd36b make sure we convert strings to dates before we use them
fixes 500 on platform admin page
2017-01-31 16:12:46 +00:00
Rebecca Law
dab89969cc If the service is inactive at the time of sending the notification to the provider, the notification is marked as technical-failure.
Removed the /service/<id>/deactivate endpoint, now using /service/<id>/archive
2017-01-31 14:28:25 +00:00
Chris Hill-Scott
8381a5e11c Ensure that monthly service usage groups by BST 2017-01-31 14:16:35 +00:00
Chris Hill-Scott
56ba653f48 Add endpoint for breakdown of activity by month
This endpoint will eventualy replace the weekly breakdown one. By month
for a given financial year is better, because it gives us consistency
with the breakdown of financial usage (and eventually consistency with
the template usage).

The code to do this is a bit convoluted, in order to fill out the counts
for months and statuses where we don’t have notifications.

This will make the admin side of this easier, because we can rely on
there always being numbers available. The admin side will deal with
summing the statuses (eg `temporary-failure` > `failed`) because this
is presentational.

This commit also modifies the usage count to use `.between()` for
consistency.
2017-01-31 14:16:34 +00:00
Rebecca Law
fde3216f9e Check the service is active before sending the notification to the provider. 2017-01-31 13:53:13 +00:00
Leo Hemsted
3113f49271 Merge pull request #810 from alphagov/letter-fix
fix api statistics to account for letters
2017-01-31 12:29:35 +00:00
Leo Hemsted
0d089a383e fix tests in service/test_rest.py 2017-01-31 12:06:25 +00:00
Rebecca Law
ef0f708da0 Merge branch 'master' into check-service-is-active 2017-01-31 12:00:30 +00:00
Rebecca Law
e2e5cb6866 Merge pull request #808 from alphagov/disable-service
Suspend/resume service feature
2017-01-31 11:56:22 +00:00
Rebecca Law
539ebdce70 This is what I meant to test 2017-01-31 11:45:35 +00:00
Rebecca Law
907a1e91ac Removed the need for 2 return statements.
Update tests to fix copy/paste errors, use freezetime to ensure there is never a random failing test.
2017-01-31 11:33:36 +00:00
Leo Hemsted
3cd8605e11 fix api statistics to account for letters 2017-01-31 11:32:53 +00:00
Rebecca Law
fe64b565a0 Create job now checks that the service is active before creating job.
Need to check what message and status code we should use for this case. Probably will create a InactiveServiceRequest exception.
2017-01-31 11:11:33 +00:00
Imdad Ahad
53b6cdcfab Only send stats from celery task if active + refactor tests 2017-01-30 18:24:18 +00:00
Imdad Ahad
c811f1b6c6 Init the perf platform client, add logs and refactor payload methods 2017-01-30 18:24:06 +00:00
Rebecca Law
87556687ab This is the first PR in the story to create a suspend service feature.
- Renaming /service/<id>/deactivate to /service/<id>/archive to match language on the UI.
  - Will need to update admin before deleting the deactive service method
- Created dao and endpoint methods to suspend and resume a service.
- I confirm the use of suspend and resume with a couple people on the team, seems to be the right choice.

The idea is that if you archive a service there is no coming back from that.
To suspend a service is marking it as inactive and revoking the api keys. To resume a service is to mark the service as active, the service will need to create new API keys.
It makes sense that if a service is under threat that the API keys should be renewed.

The next PR will update the code to check that the service is active before sending the request or allowing any actions by the service.
2017-01-30 16:32:44 +00:00
Leo Hemsted
1650fb0807 Merge pull request #797 from alphagov/persist-letters
Persist letters
2017-01-30 14:24:38 +00:00
Rebecca Law
c6eb284218 Small change to include the reference that ses send us on the callback. 2017-01-30 14:09:30 +00:00
Rebecca Law
1d734d3b28 Merge pull request #805 from alphagov/fix-duplicate-test
Fix duplicate test name
2017-01-30 09:40:41 +00:00
imdadahad
eec7564475 Merge pull request #804 from alphagov/feat-add-perf-platform-client-and-job
Add client and job to update the performance platform daily
2017-01-27 17:03:38 +00:00
Imdad Ahad
cc7bf45766 Move notification retrieval logic into perf platform client and dont filter by status 2017-01-27 16:39:01 +00:00