SES - SendEmail: source attr can contain chevrons (#4338)
This commit is contained in:
parent
d87a2eab49
commit
579b6e264f
@ -31,7 +31,7 @@ ERROR_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
|
|||||||
<Errors>
|
<Errors>
|
||||||
<Error>
|
<Error>
|
||||||
<Code>{{error_type}}</Code>
|
<Code>{{error_type}}</Code>
|
||||||
<Message>{{message}}</Message>
|
<Message><![CDATA[{{message}}]]></Message>
|
||||||
{% block extra %}{% endblock %}
|
{% block extra %}{% endblock %}
|
||||||
</Error>
|
</Error>
|
||||||
</Errors>
|
</Errors>
|
||||||
|
@ -114,6 +114,32 @@ def test_send_email_when_verify_source():
|
|||||||
sent_count.should.equal(2)
|
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
|
@mock_ses
|
||||||
def test_send_templated_email():
|
def test_send_templated_email():
|
||||||
conn = boto3.client("ses", region_name="us-east-1")
|
conn = boto3.client("ses", region_name="us-east-1")
|
||||||
|
Loading…
Reference in New Issue
Block a user