Skip to content

Commit

Permalink
SNS MessageAttributes are optional (#208)
Browse files Browse the repository at this point in the history
motivation: Notice that if you check the contents of the SQS records, some kind of transform happened on the original SNS message. MessageAttributes in the above example, these will not be set, so this is the initial fix.

changes: make MessageAttributes are optional
  • Loading branch information
DwayneCoussement committed Jun 11, 2021
1 parent 5711b3f commit 9a7d9d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/AWSLambdaEvents/SNS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public enum SNS {
public let messageId: String
public let type: String
public let topicArn: String
public let messageAttributes: [String: Attribute]
public let messageAttributes: [String: Attribute]?
public let signatureVersion: String

@ISO8601WithFractionalSecondsCoding
Expand Down
6 changes: 3 additions & 3 deletions Tests/AWSLambdaEventsTests/SNSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class SNSTests: XCTestCase {
XCTAssertEqual(record.sns.signingCertURL, "https://sns.eu-central-1.amazonaws.com/SimpleNotificationService-6aad65c2f9911b05cd53efda11f913f9.pem")
XCTAssertEqual(record.sns.unsubscribeUrl, "https://sns.eu-central-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-central-1:079477498937:EventSources-SNSTopic-1NHENSE2MQKF5:6fabdb7f-b27e-456d-8e8a-14679db9e40c")

XCTAssertEqual(record.sns.messageAttributes.count, 2)
XCTAssertEqual(record.sns.messageAttributes?.count, 2)

XCTAssertEqual(record.sns.messageAttributes["binary"], .binary([UInt8]("base64".utf8)))
XCTAssertEqual(record.sns.messageAttributes["string"], .string("abc123"))
XCTAssertEqual(record.sns.messageAttributes?["binary"], .binary([UInt8]("base64".utf8)))
XCTAssertEqual(record.sns.messageAttributes?["string"], .string("abc123"))
}
}

0 comments on commit 9a7d9d0

Please sign in to comment.