Skip to content

Commit 9962bec

Browse files
committed
Formatting
1 parent 84b6284 commit 9962bec

File tree

2 files changed

+71
-72
lines changed

2 files changed

+71
-72
lines changed

Sources/AWSLambdaEvents/SES.swift

+8-9
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public enum SES {
3535
public let mail: Mail
3636
public let receipt: Receipt
3737
}
38-
38+
3939
public struct Mail: Decodable {
4040
public let commonHeaders: CommonHeaders
4141
public let destination: [String]
@@ -45,7 +45,7 @@ public enum SES {
4545
public let source: String
4646
@ISO8601WithFractionalSecondsCoding public var timestamp: Date
4747
}
48-
48+
4949
public struct CommonHeaders: Decodable {
5050
public let bcc: [String]?
5151
public let cc: [String]?
@@ -56,12 +56,12 @@ public enum SES {
5656
public let subject: String?
5757
public let to: [String]?
5858
}
59-
59+
6060
public struct Header: Decodable {
6161
public let name: String
6262
public let value: String
6363
}
64-
64+
6565
public struct Receipt: Decodable {
6666
public let action: Action
6767
public let dmarcPolicy: DMARCPolicy?
@@ -74,28 +74,27 @@ public enum SES {
7474
@ISO8601WithFractionalSecondsCoding public var timestamp: Date
7575
public let virusVerdict: Verdict
7676
}
77-
77+
7878
public struct Action: Decodable {
7979
public let functionArn: String
8080
public let invocationType: String
8181
public let type: String
8282
}
83-
83+
8484
public struct Verdict: Decodable {
8585
public let status: Status
8686
}
87-
87+
8888
public enum DMARCPolicy: String, Decodable {
8989
case none
9090
case quarantine
9191
case reject
9292
}
93-
93+
9494
public enum Status: String, Decodable {
9595
case pass = "PASS"
9696
case fail = "FAIL"
9797
case gray = "GRAY"
9898
case processingFailed = "PROCESSING_FAILED"
9999
}
100100
}
101-

Tests/AWSLambdaEventsTests/SESTests.swift

+63-63
Original file line numberDiff line numberDiff line change
@@ -17,74 +17,74 @@ import XCTest
1717

1818
class SESTests: XCTestCase {
1919
static let eventBody = """
20+
{
21+
"Records": [
2022
{
21-
"Records": [
22-
{
23-
"eventSource": "aws:ses",
24-
"eventVersion": "1.0",
25-
"ses": {
26-
"mail": {
27-
"commonHeaders": {
28-
"date": "Wed, 7 Oct 2015 12:34:56 -0700",
29-
"from": [
30-
"Jane Doe <[email protected]>"
31-
],
32-
"messageId": "<0123456789example.com>",
33-
"returnPath": "[email protected]",
34-
"subject": "Test Subject",
35-
"to": [
36-
37-
]
38-
},
39-
"destination": [
40-
41-
],
42-
"headers": [
43-
{
44-
"name": "Return-Path",
45-
"value": "<[email protected]>"
46-
},
47-
{
48-
"name": "Received",
49-
"value": "from mailer.example.com (mailer.example.com [203.0.113.1]) by inbound-smtp.eu-west-1.amazonaws.com with SMTP id o3vrnil0e2ic28trm7dfhrc2v0cnbeccl4nbp0g1 for [email protected]; Wed, 07 Oct 2015 12:34:56 +0000 (UTC)"
50-
}
51-
],
52-
"headersTruncated": true,
53-
"messageId": "5h5auqp1oa1bg49b2q8f8tmli1oju8pcma2haao1",
54-
"source": "[email protected]",
55-
"timestamp": "1970-01-01T00:00:00.000Z"
23+
"eventSource": "aws:ses",
24+
"eventVersion": "1.0",
25+
"ses": {
26+
"mail": {
27+
"commonHeaders": {
28+
"date": "Wed, 7 Oct 2015 12:34:56 -0700",
29+
"from": [
30+
"Jane Doe <[email protected]>"
31+
],
32+
"messageId": "<0123456789example.com>",
33+
"returnPath": "[email protected]",
34+
"subject": "Test Subject",
35+
"to": [
36+
37+
]
38+
},
39+
"destination": [
40+
41+
],
42+
"headers": [
43+
{
44+
"name": "Return-Path",
45+
"value": "<[email protected]>"
5646
},
57-
"receipt": {
58-
"action": {
59-
"functionArn": "arn:aws:lambda:eu-west-1:123456789012:function:Example",
60-
"invocationType": "Event",
61-
"type": "Lambda"
62-
},
63-
"dkimVerdict": {
64-
"status": "PASS"
65-
},
66-
"processingTimeMillis": 574,
67-
"recipients": [
68-
69-
70-
],
71-
"spamVerdict": {
72-
"status": "PASS"
73-
},
74-
"spfVerdict": {
75-
"status": "PROCESSING_FAILED"
76-
},
77-
"timestamp": "1970-01-01T00:00:00.000Z",
78-
"virusVerdict": {
79-
"status": "FAIL"
80-
}
47+
{
48+
"name": "Received",
49+
"value": "from mailer.example.com (mailer.example.com [203.0.113.1]) by inbound-smtp.eu-west-1.amazonaws.com with SMTP id o3vrnil0e2ic28trm7dfhrc2v0cnbeccl4nbp0g1 for [email protected]; Wed, 07 Oct 2015 12:34:56 +0000 (UTC)"
8150
}
51+
],
52+
"headersTruncated": true,
53+
"messageId": "5h5auqp1oa1bg49b2q8f8tmli1oju8pcma2haao1",
54+
"source": "[email protected]",
55+
"timestamp": "1970-01-01T00:00:00.000Z"
56+
},
57+
"receipt": {
58+
"action": {
59+
"functionArn": "arn:aws:lambda:eu-west-1:123456789012:function:Example",
60+
"invocationType": "Event",
61+
"type": "Lambda"
62+
},
63+
"dkimVerdict": {
64+
"status": "PASS"
65+
},
66+
"processingTimeMillis": 574,
67+
"recipients": [
68+
69+
70+
],
71+
"spamVerdict": {
72+
"status": "PASS"
73+
},
74+
"spfVerdict": {
75+
"status": "PROCESSING_FAILED"
76+
},
77+
"timestamp": "1970-01-01T00:00:00.000Z",
78+
"virusVerdict": {
79+
"status": "FAIL"
8280
}
8381
}
84-
]
82+
}
8583
}
86-
"""
87-
84+
]
85+
}
86+
"""
87+
8888
func testSimpleEventFromJSON() {
8989
let data = Data(SESTests.eventBody.utf8)
9090
var event: SES.Event?
@@ -112,7 +112,7 @@ class SESTests: XCTestCase {
112112
XCTAssertEqual(record.ses.mail.messageId, "5h5auqp1oa1bg49b2q8f8tmli1oju8pcma2haao1")
113113
XCTAssertEqual(record.ses.mail.source, "[email protected]")
114114
XCTAssertEqual(record.ses.mail.timestamp.description, "1970-01-01 00:00:00 +0000")
115-
115+
116116
XCTAssertEqual(record.ses.receipt.action.functionArn, "arn:aws:lambda:eu-west-1:123456789012:function:Example")
117117
XCTAssertEqual(record.ses.receipt.action.invocationType, "Event")
118118
XCTAssertEqual(record.ses.receipt.action.type, "Lambda")

0 commit comments

Comments
 (0)