mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ses): publish a Bounce for suppressionlist@simulator and split events by cause (#4073)
* fix(ses): publish a Bounce for suppressionlist@simulator and split events by cause suppressionlist@simulator.amazonses.com published a Reject event. Real SES publishes a hard Bounce for it: bounceType Permanent, bounceSubType General, and a diagnostic that names the suppression. Reject is the outcome of the content scan, which the simulator has no address for. Verified against SES in us-east-1 on 2026-09-21 through an SNS event destination. The same probe confirmed that a recipient on the account-level suppression list bounces with bounceSubType OnAccountSuppressionList, or is complained about with complaintSubType OnAccountSuppressionList, and that SES publishes one event per cause: a message reaching both bounce@simulator and a suppressed address produces two Bounce events, each listing only its own recipients. Floci merged them into one General bounce. One classifier, SesRecipientEvents, now decides the events a send produces per recipient, and the publisher and identity notifications consume its output, so the simulator and suppression semantics have a single home. complaint@simulator now publishes Delivery before Complaint, as the simulator documents, a list-management opt-out bounces under its own cause, every bounce and complaint block carries its own feedbackId, and complaints carry arrivalDate. Reject stays reachable the way AWS documents it: a Simple send carrying the EICAR test file in its subject, a header or a text body is accepted and then rejected with reason "Bad content" and not relayed. The signature is assembled from fragments at runtime and never appears in source. Scanning raw MIME and keeping the signature out of the mailbox store follow separately. * fix(ses): drop the content of a rejected record A send the content scan rejected was still recorded in full, so its subject, body and headers reached the sent-email store, the inspection endpoint and, with persistence on, the disk. The record now keeps only its source, its envelope and RejectReason, and the inspection endpoint shows the reason. * fix(ses): keep the scanned content out of a rejected message's events The Send and Reject events of a rejected message carried the subject and the additional headers in their mail block, so with headers enabled a subject carrying the test string reached every event destination and, with persistence on, the disk. Both events now carry the envelope but no subject and no headers, a small deviation from SES that keeps the string off disk entirely; the docs say so.
This commit is contained in:
1 parent
ccb6b63d00
commit
d272cd3ceb
17 files changed
+778
-299
No files matched your search
@@ -81,7 +81,8 @@ class SesContactServiceTest {
|
||||
new ListManagementOptions(LIST, "Sports"), REGION,
|
||||
address -> address.substring(address.indexOf('<') + 1, address.indexOf('>')));
|
||||
// The ORIGINAL envelope strings key the result; the extractor only feeds the contact lookup.
|
||||
assertEquals(Map.of("Alice <alice@example.com>", "BOUNCE", "Bob <bob@example.com>", "BOUNCE"),
|
||||
assertEquals(Map.of("Alice <alice@example.com>", SesRecipientEvents.REASON_LIST_OPT_OUT,
|
||||
"Bob <bob@example.com>", SesRecipientEvents.REASON_LIST_OPT_OUT),
|
||||
optOuts);
|
||||
|
||||
AwsException e = assertThrows(AwsException.class, () -> service.collectListManagementOptOuts(
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package io.github.hectorvent.floci.services.ses;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* The test signature is obtained from {@link SesContentScan#signature()} and never spelled out
|
||||
* here, so this source file is as safe to check out as the production one.
|
||||
*/
|
||||
class SesContentScanTest {
|
||||
|
||||
private static final String SIGNATURE = SesContentScan.signature();
|
||||
|
||||
@Test
|
||||
void assembledSignatureHasTheDocumentedLength() {
|
||||
assertEquals(68, SIGNATURE.length());
|
||||
}
|
||||
|
||||
@Test
|
||||
void cleanTextIsNotFlagged() {
|
||||
assertFalse(SesContentScan.containsTestVirus("hello", "<p>hello</p>", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void signatureInsideATextBodyIsFlagged() {
|
||||
assertTrue(SesContentScan.containsTestVirus(null, "prefix " + SIGNATURE + " suffix"));
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.ses;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.services.ses.SesRecipientEvent.Cause;
|
||||
import io.github.hectorvent.floci.services.ses.model.MessageHeader;
|
||||
import io.github.hectorvent.floci.services.ses.model.MessageTag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -12,6 +13,7 @@ import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@@ -27,10 +29,7 @@ class SesEventPayloadTest {
|
||||
|
||||
@Test
|
||||
void send_buildsMailBlockWithCommonHeadersAndTags() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "SEND", "msg-1", "from@example.com",
|
||||
"arn:aws:ses:us-east-1:000000000000:identity/from@example.com",
|
||||
"000000000000", "Hello", List.of("to@example.com"), List.of("cc@example.com"),
|
||||
List.of(), List.of("to@example.com", "cc@example.com"), List.of(), List.of(), "my-cs", List.of(), List.of(), ts);
|
||||
ObjectNode node = SesEventPayload.build(mapper, SesRecipientEvent.of("SEND", Cause.SIMULATOR, List.of()), "msg-1", "from@example.com", "arn:aws:ses:us-east-1:000000000000:identity/from@example.com", "000000000000", "Hello", List.of("to@example.com"), List.of("cc@example.com"), List.of(), List.of("to@example.com", "cc@example.com"), "my-cs", List.of(), List.of(), ts);
|
||||
|
||||
assertEquals("Send", node.get("eventType").asText());
|
||||
assertTrue(node.has("send"));
|
||||
@@ -65,10 +64,7 @@ class SesEventPayloadTest {
|
||||
|
||||
@Test
|
||||
void delivery_includesRecipientsAndSmtpResponse() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "DELIVERY", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
List.of("success@simulator.amazonses.com"), List.of(), List.of(),
|
||||
List.of("success@simulator.amazonses.com"), List.of(), List.of(), "cs", List.of(), List.of(), ts);
|
||||
ObjectNode node = SesEventPayload.build(mapper, SesRecipientEvent.of("DELIVERY", Cause.SIMULATOR, List.of("success@simulator.amazonses.com")), "msg-1", "from@example.com", null, "000000000000", "", List.of("success@simulator.amazonses.com"), List.of(), List.of(), List.of("success@simulator.amazonses.com"), "cs", List.of(), List.of(), ts);
|
||||
|
||||
assertEquals("Delivery", node.get("eventType").asText());
|
||||
ObjectNode delivery = (ObjectNode) node.get("delivery");
|
||||
@@ -80,10 +76,7 @@ class SesEventPayloadTest {
|
||||
|
||||
@Test
|
||||
void bounce_includesBouncedRecipientsAndPermanentType() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "BOUNCE", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
List.of("bounce@simulator.amazonses.com"), List.of(), List.of(),
|
||||
List.of("bounce@simulator.amazonses.com"), List.of(), List.of(), "cs", List.of(), List.of(), ts);
|
||||
ObjectNode node = SesEventPayload.build(mapper, SesRecipientEvent.of("BOUNCE", Cause.SIMULATOR, List.of("bounce@simulator.amazonses.com")), "msg-1", "from@example.com", null, "000000000000", "", List.of("bounce@simulator.amazonses.com"), List.of(), List.of(), List.of("bounce@simulator.amazonses.com"), "cs", List.of(), List.of(), ts);
|
||||
|
||||
assertEquals("Bounce", node.get("eventType").asText());
|
||||
ObjectNode bounce = (ObjectNode) node.get("bounce");
|
||||
@@ -95,74 +88,18 @@ class SesEventPayloadTest {
|
||||
|
||||
@Test
|
||||
void complaint_includesComplainedRecipients() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "COMPLAINT", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
List.of("complaint@simulator.amazonses.com"), List.of(), List.of(),
|
||||
List.of("complaint@simulator.amazonses.com"), List.of(), List.of(), "cs", List.of(), List.of(), ts);
|
||||
ObjectNode node = SesEventPayload.build(mapper, SesRecipientEvent.of("COMPLAINT", Cause.SIMULATOR, List.of("complaint@simulator.amazonses.com")), "msg-1", "from@example.com", null, "000000000000", "", List.of("complaint@simulator.amazonses.com"), List.of(), List.of(), List.of("complaint@simulator.amazonses.com"), "cs", List.of(), List.of(), ts);
|
||||
|
||||
assertEquals("Complaint", node.get("eventType").asText());
|
||||
assertEquals("complaint@simulator.amazonses.com",
|
||||
node.get("complaint").get("complainedRecipients").get(0).get("emailAddress").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void bounce_filtersBouncedRecipientsToBounceSimulatorOnly() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "BOUNCE", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
List.of("normal@example.com", "bounce@simulator.amazonses.com"),
|
||||
List.of(), List.of(),
|
||||
List.of("normal@example.com", "bounce@simulator.amazonses.com"),
|
||||
List.of(), List.of(), "cs", List.of(), List.of(), ts);
|
||||
|
||||
var bounced = (com.fasterxml.jackson.databind.node.ArrayNode)
|
||||
node.get("bounce").get("bouncedRecipients");
|
||||
assertEquals(1, bounced.size());
|
||||
assertEquals("bounce@simulator.amazonses.com",
|
||||
bounced.get(0).get("emailAddress").asText());
|
||||
// mail.destination retains the full envelope
|
||||
assertEquals(2, node.get("mail").get("destination").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void delivery_filtersRecipientsToSuccessSimulatorOnly() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "DELIVERY", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
List.of("normal@example.com", "success@simulator.amazonses.com"),
|
||||
List.of(), List.of(),
|
||||
List.of("normal@example.com", "success@simulator.amazonses.com"),
|
||||
List.of(), List.of(), "cs", List.of(), List.of(), ts);
|
||||
|
||||
var recipients = node.get("delivery").get("recipients");
|
||||
assertEquals(1, recipients.size());
|
||||
assertEquals("success@simulator.amazonses.com", recipients.get(0).asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void complaint_filtersComplainedRecipientsToComplaintSimulatorOnly() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "COMPLAINT", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
List.of("normal@example.com", "complaint@simulator.amazonses.com"),
|
||||
List.of(), List.of(),
|
||||
List.of("normal@example.com", "complaint@simulator.amazonses.com"),
|
||||
List.of(), List.of(), "cs", List.of(), List.of(), ts);
|
||||
|
||||
var complained = node.get("complaint").get("complainedRecipients");
|
||||
assertEquals(1, complained.size());
|
||||
assertEquals("complaint@simulator.amazonses.com",
|
||||
complained.get(0).get("emailAddress").asText());
|
||||
assertEquals(node.get("complaint").get("timestamp").asText(),
|
||||
node.get("complaint").get("arrivalDate").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void send_emailTagsAppearInMailTagsAlongsideConfigurationSet() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "SEND", "msg-1", "from@example.com",
|
||||
null, "000000000000", "Hello",
|
||||
List.of("to@example.com"), List.of(), List.of(),
|
||||
List.of("to@example.com"),
|
||||
List.of(), List.of(),
|
||||
"my-cs",
|
||||
List.of(new MessageTag("campaign", "launch"), new MessageTag("env", "prod")),
|
||||
List.of(),
|
||||
ts);
|
||||
ObjectNode node = SesEventPayload.build(mapper, SesRecipientEvent.of("SEND", Cause.SIMULATOR, List.of()), "msg-1", "from@example.com", null, "000000000000", "Hello", List.of("to@example.com"), List.of(), List.of(), List.of("to@example.com"), "my-cs", List.of(new MessageTag("campaign", "launch"), new MessageTag("env", "prod")), List.of(), ts);
|
||||
|
||||
ObjectNode tags = (ObjectNode) node.get("mail").get("tags");
|
||||
assertEquals("my-cs", tags.get("ses:configuration-set").get(0).asText());
|
||||
@@ -172,15 +109,7 @@ class SesEventPayloadTest {
|
||||
|
||||
@Test
|
||||
void send_emailTagsTolerateNullValueAndDuplicateKey() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "SEND", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
List.of("to@example.com"), List.of(), List.of(),
|
||||
List.of("to@example.com"),
|
||||
List.of(), List.of(),
|
||||
"cs",
|
||||
List.of(new MessageTag("k", null), new MessageTag("k", "v2")),
|
||||
List.of(),
|
||||
ts);
|
||||
ObjectNode node = SesEventPayload.build(mapper, SesRecipientEvent.of("SEND", Cause.SIMULATOR, List.of()), "msg-1", "from@example.com", null, "000000000000", "", List.of("to@example.com"), List.of(), List.of(), List.of("to@example.com"), "cs", List.of(new MessageTag("k", null), new MessageTag("k", "v2")), List.of(), ts);
|
||||
|
||||
var arr = node.get("mail").get("tags").get("k");
|
||||
assertEquals(2, arr.size(), "duplicate keys append into the same array");
|
||||
@@ -190,17 +119,9 @@ class SesEventPayloadTest {
|
||||
|
||||
@Test
|
||||
void send_additionalHeadersAppendToMailHeadersAfterAutoHeaders() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "SEND", "msg-1", "from@example.com",
|
||||
null, "000000000000", "Hi",
|
||||
List.of("to@example.com"), List.of(), List.of(),
|
||||
List.of("to@example.com"),
|
||||
List.of(), List.of(),
|
||||
"cs",
|
||||
List.of(),
|
||||
List.of(
|
||||
ObjectNode node = SesEventPayload.build(mapper, SesRecipientEvent.of("SEND", Cause.SIMULATOR, List.of()), "msg-1", "from@example.com", null, "000000000000", "Hi", List.of("to@example.com"), List.of(), List.of(), List.of("to@example.com"), "cs", List.of(), List.of(
|
||||
new MessageHeader("X-Mailer", "floci"),
|
||||
new MessageHeader("List-Unsubscribe", "<mailto:u@example.com>")),
|
||||
ts);
|
||||
new MessageHeader("List-Unsubscribe", "<mailto:u@example.com>")), ts);
|
||||
|
||||
ArrayNode headers = (ArrayNode) node.get("mail").get("headers");
|
||||
// From, To, Subject auto-emitted first; then user headers in order.
|
||||
@@ -214,18 +135,10 @@ class SesEventPayloadTest {
|
||||
|
||||
@Test
|
||||
void send_additionalHeadersSkipNullOrBlankName() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "SEND", "msg-1", "from@example.com",
|
||||
null, "000000000000", "Hi",
|
||||
List.of("to@example.com"), List.of(), List.of(),
|
||||
List.of("to@example.com"),
|
||||
List.of(), List.of(),
|
||||
"cs",
|
||||
List.of(),
|
||||
List.of(
|
||||
ObjectNode node = SesEventPayload.build(mapper, SesRecipientEvent.of("SEND", Cause.SIMULATOR, List.of()), "msg-1", "from@example.com", null, "000000000000", "Hi", List.of("to@example.com"), List.of(), List.of(), List.of("to@example.com"), "cs", List.of(), List.of(
|
||||
new MessageHeader(null, "ignored"),
|
||||
new MessageHeader("", "ignored-too"),
|
||||
new MessageHeader("X-Real", "ok")),
|
||||
ts);
|
||||
new MessageHeader("X-Real", "ok")), ts);
|
||||
|
||||
ArrayNode headers = (ArrayNode) node.get("mail").get("headers");
|
||||
// Only the auto headers (From/To/Subject) and the single valid X-Real.
|
||||
@@ -241,69 +154,78 @@ class SesEventPayloadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void bounce_unionsSimulatorAndSuppressionRecipients() {
|
||||
// simulator-bounce@... is detected from the envelope, while
|
||||
// suppressed-bounce@... comes from the suppression-list group.
|
||||
// The emitted bouncedRecipients list contains both, deduplicated.
|
||||
ObjectNode node = SesEventPayload.build(mapper, "BOUNCE", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
void bounce_forAccountSuppression_rendersOnlyItsOwnRecipientsWithTheSuppressionSubtype() {
|
||||
// The envelope carries both a simulator bounce and a suppressed address, but this event is
|
||||
// the suppression one: the simulator recipient belongs to a separate BOUNCE event.
|
||||
ObjectNode node = SesEventPayload.build(mapper,
|
||||
SesRecipientEvent.of("BOUNCE", Cause.ACCOUNT_SUPPRESSION, List.of("suppressed-bounce@example.com")),
|
||||
"msg-1", "from@example.com", null, "000000000000", "",
|
||||
List.of("bounce@simulator.amazonses.com", "suppressed-bounce@example.com"), List.of(), List.of(),
|
||||
List.of("bounce@simulator.amazonses.com", "suppressed-bounce@example.com"),
|
||||
List.of(), List.of(),
|
||||
List.of("bounce@simulator.amazonses.com", "suppressed-bounce@example.com"),
|
||||
List.of("suppressed-bounce@example.com"),
|
||||
List.of(),
|
||||
"cs", List.of(), List.of(), ts);
|
||||
|
||||
var bounced = node.get("bounce").get("bouncedRecipients");
|
||||
assertEquals(2, bounced.size());
|
||||
assertEquals("bounce@simulator.amazonses.com",
|
||||
bounced.get(0).get("emailAddress").asText());
|
||||
assertEquals("suppressed-bounce@example.com",
|
||||
bounced.get(1).get("emailAddress").asText());
|
||||
ObjectNode bounce = (ObjectNode) node.get("bounce");
|
||||
assertEquals("OnAccountSuppressionList", bounce.get("bounceSubType").asText());
|
||||
assertEquals(1, bounce.get("bouncedRecipients").size());
|
||||
ObjectNode recipient = (ObjectNode) bounce.get("bouncedRecipients").get(0);
|
||||
assertEquals("suppressed-bounce@example.com", recipient.get("emailAddress").asText());
|
||||
assertEquals("failed", recipient.get("action").asText());
|
||||
assertEquals("5.1.1", recipient.get("status").asText());
|
||||
assertEquals(SesEventPayload.ACCOUNT_SUPPRESSION_DIAGNOSTIC, recipient.get("diagnosticCode").asText());
|
||||
assertEquals(2, node.get("mail").get("destination").size(), "mail.destination keeps the full envelope");
|
||||
}
|
||||
|
||||
@Test
|
||||
void complaint_unionsSimulatorAndSuppressionRecipients() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "COMPLAINT", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
void complaint_forAccountSuppression_rendersOnlyItsOwnRecipientsWithTheSuppressionSubtype() {
|
||||
ObjectNode node = SesEventPayload.build(mapper,
|
||||
SesRecipientEvent.of("COMPLAINT", Cause.ACCOUNT_SUPPRESSION, List.of("suppressed-complaint@example.com")),
|
||||
"msg-1", "from@example.com", null, "000000000000", "",
|
||||
List.of("complaint@simulator.amazonses.com", "suppressed-complaint@example.com"), List.of(), List.of(),
|
||||
List.of("complaint@simulator.amazonses.com", "suppressed-complaint@example.com"),
|
||||
List.of(), List.of(),
|
||||
List.of("complaint@simulator.amazonses.com", "suppressed-complaint@example.com"),
|
||||
List.of(),
|
||||
List.of("suppressed-complaint@example.com"),
|
||||
"cs", List.of(), List.of(), ts);
|
||||
|
||||
var complained = node.get("complaint").get("complainedRecipients");
|
||||
assertEquals(2, complained.size());
|
||||
assertEquals("complaint@simulator.amazonses.com",
|
||||
complained.get(0).get("emailAddress").asText());
|
||||
ObjectNode complaint = (ObjectNode) node.get("complaint");
|
||||
assertEquals("OnAccountSuppressionList", complaint.get("complaintSubType").asText());
|
||||
assertEquals(1, complaint.get("complainedRecipients").size());
|
||||
assertEquals("suppressed-complaint@example.com",
|
||||
complained.get(1).get("emailAddress").asText());
|
||||
complaint.get("complainedRecipients").get(0).get("emailAddress").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void bounce_simulatorAndSuppressionSameAddressNotDuplicated() {
|
||||
// If an address is both a bounce simulator AND on the suppression list with
|
||||
// reason BOUNCE, it should appear once in bouncedRecipients.
|
||||
ObjectNode node = SesEventPayload.build(mapper, "BOUNCE", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
List.of("bounce@simulator.amazonses.com"),
|
||||
List.of(), List.of(),
|
||||
List.of("bounce@simulator.amazonses.com"),
|
||||
List.of("bounce@simulator.amazonses.com"),
|
||||
List.of(),
|
||||
"cs", List.of(), List.of(), ts);
|
||||
void bounce_listManagementOptOutIsAGeneralBounceCarryingOnlyTheAddress() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, SesRecipientEvent.of("BOUNCE", Cause.LIST_MANAGEMENT, List.of("unsub@example.com")), "msg-1", "from@example.com", null, "000000000000", "", List.of("unsub@example.com"), List.of(), List.of(), List.of("unsub@example.com"), "cs", List.of(), List.of(), ts);
|
||||
|
||||
var bounced = node.get("bounce").get("bouncedRecipients");
|
||||
assertEquals(1, bounced.size());
|
||||
ObjectNode bounce = (ObjectNode) node.get("bounce");
|
||||
assertEquals("General", bounce.get("bounceSubType").asText());
|
||||
ObjectNode entry = (ObjectNode) bounce.get("bouncedRecipients").get(0);
|
||||
assertEquals("unsub@example.com", entry.get("emailAddress").asText());
|
||||
assertFalse(entry.has("diagnosticCode"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void feedbackIdsDifferBetweenTheEventsOfOneSend() {
|
||||
List<String> envelope = List.of("bounce@simulator.amazonses.com", "blocked@example.com");
|
||||
ObjectNode simulator = SesEventPayload.build(mapper, SesRecipientEvent.of("BOUNCE", Cause.SIMULATOR, List.of("bounce@simulator.amazonses.com")), "msg-1", "from@example.com", null, "000000000000", "", envelope, List.of(), List.of(), envelope, "cs", List.of(), List.of(), ts);
|
||||
ObjectNode suppressed = SesEventPayload.build(mapper, SesRecipientEvent.of("BOUNCE", Cause.ACCOUNT_SUPPRESSION, List.of("blocked@example.com")), "msg-1", "from@example.com", null, "000000000000", "", envelope, List.of(), List.of(), envelope, "cs", List.of(), List.of(), ts);
|
||||
|
||||
assertNotEquals(simulator.get("bounce").get("feedbackId").asText(),
|
||||
suppressed.get("bounce").get("feedbackId").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void feedbackIdIsTheSameOnTheEventAndOnTheIdentityNotificationOfOneOutcome() {
|
||||
SesRecipientEvent bounce = SesRecipientEvent.of("BOUNCE", Cause.SIMULATOR, List.of("bounce@simulator.amazonses.com"));
|
||||
List<String> envelope = List.of("bounce@simulator.amazonses.com");
|
||||
ObjectNode event = SesEventPayload.build(mapper, bounce, "msg-1", "from@example.com", null, "000000000000", "", envelope, List.of(), List.of(), envelope, "cs", List.of(), List.of(), ts);
|
||||
ObjectNode notification = SesEventPayload.buildIdentityNotification(mapper, bounce, "msg-1", "from@example.com", null, "000000000000", "", envelope, List.of(), List.of(), envelope, List.of(), ts, false);
|
||||
|
||||
assertEquals(event.get("bounce").get("feedbackId").asText(),
|
||||
notification.get("bounce").get("feedbackId").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void reject_hasReason() {
|
||||
ObjectNode node = SesEventPayload.build(mapper, "REJECT", "msg-1", "from@example.com",
|
||||
null, "000000000000", "",
|
||||
List.of("suppressionlist@simulator.amazonses.com"), List.of(), List.of(),
|
||||
List.of("suppressionlist@simulator.amazonses.com"), List.of(), List.of(), "cs", List.of(), List.of(), ts);
|
||||
ObjectNode node = SesEventPayload.build(mapper, SesRecipientEvent.of("REJECT", Cause.CONTENT_REJECTED, List.of()), "msg-1", "from@example.com", null, "000000000000", "", List.of("suppressionlist@simulator.amazonses.com"), List.of(), List.of(), List.of("suppressionlist@simulator.amazonses.com"), "cs", List.of(), List.of(), ts);
|
||||
|
||||
assertEquals("Reject", node.get("eventType").asText());
|
||||
assertNotNull(node.get("reject").get("reason"));
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import io.github.hectorvent.floci.services.cloudwatch.metrics.CloudWatchMetricsService;
|
||||
import io.github.hectorvent.floci.services.eventbridge.EventBridgeService;
|
||||
import io.github.hectorvent.floci.services.firehose.FirehoseService;
|
||||
import io.github.hectorvent.floci.services.ses.SesRecipientEvent.Cause;
|
||||
import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;
|
||||
import io.github.hectorvent.floci.services.ses.model.EventBridgeDestination;
|
||||
import io.github.hectorvent.floci.services.ses.model.EventDestination;
|
||||
@@ -72,10 +73,7 @@ class SesEventPublisherTest {
|
||||
when(eventBridgeService.putEvents(any(), anyString()))
|
||||
.thenReturn(new EventBridgeService.PutEventsResult(0, List.of()));
|
||||
|
||||
publisher.publish(configurationSetWithEventBridgeDestination(DEFAULT_BUS_ARN),
|
||||
"SEND", "msg-1", null, null, "000000000000", "subj",
|
||||
List.of("to@example.com"), null, null, List.of("to@example.com"),
|
||||
null, null, null, null, Instant.now(), "us-east-1");
|
||||
publisher.publish(configurationSetWithEventBridgeDestination(DEFAULT_BUS_ARN), SesRecipientEvent.of("SEND", Cause.SIMULATOR, List.of()), "msg-1", null, null, "000000000000", "subj", List.of("to@example.com"), null, null, List.of("to@example.com"), null, null, Instant.now(), "us-east-1");
|
||||
|
||||
Map<String, Object> entry = captureSingleEntry();
|
||||
assertTrue(entry.containsKey("Resources"),
|
||||
@@ -94,10 +92,7 @@ class SesEventPublisherTest {
|
||||
when(eventBridgeService.putEvents(any(), anyString()))
|
||||
.thenReturn(new EventBridgeService.PutEventsResult(0, List.of()));
|
||||
|
||||
publisher.publish(configurationSetWithEventBridgeDestination(DEFAULT_BUS_ARN),
|
||||
"SEND", "msg-1", "sender@example.com", arn, "000000000000", "subj",
|
||||
List.of("to@example.com"), null, null, List.of("to@example.com"),
|
||||
null, null, null, null, Instant.now(), "us-east-1");
|
||||
publisher.publish(configurationSetWithEventBridgeDestination(DEFAULT_BUS_ARN), SesRecipientEvent.of("SEND", Cause.SIMULATOR, List.of()), "msg-1", "sender@example.com", arn, "000000000000", "subj", List.of("to@example.com"), null, null, List.of("to@example.com"), null, null, Instant.now(), "us-east-1");
|
||||
|
||||
Map<String, Object> entry = captureSingleEntry();
|
||||
Object resources = entry.get("Resources");
|
||||
|
||||
+150
@@ -19,9 +19,14 @@ import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasKey;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
@@ -535,6 +540,11 @@ class SesEventPublishingV2IntegrationTest {
|
||||
.findFirst().orElseThrow();
|
||||
assertEquals(suppressed,
|
||||
bounce.path("bounce").path("bouncedRecipients").get(0).path("emailAddress").asText());
|
||||
// Probed 2026-09-21: an account-suppressed recipient carries the suppression subtype
|
||||
// and SES's own diagnostic text, not the simulator's SMTP response.
|
||||
assertEquals("OnAccountSuppressionList", bounce.path("bounce").path("bounceSubType").asText());
|
||||
assertTrue(bounce.path("bounce").path("bouncedRecipients").get(0).path("diagnosticCode").asText()
|
||||
.startsWith("Amazon SES did not send the message to this address"));
|
||||
} finally {
|
||||
// Always run cleanup so the suppression list doesn't leak into subsequent tests.
|
||||
given()
|
||||
@@ -638,6 +648,7 @@ class SesEventPublishingV2IntegrationTest {
|
||||
.findFirst().orElseThrow();
|
||||
assertEquals(suppressed,
|
||||
complaint.path("complaint").path("complainedRecipients").get(0).path("emailAddress").asText());
|
||||
assertEquals("OnAccountSuppressionList", complaint.path("complaint").path("complaintSubType").asText());
|
||||
} finally {
|
||||
given()
|
||||
.header("Authorization", SES_AUTH)
|
||||
@@ -1578,6 +1589,145 @@ class SesEventPublishingV2IntegrationTest {
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(32)
|
||||
void suppressionListSimulator_publishesAGeneralBounceNotAReject() throws Exception {
|
||||
drainQueue();
|
||||
sendEmail("suppressionlist@simulator.amazonses.com");
|
||||
|
||||
List<JsonNode> events = receiveSesEvents(2);
|
||||
assertEquals(2, events.size(), "expected Send and Bounce events");
|
||||
assertTrue(events.stream().noneMatch(e -> "Reject".equals(e.path("eventType").asText())));
|
||||
JsonNode bounce = events.stream()
|
||||
.filter(e -> "Bounce".equals(e.path("eventType").asText()))
|
||||
.findFirst().orElseThrow();
|
||||
// Probed 2026-09-21: an ordinary hard bounce whose diagnostic names the suppression.
|
||||
assertEquals("General", bounce.path("bounce").path("bounceSubType").asText());
|
||||
JsonNode recipient = bounce.path("bounce").path("bouncedRecipients").get(0);
|
||||
assertEquals("suppressionlist@simulator.amazonses.com", recipient.path("emailAddress").asText());
|
||||
assertEquals("5.1.1", recipient.path("status").asText());
|
||||
assertTrue(recipient.path("diagnosticCode").asText().contains("suppressed address: suppressionlist@"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(33)
|
||||
void simulatorAndSuppressedBounces_arePublishedAsSeparateEvents() throws Exception {
|
||||
String suppressed = "split-suppressed-" + System.nanoTime() + "@example.com";
|
||||
given().contentType("application/json").header("Authorization", SES_AUTH)
|
||||
.body("{\"EmailAddress\":\"" + suppressed + "\",\"Reason\":\"BOUNCE\"}")
|
||||
.when().put("/v2/email/suppression/addresses").then().statusCode(200);
|
||||
try {
|
||||
drainQueue();
|
||||
given().contentType("application/json").header("Authorization", SES_AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
"Destination": {"ToAddresses": ["bounce@simulator.amazonses.com", "%s"]},
|
||||
"ConfigurationSetName": "%s",
|
||||
"Content": {"Simple": {"Subject": {"Data": "split"},
|
||||
"Body": {"Text": {"Data": "hi"}}}}
|
||||
}
|
||||
""".formatted(SENDER, suppressed, CS))
|
||||
.when().post("/v2/email/outbound-emails").then().statusCode(200);
|
||||
|
||||
List<JsonNode> events = receiveSesEvents(3);
|
||||
assertEquals(3, events.size(), "expected Send plus one Bounce per cause");
|
||||
List<JsonNode> bounces = events.stream()
|
||||
.filter(e -> "Bounce".equals(e.path("eventType").asText())).toList();
|
||||
assertEquals(2, bounces.size());
|
||||
for (JsonNode bounce : bounces) {
|
||||
JsonNode recipients = bounce.path("bounce").path("bouncedRecipients");
|
||||
assertEquals(1, recipients.size(), "each Bounce lists only its own cause's recipients");
|
||||
String subtype = bounce.path("bounce").path("bounceSubType").asText();
|
||||
String address = recipients.get(0).path("emailAddress").asText();
|
||||
assertEquals(address.equals(suppressed) ? "OnAccountSuppressionList" : "General", subtype);
|
||||
assertEquals(2, bounce.path("mail").path("destination").size(),
|
||||
"mail.destination carries the full envelope on every event");
|
||||
}
|
||||
} finally {
|
||||
given().header("Authorization", SES_AUTH)
|
||||
.when().delete("/v2/email/suppression/addresses/" + suppressed);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(35)
|
||||
void eicarInSimpleBody_isAcceptedThenRejectedAndStoredWithoutItsContent() throws Exception {
|
||||
drainQueue();
|
||||
String messageId = given().contentType("application/json").header("Authorization", SES_AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s",
|
||||
"Destination": {"ToAddresses": ["success@simulator.amazonses.com"]},
|
||||
"ConfigurationSetName": "%s",
|
||||
"Content": {"Simple": {"Subject": {"Data": "scan"},
|
||||
"Body": {"Text": {"Data": "%s"},
|
||||
"Html": {"Data": "<p>clean</p>"}}}}}
|
||||
""".formatted(SENDER, CS, SesContentScan.signature().replace("\\", "\\\\")))
|
||||
.when().post("/v2/email/outbound-emails").then().statusCode(200)
|
||||
.extract().jsonPath().getString("MessageId");
|
||||
|
||||
List<JsonNode> events = receiveSesEvents(2);
|
||||
assertEquals(2, events.size(), "expected Send and Reject, and no Delivery");
|
||||
assertTrue(events.stream().anyMatch(e -> "Reject".equals(e.path("eventType").asText())));
|
||||
assertTrue(events.stream().noneMatch(e -> "Delivery".equals(e.path("eventType").asText())));
|
||||
|
||||
// The record keeps the reason and the envelope, but none of the scanned content.
|
||||
given().header("Authorization", SES_AUTH)
|
||||
.when().get("/_aws/ses?id=" + messageId).then().statusCode(200)
|
||||
.body("messages[0].RejectReason", equalTo("Bad content"))
|
||||
.body("messages[0].Subject", nullValue())
|
||||
.body("messages[0].Body.text_part", nullValue())
|
||||
.body("messages[0].Body.html_part", nullValue())
|
||||
.body("messages[0]", not(hasKey("Headers")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(36)
|
||||
void eicarInSimpleSubjectOrHeader_isRejectedLikeARawSend() throws Exception {
|
||||
// The signature can sit in the subject or in a caller-supplied header name or value as
|
||||
// well as in a body, so the simple path scans all of them, and the record keeps none.
|
||||
String signature = SesContentScan.signature().replace("\\", "\\\\");
|
||||
for (String content : new String[] {
|
||||
"\"Subject\": {\"Data\": \"" + signature + "\"}, \"Body\": {\"Text\": {\"Data\": \"clean\"}}",
|
||||
"\"Subject\": {\"Data\": \"clean\"}, \"Body\": {\"Text\": {\"Data\": \"clean\"}}, "
|
||||
+ "\"Headers\": [{\"Name\": \"X-Probe\", \"Value\": \"" + signature + "\"}]",
|
||||
"\"Subject\": {\"Data\": \"clean\"}, \"Body\": {\"Text\": {\"Data\": \"clean\"}}, "
|
||||
+ "\"Headers\": [{\"Name\": \"" + signature + "\", \"Value\": \"x\"}]"}) {
|
||||
drainQueue();
|
||||
String messageId = given().contentType("application/json").header("Authorization", SES_AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s",
|
||||
"Destination": {"ToAddresses": ["success@simulator.amazonses.com"]},
|
||||
"ConfigurationSetName": "%s",
|
||||
"Content": {"Simple": {%s}}}
|
||||
""".formatted(SENDER, CS, content))
|
||||
.when().post("/v2/email/outbound-emails").then().statusCode(200)
|
||||
.extract().jsonPath().getString("MessageId");
|
||||
|
||||
List<JsonNode> events = receiveSesEvents(2);
|
||||
assertTrue(events.stream().anyMatch(e -> "Reject".equals(e.path("eventType").asText())),
|
||||
"expected a Reject for: " + content.substring(0, 30));
|
||||
assertTrue(events.stream().noneMatch(e -> "Delivery".equals(e.path("eventType").asText())));
|
||||
// Neither the Send nor the Reject event carries the scanned subject or headers.
|
||||
for (JsonNode event : events) {
|
||||
JsonNode mail = event.path("mail");
|
||||
assertTrue(mail.path("commonHeaders").path("subject").isMissingNode(),
|
||||
event.path("eventType").asText() + " must not carry the subject");
|
||||
for (JsonNode header : mail.path("headers")) {
|
||||
String name = header.path("name").asText();
|
||||
assertTrue(name.equals("From") || name.equals("To") || name.equals("Cc"),
|
||||
event.path("eventType").asText() + " must not carry header " + name);
|
||||
}
|
||||
}
|
||||
|
||||
given().header("Authorization", SES_AUTH)
|
||||
.when().get("/_aws/ses?id=" + messageId).then().statusCode(200)
|
||||
.body("messages[0].RejectReason", equalTo("Bad content"))
|
||||
.body("messages[0].Subject", nullValue())
|
||||
.body("messages[0]", not(hasKey("Headers")));
|
||||
}
|
||||
}
|
||||
|
||||
private void sendEmail(String to) {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
package io.github.hectorvent.floci.services.ses;
|
||||
|
||||
import io.github.hectorvent.floci.services.ses.SesRecipientEvent.Cause;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class SesRecipientEventsTest {
|
||||
|
||||
private static List<String> types(List<SesRecipientEvent> events) {
|
||||
return events.stream().map(SesRecipientEvent::eventType).toList();
|
||||
}
|
||||
|
||||
private static SesRecipientEvent find(List<SesRecipientEvent> events, String type, Cause cause) {
|
||||
return events.stream().filter(e -> e.eventType().equals(type) && e.cause() == cause)
|
||||
.findFirst().orElseThrow();
|
||||
}
|
||||
|
||||
@Test
|
||||
void ordinaryRecipientProducesOnlySend() {
|
||||
assertEquals(List.of("SEND"),
|
||||
types(SesRecipientEvents.classify(List.of("user@example.com"), Map.of(), false)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void successSimulatorIsDelivered() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("success@simulator.amazonses.com"), Map.of(), false);
|
||||
|
||||
assertEquals(List.of("SEND", "DELIVERY"), types(events));
|
||||
assertEquals(List.of("success@simulator.amazonses.com"),
|
||||
find(events, "DELIVERY", Cause.SIMULATOR).recipients());
|
||||
}
|
||||
|
||||
@Test
|
||||
void bounceAndSuppressionListSimulatorsShareOneGeneralBounce() {
|
||||
// Probed 2026-09-21: suppressionlist@ is an ordinary hard bounce, not a Reject.
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("bounce@simulator.amazonses.com", "suppressionlist@simulator.amazonses.com"),
|
||||
Map.of(), false);
|
||||
|
||||
assertEquals(List.of("SEND", "BOUNCE"), types(events));
|
||||
assertEquals(List.of("bounce@simulator.amazonses.com", "suppressionlist@simulator.amazonses.com"),
|
||||
find(events, "BOUNCE", Cause.SIMULATOR).recipients());
|
||||
}
|
||||
|
||||
@Test
|
||||
void complaintSimulatorIsDeliveredThenComplainedAbout() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("complaint@simulator.amazonses.com"), Map.of(), false);
|
||||
|
||||
assertEquals(List.of("SEND", "DELIVERY", "COMPLAINT"), types(events));
|
||||
}
|
||||
|
||||
@Test
|
||||
void suppressedRecipientsBounceOrComplainUnderTheirReason() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("a@example.com", "b@example.com"),
|
||||
Map.of("a@example.com", "BOUNCE", "b@example.com", "COMPLAINT"), false);
|
||||
|
||||
assertEquals(List.of("SEND", "BOUNCE", "COMPLAINT"), types(events));
|
||||
assertEquals(List.of("a@example.com"), find(events, "BOUNCE", Cause.ACCOUNT_SUPPRESSION).recipients());
|
||||
assertEquals(List.of("b@example.com"), find(events, "COMPLAINT", Cause.ACCOUNT_SUPPRESSION).recipients());
|
||||
}
|
||||
|
||||
@Test
|
||||
void simulatorAndSuppressionBouncesAreSeparateEvents() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("bounce@simulator.amazonses.com", "blocked@example.com"),
|
||||
Map.of("blocked@example.com", "BOUNCE"), false);
|
||||
|
||||
assertEquals(List.of("SEND", "BOUNCE", "BOUNCE"), types(events));
|
||||
assertEquals(List.of("bounce@simulator.amazonses.com"),
|
||||
find(events, "BOUNCE", Cause.SIMULATOR).recipients());
|
||||
assertEquals(List.of("blocked@example.com"),
|
||||
find(events, "BOUNCE", Cause.ACCOUNT_SUPPRESSION).recipients());
|
||||
}
|
||||
|
||||
@Test
|
||||
void suppressionWinsOverTheSimulatorAddress() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("bounce@simulator.amazonses.com"),
|
||||
Map.of("bounce@simulator.amazonses.com", "COMPLAINT"), false);
|
||||
|
||||
assertEquals(List.of("SEND", "COMPLAINT"), types(events));
|
||||
assertEquals(Cause.ACCOUNT_SUPPRESSION, events.get(1).cause());
|
||||
}
|
||||
|
||||
@Test
|
||||
void labelledSimulatorAddressKeepsItsScenarioAndItsSpelling() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("bounce+order-1@simulator.amazonses.com"), Map.of(), false);
|
||||
|
||||
assertEquals(List.of("bounce+order-1@simulator.amazonses.com"),
|
||||
find(events, "BOUNCE", Cause.SIMULATOR).recipients());
|
||||
}
|
||||
|
||||
@Test
|
||||
void recipientsAreTrimmedAndDeduplicated() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of(" bounce@simulator.amazonses.com", "bounce@simulator.amazonses.com "), Map.of(), false);
|
||||
|
||||
assertEquals(List.of("bounce@simulator.amazonses.com"),
|
||||
find(events, "BOUNCE", Cause.SIMULATOR).recipients());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectedMessagePublishesOnlySendAndReject() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("success@simulator.amazonses.com", "blocked@example.com"),
|
||||
Map.of("blocked@example.com", "BOUNCE"), true);
|
||||
|
||||
assertEquals(List.of("SEND", "REJECT"), types(events));
|
||||
assertEquals(Cause.CONTENT_REJECTED, events.get(1).cause());
|
||||
}
|
||||
|
||||
@Test
|
||||
void nullEnvelopeAndNullReasonsAreTolerated() {
|
||||
assertEquals(List.of("SEND"), types(SesRecipientEvents.classify(null, null, false)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ordinaryAndSimulatorRecipientsShareTheSendButNotTheOutcome() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("user@example.com", "bounce@simulator.amazonses.com"), Map.of(), false);
|
||||
|
||||
assertEquals(List.of("SEND", "BOUNCE"), types(events));
|
||||
assertEquals(List.of("bounce@simulator.amazonses.com"),
|
||||
find(events, "BOUNCE", Cause.SIMULATOR).recipients());
|
||||
}
|
||||
|
||||
@Test
|
||||
void bounceSimulatorSuppressedForBouncesBouncesOnceUnderTheSuppression() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("bounce@simulator.amazonses.com"),
|
||||
Map.of("bounce@simulator.amazonses.com", "BOUNCE"), false);
|
||||
|
||||
assertEquals(List.of("SEND", "BOUNCE"), types(events));
|
||||
assertEquals(List.of("bounce@simulator.amazonses.com"),
|
||||
find(events, "BOUNCE", Cause.ACCOUNT_SUPPRESSION).recipients());
|
||||
}
|
||||
|
||||
@Test
|
||||
void complaintSimulatorAndSuppressedComplaintAreSeparateEvents() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("complaint@simulator.amazonses.com", "blocked@example.com"),
|
||||
Map.of("blocked@example.com", "COMPLAINT"), false);
|
||||
|
||||
assertEquals(List.of("SEND", "DELIVERY", "COMPLAINT", "COMPLAINT"), types(events));
|
||||
assertEquals(List.of("complaint@simulator.amazonses.com"),
|
||||
find(events, "DELIVERY", Cause.SIMULATOR).recipients());
|
||||
assertEquals(List.of("complaint@simulator.amazonses.com"),
|
||||
find(events, "COMPLAINT", Cause.SIMULATOR).recipients());
|
||||
assertEquals(List.of("blocked@example.com"),
|
||||
find(events, "COMPLAINT", Cause.ACCOUNT_SUPPRESSION).recipients());
|
||||
}
|
||||
|
||||
@Test
|
||||
void listManagementOptOutBouncesUnderItsOwnCause() {
|
||||
List<SesRecipientEvent> events = SesRecipientEvents.classify(
|
||||
List.of("unsub@example.com", "blocked@example.com"),
|
||||
Map.of("unsub@example.com", SesRecipientEvents.REASON_LIST_OPT_OUT,
|
||||
"blocked@example.com", "BOUNCE"), false);
|
||||
|
||||
assertEquals(List.of("SEND", "BOUNCE", "BOUNCE"), types(events));
|
||||
assertEquals(List.of("blocked@example.com"),
|
||||
find(events, "BOUNCE", Cause.ACCOUNT_SUPPRESSION).recipients());
|
||||
assertEquals(List.of("unsub@example.com"),
|
||||
find(events, "BOUNCE", Cause.LIST_MANAGEMENT).recipients());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user