mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(ses): add v2 PutAccountSuppressionAttributes (#853)
Implements PUT /v2/email/account/suppression so callers can change the account-level suppression list reasons (BOUNCE / COMPLAINT). Entries are persisted per region in ses-account-suppression.json via a new AccountSuppressionAttributes model. GetAccount's response is extended with a SuppressionAttributes object that carries the stored SuppressedReasons. The setting itself is metadata-only — floci does not synthesise bounce/complaint events so no auto-suppression is triggered; the configuration round-trips for SDK users and tooling that introspects account-level settings. Behaviour aligned with real-AWS verification: - SuppressedReasons accepts BOUNCE / COMPLAINT, validated against the AWS-canonical nested "Member must satisfy constraint: [Member must satisfy enum value set: [BOUNCE, COMPLAINT]]" wording (verbatim match against real AWS). - SuppressedReasons may be omitted (treated as empty list) or supplied as an empty array (clears the reasons) — both return 200. - Non-textual array members (JSON null, numeric, etc.) are rejected with BadRequestException. - Fresh regions report the AWS-default [BOUNCE, COMPLAINT] via GetAccount; an explicit PUT (including an empty list) overrides it. - The optional ValidationAttributes body field is accepted but not parsed (Tier S scope). Tests: - SesV2IntegrationTest gains nine cases covering store-and-list, clear-with-empty-array, missing field defaulting to empty, invalid Reason (with the AWS-canonical nested message asserted), non-array SuppressedReasons, JSON null array member, numeric array member, optional ValidationAttributes, and the default-on-fresh-region assertion in the existing getAccount case. - SesAccountSuppressionTest exercises the Java SDK round trip and an explicit empty list through SesV2Client; @BeforeAll captures the caller's existing SuppressedReasons and @AfterAll restores it with failures surfaced so a real-AWS run cannot silently leave the account with auto-suppression disabled.
This commit is contained in:
1 parent
6d36f66e5f
commit
010bbd15cd
8 files changed
+362
-2
No files matched your search
+80
@@ -0,0 +1,80 @@
|
||||
package com.floci.test;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import software.amazon.awssdk.services.sesv2.SesV2Client;
|
||||
import software.amazon.awssdk.services.sesv2.model.GetAccountRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.GetAccountResponse;
|
||||
import software.amazon.awssdk.services.sesv2.model.PutAccountSuppressionAttributesRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.SuppressionListReason;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("SES V2 PutAccountSuppressionAttributes")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesAccountSuppressionTest {
|
||||
|
||||
private static SesV2Client sesV2;
|
||||
private static List<SuppressionListReason> originalReasons;
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
sesV2 = TestFixtures.sesV2Client();
|
||||
// Capture the caller's existing account-level setting so cleanup can restore
|
||||
// it — the suite can run against real AWS and must not leave auto-suppression
|
||||
// disabled for the caller's account.
|
||||
originalReasons = sesV2.getAccount(GetAccountRequest.builder().build())
|
||||
.suppressionAttributes()
|
||||
.suppressedReasons();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void cleanup() {
|
||||
if (sesV2 == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Let restore failures propagate — the test mutates account-level state,
|
||||
// so a silent failure here would leave a real AWS caller's suppression
|
||||
// setting disabled even though the suite reports green.
|
||||
sesV2.putAccountSuppressionAttributes(PutAccountSuppressionAttributesRequest.builder()
|
||||
.suppressedReasons(originalReasons)
|
||||
.build());
|
||||
} finally {
|
||||
sesV2.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void putAndGet_suppressedReasonsRoundTrip() {
|
||||
sesV2.putAccountSuppressionAttributes(PutAccountSuppressionAttributesRequest.builder()
|
||||
.suppressedReasons(SuppressionListReason.BOUNCE, SuppressionListReason.COMPLAINT)
|
||||
.build());
|
||||
|
||||
GetAccountResponse account = sesV2.getAccount(GetAccountRequest.builder().build());
|
||||
assertThat(account.suppressionAttributes()).isNotNull();
|
||||
assertThat(account.suppressionAttributes().suppressedReasons())
|
||||
.containsExactlyInAnyOrder(SuppressionListReason.BOUNCE, SuppressionListReason.COMPLAINT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void put_explicitEmptyList_clearsReasons() {
|
||||
sesV2.putAccountSuppressionAttributes(PutAccountSuppressionAttributesRequest.builder()
|
||||
.suppressedReasons(Collections.emptyList())
|
||||
.build());
|
||||
|
||||
GetAccountResponse account = sesV2.getAccount(GetAccountRequest.builder().build());
|
||||
assertThat(account.suppressionAttributes().suppressedReasons()).isEmpty();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user