Skip to content

Commit

Permalink
SNS - Do not pass empty subject (#4679)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers committed Dec 12, 2021
1 parent bc6f6c1 commit b8cd79c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion moto/sns/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ def get_post_data(self, message, message_id, subject, message_attributes=None):
"Type": "Notification",
"MessageId": message_id,
"TopicArn": self.topic.arn,
"Subject": subject,
"Message": message,
"Timestamp": iso_8601_datetime_with_milliseconds(
datetime.datetime.utcnow()
Expand All @@ -324,6 +323,8 @@ def get_post_data(self, message, message_id, subject, message_attributes=None):
DEFAULT_ACCOUNT_ID
),
}
if subject:
post_data["Subject"] = subject
if message_attributes:
post_data["MessageAttributes"] = message_attributes
return post_data
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sns/test_publishing_boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def test_publish_null_subject():

acquired_message = json.loads(messages[0].body)
acquired_message["Message"].should.equal(message)
acquired_message["Subject"].should.equal(None)
acquired_message.shouldnt.have.key("Subject")


@mock_sns
Expand Down

0 comments on commit b8cd79c

Please sign in to comment.