mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
refactor(ses): drop the tenant-free suppression overloads from SesService (#3860)
The four short signatures of putSuppressedDestination, getSuppressedDestination, deleteSuppressedDestination and listSuppressedDestinations only passed null as the TenantName to the tenant-aware version, which then forwarded straight to SesSuppressionService. The v2 controller always passes a TenantName, so nothing in src/main called them; the only callers were tests seeding or reading suppression entries. SesSuppressionService already exposes those exact three-argument signatures, so the tests reach it through the builder accessor instead, the way SesSuppressionServiceTest already did. They keep the facade for what is actually facade behavior: sendEmail and resolveSuppressionReason. Retitle the suppression section and fold its two comment paragraphs into one. The heading still claimed "account attributes + list" although the account attributes moved to SesSuppressionService in the store split and are read and written by the v2 controller; only the tenant-routed list operations remain. Also squash the four runs of consecutive blank lines in the file, including the one the earlier inspection cleanup left before the Templates section comment.
This commit is contained in:
1 parent
6e53c5275a
commit
938eca1fe9
4 files changed
+27
-47
No files matched your search
@@ -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", "to@example.com", "BOUNCE");
|
||||
service.putSuppressedDestination("us-east-1", "cc@example.com", "COMPLAINT");
|
||||
suppression.putSuppressedDestination("us-east-1", "to@example.com", "BOUNCE");
|
||||
suppression.putSuppressedDestination("us-east-1", "cc@example.com", "COMPLAINT");
|
||||
|
||||
String messageId = service.sendEmail("from@example.com",
|
||||
List.of("to@example.com"),
|
||||
@@ -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", "suppressed@example.com", "BOUNCE");
|
||||
suppression.putSuppressedDestination("us-east-1", "suppressed@example.com", "BOUNCE");
|
||||
|
||||
service.sendEmail("from@example.com",
|
||||
List.of("to@example.com", "suppressed@example.com"),
|
||||
@@ -206,7 +208,7 @@ class SesServiceSmtpTest {
|
||||
|
||||
@Test
|
||||
void sendRawEmail_allRecipientsSuppressed_skipsRelayRawButStillStores() {
|
||||
service.putSuppressedDestination("us-east-1", "to@example.com", "BOUNCE");
|
||||
suppression.putSuppressedDestination("us-east-1", "to@example.com", "BOUNCE");
|
||||
|
||||
String messageId = service.sendRawEmail("from@example.com",
|
||||
List.of("to@example.com"), "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", "suppressed@example.com", "COMPLAINT");
|
||||
suppression.putSuppressedDestination("us-east-1", "suppressed@example.com", "COMPLAINT");
|
||||
|
||||
service.sendRawEmail("from@example.com",
|
||||
List.of("to@example.com", "suppressed@example.com"),
|
||||
@@ -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", "to@example.com", "BOUNCE");
|
||||
suppression.putSuppressedDestination("us-east-1", "to@example.com", "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", "complainer@example.com", "COMPLAINT");
|
||||
suppression.putSuppressedDestination("us-east-1", "complainer@example.com", "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", "to@example.com", "BOUNCE");
|
||||
suppression.putSuppressedDestination("us-east-1", "to@example.com", "BOUNCE");
|
||||
service.createConfigurationSet(new ConfigurationSet("cs-default"), "us-east-1");
|
||||
|
||||
service.sendEmail("from@example.com",
|
||||
@@ -279,7 +281,7 @@ class SesServiceSmtpTest {
|
||||
|
||||
@Test
|
||||
void sendRawEmail_csOverridesAccountToEmptyList_suppressionListIsIgnored() {
|
||||
service.putSuppressedDestination("us-east-1", "to@example.com", "BOUNCE");
|
||||
suppression.putSuppressedDestination("us-east-1", "to@example.com", "BOUNCE");
|
||||
service.createConfigurationSet(new ConfigurationSet("cs-no-suppression-raw"), "us-east-1");
|
||||
configSets.putSuppressionOptions("cs-no-suppression-raw", List.of(), "us-east-1");
|
||||
|
||||
|
||||
+4
-4
@@ -47,14 +47,14 @@ class SesServiceSuppressionReasonTest {
|
||||
|
||||
@Test
|
||||
void onListAndReasonInAccountSettings_returnsReason() {
|
||||
service.putSuppressedDestination(REGION, "bouncer@example.com", "BOUNCE");
|
||||
suppression.putSuppressedDestination(REGION, "bouncer@example.com", "BOUNCE");
|
||||
// Account-level suppressedReasons defaults to [BOUNCE, COMPLAINT].
|
||||
assertEquals("BOUNCE", service.resolveSuppressionReason("bouncer@example.com", null, REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void onListButReasonNotInAccountSettings_returnsNull() {
|
||||
service.putSuppressedDestination(REGION, "complainer@example.com", "COMPLAINT");
|
||||
suppression.putSuppressedDestination(REGION, "complainer@example.com", "COMPLAINT");
|
||||
// Narrow the account settings to BOUNCE only.
|
||||
suppression.putAccountSuppressionAttributes(REGION, List.of("BOUNCE"));
|
||||
assertNull(service.resolveSuppressionReason("complainer@example.com", null, REGION));
|
||||
@@ -62,7 +62,7 @@ class SesServiceSuppressionReasonTest {
|
||||
|
||||
@Test
|
||||
void accountSettingsEmpty_returnsNull() {
|
||||
service.putSuppressedDestination(REGION, "bouncer@example.com", "BOUNCE");
|
||||
suppression.putSuppressedDestination(REGION, "bouncer@example.com", "BOUNCE");
|
||||
// Disable account-level suppression by passing an empty list.
|
||||
suppression.putAccountSuppressionAttributes(REGION, new ArrayList<>());
|
||||
assertNull(service.resolveSuppressionReason("bouncer@example.com", null, REGION));
|
||||
@@ -70,7 +70,7 @@ class SesServiceSuppressionReasonTest {
|
||||
|
||||
@Test
|
||||
void leadingTrailingWhitespaceIsNormalized() {
|
||||
service.putSuppressedDestination(REGION, "trim-me@example.com", "BOUNCE");
|
||||
suppression.putSuppressedDestination(REGION, "trim-me@example.com", "BOUNCE");
|
||||
// Caller may pass the recipient with surrounding whitespace (e.g. from a header).
|
||||
assertEquals("BOUNCE",
|
||||
service.resolveSuppressionReason(" trim-me@example.com ", null, REGION));
|
||||
|
||||
+5
-3
@@ -25,6 +25,7 @@ class SesSuppressionLegacyKeyTest {
|
||||
private static final String CANONICAL_KEY = "suppression::" + REGION + "::Foo.Bar@example.com";
|
||||
|
||||
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();
|
||||
|
||||
Reference in new issue
Block a user