Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix amazon_ses inbound email ESP provider #3509

Merged
merged 17 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions engine/apps/email/tests/test_inbound_email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import pytest, anymail, json
from django.urls import reverse
from rest_framework.test import APIClient
from rest_framework import status

@pytest.mark.django_db
def test_amazon_ses_provider_load(
settings,
make_organization_and_user_with_token,
make_alert_receive_channel
):
settings.INBOUND_EMAIL_ESP = "amazon_ses"
settings.INBOUND_EMAIL_DOMAIN = "example.com"

dummy_channel_token = "dummy-channel-token"

mime = """From: sender@example.com
Subject: Dummy email message
To: %s@example.com
Content-Type: text/plain

Hello!
""" % dummy_channel_token

message = {
"notificationType" : "Received",
"receipt": {
"action": {"type": "SNS"},
"recipients": ["%s@example.com" % dummy_channel_token]
},
"content": "%s" % mime
}

dummy_sns_message_id = "22b80b92-fdea-4c2c-8f9d-bdfb0c7bf324"
dummy_sns_payload = {
"Type" : "Notification",
"MessageId" : f"{dummy_sns_message_id}",
"TopicArn" : "arn:aws:sns:us-east-1:123456789012:MyTopic",
"Subject" : "My First Message",
"Message" : "%s" % json.dumps(message)
}

organization, user, token = make_organization_and_user_with_token()
integration = make_alert_receive_channel(organization, token=f"{dummy_channel_token}")

client = APIClient()
url = reverse("integrations:inbound_email_webhook")
response = client.post(url, data=json.dumps(dummy_sns_payload),
content_type="application/json",
HTTP_AUTHORIZATION=f"{token}",
HTTP_X_AMZ_SNS_MESSAGE_TYPE="Notification",
HTTP_X_AMZ_SNS_MESSAGE_ID=f"{dummy_sns_message_id}")
assert response.status_code == status.HTTP_200_OK
1 change: 1 addition & 0 deletions engine/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ opentelemetry-exporter-otlp-proto-grpc==1.15.0
django-dbconn-retry==0.1.7
django-ipware==4.0.2
django-anymail==8.6
django-amazon-ses==4.0.1
django-deprecate-fields==0.1.1
pymdown-extensions==10.0
requests==2.31.0
Expand Down
Loading