SES - SendEmail: source attr can contain chevrons (#4338)

This commit is contained in:
Bert Blommers 2021-09-23 18:56:22 +00:00 committed by GitHub
parent d87a2eab49
commit 579b6e264f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -31,7 +31,7 @@ ERROR_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
<Errors>
<Error>
<Code>{{error_type}}</Code>
<Message>{{message}}</Message>
<Message><![CDATA[{{message}}]]></Message>
{% block extra %}{% endblock %}
</Error>
</Errors>

View File

@ -114,6 +114,32 @@ def test_send_email_when_verify_source():
sent_count.should.equal(2)
@mock_ses
def test_send_unverified_email_with_chevrons():
conn = boto3.client("ses", region_name="us-east-1")
# Sending an email to an unverified source should fail
with pytest.raises(ClientError) as ex:
conn.send_email(
Source=f"John Smith <foobar@example.com>", # << Unverified source address
Destination={
"ToAddresses": ["blah@example.com"],
"CcAddresses": [],
"BccAddresses": [],
},
Message={
"Subject": {"Data": "Hello!"},
"Body": {"Html": {"Data": "<html>Hi</html>"}},
},
)
err = ex.value.response["Error"]
err["Code"].should.equal("MessageRejected")
# The source should be returned exactly as provided - without XML encoding issues
err["Message"].should.equal(
"Email address not verified John Smith <foobar@example.com>"
)
@mock_ses
def test_send_templated_email():
conn = boto3.client("ses", region_name="us-east-1")