SNS - Do not pass empty subject (#4679)

This commit is contained in:
Bert Blommers 2021-12-12 18:07:31 -01:00 committed by GitHub
parent bc6f6c1618
commit b8cd79cd06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -312,7 +312,6 @@ class Subscription(BaseModel):
"Type": "Notification", "Type": "Notification",
"MessageId": message_id, "MessageId": message_id,
"TopicArn": self.topic.arn, "TopicArn": self.topic.arn,
"Subject": subject,
"Message": message, "Message": message,
"Timestamp": iso_8601_datetime_with_milliseconds( "Timestamp": iso_8601_datetime_with_milliseconds(
datetime.datetime.utcnow() datetime.datetime.utcnow()
@ -324,6 +323,8 @@ class Subscription(BaseModel):
DEFAULT_ACCOUNT_ID DEFAULT_ACCOUNT_ID
), ),
} }
if subject:
post_data["Subject"] = subject
if message_attributes: if message_attributes:
post_data["MessageAttributes"] = message_attributes post_data["MessageAttributes"] = message_attributes
return post_data return post_data

View File

@ -416,7 +416,7 @@ def test_publish_null_subject():
acquired_message = json.loads(messages[0].body) acquired_message = json.loads(messages[0].body)
acquired_message["Message"].should.equal(message) acquired_message["Message"].should.equal(message)
acquired_message["Subject"].should.equal(None) acquired_message.shouldnt.have.key("Subject")
@mock_sns @mock_sns