[Breaking] Webhooks: disallow deprecated WEBHOOK_AUTHORIZATION setting

Drop support for the WEBHOOK_AUTHORIZATION setting deprecated in v1.4.
Only the WEBHOOK_SECRET replacement is allowed now.

Most Django management commands will now issue a system check error
if the old name is still used in settings.py
This commit is contained in:
medmunds
2018-03-01 14:11:15 -08:00
parent deea8c5d5b
commit 9478bf5958
5 changed files with 18 additions and 24 deletions

View File

@@ -11,17 +11,17 @@ class DeprecatedSettingsTests(SimpleTestCase, AnymailTestMixin):
@override_settings(ANYMAIL={"WEBHOOK_AUTHORIZATION": "abcde:12345"})
def test_webhook_authorization(self):
errors = check_deprecated_settings(None)
self.assertEqual(errors, [checks.Warning(
self.assertEqual(errors, [checks.Error(
"The ANYMAIL setting 'WEBHOOK_AUTHORIZATION' has been renamed 'WEBHOOK_SECRET' to improve security.",
hint="You must update your settings.py. The old name will stop working in a near-future release.",
id="anymail.W001",
hint="You must update your settings.py.",
id="anymail.E001",
)])
@override_settings(ANYMAIL_WEBHOOK_AUTHORIZATION="abcde:12345", ANYMAIL={})
def test_anymail_webhook_authorization(self):
errors = check_deprecated_settings(None)
self.assertEqual(errors, [checks.Warning(
self.assertEqual(errors, [checks.Error(
"The ANYMAIL_WEBHOOK_AUTHORIZATION setting has been renamed ANYMAIL_WEBHOOK_SECRET to improve security.",
hint="You must update your settings.py. The old name will stop working in a near-future release.",
id="anymail.W001",
hint="You must update your settings.py.",
id="anymail.E001",
)])

View File

@@ -125,9 +125,3 @@ class WebhookBasicAuthTestsMixin(object):
self.set_basic_auth('baduser', 'wrongpassword')
response = self.call_webhook()
self.assertEqual(response.status_code, 400)
@override_settings(ANYMAIL={'WEBHOOK_AUTHORIZATION': "username:password"})
def test_deprecated_setting(self):
"""The older WEBHOOK_AUTHORIZATION setting is still supported (for now)"""
response = self.call_webhook()
self.assertEqual(response.status_code, 200)