From b8cd79cd06a6cc591b0a51086ead50609af4dd4d Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Sun, 12 Dec 2021 18:07:31 -0100 Subject: [PATCH] SNS - Do not pass empty subject (#4679) --- moto/sns/models.py | 3 ++- tests/test_sns/test_publishing_boto3.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/moto/sns/models.py b/moto/sns/models.py index 081e80695..21c80f05a 100644 --- a/moto/sns/models.py +++ b/moto/sns/models.py @@ -312,7 +312,6 @@ class Subscription(BaseModel): "Type": "Notification", "MessageId": message_id, "TopicArn": self.topic.arn, - "Subject": subject, "Message": message, "Timestamp": iso_8601_datetime_with_milliseconds( datetime.datetime.utcnow() @@ -324,6 +323,8 @@ class Subscription(BaseModel): DEFAULT_ACCOUNT_ID ), } + if subject: + post_data["Subject"] = subject if message_attributes: post_data["MessageAttributes"] = message_attributes return post_data diff --git a/tests/test_sns/test_publishing_boto3.py b/tests/test_sns/test_publishing_boto3.py index ffb09468b..8dc6c5eb9 100644 --- a/tests/test_sns/test_publishing_boto3.py +++ b/tests/test_sns/test_publishing_boto3.py @@ -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