Commit Graph

4019 Commits

Author SHA1 Message Date
Alexey Bezhan
3bcde5437b Add tests for aborting unauthenticated requests
Tests are disabled until aborts are switched on
2017-11-22 09:54:42 +00:00
Alexey Bezhan
5e53d781e0 Add FIRETEXT_INBOUND_SMS_AUTH config variable and auth check
Checks authentication header value on inbound SMS requests from
Firetext against a list of allowed API keys set in the application
config.

At the moment, we're only logging the attempts without aborting the
requests. Once this is rolled out to production and we've checked
the logs we'll switch on the aborts and add the tests for 401 and 403
responses.
2017-11-22 09:54:42 +00:00
Chris Hill-Scott
22ec134668 Merge pull request #1376 from alphagov/remove-computed-sms-prefix
Remove computed SMS prefix
2017-11-21 14:29:33 +00:00
Chris Hill-Scott
ac885dd4e6 Remove computed SMS prefix
This is no longer used no that the column in the table (`prefix_sms`) is
populated.
2017-11-21 14:12:35 +00:00
Richard Chapman
ef9f18a175 Merge pull request #1410 from alphagov/rc-monthly-template-usage-endpoint
Fixed bug in test which was passing but not testing the services_dao properly
2017-11-21 11:33:19 +00:00
Richard Chapman
fa75402a95 Merge pull request #1411 from alphagov/remove-unused-service-columns
Remove email_reply_to and letter_contact_block from Services
2017-11-21 11:33:03 +00:00
Rebecca Law
c80bdbaffe Remove email_reply_to and letter_contact_block from Services 2017-11-21 11:06:07 +00:00
Richard Chapman
f91c0a820f Fixed bug in test which was passing but not testing the services_dao
correctly

The dao_fetch_monthly_historical_usage_by_template_for_service code
wasn't being tested properly due to an bug on the test which created a
notification with the same template and hence was not testing that
a specific service would have a different template id.

- Fixed the bug in the test
- Update services_dao so that the service id check is made
2017-11-21 10:54:08 +00:00
Rebecca Law
adaadefed5 Merge pull request #1408 from alphagov/remove-unused-code
Remove unused code
2017-11-21 10:38:41 +00:00
Rebecca Law
e9db7a1561 Need to do the db migration in the next deploy 2017-11-21 10:22:38 +00:00
Sakis
680487eb20 Merge pull request #1405 from alphagov/bump_utils_2301
Bump utils to 23.0.1
2017-11-21 09:09:28 +00:00
Athanasios Voutsadakis
73dfc67400 Merge branch 'master' into bump_utils_2301 2017-11-20 17:40:45 +00:00
Rebecca Law
1bfc22bbb5 Fix merge conflict for db migration 2017-11-20 17:05:46 +00:00
Rebecca Law
785763a172 Merge branch 'master' into remove-unused-code 2017-11-20 16:56:52 +00:00
Alexey Bezhan
cb92ab7107 Merge pull request #1397 from alphagov/validate-template-history-fk-constraint
Validate notifcations.template_history foreign key constraints
2017-11-20 15:33:45 +00:00
Alexey Bezhan
0a50993fc2 Validate notifcations.template_history foreign key constraints
Removes "NOT VALID" mark from the notifications -> template_history
foreign key constraint by validating existing records.

From postgres docs:

> This form validates a foreign key or check constraint that was
> previously created as NOT VALID, by scanning the table to ensure there
> are no rows for which the constraint is not satisfied. Nothing happens
> if the constraint is already marked valid.

> Validation can be a long process on larger tables. The value of
> separating validation from initial creation is that you can defer
> validation to less busy times, or can be used to give additional time
> to correct pre-existing errors while preventing new errors. Note also
> that validation on its own does not prevent normal write commands
> against the table while it runs.

> Validation acquires only a SHARE UPDATE EXCLUSIVE lock on the table
> being altered. If the constraint is a foreign key then a ROW SHARE
> lock is also required on the table referenced by the constraint.
2017-11-20 15:23:27 +00:00
Rebecca Law
d5a1ec0fe3 Remove unused methods 2017-11-20 14:45:11 +00:00
Rebecca Law
c2648d5c9e Remove Services.reply_to_email_address and Services.letter_contact_block 2017-11-20 14:40:24 +00:00
Rebecca Law
33aab4e1b5 Merge branch 'master' into remove-unused-code 2017-11-20 14:34:52 +00:00
Rebecca Law
577463b0ac Remove create_or_update_email_reply_to and create_or_update_letter_contact - no longer needed.
Remove Services.reply_to_email_address and Services.letter_contact_block
2017-11-20 14:33:15 +00:00
Rebecca Law
f4ca658d04 Merge pull request #1407 from alphagov/remove-unused-objects
Remove notification_statistics and Service.sms_sender
2017-11-20 14:26:58 +00:00
Rebecca Law
93f19956b8 Remove notification_statistics and Service.sms_sender 2017-11-20 13:13:13 +00:00
Richard Chapman
f3f8225dfe Merge pull request #1406 from alphagov/rc-monthly-template-usage-endpoint
Template usage stats updates for FY usage and bug fix
2017-11-20 11:45:30 +00:00
Athanasios Voutsadakis
a0beb190f3 Merge branch 'master' into bump_utils_2301 2017-11-20 11:16:29 +00:00
Chris Hill-Scott
42bf329593 Merge pull request #1388 from alphagov/pyup-update-sqlalchemy-utils-0.32.19-to-0.32.21
Update sqlalchemy-utils to 0.32.21
2017-11-20 10:26:22 +00:00
Chris Hill-Scott
3f7aca5f78 Merge pull request #1372 from alphagov/sms-prefix-non-nullable
Make SMS prefix setting non-nullable
2017-11-20 10:15:07 +00:00
Richard Chapman
58b0658a13 Return financial year not calendar and ensure double precision values
are not returned from queries

