Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion aws_lambda_powertools/utilities/parser/models/ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SesMailCommonHeaders(BaseModel):
cc: List[str] | None = None
bcc: List[str] | None = None
sender: List[str] | None = None
reply_to: List[str] | None = Field(None, alias="reply-to")
reply_to: List[str] | None = Field(None, alias="replyTo")
returnPath: str
messageId: str
date: str
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/parser/_pydantic/test_ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,25 @@ def test_ses_trigger_event():
assert action.type == raw_receipt["action"]["type"]
assert action.functionArn == raw_receipt["action"]["functionArn"]
assert action.invocationType == raw_receipt["action"]["invocationType"]


def test_ses_trigger_event_with_optional_common_headers():
# GIVEN an SES event with cc, bcc, sender and reply-to common headers
raw_event = load_event("sesEvent.json")
raw_event["Records"][0]["ses"]["mail"]["commonHeaders"].update(
{
"cc": ["cc@example.com"],
"bcc": ["bcc@example.com"],
"sender": ["sender@example.com"],
"replyTo": ["reply@example.com"],
},
)

# WHEN parsing the event
common_headers = SesModel(**raw_event).Records[0].ses.mail.commonHeaders

# THEN the optional common headers are populated
assert common_headers.cc == ["cc@example.com"]
assert common_headers.bcc == ["bcc@example.com"]
assert common_headers.sender == ["sender@example.com"]
assert common_headers.reply_to == ["reply@example.com"]