Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

refactor(ses): drop the tenant-free suppression overloads from SesService (#3860)

Kenshin Okinaka938eca1fe9a6
diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java
index 41c5f012bf..87211742bb 100644
--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java
@@ -613,8 +613,6 @@ public class SesService {
return cs;
}
-
-
// ──────────────────────────── Templates ────────────────────────────
// Email templates live in SesTemplateService, which the v2 controller and the v1 handler call
@@ -1053,7 +1051,6 @@ public class SesService {
suppressionService.getAccountSuppressionAttributes(region).getSuppressedReasons());
}
-
public List<Tag> listResourceTags(String arn, String region) {
ResourceRef ref = parseSesArn(arn);
requireCallerAccount(ref);
@@ -1172,31 +1169,13 @@ public class SesService {
resource.substring(0, slash), resource.substring(slash + 1));
}
- // ──────────────────── Suppression (account attributes + list) ────────────────────
- // Storage lives in SesSuppressionService; the account attributes are read and written by the v2
- // controller directly, the list operations below keep the tenant routing here, and the send
- // filters (collectSuppressedReasons / resolveSuppressionReason) read entries back through it.
-
- // A TenantName routes each suppression-list operation to that tenant's own list (fully separate
- // from the account list on AWS); the reason/address validation still runs first, matching the
- // probed precedence where request validation precedes tenant existence.
-
- public void putSuppressedDestination(String region, String emailAddress, String reason) {
- putSuppressedDestination(region, emailAddress, reason, null);
- }
-
- public SuppressedDestination getSuppressedDestination(String region, String emailAddress) {
- return getSuppressedDestination(region, emailAddress, null);
- }
-
- public void deleteSuppressedDestination(String region, String emailAddress) {
- deleteSuppressedDestination(region, emailAddress, null);
- }
-
- public List<SuppressedDestination> listSuppressedDestinations(String region,
- List<String> reasonFilters) {
- return listSuppressedDestinations(region, reasonFilters, null);
- }
+ // ──────────────────────────── Suppression list ────────────────────────────
+ // Storage lives in SesSuppressionService, and the account-level attributes are read and
+ // written by the v2 controller through it directly. What stays here is the tenant routing: a
+ // TenantName sends the operation to that tenant's own list, which is fully separate from the
+ // account list on AWS, and the reason and address validation still runs first, matching the
+ // probed precedence where request validation precedes tenant existence. The send filters
+ // (collectSuppressedReasons, resolveSuppressionReason) read entries back through the service.
public void putSuppressedDestination(String region, String emailAddress, String reason,
String tenantName) {
@@ -1352,7 +1331,6 @@ public class SesService {
return out;
}
-
/**
* Filter out recipients whose effective suppression reason is non-null. Returns a new
* list containing only the addresses that should reach the SMTP relay, mirroring AWS
@@ -1411,8 +1389,6 @@ public class SesService {
return effective.contains(entry.getReason()) ? entry.getReason() : null;
}
-
-
public String sendTemplatedEmail(String source, List<String> toAddresses, List<String> ccAddresses,
List<String> bccAddresses, List<String> replyToAddresses,
String returnPath, String templateName, JsonNode templateData,
diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.java
index e7b09b713f..60611e3a52 100644
--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.java
@@ -24,6 +24,7 @@ class SesServiceSmtpTest {
private SesService service;
private SesConfigurationSetService configSets;
private SesSentEmailService sentEmails;
+ private SesSuppressionService suppression;
private InMemoryStorage<String, SentEmail> emailStore;
@BeforeEach
@@ -33,6 +34,7 @@ class SesServiceSmtpTest {
service = builder.build();
configSets = builder.configSetService();
sentEmails = builder.sentEmailService();
+ suppression = builder.suppressionService();
}
private SentEmail storedEmail(String messageId) {
@@ -173,8 +175,8 @@ class SesServiceSmtpTest {
@Test
void sendEmail_allRecipientsSuppressed_skipsRelayButStillStores() {
- service.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
- service.putSuppressedDestination("us-east-1", "[email protected]", "COMPLAINT");
+ suppression.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
+ suppression.putSuppressedDestination("us-east-1", "[email protected]", "COMPLAINT");
String messageId = service.sendEmail("[email protected]",
List.of("[email protected]"),
@@ -191,7 +193,7 @@ class SesServiceSmtpTest {
@Test
void sendEmail_partialSuppression_relayCalledWithFilteredRecipients() {
// Only suppress one of the To recipients; the other should still reach the relay.
- service.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
+ suppression.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
service.sendEmail("[email protected]",
@@ -206,7 +208,7 @@ class SesServiceSmtpTest {
@Test
void sendRawEmail_allRecipientsSuppressed_skipsRelayRawButStillStores() {
- service.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
+ suppression.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
String messageId = service.sendRawEmail("[email protected]",
List.of("[email protected]"), "raw MIME", null, null, List.of(), null, "us-east-1");
@@ -218,7 +220,7 @@ class SesServiceSmtpTest {
@Test
void sendRawEmail_partialSuppression_relayRawCalledWithFilteredRecipients() {
- service.putSuppressedDestination("us-east-1", "[email protected]", "COMPLAINT");
+ suppression.putSuppressedDestination("us-east-1", "[email protected]", "COMPLAINT");
service.sendRawEmail("[email protected]",
@@ -235,7 +237,7 @@ class SesServiceSmtpTest {
// overrides to an empty list, which is the AWS V2 contract for "disable
// suppression filtering for this configuration set". A recipient on the
// suppression list with reason=BOUNCE should still reach the SMTP relay.
- service.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
+ suppression.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
service.createConfigurationSet(new ConfigurationSet("cs-no-suppression"), "us-east-1");
configSets.putSuppressionOptions("cs-no-suppression", List.of(), "us-east-1");
@@ -251,7 +253,7 @@ class SesServiceSmtpTest {
// Account-level reasons include both BOUNCE and COMPLAINT by default.
// The CS narrows the effective reasons to [BOUNCE] only — so a recipient
// suppressed for COMPLAINT is NOT filtered when sending through this CS.
- service.putSuppressedDestination("us-east-1", "[email protected]", "COMPLAINT");
+ suppression.putSuppressedDestination("us-east-1", "[email protected]", "COMPLAINT");
service.createConfigurationSet(new ConfigurationSet("cs-bounce-only"), "us-east-1");
configSets.putSuppressionOptions("cs-bounce-only", List.of("BOUNCE"), "us-east-1");
@@ -267,7 +269,7 @@ class SesServiceSmtpTest {
// A configuration set whose SuppressionOptions block was never PUT must
// fall back to account-level reasons — same filtering behaviour as a
// send without any configuration set.
- service.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
+ suppression.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
service.createConfigurationSet(new ConfigurationSet("cs-default"), "us-east-1");
service.sendEmail("[email protected]",
@@ -279,7 +281,7 @@ class SesServiceSmtpTest {
@Test
void sendRawEmail_csOverridesAccountToEmptyList_suppressionListIsIgnored() {
- service.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
+ suppression.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");
service.createConfigurationSet(new ConfigurationSet("cs-no-suppression-raw"), "us-east-1");
configSets.putSuppressionOptions("cs-no-suppression-raw", List.of(), "us-east-1");
diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionReasonTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionReasonTest.java
index 26e8172be7..238dc03ef3 100644
--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionReasonTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionReasonTest.java
@@ -47,14 +47,14 @@ class SesServiceSuppressionReasonTest {
@Test
void onListAndReasonInAccountSettings_returnsReason() {
- service.putSuppressedDestination(REGION, "[email protected]", "BOUNCE");
+ suppression.putSuppressedDestination(REGION, "[email protected]", "BOUNCE");
// Account-level suppressedReasons defaults to [BOUNCE, COMPLAINT].
assertEquals("BOUNCE", service.resolveSuppressionReason("[email protected]", null, REGION));
}
@Test
void onListButReasonNotInAccountSettings_returnsNull() {
- service.putSuppressedDestination(REGION, "[email protected]", "COMPLAINT");
+ suppression.putSuppressedDestination(REGION, "[email protected]", "COMPLAINT");
// Narrow the account settings to BOUNCE only.
suppression.putAccountSuppressionAttributes(REGION, List.of("BOUNCE"));
assertNull(service.resolveSuppressionReason("[email protected]", null, REGION));
@@ -62,7 +62,7 @@ class SesServiceSuppressionReasonTest {
@Test
void accountSettingsEmpty_returnsNull() {
- service.putSuppressedDestination(REGION, "[email protected]", "BOUNCE");
+ suppression.putSuppressedDestination(REGION, "[email protected]", "BOUNCE");
// Disable account-level suppression by passing an empty list.
suppression.putAccountSuppressionAttributes(REGION, new ArrayList<>());
assertNull(service.resolveSuppressionReason("[email protected]", null, REGION));
@@ -70,7 +70,7 @@ class SesServiceSuppressionReasonTest {
@Test
void leadingTrailingWhitespaceIsNormalized() {
- service.putSuppressedDestination(REGION, "[email protected]", "BOUNCE");
+ suppression.putSuppressedDestination(REGION, "[email protected]", "BOUNCE");
// Caller may pass the recipient with surrounding whitespace (e.g. from a header).
assertEquals("BOUNCE",
service.resolveSuppressionReason(" [email protected] ", null, REGION));
diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesSuppressionLegacyKeyTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesSuppressionLegacyKeyTest.java
index 3477459fa7..f18c03d3e8 100644
--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesSuppressionLegacyKeyTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesSuppressionLegacyKeyTest.java
@@ -25,6 +25,7 @@ class SesSuppressionLegacyKeyTest {
private static final String CANONICAL_KEY = "suppression::" + REGION + "::[email protected]";
private SesService service;
+ private SesSuppressionService suppression;
private InMemoryStorage<String, SuppressedDestination> suppressionStore;
@BeforeEach
@@ -32,6 +33,7 @@ class SesSuppressionLegacyKeyTest {
SesServiceTestBuilder builder = SesServiceTestBuilder.create();
suppressionStore = builder.suppressionStore();
service = builder.build();
+ suppression = builder.suppressionService();
}
private void seedLegacyEntry() {
@@ -41,7 +43,7 @@ class SesSuppressionLegacyKeyTest {
@Test
void getReachesLegacyEntryByExactAddress() {
seedLegacyEntry();
- SuppressedDestination got = service.getSuppressedDestination(REGION, LEGACY_ADDR);
+ SuppressedDestination got = suppression.getSuppressedDestination(REGION, LEGACY_ADDR);
assertEquals(LEGACY_ADDR, got.getEmailAddress());
assertEquals("BOUNCE", got.getReason());
}
@@ -49,7 +51,7 @@ class SesSuppressionLegacyKeyTest {
@Test
void deleteRemovesLegacyEntry() {
seedLegacyEntry();
- service.deleteSuppressedDestination(REGION, LEGACY_ADDR);
+ suppression.deleteSuppressedDestination(REGION, LEGACY_ADDR);
assertFalse(suppressionStore.get(LEGACY_KEY).isPresent());
}
@@ -65,7 +67,7 @@ class SesSuppressionLegacyKeyTest {
@Test
void putMigratesLegacyEntryOntoCanonicalKeyWithoutDuplicate() {
seedLegacyEntry();
- service.putSuppressedDestination(REGION, LEGACY_ADDR, "COMPLAINT");
+ suppression.putSuppressedDestination(REGION, LEGACY_ADDR, "COMPLAINT");
assertFalse(suppressionStore.get(LEGACY_KEY).isPresent(), "legacy key should be migrated away");
assertTrue(suppressionStore.get(CANONICAL_KEY).isPresent(), "entry should live under canonical key");
SuppressedDestination migrated = suppressionStore.get(CANONICAL_KEY).orElseThrow();