mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(ses): implement PutAccountVdmAttributes and return VdmAttributes from GetAccount (v2) (#2265)
* feat(ses): implement PutAccountVdmAttributes and return VdmAttributes from GetAccount (v2) Add the SES v2 PutAccountVdmAttributes action (PUT /v2/email/account/vdm) and surface the account's VDM settings in GetAccount under VdmAttributes. The settings (VdmEnabled, DashboardAttributes.EngagementMetrics, GuardianAttributes.OptimizedSharedDelivery — each an ENABLED/DISABLED FeatureStatus) are stored per region and round-trip through GetAccount. VDM is opt-in, so each flag defaults to DISABLED. An invalid FeatureStatus value is a BadRequestException, matching AWS; Floci stores the settings but does not run VDM analytics. * fix(ses): reject non-string FeatureStatus values in PutAccountVdmAttributes parseFeatureStatus coerced any JSON node via asText(), so a boolean or object VdmEnabled produced a misleading enum error instead of being rejected as a type mismatch. Guard on isTextual() before matching the ENABLED/DISABLED enum, consistent with the other SES v2 parsers. * fix(ses): match AWS GetAccount VdmAttributes shape GetAccount always emitted VdmAttributes with the nested Dashboard/Guardian objects. AWS instead omits VdmAttributes entirely until VDM has been configured for the region, and once present adds the Dashboard/Guardian sub-objects only while VdmEnabled is ENABLED. Return VdmAttributes only when the region has stored VDM state, and gate the nested objects on the stored VdmEnabled flag. * test(ses): record live-AWS confirmation that unconfigured VDM omits VdmAttributes eu-west-1 and ap-northeast-1 (never configured) omit the VdmAttributes key, while a configured-then-disabled region reports VdmEnabled DISABLED.
This commit is contained in:
1 parent
a985fa4640
commit
80d1dc732e
14 files changed
+468
-165
No files matched your search
+131
@@ -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());
|
||||
}
|
||||
}
|
||||
+2
@@ -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>(),
|
||||
|
||||
+2
@@ -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>(),
|
||||
|
||||
+2
@@ -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,
|
||||
|
||||
@@ -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>(),
|
||||
|
||||
+2
@@ -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>(),
|
||||
|
||||
+2
@@ -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>(),
|
||||
|
||||
Reference in new issue
Block a user