-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #361: AttributeError in mailgun webhooks
This fixes the case of delivery-status being None in the event data posted to mailgun webhook handler. See: #361
- Loading branch information
Showing
2 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -630,6 +630,63 @@ def test_clicked_event(self): | |
self.assertEqual(event.event_type, "clicked") | ||
self.assertEqual(event.click_url, "https://example.com/test") | ||
|
||
def test_no_delivery_status(self): | ||
raw_event = mailgun_sign_payload( | ||
{ | ||
"signature": { | ||
"timestamp": "1534108637", | ||
"token": "651869375b9df3c98fc15c4889b102119add1235c38fc92824", | ||
"signature": "...", | ||
}, | ||
"event-data": { | ||
"tags": [], | ||
"timestamp": 1534108637.153125, | ||
"storage": { | ||
"url": "https://sw.api.mailgun.net/v3/domains/" | ||
"example.org/messages/eyJwI...", | ||
"key": "eyJwI...", | ||
}, | ||
"recipient-domain": "example.com", | ||
"id": "hTWCTD81RtiDN-...", | ||
"campaigns": [], | ||
"user-variables": {}, | ||
"flags": { | ||
"is-routed": False, | ||
"is-authenticated": True, | ||
"is-system-test": False, | ||
"is-test-mode": False, | ||
}, | ||
"log-level": "info", | ||
"envelope": { | ||
"sending-ip": "333.123.123.200", | ||
"sender": "[email protected]", | ||
"transport": "smtp", | ||
"targets": "[email protected]", | ||
}, | ||
"message": { | ||
"headers": { | ||
"to": "[email protected]", | ||
"message-id": "20180812211713.1.DF5966851B4BAA99" | ||
"@example.org", | ||
"from": "[email protected]", | ||
"subject": "Testing", | ||
}, | ||
"attachments": [], | ||
"size": 809, | ||
}, | ||
"recipient": "[email protected]", | ||
"event": "accepted", | ||
"delivery-status": None, | ||
}, | ||
} | ||
) | ||
response = self.client.post( | ||
"/anymail/mailgun/tracking/", | ||
data=json.dumps(raw_event), | ||
content_type="application/json", | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
|
||
|
||
@tag("mailgun") | ||
@override_settings(ANYMAIL_MAILGUN_WEBHOOK_SIGNING_KEY=TEST_WEBHOOK_SIGNING_KEY) | ||
|