mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Mailgun: better errors for misconfigured webhooks
Detect cases where inbound or tracking webhook url has been configured in wrong Mailgun webhook. See #129.
This commit is contained in:
@@ -8,6 +8,7 @@ from django.test import override_settings
|
||||
from django.utils.timezone import utc
|
||||
from mock import ANY
|
||||
|
||||
from anymail.exceptions import AnymailConfigurationError
|
||||
from anymail.signals import AnymailTrackingEvent
|
||||
from anymail.webhooks.mailgun import MailgunTrackingWebhookView
|
||||
|
||||
@@ -698,3 +699,16 @@ class MailgunLegacyTestCase(WebhookTestCase):
|
||||
kwargs = self.assert_handler_called_once_with(self.tracking_handler)
|
||||
event = kwargs['event']
|
||||
self.assertEqual(event.tags, ["tag1", "tag2"])
|
||||
|
||||
def test_misconfigured_inbound(self):
|
||||
raw_event = mailgun_sign_legacy_payload({
|
||||
'recipient': 'test@inbound.example.com',
|
||||
'sender': 'envelope-from@example.org',
|
||||
'message-headers': '[]',
|
||||
'body-plain': 'Test body plain',
|
||||
'body-html': '<div>Test body html</div>',
|
||||
})
|
||||
|
||||
errmsg = "You seem to have set Mailgun's *inbound* route to Anymail's Mailgun *tracking* webhook URL."
|
||||
with self.assertRaisesMessage(AnymailConfigurationError, errmsg):
|
||||
self.client.post('/anymail/mailgun/tracking/', data=raw_event)
|
||||
|
||||
Reference in New Issue
Block a user