- Updated stats_template_usage_by_month_dao.py to return the results for
financial year not calendar, as the report os for FY only and hence
only the FY data is required
- Updated services_dao.py to ensure double precision values are converted
to an int as the 'exact' function returns double precision from the
database query, as the admin code requires the value for month to be an
int
2017-11-20 10:01:45 +00:00
Venus Bailey
10f3bc24f0 Merge pull request #1404 from alphagov/vb-test-token
Inbound sms pre-implementation test 1
2017-11-20 09:30:50 +00:00
Athanasios Voutsadakis
b0546f4886 Remove unused variable 2017-11-17 16:22:36 +00:00
Chris Hill-Scott
32e19b6552 Bump utils to 23.0.0
Changes arguments to `SMSMessageTemplate` to better describe what they
do.
2017-11-17 16:20:48 +00:00
venusbb
d70fdbb5c2 no auth check 2017-11-17 15:57:41 +00:00
Athanasios Voutsadakis
69e42b7a74 Bump utils to 23.0.1 2017-11-17 15:00:26 +00:00
Leo Hemsted
354d68de88 Merge pull request #1403 from alphagov/fix-research-mode-email-callbacks
Fix research mode email callbacks
2017-11-17 14:48:37 +00:00
venusbb
12a99f9a7f Verify authorisation header being send 2017-11-17 14:36:28 +00:00
Leo Hemsted
04e3218087 ensure sample SES callbacks and SNS subscription payloads are accurate in research mode and unit tests 2017-11-17 14:34:16 +00:00
Leo Hemsted
d2154451e5 update research mode email callbacks to add process-ses-response task to queue
this involved:
* moving that task to callback_tasks to prevent circular imports
* updating the dummy research mode callbacks (with actual SNS messages from the
  ses simulator emails)
* refactoring tests
2017-11-17 13:41:45 +00:00
Leo Hemsted
0e477b7715 Merge pull request #1401 from alphagov/ses-logging
Ses logging
2017-11-17 10:42:17 +00:00
Sakis
9d2cecd001 Merge pull request #1391 from alphagov/add_proxy_header_check
Add proxy header check
2017-11-17 10:35:43 +00:00
Leo Hemsted
890604990d remove unneccessary ses endpoint tests 2017-11-17 10:31:34 +00:00
Leo Hemsted
5855adf826 removed unused HTTP ses callback handler 2017-11-16 17:53:19 +00:00
Leo Hemsted
1f317b6717 log the bounce message from SES 2017-11-16 17:46:58 +00:00
Leo Hemsted
ff449735e4 make sure fns aren't named the same 2017-11-16 17:46:41 +00:00
Athanasios Voutsadakis
26ba4dad06 Parametrize tests 2017-11-16 17:00:38 +00:00
kentsanggds
6d36a65b65 Merge pull request #1400 from alphagov/ken-allow-include_jobs-arg-get_all_notis
Allow include jobs request param on v2 get all notifications
2017-11-16 16:41:10 +00:00
Athanasios Voutsadakis
0886f6d9f9 Merge branch 'master' into add_proxy_header_check 2017-11-16 16:36:02 +00:00
Ken Tsang
64c0ae6492 Update test to show gets all notifications except job notis 2017-11-16 16:02:31 +00:00
Richard Chapman
2ee91cd629 Merge pull request #1399 from alphagov/rc-monthly-template-usage-endpoint
Added a template_type to the rest call and Aggregation Bug Fix
2017-11-16 15:55:55 +00:00
Rebecca Law
35f1704a9d Merge pull request #1395 from alphagov/catch-inbound-sms-push-exception
Retry unknown exceptions for send_inbound_sms_to_service task
2017-11-16 15:47:14 +00:00
Richard Chapman
b56825a680 Updated Tests to use a variety of templates
All of the tests defaulted to sms templates, updated a few to use a
variety of templates types so all types are tested.
2017-11-16 15:43:21 +00:00
Richard Chapman
fd89a252e0 Code Style Updates
Updated the to conform with the line ends expected by the code style in
tests rather than PyCharm.
2017-11-16 15:17:27 +00:00