Light, fluffy, and always free - The AWS Local Emulator alternative
feat(ses): implement PutAccountVdmAttributes and return VdmAttributes from GetAccount (v2) (#2265)
Kenshin Okinaka80d1dc732e51
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesAccountAttributesTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesAccountAttributesTest.javanew file mode 100644index 0000000000..94deb43157--- /dev/null+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesAccountAttributesTest.java@@ -0,0 +1,201 @@+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.ArrayList;+import java.util.Collections;+import java.util.List;++import software.amazon.awssdk.services.ses.SesClient;+import software.amazon.awssdk.services.ses.model.GetAccountSendingEnabledResponse;+import software.amazon.awssdk.services.ses.model.UpdateAccountSendingEnabledRequest;++import software.amazon.awssdk.services.sesv2.SesV2Client;+import software.amazon.awssdk.services.sesv2.model.DashboardAttributes;+import software.amazon.awssdk.services.sesv2.model.FeatureStatus;+import software.amazon.awssdk.services.sesv2.model.GetAccountRequest;+import software.amazon.awssdk.services.sesv2.model.GetAccountResponse;+import software.amazon.awssdk.services.sesv2.model.GuardianAttributes;+import software.amazon.awssdk.services.sesv2.model.PutAccountSendingAttributesRequest;+import software.amazon.awssdk.services.sesv2.model.PutAccountSuppressionAttributesRequest;+import software.amazon.awssdk.services.sesv2.model.PutAccountVdmAttributesRequest;+import software.amazon.awssdk.services.sesv2.model.SuppressionListReason;+import software.amazon.awssdk.services.sesv2.model.VdmAttributes;++import static org.assertj.core.api.Assertions.assertThat;++@DisplayName("SES account attributes: sending, suppression, VDM (v1 + v2)")+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)+class SesAccountAttributesTest {++ private static SesClient sesV1;+ private static SesV2Client sesV2;+ private static List<SuppressionListReason> originalReasons;+ private static VdmAttributes originalVdm;+ private static Boolean originalSendingEnabled;++ @BeforeAll+ static void setup() {+ sesV1 = TestFixtures.sesClient();+ sesV2 = TestFixtures.sesV2Client();+ // Capture the caller's existing account-level settings so cleanup can restore them — the+ // suite can run against real AWS and must not leave the caller's account attributes changed.+ GetAccountResponse account = sesV2.getAccount(GetAccountRequest.builder().build());+ originalReasons = account.suppressionAttributes().suppressedReasons();+ originalVdm = account.vdmAttributes();+ originalSendingEnabled = account.sendingEnabled();+ }++ @AfterAll+ static void cleanup() {+ // Attempt each restoration independently so one failure can't leave the other account+ // settings modified, then propagate an aggregated failure — the tests mutate account-level+ // state, so a silent failure would leave a real AWS caller's settings changed while the+ // suite reports green.+ List<Throwable> failures = new ArrayList<>();+ restoreQuietly(failures, SesAccountAttributesTest::restoreVdmAttributes);+ restoreQuietly(failures, SesAccountAttributesTest::restoreSuppression);+ restoreQuietly(failures, SesAccountAttributesTest::restoreSending);+ if (sesV1 != null) {+ sesV1.close();+ }+ if (sesV2 != null) {+ sesV2.close();+ }+ if (!failures.isEmpty()) {+ RuntimeException aggregate = new RuntimeException("account attribute cleanup failed");+ failures.forEach(aggregate::addSuppressed);+ throw aggregate;+ }+ }++ private static void restoreQuietly(List<Throwable> failures, Runnable restore) {+ try {+ restore.run();+ } catch (RuntimeException e) {+ failures.add(e);+ }+ }++ private static void restoreVdmAttributes() {+ if (sesV2 == null) {+ return;+ }+ // VDM has no un-configure API, so a region that started unconfigured (no VdmAttributes in+ // GetAccount) can only be reset to DISABLED once the round-trip test has enabled it.+ VdmAttributes.Builder vdm = VdmAttributes.builder();+ if (originalVdm != null && originalVdm.vdmEnabled() != null) {+ vdm.vdmEnabled(originalVdm.vdmEnabled())+ .dashboardAttributes(originalVdm.dashboardAttributes())+ .guardianAttributes(originalVdm.guardianAttributes());+ } else {+ vdm.vdmEnabled(FeatureStatus.DISABLED);+ }+ sesV2.putAccountVdmAttributes(PutAccountVdmAttributesRequest.builder()+ .vdmAttributes(vdm.build())+ .build());+ }++ private static void restoreSuppression() {+ if (sesV2 == null || originalReasons == null) {+ return;+ }+ sesV2.putAccountSuppressionAttributes(PutAccountSuppressionAttributesRequest.builder()+ .suppressedReasons(originalReasons)+ .build());+ }++ private static void restoreSending() {+ if (sesV1 == null || originalSendingEnabled == null) {+ return;+ }+ sesV1.updateAccountSendingEnabled(UpdateAccountSendingEnabledRequest.builder()+ .enabled(originalSendingEnabled).build());+ }++ @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();+ }++ @Test+ @Order(3)+ void putAndGet_vdmAttributesRoundTrip() {+ sesV2.putAccountVdmAttributes(PutAccountVdmAttributesRequest.builder()+ .vdmAttributes(VdmAttributes.builder()+ .vdmEnabled(FeatureStatus.ENABLED)+ .dashboardAttributes(DashboardAttributes.builder()+ .engagementMetrics(FeatureStatus.ENABLED).build())+ .guardianAttributes(GuardianAttributes.builder()+ .optimizedSharedDelivery(FeatureStatus.ENABLED).build())+ .build())+ .build());++ GetAccountResponse account = sesV2.getAccount(GetAccountRequest.builder().build());+ assertThat(account.vdmAttributes()).isNotNull();+ assertThat(account.vdmAttributes().vdmEnabled()).isEqualTo(FeatureStatus.ENABLED);+ assertThat(account.vdmAttributes().dashboardAttributes().engagementMetrics())+ .isEqualTo(FeatureStatus.ENABLED);+ assertThat(account.vdmAttributes().guardianAttributes().optimizedSharedDelivery())+ .isEqualTo(FeatureStatus.ENABLED);+ }++ @Test+ @Order(4)+ void v1UpdateAccountSendingEnabled_disablesAndReenables() {+ sesV1.updateAccountSendingEnabled(UpdateAccountSendingEnabledRequest.builder()+ .enabled(false).build());++ GetAccountSendingEnabledResponse disabled = sesV1.getAccountSendingEnabled();+ assertThat(disabled.enabled()).isFalse();++ sesV1.updateAccountSendingEnabled(UpdateAccountSendingEnabledRequest.builder()+ .enabled(true).build());++ GetAccountSendingEnabledResponse enabled = sesV1.getAccountSendingEnabled();+ assertThat(enabled.enabled()).isTrue();+ }++ @Test+ @Order(5)+ void v1AndV2_shareAccountSendingState() {+ // Disable via v1, observe via v2 GetAccount+ sesV1.updateAccountSendingEnabled(UpdateAccountSendingEnabledRequest.builder()+ .enabled(false).build());++ GetAccountResponse afterV1Disable = sesV2.getAccount(GetAccountRequest.builder().build());+ assertThat(afterV1Disable.sendingEnabled()).isFalse();++ // Re-enable via v2, observe via v1 GetAccountSendingEnabled+ sesV2.putAccountSendingAttributes(PutAccountSendingAttributesRequest.builder()+ .sendingEnabled(true).build());++ GetAccountSendingEnabledResponse afterV2Enable = sesV1.getAccountSendingEnabled();+ assertThat(afterV2Enable.enabled()).isTrue();+ }+}diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesAccountSendingTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesAccountSendingTest.javadeleted file mode 100644index 1e52e777c6..0000000000--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesAccountSendingTest.java+++ /dev/null@@ -1,83 +0,0 @@-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 software.amazon.awssdk.services.ses.SesClient;-import software.amazon.awssdk.services.ses.model.GetAccountSendingEnabledResponse;-import software.amazon.awssdk.services.ses.model.UpdateAccountSendingEnabledRequest;--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.PutAccountSendingAttributesRequest;--import static org.assertj.core.api.Assertions.assertThat;--@DisplayName("SES Account Sending Enabled (v1 + v2)")-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)-class SesAccountSendingTest {-- private static SesClient sesV1;- private static SesV2Client sesV2;-- @BeforeAll- static void setup() {- sesV1 = TestFixtures.sesClient();- sesV2 = TestFixtures.sesV2Client();- }-- @AfterAll- static void cleanup() {- // Always restore the account-wide flag so it does not leak to other suites.- if (sesV1 != null) {- try {- sesV1.updateAccountSendingEnabled(UpdateAccountSendingEnabledRequest.builder()- .enabled(true).build());- } catch (Exception ignored) {}- sesV1.close();- }- if (sesV2 != null) {- sesV2.close();- }- }-- @Test- @Order(1)- void v1UpdateAccountSendingEnabled_disablesAndReenables() {- sesV1.updateAccountSendingEnabled(UpdateAccountSendingEnabledRequest.builder()- .enabled(false).build());-- GetAccountSendingEnabledResponse disabled = sesV1.getAccountSendingEnabled();- assertThat(disabled.enabled()).isFalse();-- sesV1.updateAccountSendingEnabled(UpdateAccountSendingEnabledRequest.builder()- .enabled(true).build());-- GetAccountSendingEnabledResponse enabled = sesV1.getAccountSendingEnabled();- assertThat(enabled.enabled()).isTrue();- }-- @Test- @Order(2)- void v1AndV2_shareAccountSendingState() {- // Disable via v1, observe via v2 GetAccount- sesV1.updateAccountSendingEnabled(UpdateAccountSendingEnabledRequest.builder()- .enabled(false).build());-- GetAccountResponse afterV1Disable = sesV2.getAccount(GetAccountRequest.builder().build());- assertThat(afterV1Disable.sendingEnabled()).isFalse();-- // Re-enable via v2, observe via v1 GetAccountSendingEnabled- sesV2.putAccountSendingAttributes(PutAccountSendingAttributesRequest.builder()- .sendingEnabled(true).build());-- GetAccountSendingEnabledResponse afterV2Enable = sesV1.getAccountSendingEnabled();- assertThat(afterV2Enable.enabled()).isTrue();- }-}diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesAccountSuppressionTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesAccountSuppressionTest.javadeleted file mode 100644index 76327a1724..0000000000--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesAccountSuppressionTest.java+++ /dev/null@@ -1,80 +0,0 @@-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();- }-}diff --git a/docs/services/ses.md b/docs/services/ses.mdindex 271c6f3a03..b573d5fad3 100644--- a/docs/services/ses.md+++ b/docs/services/ses.md@@ -205,6 +205,7 @@ Alongside the classic Query API, Floci implements a subset of the SES v2 REST JS| `GET` | `/v2/email/account` | `GetAccount` || `PUT` | `/v2/email/account/sending` | `PutAccountSendingAttributes` || `PUT` | `/v2/email/account/suppression` | `PutAccountSuppressionAttributes` |+| `PUT` | `/v2/email/account/vdm` | `PutAccountVdmAttributes` || `POST` | `/v2/email/templates` | `CreateEmailTemplate` || `GET` | `/v2/email/templates` | `ListEmailTemplates` || `GET` | `/v2/email/templates/{templateName}` | `GetEmailTemplate` |@@ -269,6 +270,8 @@ Floci recognises the AWS [mailbox simulator addresses](https://docs.aws.amazon.cA successful send without a simulator-address recipient emits only the `Send` event.+Account-level VDM (Virtual Deliverability Manager) attributes are stored per region. `PutAccountVdmAttributes` sets `VdmEnabled` (opt-in, defaults `DISABLED`) plus the optional `DashboardAttributes.EngagementMetrics` and `GuardianAttributes.OptimizedSharedDelivery`. `GetAccount` omits `VdmAttributes` until VDM has been configured for the region, then returns `VdmEnabled`, adding the `DashboardAttributes`/`GuardianAttributes` sub-objects only while `VdmEnabled` is `ENABLED`. Floci stores the settings but does not run VDM analytics.+Suppression list entries are stored per region with `Reason` ∈ {`BOUNCE`, `COMPLAINT`}. At send time, a recipient is suppressed when it appears on the suppression list AND its stored `Reason` is contained in the **effective** `SuppressedReasons` for the send. The effective list is the configuration set's `SuppressionOptions.SuppressedReasons` (set via `PutConfigurationSetSuppressionOptions`) when present — an **empty list is preserved as an explicit "no suppression filtering for this configuration set"** — otherwise it falls back to the account-level `AccountSuppressionAttributes.SuppressedReasons` (set via `PutAccountSuppressionAttributes`, default `[BOUNCE, COMPLAINT]`). Following the AWS V2 contract, there is no dedicated `GetConfigurationSetSuppressionOptions` action; once set, the block is read back through `GetConfigurationSet`'s response (the field is omitted when the configuration set has no override).Suppressed recipients are filtered out of the SMTP relay step (non-suppressed recipients on the same send still reach the relay normally), and the configuration set's event destinations receive a synthetic `Bounce` or `Complaint` event alongside the always-emitted `Send` event. The `SendEmail` API response (`200` + `MessageId`), the stored `SentEmail` visible at `GET /_aws/ses`, and the published event's `mail.destination` all retain the original recipient list — matching the AWS contract that the message is "accepted, just not sent" for suppressed addresses.diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesController.javaindex 086cb81c0d..42185d3b49 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.ses;import io.github.hectorvent.floci.core.common.AwsException;import io.github.hectorvent.floci.core.common.RegionResolver;import io.github.hectorvent.floci.services.ses.model.AccountSuppressionAttributes;+import io.github.hectorvent.floci.services.ses.model.AccountVdmAttributes;import io.github.hectorvent.floci.services.ses.model.ArchivingOptions;import io.github.hectorvent.floci.services.ses.model.DashboardOptions;import io.github.hectorvent.floci.services.ses.model.GuardianOptions;@@ -1811,9 +1812,88 @@ public class SesController {reasons.add(r);}+ // AWS only surfaces VdmAttributes once VDM has been configured for the region (an untouched+ // region omits the key entirely), and only adds the Dashboard/Guardian sub-attributes while+ // VdmEnabled is ENABLED.+ sesService.findAccountVdmAttributes(region).ifPresent(vdm -> {+ ObjectNode vdmAttrs = result.putObject("VdmAttributes");+ vdmAttrs.put("VdmEnabled", featureStatus(vdm.vdmEnabled()));+ if (vdm.vdmEnabled()) {+ vdmAttrs.putObject("DashboardAttributes")+ .put("EngagementMetrics", featureStatus(vdm.engagementMetrics()));+ vdmAttrs.putObject("GuardianAttributes")+ .put("OptimizedSharedDelivery", featureStatus(vdm.optimizedSharedDelivery()));+ }+ });+return Response.ok(result).build();}+ private static String featureStatus(boolean enabled) {+ return enabled ? "ENABLED" : "DISABLED";+ }++ @PUT+ @Path("/account/vdm")+ public Response putAccountVdmAttributes(@Context HttpHeaders headers, String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ JsonNode request = (body == null || body.isBlank())+ ? objectMapper.createObjectNode()+ : objectMapper.readTree(body);+ requireJsonObject(request);+ JsonNode vdm = request.path("VdmAttributes");+ if (!vdm.isObject()) {+ throw new AwsException("BadRequestException", "VdmAttributes is required.", 400);+ }+ boolean vdmEnabled = parseFeatureStatus(vdm, "VdmEnabled",+ "vdmAttributes.vdmEnabled", true);+ boolean engagement = parseFeatureStatus(+ requireObjectOrAbsent(vdm, "DashboardAttributes"), "EngagementMetrics",+ "vdmAttributes.dashboardAttributes.engagementMetrics", false);+ boolean osd = parseFeatureStatus(+ requireObjectOrAbsent(vdm, "GuardianAttributes"), "OptimizedSharedDelivery",+ "vdmAttributes.guardianAttributes.optimizedSharedDelivery", false);+ sesService.putAccountVdmAttributes(region,+ new AccountVdmAttributes(vdmEnabled, engagement, osd));+ LOG.infov("SES V2 PutAccountVdmAttributes: enabled={0}, engagement={1}, osd={2}",+ vdmEnabled, engagement, osd);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ } catch (com.fasterxml.jackson.core.JsonProcessingException e) {+ throw new AwsException("BadRequestException", e.getMessage(), 400);+ }+ }++ // Parse an AWS FeatureStatus (ENABLED/DISABLED) field. A required member that is absent, or any+ // value outside the enum, is a Smithy BadRequestException the way AWS returns it; an absent+ // optional member defaults to DISABLED (false).+ private static boolean parseFeatureStatus(JsonNode parent, String field, String path, boolean required) {+ JsonNode node = parent.path(field);+ if (node.isMissingNode() || node.isNull()) {+ if (required) {+ throw new AwsException("BadRequestException",+ "1 validation error detected: Value null at '" + path+ + "' failed to satisfy constraint: Member must not be null", 400);+ }+ return false;+ }+ if (node.isTextual()) {+ String value = node.asText();+ if ("ENABLED".equals(value)) {+ return true;+ }+ if ("DISABLED".equals(value)) {+ return false;+ }+ }+ throw new AwsException("BadRequestException",+ "1 validation error detected: Value at '" + path+ + "' failed to satisfy constraint: Member must satisfy enum value set: [ENABLED, DISABLED]",+ 400);+ }+@PUT@Path("/account/suppression")public Response putAccountSuppressionAttributes(@Context HttpHeaders headers, String body) {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.javaindex 11258b1f50..a55d615802 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@@ -10,6 +10,7 @@ import io.github.hectorvent.floci.services.route53.model.HostedZone;import io.github.hectorvent.floci.services.route53.model.ResourceRecord;import io.github.hectorvent.floci.services.route53.model.ResourceRecordSet;import io.github.hectorvent.floci.services.ses.model.AccountSuppressionAttributes;+import io.github.hectorvent.floci.services.ses.model.AccountVdmAttributes;import io.github.hectorvent.floci.services.ses.model.ArchivingOptions;import io.github.hectorvent.floci.services.ses.model.BulkEmailEntry;import io.github.hectorvent.floci.services.ses.model.BulkEmailEntryResult;@@ -89,6 +90,7 @@ public class SesService {private final StorageBackend<String, ConfigurationSet> configSetStore;private final StorageBackend<String, SuppressedDestination> suppressionStore;private final StorageBackend<String, AccountSuppressionAttributes> accountSuppressionStore;+ private final StorageBackend<String, AccountVdmAttributes> accountVdmStore;private final StorageBackend<String, DedicatedIpPool> dedicatedIpPoolStore;private final StorageBackend<String, ContactList> contactListStore;private final StorageBackend<String, Contact> contactStore;@@ -142,6 +144,8 @@ public class SesService {new TypeReference<Map<String, SuppressedDestination>>() {});this.accountSuppressionStore = storageFactory.create("ses", "ses-account-suppression.json",new TypeReference<Map<String, AccountSuppressionAttributes>>() {});+ this.accountVdmStore = storageFactory.create("ses", "ses-account-vdm.json",+ new TypeReference<Map<String, AccountVdmAttributes>>() {});this.dedicatedIpPoolStore = storageFactory.create("ses", "ses-dedicated-ip-pools.json",new TypeReference<Map<String, DedicatedIpPool>>() {});this.contactListStore = storageFactory.create("ses", "ses-contact-lists.json",@@ -170,6 +174,7 @@ public class SesService {StorageBackend<String, ConfigurationSet> configSetStore,StorageBackend<String, SuppressedDestination> suppressionStore,StorageBackend<String, AccountSuppressionAttributes> accountSuppressionStore,+ StorageBackend<String, AccountVdmAttributes> accountVdmStore,StorageBackend<String, DedicatedIpPool> dedicatedIpPoolStore,StorageBackend<String, ContactList> contactListStore,StorageBackend<String, Contact> contactStore,@@ -180,8 +185,8 @@ public class SesService {ObjectMapper objectMapper,Clock clock) {this(identityStore, emailStore, accountSettingsStore, templateStore, configSetStore, suppressionStore,- accountSuppressionStore, dedicatedIpPoolStore, contactListStore, contactStore, policyStore,- receiptRuleSetStore, cvetStore, smtpRelay, objectMapper, null, clock);+ accountSuppressionStore, accountVdmStore, dedicatedIpPoolStore, contactListStore, contactStore,+ policyStore, receiptRuleSetStore, cvetStore, smtpRelay, objectMapper, null, clock);}SesService(StorageBackend<String, Identity> identityStore,@@ -191,6 +196,7 @@ public class SesService {StorageBackend<String, ConfigurationSet> configSetStore,StorageBackend<String, SuppressedDestination> suppressionStore,StorageBackend<String, AccountSuppressionAttributes> accountSuppressionStore,+ StorageBackend<String, AccountVdmAttributes> accountVdmStore,StorageBackend<String, DedicatedIpPool> dedicatedIpPoolStore,StorageBackend<String, ContactList> contactListStore,StorageBackend<String, Contact> contactStore,@@ -208,6 +214,7 @@ public class SesService {this.configSetStore = configSetStore;this.suppressionStore = suppressionStore;this.accountSuppressionStore = accountSuppressionStore;+ this.accountVdmStore = accountVdmStore;this.dedicatedIpPoolStore = dedicatedIpPoolStore;this.contactListStore = contactListStore;this.contactStore = contactStore;@@ -1009,6 +1016,23 @@ public class SesService {LOG.infov("Updated account sending enabled for region {0}: {1}", region, enabled);}+ // VDM (Virtual Deliverability Manager) is opt-in and per region: GetAccount omits VdmAttributes+ // entirely until PutAccountVdmAttributes is called for the region, so this returns empty when the+ // region was never configured. The whole tuple is stored under one region key so GetAccount never+ // observes a partially updated state.+ public Optional<AccountVdmAttributes> findAccountVdmAttributes(String region) {+ return accountVdmStore.get(accountVdmKey(region));+ }++ public void putAccountVdmAttributes(String region, AccountVdmAttributes vdm) {+ accountVdmStore.put(accountVdmKey(region), vdm);+ LOG.infov("Updated account VDM attributes for region {0}: enabled={1}", region, vdm.vdmEnabled());+ }++ private static String accountVdmKey(String region) {+ return "account-vdm::" + region;+ }+public void setConfigurationSetSendingEnabled(String configSetName, boolean enabled, String region) {ConfigurationSet cs = getConfigurationSet(configSetName, region);cs.setSendingEnabled(enabled);diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/model/AccountVdmAttributes.java b/src/main/java/io/github/hectorvent/floci/services/ses/model/AccountVdmAttributes.javanew file mode 100644index 0000000000..d001cea501--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/ses/model/AccountVdmAttributes.java@@ -0,0 +1,15 @@+package io.github.hectorvent.floci.services.ses.model;++import com.fasterxml.jackson.annotation.JsonIgnoreProperties;+import io.quarkus.runtime.annotations.RegisterForReflection;++/**+ * Account-level Virtual Deliverability Manager (VDM) settings, returned by GetAccount and set by+ * PutAccountVdmAttributes. Each flag maps to the AWS {@code FeatureStatus} enum (ENABLED / DISABLED).+ */+@RegisterForReflection+@JsonIgnoreProperties(ignoreUnknown = true)+public record AccountVdmAttributes(boolean vdmEnabled,+ boolean engagementMetrics,+ boolean optimizedSharedDelivery) {+}diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesAccountVdmV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesAccountVdmV2IntegrationTest.javanew file mode 100644index 0000000000..13b5b5b0c5--- /dev/null+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesAccountVdmV2IntegrationTest.java@@ -0,0 +1,131 @@+package io.github.hectorvent.floci.services.ses;++import io.quarkus.test.junit.QuarkusTest;+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 static io.restassured.RestAssured.given;+import static org.hamcrest.Matchers.equalTo;+import static org.hamcrest.Matchers.nullValue;++/**+ * Integration tests for the SES V2 account VDM attributes: {@code PUT /v2/email/account/vdm}+ * (PutAccountVdmAttributes) and the {@code GET /v2/email/account} (GetAccount) round-trip. VDM is+ * account/region-scoped, so this uses an isolated region and leaves it DISABLED at the end. Shapes+ * and defaults are verified against real AWS: VDM is opt-in and defaults to DISABLED, and the+ * Dashboard/Guardian sub-attributes are only returned while VdmEnabled is ENABLED.+ */+@QuarkusTest+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)+class SesAccountVdmV2IntegrationTest {++ private static final String AUTH =+ "AWS4-HMAC-SHA256 Credential=AKID/20260101/eu-central-1/ses/aws4_request";++ @Test+ @Order(0)+ void getAccount_vdmAttributesAbsentUntilConfigured() {+ // A region where PutAccountVdmAttributes was never called omits the VdmAttributes key+ // entirely; AWS only surfaces it once VDM has been configured for that region. Confirmed+ // against a live account: eu-west-1 and ap-northeast-1 (never configured) omit VdmAttributes,+ // while a region that was configured then disabled reports VdmEnabled DISABLED.+ given().header("Authorization", AUTH)+ .when().get("/v2/email/account").then().statusCode(200)+ .body("VdmAttributes", nullValue());+ }++ @Test+ @Order(1)+ void putVdm_enablesAndRoundTripsThroughGetAccount() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body("""+ {"VdmAttributes":{"VdmEnabled":"ENABLED",+ "DashboardAttributes":{"EngagementMetrics":"ENABLED"},+ "GuardianAttributes":{"OptimizedSharedDelivery":"ENABLED"}}}+ """)+ .when().put("/v2/email/account/vdm").then().statusCode(200);++ given().header("Authorization", AUTH)+ .when().get("/v2/email/account").then().statusCode(200)+ .body("VdmAttributes.VdmEnabled", equalTo("ENABLED"))+ .body("VdmAttributes.DashboardAttributes.EngagementMetrics", equalTo("ENABLED"))+ .body("VdmAttributes.GuardianAttributes.OptimizedSharedDelivery", equalTo("ENABLED"));+ }++ @Test+ @Order(2)+ void putVdm_invalidEnum_returnsBadRequest() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body("{\"VdmAttributes\":{\"VdmEnabled\":\"MAYBE\"}}")+ .when().put("/v2/email/account/vdm").then().statusCode(400)+ .body("__type", equalTo("BadRequestException"));+ }++ @Test+ @Order(3)+ void putVdm_missingVdmEnabled_returnsBadRequest() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body("{\"VdmAttributes\":{}}")+ .when().put("/v2/email/account/vdm").then().statusCode(400)+ .body("__type", equalTo("BadRequestException"));+ }++ @Test+ @Order(4)+ void putVdm_emptyBody_returnsBadRequest() {+ given().contentType("application/json").header("Authorization", AUTH)+ .when().put("/v2/email/account/vdm").then().statusCode(400)+ .body("__type", equalTo("BadRequestException"));+ }++ @Test+ @Order(5)+ void putVdm_nonObjectDashboardAttributes_returnsBadRequest() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body("{\"VdmAttributes\":{\"VdmEnabled\":\"ENABLED\",\"DashboardAttributes\":\"oops\"}}")+ .when().put("/v2/email/account/vdm").then().statusCode(400)+ .body("__type", equalTo("BadRequestException"));+ }++ @Test+ @Order(6)+ void putVdm_nonStringVdmEnabled_returnsBadRequest() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body("{\"VdmAttributes\":{\"VdmEnabled\":true}}")+ .when().put("/v2/email/account/vdm").then().statusCode(400)+ .body("__type", equalTo("BadRequestException"));+ }++ @Test+ @Order(7)+ void putVdm_enabledWithoutNested_defaultsNestedToDisabled() {+ // Enabling VDM without supplying the optional members: AWS surfaces both nested objects with+ // their DISABLED defaults once VdmEnabled is ENABLED.+ given().contentType("application/json").header("Authorization", AUTH)+ .body("{\"VdmAttributes\":{\"VdmEnabled\":\"ENABLED\"}}")+ .when().put("/v2/email/account/vdm").then().statusCode(200);++ given().header("Authorization", AUTH)+ .when().get("/v2/email/account").then().statusCode(200)+ .body("VdmAttributes.VdmEnabled", equalTo("ENABLED"))+ .body("VdmAttributes.DashboardAttributes.EngagementMetrics", equalTo("DISABLED"))+ .body("VdmAttributes.GuardianAttributes.OptimizedSharedDelivery", equalTo("DISABLED"));+ }++ @Test+ @Order(8)+ void putVdm_disabled_omitsNestedAttributes() {+ // Disabling VDM drops the nested objects again, and restores this region to DISABLED.+ given().contentType("application/json").header("Authorization", AUTH)+ .body("{\"VdmAttributes\":{\"VdmEnabled\":\"DISABLED\"}}")+ .when().put("/v2/email/account/vdm").then().statusCode(200);++ given().header("Authorization", AUTH)+ .when().get("/v2/email/account").then().statusCode(200)+ .body("VdmAttributes.VdmEnabled", equalTo("DISABLED"))+ .body("VdmAttributes.DashboardAttributes", nullValue())+ .body("VdmAttributes.GuardianAttributes", nullValue());+ }+}diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceDkimLookupCacheTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceDkimLookupCacheTest.javaindex 7dc344d0f4..d99b4f55dd 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceDkimLookupCacheTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceDkimLookupCacheTest.java@@ -7,6 +7,7 @@ import io.github.hectorvent.floci.services.route53.model.HostedZone;import io.github.hectorvent.floci.services.route53.model.ResourceRecord;import io.github.hectorvent.floci.services.route53.model.ResourceRecordSet;import io.github.hectorvent.floci.services.ses.model.AccountSuppressionAttributes;+import io.github.hectorvent.floci.services.ses.model.AccountVdmAttributes;import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.ContactList;import io.github.hectorvent.floci.services.ses.model.Contact;@@ -56,6 +57,7 @@ class SesServiceDkimLookupCacheTest {new InMemoryStorage<String, ConfigurationSet>(),new InMemoryStorage<String, SuppressedDestination>(),new InMemoryStorage<String, AccountSuppressionAttributes>(),+ new InMemoryStorage<String, AccountVdmAttributes>(),new InMemoryStorage<String, DedicatedIpPool>(),new InMemoryStorage<String, ContactList>(),new InMemoryStorage<String, Contact>(),diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceLegacyDkimTokensTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceLegacyDkimTokensTest.javaindex 5fa99c2502..bc8ff05c0b 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceLegacyDkimTokensTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceLegacyDkimTokensTest.java@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.ses;import com.fasterxml.jackson.databind.ObjectMapper;import io.github.hectorvent.floci.core.storage.InMemoryStorage;import io.github.hectorvent.floci.services.ses.model.AccountSuppressionAttributes;+import io.github.hectorvent.floci.services.ses.model.AccountVdmAttributes;import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.ContactList;import io.github.hectorvent.floci.services.ses.model.Contact;@@ -45,6 +46,7 @@ class SesServiceLegacyDkimTokensTest {new InMemoryStorage<String, ConfigurationSet>(),new InMemoryStorage<String, SuppressedDestination>(),new InMemoryStorage<String, AccountSuppressionAttributes>(),+ new InMemoryStorage<String, AccountVdmAttributes>(),new InMemoryStorage<String, DedicatedIpPool>(),new InMemoryStorage<String, ContactList>(),new InMemoryStorage<String, Contact>(),diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceListManagementTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceListManagementTest.javaindex 86edaa59e2..97798409e8 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceListManagementTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceListManagementTest.java@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;import io.github.hectorvent.floci.core.common.AwsException;import io.github.hectorvent.floci.core.storage.InMemoryStorage;import io.github.hectorvent.floci.services.ses.model.AccountSuppressionAttributes;+import io.github.hectorvent.floci.services.ses.model.AccountVdmAttributes;import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.Contact;import io.github.hectorvent.floci.services.ses.model.ContactList;@@ -65,6 +66,7 @@ class SesServiceListManagementTest {new InMemoryStorage<String, ConfigurationSet>(),new InMemoryStorage<String, SuppressedDestination>(),new InMemoryStorage<String, AccountSuppressionAttributes>(),+ new InMemoryStorage<String, AccountVdmAttributes>(),new InMemoryStorage<String, DedicatedIpPool>(),new InMemoryStorage<String, ContactList>(),contactStore,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.javaindex 453addfa0b..df42df70c8 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@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.ses;import com.fasterxml.jackson.databind.ObjectMapper;import io.github.hectorvent.floci.core.storage.InMemoryStorage;import io.github.hectorvent.floci.services.ses.model.AccountSuppressionAttributes;+import io.github.hectorvent.floci.services.ses.model.AccountVdmAttributes;import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.ContactList;import io.github.hectorvent.floci.services.ses.model.Contact;@@ -44,6 +45,7 @@ class SesServiceSmtpTest {new InMemoryStorage<String, ConfigurationSet>(),new InMemoryStorage<String, SuppressedDestination>(),new InMemoryStorage<String, AccountSuppressionAttributes>(),+ new InMemoryStorage<String, AccountVdmAttributes>(),new InMemoryStorage<String, DedicatedIpPool>(),new InMemoryStorage<String, ContactList>(),new InMemoryStorage<String, Contact>(),diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionLegacyKeyTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionLegacyKeyTest.javaindex 130f688e6a..b9715bab3e 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionLegacyKeyTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionLegacyKeyTest.java@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.ses;import com.fasterxml.jackson.databind.ObjectMapper;import io.github.hectorvent.floci.core.storage.InMemoryStorage;import io.github.hectorvent.floci.services.ses.model.AccountSuppressionAttributes;+import io.github.hectorvent.floci.services.ses.model.AccountVdmAttributes;import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.ContactList;import io.github.hectorvent.floci.services.ses.model.Contact;@@ -52,6 +53,7 @@ class SesServiceSuppressionLegacyKeyTest {new InMemoryStorage<String, ConfigurationSet>(),suppressionStore,new InMemoryStorage<String, AccountSuppressionAttributes>(),+ new InMemoryStorage<String, AccountVdmAttributes>(),new InMemoryStorage<String, DedicatedIpPool>(),new InMemoryStorage<String, ContactList>(),new InMemoryStorage<String, Contact>(),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.javaindex 407ff60822..749b71309b 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@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.ses;import com.fasterxml.jackson.databind.ObjectMapper;import io.github.hectorvent.floci.core.storage.InMemoryStorage;import io.github.hectorvent.floci.services.ses.model.AccountSuppressionAttributes;+import io.github.hectorvent.floci.services.ses.model.AccountVdmAttributes;import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.ContactList;import io.github.hectorvent.floci.services.ses.model.Contact;@@ -52,6 +53,7 @@ class SesServiceSuppressionReasonTest {new InMemoryStorage<String, ConfigurationSet>(),suppressionStore,accountSuppressionStore,+ new InMemoryStorage<String, AccountVdmAttributes>(),new InMemoryStorage<String, DedicatedIpPool>(),new InMemoryStorage<String, ContactList>(),new InMemoryStorage<String, Contact>(),