feat(ses): support global shared delivery (PutAccountDeliveryAttributes) (#9445)

PutAccountDeliveryAttributes stores the account's SharedPoolDeliveryMode per Region, GetAccount always reports it under DeliveryAttributes (GLOBAL when unset), and configuration sets accept DeliveryOptions.SharedPoolDeliveryMode, which PutConfigurationSetDeliveryOptions keeps when a request omits it. The Java compatibility suite moves to AWS SDK 2.59.7.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-11-26 11:21:11 -04:00
1 parent 537b57c381
commit b33ca9e7ea
18 files changed
+520 -16

No files matched your search

+2 -2
View File
@@ -16,8 +16,8 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<aws.sdk.version>2.55.11</aws.sdk.version>
<awsjavasdk.version>2.55.11</awsjavasdk.version>
<aws.sdk.version>2.59.7</aws.sdk.version>
<awsjavasdk.version>2.59.7</awsjavasdk.version>
<jackson.version>2.18.8</jackson.version>
<kafka.clients.version>3.9.2</kafka.clients.version>
<netty.version>4.1.135.Final</netty.version>
@@ -0,0 +1,148 @@
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 org.junit.jupiter.api.parallel.ResourceLock;
import software.amazon.awssdk.services.ses.SesClient;
import software.amazon.awssdk.services.sesv2.SesV2Client;
import software.amazon.awssdk.services.sesv2.model.AccountSharedPoolDeliveryMode;
import software.amazon.awssdk.services.sesv2.model.BadRequestException;
import software.amazon.awssdk.services.sesv2.model.CreateConfigurationSetRequest;
import software.amazon.awssdk.services.sesv2.model.DeleteConfigurationSetRequest;
import software.amazon.awssdk.services.sesv2.model.DeliveryOptions;
import software.amazon.awssdk.services.sesv2.model.GetAccountRequest;
import software.amazon.awssdk.services.sesv2.model.GetConfigurationSetRequest;
import software.amazon.awssdk.services.sesv2.model.PutAccountDeliveryAttributesRequest;
import software.amazon.awssdk.services.sesv2.model.PutConfigurationSetDeliveryOptionsRequest;
import software.amazon.awssdk.services.sesv2.model.SharedPoolDeliveryMode;
import software.amazon.awssdk.services.sesv2.model.TlsPolicy;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@DisplayName("SES v2 global shared delivery (SharedPoolDeliveryMode)")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@ResourceLock("ses-account")
class SesSharedPoolDeliveryTest {
private static SesV2Client sesV2;
private static SesClient sesV1;
private static AccountSharedPoolDeliveryMode originalMode;
private static String csName;
@BeforeAll
static void setup() {
sesV2 = TestFixtures.sesV2Client();
sesV1 = TestFixtures.sesClient();
// The suite can run against real AWS: remember the account's mode so cleanup restores it.
originalMode = sesV2.getAccount(GetAccountRequest.builder().build())
.deliveryAttributes().sharedPoolDeliveryMode();
csName = "sdk-cs-shared-pool-" + TestFixtures.uniqueName();
}
@AfterAll
static void cleanup() {
if (sesV2 != null) {
try {
sesV2.deleteConfigurationSet(DeleteConfigurationSetRequest.builder()
.configurationSetName(csName).build());
} catch (Exception ignored) {
// The set may never have been created when an earlier step failed.
}
if (originalMode != null) {
sesV2.putAccountDeliveryAttributes(PutAccountDeliveryAttributesRequest.builder()
.sharedPoolDeliveryMode(originalMode).build());
}
sesV2.close();
}
if (sesV1 != null) {
sesV1.close();
}
}
@Test
@Order(1)
@DisplayName("GetAccount reports DeliveryAttributes before it is ever set")
void getAccountReportsDeliveryAttributes() {
assertThat(originalMode).isIn(AccountSharedPoolDeliveryMode.GLOBAL, AccountSharedPoolDeliveryMode.REGIONAL);
}
@Test
@Order(2)
@DisplayName("PutAccountDeliveryAttributes round-trips through GetAccount")
void putAccountDeliveryAttributesRoundTrips() {
for (AccountSharedPoolDeliveryMode mode : new AccountSharedPoolDeliveryMode[] {
AccountSharedPoolDeliveryMode.REGIONAL, AccountSharedPoolDeliveryMode.GLOBAL}) {
sesV2.putAccountDeliveryAttributes(PutAccountDeliveryAttributesRequest.builder()
.sharedPoolDeliveryMode(mode).build());
assertThat(sesV2.getAccount(GetAccountRequest.builder().build())
.deliveryAttributes().sharedPoolDeliveryMode()).isEqualTo(mode);
}
}
@Test
@Order(3)
@DisplayName("PutAccountDeliveryAttributes refuses the configuration-set-only ACCOUNT value")
void putAccountDeliveryAttributesRefusesAccountValue() {
assertThatThrownBy(() -> sesV2.putAccountDeliveryAttributes(PutAccountDeliveryAttributesRequest.builder()
.sharedPoolDeliveryMode("ACCOUNT").build()))
.isInstanceOf(BadRequestException.class);
}
@Test
@Order(4)
@DisplayName("CreateConfigurationSet stores DeliveryOptions.SharedPoolDeliveryMode")
void createConfigurationSetStoresMode() {
sesV2.createConfigurationSet(CreateConfigurationSetRequest.builder()
.configurationSetName(csName)
.deliveryOptions(DeliveryOptions.builder()
.sharedPoolDeliveryMode(SharedPoolDeliveryMode.ACCOUNT).build())
.build());
assertThat(sesV2.getConfigurationSet(GetConfigurationSetRequest.builder()
.configurationSetName(csName).build())
.deliveryOptions().sharedPoolDeliveryMode()).isEqualTo(SharedPoolDeliveryMode.ACCOUNT);
}
@Test
@Order(5)
@DisplayName("PutConfigurationSetDeliveryOptions keeps the mode when the request omits it")
void putDeliveryOptionsKeepsOmittedMode() {
sesV2.putConfigurationSetDeliveryOptions(PutConfigurationSetDeliveryOptionsRequest.builder()
.configurationSetName(csName)
.sharedPoolDeliveryMode(SharedPoolDeliveryMode.REGIONAL)
.build());
sesV2.putConfigurationSetDeliveryOptions(PutConfigurationSetDeliveryOptionsRequest.builder()
.configurationSetName(csName)
.tlsPolicy(TlsPolicy.REQUIRE)
.build());
DeliveryOptions stored = sesV2.getConfigurationSet(GetConfigurationSetRequest.builder()
.configurationSetName(csName).build()).deliveryOptions();
assertThat(stored.tlsPolicy()).isEqualTo(TlsPolicy.REQUIRE);
assertThat(stored.sharedPoolDeliveryMode()).isEqualTo(SharedPoolDeliveryMode.REGIONAL);
}
@Test
@Order(6)
@DisplayName("A v1 PutConfigurationSetDeliveryOptions keeps the mode")
void v1PutDeliveryOptionsKeepsMode() {
// The v1 request and DeliveryOptions types share their names with the imported v2 ones.
sesV1.putConfigurationSetDeliveryOptions(
software.amazon.awssdk.services.ses.model.PutConfigurationSetDeliveryOptionsRequest.builder()
.configurationSetName(csName)
.deliveryOptions(software.amazon.awssdk.services.ses.model.DeliveryOptions.builder()
.tlsPolicy("Optional").build())
.build());
DeliveryOptions stored = sesV2.getConfigurationSet(GetConfigurationSetRequest.builder()
.configurationSetName(csName).build()).deliveryOptions();
assertThat(stored.tlsPolicy()).isEqualTo(TlsPolicy.OPTIONAL);
assertThat(stored.sharedPoolDeliveryMode()).isEqualTo(SharedPoolDeliveryMode.REGIONAL);
}
}
@@ -3,7 +3,6 @@ package com.floci.test;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.signin.SigninClient;
import software.amazon.awssdk.services.signin.model.OAuth2ErrorCode;
import software.amazon.awssdk.services.signin.model.ValidationException;
import static org.assertj.core.api.Assertions.assertThat;
@@ -25,7 +24,10 @@ class SigninTest {
.isInstanceOfSatisfying(ValidationException.class, exception -> {
assertThat(exception.statusCode()).isEqualTo(400);
assertThat(exception.awsErrorDetails().errorCode()).isEqualTo("ValidationException");
assertThat(exception.error()).isEqualTo(OAuth2ErrorCode.INVALID_REQUEST);
// AWS sends "INVALID_REQUEST" (probed in us-west-2, 2026-11-26), while SDK 2.59.7
// maps OAuth2ErrorCode.INVALID_REQUEST to "invalid_request", so error() reads it as
// UNKNOWN_TO_SDK_VERSION against AWS too. Assert the wire value.
assertThat(exception.errorAsString()).isEqualTo("INVALID_REQUEST");
});
}
}
+1 -1
View File
@@ -114,7 +114,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac
| [Resource Groups Tagging API](resource-groups-tagging.md) | `POST /` + `X-Amz-Target: ResourceGroupsTaggingAPI_20170126.*` | JSON 1.1 | 5 |
| [Resource Explorer](resource-explorer.md) | `POST /{OperationName}`, rewritten to `/_re2/*` for the four paths S3 Vectors also claims | REST JSON | 32 |
| [SES](ses.md) | `POST /` with `Action=` param | Query | 70 |
| [SES v2](ses.md#v2) | `/v2/email/*` | REST JSON | 102 |
| [SES v2](ses.md#v2) | `/v2/email/*` | REST JSON | 103 |
| [OpenSearch](opensearch.md) | `/2021-01-01/opensearch/...`, legacy `/2015-01-01/es/...` | REST JSON | 36 |
| [AppConfig](appconfig.md) | `/applications/...`, `/deploymentstrategies/...` | REST JSON | 29 |
| [AppConfigData](appconfig.md#data-plane) | `/configurationsessions`, `/configuration` | REST JSON | 2 |
+3
View File
@@ -429,6 +429,7 @@ Alongside the classic Query API, Floci implements a subset of the SES v2 REST JS
| `PUT` | `/v2/email/reputation/entities/{ReputationEntityType}/{ReputationEntityReference}/customer-managed-status` | `UpdateReputationEntityCustomerManagedStatus` |
| `POST` | `/v2/email/email-address-insights/` | `GetEmailAddressInsights` |
| `POST` | `/v2/email/vdm/recommendations` | `ListRecommendations` |
| `POST` | `/v2/email/account/delivery` | `PutAccountDeliveryAttributes` |
Floci models no leased dedicated IPs: `GetDedicatedIps` is empty and IP-targeted operations return `NotFoundException`, as real AWS does for an account with no leased IPs, with required request members validated first (`BadRequestException`). `PutDedicatedIpPoolScalingAttributes` rejects downgrading a `MANAGED` pool to `STANDARD`, and `PutAccountDedicatedIpWarmupAttributes` stores the flag behind `GetAccount.DedicatedIpAutoWarmupEnabled` (default `true`).
@@ -458,6 +459,8 @@ Account-level VDM (Virtual Deliverability Manager) attributes are stored per reg
Account provisioning details are stored per region. `PutAccountDetails` sets `MailType` (required, ∈ {`MARKETING`, `TRANSACTIONAL`}) and `WebsiteURL` (required, 1–1000 chars) plus the optional `ContactLanguage` (∈ {`EN`, `JA`}), `UseCaseDescription` (≤5000 chars), `AdditionalContactEmailAddresses` (1–4 entries, each 6–254 chars matching `^(.+)@(.+)$`), and `ProductionAccessEnabled`. Floci stores `ProductionAccessEnabled` as given but stays production-enabled regardless (it has no sandbox), so the flag has no functional effect. Like `VdmAttributes`, `GetAccount` omits `Details` until it has been configured for the region, then echoes the stored fields under `Details` with a `ReviewDetails` block. Matching AWS, all modeled-constraint violations (null / enum / length / list) are aggregated into a single `BadRequestException` reporting every failure; a malformed (but in-range) `WebsiteURL` is reported separately as `Url contains invalid format`. Floci has no sandbox and does not run a production-access review, so `ReviewDetails.Status` is always `GRANTED`.
[Global shared delivery](https://docs.aws.amazon.com/ses/latest/dg/global-shared-delivery.html) settings are stored, not acted on: Floci has no shared IP pools to route through. `PutAccountDeliveryAttributes` sets the account's `SharedPoolDeliveryMode` per region, and `GetAccount` always reports it under `DeliveryAttributes`. A region that never set it reads `GLOBAL`, the default AWS gives an account that starts using SES on or after 2026-11-19; an older AWS account reads `REGIONAL`. A configuration set's `DeliveryOptions.SharedPoolDeliveryMode` also takes `ACCOUNT` and is omitted when never set. `PutConfigurationSetDeliveryOptions` replaces the other delivery options but keeps the stored `SharedPoolDeliveryMode` when the request omits it, as the API reference documents, so a v1 `PutConfigurationSetDeliveryOptions`, which has no such member, never clears it.
Tenants (multi-tenancy) are stored per region. `CreateTenant` requires a `TenantName` (1–64 chars, `[A-Za-z0-9_-]`) and accepts optional `Tags`; it returns the tenant with a generated `TenantId` (`tn-` + 30 hex), a `TenantArn` (`arn:aws:ses:<region>:<account>:tenant/<name>/<id>`), a `CreatedTimestamp`, and `SendingStatus` `ENABLED`. The operations use RPC-style POST subpaths (`/tenants/get`, `/tenants/list`, `/tenants/delete`); `ListTenants` returns the `TenantInfo` subset (no `Tags`/`SendingStatus`). A duplicate name is `AlreadyExistsException`; an unknown tenant on get/delete is `NotFoundException`.
Tenant resource associations link a tenant to email identities, configuration sets, and email templates. Matching real AWS, the wire values for `ResourceType` (in responses and as the `Filter` `RESOURCE_TYPE` value) are the ARN segments `identity` / `configuration-set` / `template`; the SDK's `EMAIL_IDENTITY`-style enum constants are rejected, as AWS itself does. The resource must exist in the same account and region; a duplicate association is `AlreadyExistsException`, and deleting a missing one succeeds silently. Deleting a resource that still has associations is rejected, while `DeleteTenant` cascades its associations away.
@@ -79,6 +79,9 @@ public class SesAccountController {
result.put("ProductionAccessEnabled", true);
result.put("SendingEnabled", sendingEnabled);
result.putObject("DeliveryAttributes")
.put("SharedPoolDeliveryMode", accountService.getSharedPoolDeliveryMode(region));
ObjectNode sendQuota = result.putObject("SendQuota");
sendQuota.put("Max24HourSend", 200.0);
sendQuota.put("MaxSendRate", 1.0);
@@ -203,6 +206,21 @@ public class SesAccountController {
}
}
@POST
@Path("/account/delivery")
public Response putAccountDeliveryAttributes(@Context HttpHeaders headers, String body) {
String region = regionResolver.resolveRegion(headers);
try {
JsonNode request = readOptionBody(objectMapper, body);
String mode = stringMemberOrAbsent(request, "SharedPoolDeliveryMode");
accountService.putSharedPoolDeliveryMode(region, mode);
LOG.infov("SES V2 PutAccountDeliveryAttributes: region={0}, mode={1}", region, mode);
return Response.ok(objectMapper.createObjectNode()).build();
} catch (AwsException e) {
throw remapV1Exception(e);
}
}
@PUT
@Path("/account/dedicated-ips/warmup")
public Response putAccountDedicatedIpWarmupAttributes(@Context HttpHeaders headers, String body) {
@@ -24,8 +24,8 @@ import java.util.regex.Pattern;
* split. Reached through the {@code SesService} facade, which delegates here.
*
* <p>Owns the account sending-enabled flag ({@code accountSettingsStore}), the VDM (Virtual
* Deliverability Manager) attributes ({@code accountVdmStore}), and the provisioning details
* ({@code accountDetailsStore}). Account suppression is account-level too, but it shares
* Deliverability Manager) attributes ({@code accountVdmStore}), the provisioning details
* ({@code accountDetailsStore}), and the shared pool delivery mode ({@code accountDeliveryStore}). Account suppression is account-level too, but it shares
* {@code validateSuppressionReason} with the suppression list, so it lives in
* {@link SesSuppressionService} instead.
*/
@@ -37,6 +37,7 @@ public class SesAccountService {
private final StorageBackend<String, Boolean> accountSettingsStore;
private final StorageBackend<String, AccountVdmAttributes> accountVdmStore;
private final StorageBackend<String, AccountDetails> accountDetailsStore;
private final StorageBackend<String, String> accountDeliveryStore;
@Inject
public SesAccountService(StorageFactory storageFactory) {
@@ -46,14 +47,18 @@ public class SesAccountService {
new TypeReference<Map<String, AccountVdmAttributes>>() {});
this.accountDetailsStore = storageFactory.create("ses", "ses-account-details.json",
new TypeReference<Map<String, AccountDetails>>() {});
this.accountDeliveryStore = storageFactory.create("ses", "ses-account-delivery.json",
new TypeReference<Map<String, String>>() {});
}
SesAccountService(StorageBackend<String, Boolean> accountSettingsStore,
StorageBackend<String, AccountVdmAttributes> accountVdmStore,
StorageBackend<String, AccountDetails> accountDetailsStore) {
StorageBackend<String, AccountDetails> accountDetailsStore,
StorageBackend<String, String> accountDeliveryStore) {
this.accountSettingsStore = accountSettingsStore;
this.accountVdmStore = accountVdmStore;
this.accountDetailsStore = accountDetailsStore;
this.accountDeliveryStore = accountDeliveryStore;
}
public boolean isAccountSendingEnabled(String region) {
@@ -83,6 +88,31 @@ public class SesAccountService {
accountSettingsStore.put("dedicatedIpAutoWarmup::" + region, enabled);
}
// GetAccount reports DeliveryAttributes even for a region that never set it (probed 2026-11-25:
// REGIONAL for an account older than the 2026-11-19 launch). The Developer Guide enables global
// shared delivery for accounts that start using SES on or after that date, which every Floci
// account does, so an unset region reads GLOBAL.
public String getSharedPoolDeliveryMode(String region) {
return accountDeliveryStore.get(accountDeliveryKey(region)).orElse(SHARED_POOL_GLOBAL);
}
public void putSharedPoolDeliveryMode(String region, String mode) {
if (mode == null) {
throw SmithyValidationErrors.badRequest(
SmithyValidationErrors.notNullWithoutValue("sharedPoolDeliveryMode"));
}
if (!ACCOUNT_SHARED_POOL_DELIVERY_MODES.contains(mode)) {
throw SmithyValidationErrors.badRequest(constraint("sharedPoolDeliveryMode",
"Member must satisfy enum value set: " + ACCOUNT_SHARED_POOL_DELIVERY_MODES));
}
accountDeliveryStore.put(accountDeliveryKey(region), mode);
LOG.infov("Updated account shared pool delivery mode for region {0}: {1}", region, mode);
}
private static String accountDeliveryKey(String region) {
return "account-delivery::" + region;
}
// 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
@@ -156,6 +186,8 @@ public class SesAccountService {
+ Math.floorMod((region + "::" + mailType + "::" + websiteUrl).hashCode(), 1_000_000_000));
}
private static final String SHARED_POOL_GLOBAL = "GLOBAL";
private static final List<String> ACCOUNT_SHARED_POOL_DELIVERY_MODES = List.of(SHARED_POOL_GLOBAL, "REGIONAL");
private static final Set<String> MAIL_TYPES = Set.of("MARKETING", "TRANSACTIONAL");
private static final Set<String> CONTACT_LANGUAGES = Set.of("EN", "JA");
// Modeled constraint bounds (from the SES v2 SDK model, probe-confirmed against real AWS).
@@ -448,7 +448,9 @@ public class SesConfigurationSetController {
}
d.setMaxDeliverySeconds(max.asLong());
}
if (d.getTlsPolicy() == null && d.getSendingPoolName() == null && d.getMaxDeliverySeconds() == null) {
d.setSharedPoolDeliveryMode(stringMemberOrAbsent(node, "SharedPoolDeliveryMode"));
if (d.getTlsPolicy() == null && d.getSendingPoolName() == null && d.getMaxDeliverySeconds() == null
&& d.getSharedPoolDeliveryMode() == null) {
return null;
}
return d;
@@ -221,6 +221,7 @@ public class SesConfigurationSetService implements SesTaggable {
private static final Set<String> HTTPS_POLICIES =
Set.of("REQUIRE", "REQUIRE_OPEN_ONLY", "OPTIONAL");
private static final Set<String> TLS_POLICIES = Set.of("REQUIRE", "OPTIONAL");
private static final List<String> SHARED_POOL_DELIVERY_MODES = List.of("GLOBAL", "REGIONAL", "ACCOUNT");
void validateTrackingOptions(TrackingOptions options, Predicate<String> verifiedDomainIdentity) {
@@ -259,6 +260,13 @@ public class SesConfigurationSetService implements SesTaggable {
"Value at 'tlsPolicy' failed to satisfy constraint: "
+ "Member must satisfy enum value set: [OPTIONAL, REQUIRE]");
}
// The value order follows the model; AWS's own order for this enum is unprobed.
if (options.getSharedPoolDeliveryMode() != null
&& !SHARED_POOL_DELIVERY_MODES.contains(options.getSharedPoolDeliveryMode())) {
throw SmithyValidationErrors.badRequest(
"Value at 'sharedPoolDeliveryMode' failed to satisfy constraint: "
+ "Member must satisfy enum value set: " + SHARED_POOL_DELIVERY_MODES);
}
// AWS rejects a blank SendingPoolName outright, and a non-existent
// dedicated IP pool (both verified against real AWS 2026-06-17). The
// pool must have been created via CreateDedicatedIpPool.
@@ -315,16 +323,30 @@ public class SesConfigurationSetService implements SesTaggable {
LOG.infov("Updated TrackingOptions on configuration set {0} in region {1}", configSetName, region);
}
/** v2 PutConfigurationSetDeliveryOptions: validated replace of the delivery options. */
/**
* v1 and v2 PutConfigurationSetDeliveryOptions: validated replace of the delivery options,
* except that an omitted SharedPoolDeliveryMode keeps the stored one, as the v2 model documents.
* v1 has no such member, so a v1 write never clears it.
*/
public void setDeliveryOptions(String configSetName, DeliveryOptions options, String region,
Predicate<String> dedicatedIpPoolExists) {
ConfigurationSet cs = get(configSetName, region);
validateDeliveryOptions(options, dedicatedIpPoolExists);
cs.setDeliveryOptions(options);
cs.setDeliveryOptions(keepSharedPoolDeliveryMode(options, cs.getDeliveryOptions()));
save(cs, region);
LOG.infov("Updated DeliveryOptions on configuration set {0} in region {1}", configSetName, region);
}
private static DeliveryOptions keepSharedPoolDeliveryMode(DeliveryOptions options, DeliveryOptions stored) {
if (stored == null || stored.getSharedPoolDeliveryMode() == null
|| (options != null && options.getSharedPoolDeliveryMode() != null)) {
return options;
}
DeliveryOptions merged = options != null ? options : new DeliveryOptions();
merged.setSharedPoolDeliveryMode(stored.getSharedPoolDeliveryMode());
return merged;
}
/** v1 CreateConfigurationSetTrackingOptions: rejects a set that already has a redirect domain. */
public void createTrackingOptions(String configSetName, String customRedirectDomain, String region,
Predicate<String> verifiedDomainIdentity) {
@@ -8,7 +8,7 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
/**
* Per-configuration-set delivery override. Mirrors the AWS SES V2
* {@code DeliveryOptions} shape: the TLS policy, an optional dedicated-IP
* sending pool, and the maximum delivery time.
* sending pool, the maximum delivery time, and the shared pool delivery mode.
*/
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -24,6 +24,9 @@ public class DeliveryOptions {
@JsonProperty("MaxDeliverySeconds")
private Long maxDeliverySeconds;
@JsonProperty("SharedPoolDeliveryMode")
private String sharedPoolDeliveryMode;
public DeliveryOptions() {}
public String getTlsPolicy() { return tlsPolicy; }
@@ -34,4 +37,9 @@ public class DeliveryOptions {
public Long getMaxDeliverySeconds() { return maxDeliverySeconds; }
public void setMaxDeliverySeconds(Long maxDeliverySeconds) { this.maxDeliverySeconds = maxDeliverySeconds; }
public String getSharedPoolDeliveryMode() { return sharedPoolDeliveryMode; }
public void setSharedPoolDeliveryMode(String sharedPoolDeliveryMode) {
this.sharedPoolDeliveryMode = sharedPoolDeliveryMode;
}
}
@@ -64,6 +64,22 @@ class SesV2IamEnforcementIntegrationTest {
assertAccessDenied(getAccount(accessKeyId));
}
@Test
void aDeniedAccountDeliveryWriteLeavesTheModeUnchanged() {
String accessKeyId = userWithPolicy("""
{"Version":"2012-10-17","Statement":[
{"Effect":"Allow","Action":"*","Resource":"*"},
{"Effect":"Deny","Action":"ses:PutAccountDeliveryAttributes","Resource":"*"}]}""");
assertAccessDenied(given()
.contentType("application/json")
.header("Authorization", auth(accessKeyId, "ses"))
.body("{\"SharedPoolDeliveryMode\":\"REGIONAL\"}")
.when().post("/v2/email/account/delivery"));
getAccount(accessKeyId).then().statusCode(200)
.body("DeliveryAttributes.SharedPoolDeliveryMode", equalTo("GLOBAL"));
}
@Test
void aTargetHeaderDoesNotChangeTheActionARestCallIsCheckedAs() {
String accessKeyId = userWithPolicy("""
@@ -27,7 +27,8 @@ class SesAccountServiceTest {
@BeforeEach
void setUp() {
service = new SesAccountService(new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>());
service = new SesAccountService(new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
new InMemoryStorage<>());
}
@Test
@@ -50,6 +51,28 @@ class SesAccountServiceTest {
assertTrue(service.isAccountSendingEnabled("eu-west-1"));
}
@Test
void sharedPoolDeliveryMode_defaultsGlobal_thenRoundTripsPerRegion() {
assertEquals("GLOBAL", service.getSharedPoolDeliveryMode(REGION));
service.putSharedPoolDeliveryMode(REGION, "REGIONAL");
assertEquals("REGIONAL", service.getSharedPoolDeliveryMode(REGION));
assertEquals("GLOBAL", service.getSharedPoolDeliveryMode("eu-west-1"));
}
@Test
void putSharedPoolDeliveryMode_rejectsMissingAndConfigurationSetOnlyValues() {
AwsException missing = assertThrows(AwsException.class,
() -> service.putSharedPoolDeliveryMode(REGION, null));
assertTrue(missing.getMessage().contains("'sharedPoolDeliveryMode' failed to satisfy constraint: "
+ "Member must not be null"));
AwsException account = assertThrows(AwsException.class,
() -> service.putSharedPoolDeliveryMode(REGION, "ACCOUNT"));
assertTrue(account.getMessage().contains("enum value set: [GLOBAL, REGIONAL]"));
assertEquals("GLOBAL", service.getSharedPoolDeliveryMode(REGION));
}
@Test
void vdmAttributes_absentUntilConfigured_thenRoundTrip() {
// Opt-in: a never-configured region has no VdmAttributes at all.
@@ -157,6 +157,55 @@ class SesConfigurationSetServiceTest {
service.validateTrackingOptions(null, domain -> { throw new AssertionError("not called"); });
}
@Test
void setDeliveryOptions_omittedSharedPoolDeliveryModeKeepsStoredValue() {
service.create(cs("my-cs"), REGION);
DeliveryOptions regional = new DeliveryOptions();
regional.setSharedPoolDeliveryMode("REGIONAL");
regional.setTlsPolicy("REQUIRE");
service.setDeliveryOptions("my-cs", regional, REGION, pool -> true);
DeliveryOptions tlsOnly = new DeliveryOptions();
tlsOnly.setTlsPolicy("OPTIONAL");
service.setDeliveryOptions("my-cs", tlsOnly, REGION, pool -> true);
DeliveryOptions stored = service.get("my-cs", REGION).getDeliveryOptions();
assertEquals("OPTIONAL", stored.getTlsPolicy());
assertEquals("REGIONAL", stored.getSharedPoolDeliveryMode());
service.setDeliveryOptions("my-cs", null, REGION, pool -> true);
stored = service.get("my-cs", REGION).getDeliveryOptions();
assertNull(stored.getTlsPolicy());
assertEquals("REGIONAL", stored.getSharedPoolDeliveryMode());
DeliveryOptions global = new DeliveryOptions();
global.setSharedPoolDeliveryMode("GLOBAL");
service.setDeliveryOptions("my-cs", global, REGION, pool -> true);
assertEquals("GLOBAL", service.get("my-cs", REGION).getDeliveryOptions().getSharedPoolDeliveryMode());
}
@Test
void setDeliveryOptions_withoutStoredModeClearsAsBefore() {
service.create(cs("my-cs"), REGION);
DeliveryOptions tls = new DeliveryOptions();
tls.setTlsPolicy("REQUIRE");
service.setDeliveryOptions("my-cs", tls, REGION, pool -> true);
service.setDeliveryOptions("my-cs", null, REGION, pool -> true);
assertNull(service.get("my-cs", REGION).getDeliveryOptions());
}
@Test
void validateDeliveryOptions_rejectsUnknownSharedPoolDeliveryMode() {
DeliveryOptions bad = new DeliveryOptions();
bad.setSharedPoolDeliveryMode("EVERYWHERE");
assertTrue(assertThrows(AwsException.class, () -> service.validateDeliveryOptions(bad, pool -> true))
.getMessage().contains("enum value set: [GLOBAL, REGIONAL, ACCOUNT]"));
DeliveryOptions account = new DeliveryOptions();
account.setSharedPoolDeliveryMode("ACCOUNT");
service.validateDeliveryOptions(account, pool -> true);
}
@Test
void validateDeliveryOptions_orderAndPredicate() {
DeliveryOptions badTls = new DeliveryOptions();
@@ -78,7 +78,8 @@ class SesIdentityRoute53ScanTest {
void recommendationsReadNoZonesWithoutAVerifiedDomain() {
identities.save(new Identity("alice@example.com", "EmailAddress"), REGION);
SesAccountService accounts =
new SesAccountService(new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>());
new SesAccountService(new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
new InMemoryStorage<>());
accounts.putAccountVdmAttributes(REGION, new AccountVdmAttributes(true, false, false));
SesRecommendationService recommendations = new SesRecommendationService(identities, accounts,
new RegionResolver(REGION, "000000000000"), new MutableClock());
@@ -37,7 +37,8 @@ class SesRecommendationServiceTest {
clock = new MutableClock();
// No Route53, so no domain has DMARC or BIMI records.
identities = new SesIdentityService(new InMemoryStorage<>(), null, clock);
accounts = new SesAccountService(new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>());
accounts = new SesAccountService(new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
new InMemoryStorage<>());
accounts.putAccountVdmAttributes(REGION, new AccountVdmAttributes(true, false, false));
service = new SesRecommendationService(identities, accounts, new RegionResolver(REGION, ACCOUNT), clock);
}
@@ -66,7 +66,8 @@ final class SesServiceTestBuilder {
private SesSentEmailService sentEmailService;
private SesIdentityCertificateService certificateService;
private final SesAccountService accountService =
new SesAccountService(new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>());
new SesAccountService(new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
new InMemoryStorage<>());
static SesServiceTestBuilder create() {
return new SesServiceTestBuilder();
@@ -0,0 +1,177 @@
package io.floci.aws.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 java.util.Map;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.not;
/**
* Global shared delivery: {@code PutAccountDeliveryAttributes} with the {@code GetAccount}
* {@code DeliveryAttributes} round-trip, and the configuration set's
* {@code DeliveryOptions.SharedPoolDeliveryMode}.
*/
@QuarkusTest
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class SesSharedPoolDeliveryV2IntegrationTest {
private static final String AUTH = SesV2Requests.authFor("eu-south-2");
private static final String OTHER_REGION_AUTH = SesV2Requests.authFor("me-central-1");
@Test
@Order(0)
void getAccount_unsetRegionReportsGlobal() {
// AWS reports DeliveryAttributes before it is ever set; an account new since the 2026-11-19
// launch starts on GLOBAL.
given().header("Authorization", AUTH)
.when().get("/v2/email/account").then().statusCode(200)
.body("DeliveryAttributes.SharedPoolDeliveryMode", equalTo("GLOBAL"));
}
@Test
@Order(1)
void putAccountDeliveryAttributes_roundTripsPerRegion() {
v2(AUTH)
.body("{\"SharedPoolDeliveryMode\":\"REGIONAL\"}")
.when().post("/v2/email/account/delivery").then().statusCode(200)
.body("$", equalTo(Map.of()));
given().header("Authorization", AUTH)
.when().get("/v2/email/account").then().statusCode(200)
.body("DeliveryAttributes.SharedPoolDeliveryMode", equalTo("REGIONAL"));
given().header("Authorization", OTHER_REGION_AUTH)
.when().get("/v2/email/account").then().statusCode(200)
.body("DeliveryAttributes.SharedPoolDeliveryMode", equalTo("GLOBAL"));
}
@Test
@Order(2)
void putAccountDeliveryAttributes_missingMode_returns400() {
v2(AUTH)
.body("{}")
.when().post("/v2/email/account/delivery").then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
.body("message", equalTo("1 validation error detected: Value at 'sharedPoolDeliveryMode' "
+ "failed to satisfy constraint: Member must not be null"));
}
@Test
@Order(3)
void putAccountDeliveryAttributes_accountValueIsConfigurationSetOnly() {
v2(AUTH)
.body("{\"SharedPoolDeliveryMode\":\"ACCOUNT\"}")
.when().post("/v2/email/account/delivery").then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
.body("message", equalTo("1 validation error detected: Value at 'sharedPoolDeliveryMode' "
+ "failed to satisfy constraint: Member must satisfy enum value set: [GLOBAL, REGIONAL]"));
}
@Test
@Order(4)
void putAccountDeliveryAttributes_nonStringMode_returnsSerializationException() {
v2(AUTH)
.body("{\"SharedPoolDeliveryMode\":1}")
.when().post("/v2/email/account/delivery").then().statusCode(400)
.body("__type", equalTo("SerializationException"));
}
@Test
@Order(10)
void createConfigurationSet_storesMode() {
v2(AUTH)
.body("{\"ConfigurationSetName\":\"spd-create\","
+ "\"DeliveryOptions\":{\"SharedPoolDeliveryMode\":\"ACCOUNT\"}}")
.when().post("/v2/email/configuration-sets").then().statusCode(200);
given().header("Authorization", AUTH)
.when().get("/v2/email/configuration-sets/spd-create").then().statusCode(200)
.body("DeliveryOptions.SharedPoolDeliveryMode", equalTo("ACCOUNT"));
}
@Test
@Order(11)
void createConfigurationSet_withoutMode_omitsIt() {
v2(AUTH)
.body("{\"ConfigurationSetName\":\"spd-none\",\"DeliveryOptions\":{\"TlsPolicy\":\"REQUIRE\"}}")
.when().post("/v2/email/configuration-sets").then().statusCode(200);
given().header("Authorization", AUTH)
.when().get("/v2/email/configuration-sets/spd-none").then().statusCode(200)
.body("DeliveryOptions", not(hasKey("SharedPoolDeliveryMode")));
}
@Test
@Order(12)
void putDeliveryOptions_omittedModeKeepsStoredValue() {
v2(AUTH)
.body("{\"SharedPoolDeliveryMode\":\"REGIONAL\",\"TlsPolicy\":\"REQUIRE\"}")
.when().put("/v2/email/configuration-sets/spd-create/delivery-options").then().statusCode(200);
v2(AUTH)
.body("{\"TlsPolicy\":\"OPTIONAL\"}")
.when().put("/v2/email/configuration-sets/spd-create/delivery-options").then().statusCode(200);
given().header("Authorization", AUTH)
.when().get("/v2/email/configuration-sets/spd-create").then().statusCode(200)
.body("DeliveryOptions.TlsPolicy", equalTo("OPTIONAL"))
.body("DeliveryOptions.SharedPoolDeliveryMode", equalTo("REGIONAL"));
}
@Test
@Order(13)
void putDeliveryOptions_emptyBodyKeepsOnlyTheMode() {
v2(AUTH)
.body("{}")
.when().put("/v2/email/configuration-sets/spd-create/delivery-options").then().statusCode(200);
given().header("Authorization", AUTH)
.when().get("/v2/email/configuration-sets/spd-create").then().statusCode(200)
.body("DeliveryOptions", not(hasKey("TlsPolicy")))
.body("DeliveryOptions.SharedPoolDeliveryMode", equalTo("REGIONAL"));
}
@Test
@Order(14)
void putDeliveryOptions_v1WriteKeepsTheMode() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "PutConfigurationSetDeliveryOptions")
.formParam("ConfigurationSetName", "spd-create")
.formParam("DeliveryOptions.TlsPolicy", "Require")
.when().post("/").then().statusCode(200);
given().header("Authorization", AUTH)
.when().get("/v2/email/configuration-sets/spd-create").then().statusCode(200)
.body("DeliveryOptions.TlsPolicy", equalTo("REQUIRE"))
.body("DeliveryOptions.SharedPoolDeliveryMode", equalTo("REGIONAL"));
}
@Test
@Order(16)
void putDeliveryOptions_nonStringMode_returnsSerializationException() {
v2(AUTH)
.body("{\"SharedPoolDeliveryMode\":1}")
.when().put("/v2/email/configuration-sets/spd-create/delivery-options").then().statusCode(400)
.body("__type", equalTo("SerializationException"));
}
@Test
@Order(15)
void putDeliveryOptions_invalidMode_returns400() {
v2(AUTH)
.body("{\"SharedPoolDeliveryMode\":\"EVERYWHERE\"}")
.when().put("/v2/email/configuration-sets/spd-create/delivery-options").then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
.body("message", equalTo("1 validation error detected: Value at 'sharedPoolDeliveryMode' "
+ "failed to satisfy constraint: "
+ "Member must satisfy enum value set: [GLOBAL, REGIONAL, ACCOUNT]"));
}
}
@@ -35,6 +35,7 @@ class SesV2BodyReadIntegrationTest {
Arguments.of("POST", "/v2/email/contact-lists"),
Arguments.of("POST", "/v2/email/contact-lists/body-read-ghost/contacts/list"),
Arguments.of("POST", "/v2/email/account/details"),
Arguments.of("POST", "/v2/email/account/delivery"),
Arguments.of("PUT", IDENTITY + "/dkim/signing"),
Arguments.of("PUT", IDENTITY + "/configuration-set"),
Arguments.of("PUT", IDENTITY + "/mail-from"),