feat(ses): support V1 ConfigurationSetEventDestination CRUD (#1111)

V2 SES already exposes ConfigurationSet event-destination CRUD via
REST JSON; this PR adds the matching V1 Query actions
(CreateConfigurationSetEventDestination /
UpdateConfigurationSetEventDestination /
DeleteConfigurationSetEventDestination) and extends
DescribeConfigurationSet so V1 callers can round-trip their stored
destinations. The service layer (`SesService.createConfigurationSetEventDestination`
etc.) already had the persistence and validation logic, so most of the
work is wire-format: parse V1 Query parameter shapes, render V1 XML
responses, and route the new action names.

- SesQueryHandler: three new Query actions plus
  `readEventDestination(params, prefix)` and `writeEventDestination`
  helpers. V1 wire field names use uppercase `ARN` / `NS` suffix
  variants (`SNSDestination.TopicARN`,
  `KinesisFirehoseDestination.IAMRoleARN` / `DeliveryStreamARN`,
  `CloudWatchDestination.DimensionConfigurations.member.N`) which are
  mapped onto the existing model classes; the `EventDestination.Enabled`
  default mirrors the V2 primitive-boolean default of `false` when
  omitted.
- V1 event-type wire forms are lowercase camelCase (`send`,
  `complaint`, `renderingFailure`) while floci stores the V2 canonical
  form (SCREAMING_SNAKE). New `V1_EVENT_TYPE_TO_INTERNAL` /
  `INTERNAL_EVENT_TYPE_TO_V1` maps translate in both directions; unknown
  values pass through so the existing validate-against-VALID_EVENT_TYPES
  check still catches typos.
- `handleDescribeConfigurationSet`: when
  `ConfigurationSetAttributeNames.member.N=eventDestinations` is
  requested, render the stored event destinations as a V1 XML block.
  Treat a null `ConfigurationSet.eventDestinations` list as empty when
  rendering, so a corrupted persisted JSON with `"EventDestinations": null`
  still produces an empty `<EventDestinations/>` container rather than
  NPE-ing. Other ConfigurationSet attribute names (trackingOptions,
  deliveryOptions, reputationOptions) remain unsupported and are
  silently ignored — they will land with their respective Put*Options
  PRs. The container is emitted even when the destination list is
  empty so the response depends only on the requested attributes.
- `writeEventDestination`: skip destination blocks when required fields
  are blank (defensive belt-and-suspenders for any legacy state) and
  filter incomplete CloudWatch dimension members so partial members
  don't leak into the XML.
- `SesService.validateEventDestination`: centralize required-field
  validation for SNS / Firehose / CloudWatch dimensions, so both V1
  and V2 reject partial destinations at create/update time. Members
  with missing required fields now fail with a 400
  `InvalidParameterValue` carrying the offending member index.
- `AwsQueryController.SES_ACTIONS`: include the three new actions in
  the action-name → "email" service routing fallback so SigV4 requests
  whose credential scope doesn't pin the service still reach SES.

Tests
- `SesConfigurationSetEventDestinationV1IntegrationTest`: 15 cases
  covering create / describe-with-attribute / describe-without-attribute
  / describe-empty-attribute / duplicate / update / update-unknown /
  delete / delete-unknown / partial Firehose / partial CloudWatch dim
  / blank SNS TopicARN / action-name routing fallback when the
  Authorization header is absent.
- `SesServiceEventDestinationTest`: 8 new unit cases for the
  centralized SNS / Firehose / CloudWatch dim validation, exercising
  validateEventDestination directly.
- `compatibility-tests/sdk-test-java SesConfigurationSetEventDestinationTest`:
  extended to drive both V1 (SesClient) and V2 (SesV2Client) against a
  live Floci. Each protocol gets its own config set; nine new V1 tests
  mirror the V2 lifecycle plus partial-Firehose rejection.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-06-02 00:14:53 -05:00
1 parent 35211adc4a
commit 2c9e0bce7c
6 files changed
+921 -50

No files matched your search

@@ -9,6 +9,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.services.ses.SesClient;
import software.amazon.awssdk.services.sesv2.SesV2Client;
import software.amazon.awssdk.services.sesv2.model.CreateConfigurationSetEventDestinationRequest;
import software.amazon.awssdk.services.sesv2.model.CreateConfigurationSetRequest;
@@ -25,52 +26,77 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* SES V2 ConfigurationSet event destination compatibility tests using the
* real AWS SDK for Java v2 (SesV2Client) against a live Floci instance.
* SES ConfigurationSet event destination compatibility tests against both the
* V1 (query) SES API via {@link SesClient} and the V2 (REST JSON) SESv2 API via
* {@link SesV2Client}. Each protocol gets its own configuration set so V1 and V2
* tests don't fight each other; the orderings within each cluster mirror the
* AWS create / describe / duplicate / update / delete lifecycle.
*/
@DisplayName("SES Configuration Set Event Destinations")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class SesConfigurationSetEventDestinationTest {
private static SesV2Client ses;
private static String csName;
private static SesClient sesV1;
private static SesV2Client sesV2;
private static String v1CsName;
private static String v2CsName;
private static final String ED_NAME = "ed-sns";
private static final String TOPIC_ARN = "arn:aws:sns:us-east-1:000000000000:ses-events";
private static final String TOPIC_ARN_2 = "arn:aws:sns:us-east-1:000000000000:ses-events-2";
@BeforeAll
static void setup() {
ses = TestFixtures.sesV2Client();
csName = "sdk-ed-cs-" + TestFixtures.uniqueName();
ses.createConfigurationSet(CreateConfigurationSetRequest.builder()
.configurationSetName(csName)
sesV1 = TestFixtures.sesClient();
sesV2 = TestFixtures.sesV2Client();
String suffix = TestFixtures.uniqueName();
v1CsName = "sdk-v1-ed-cs-" + suffix;
v2CsName = "sdk-v2-ed-cs-" + suffix;
sesV1.createConfigurationSet(software.amazon.awssdk.services.ses.model.CreateConfigurationSetRequest.builder()
.configurationSet(b -> b.name(v1CsName))
.build());
sesV2.createConfigurationSet(CreateConfigurationSetRequest.builder()
.configurationSetName(v2CsName)
.build());
}
@AfterAll
static void cleanup() {
if (ses == null) {
return;
if (sesV2 != null) {
try {
sesV2.deleteConfigurationSetEventDestination(DeleteConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v2CsName)
.eventDestinationName(ED_NAME)
.build());
} catch (Exception ignored) {}
try {
sesV2.deleteConfigurationSet(DeleteConfigurationSetRequest.builder()
.configurationSetName(v2CsName)
.build());
} catch (Exception ignored) {}
sesV2.close();
}
if (sesV1 != null) {
try {
sesV1.deleteConfigurationSetEventDestination(
software.amazon.awssdk.services.ses.model.DeleteConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v1CsName)
.eventDestinationName(ED_NAME)
.build());
} catch (Exception ignored) {}
try {
sesV1.deleteConfigurationSet(software.amazon.awssdk.services.ses.model.DeleteConfigurationSetRequest.builder()
.configurationSetName(v1CsName)
.build());
} catch (Exception ignored) {}
sesV1.close();
}
try {
ses.deleteConfigurationSetEventDestination(DeleteConfigurationSetEventDestinationRequest.builder()
.configurationSetName(csName)
.eventDestinationName(ED_NAME)
.build());
} catch (Exception ignored) {}
try {
ses.deleteConfigurationSet(DeleteConfigurationSetRequest.builder()
.configurationSetName(csName)
.build());
} catch (Exception ignored) {}
ses.close();
}
@Test
@Order(1)
void createEventDestination() {
ses.createConfigurationSetEventDestination(CreateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(csName)
sesV2.createConfigurationSetEventDestination(CreateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v2CsName)
.eventDestinationName(ED_NAME)
.eventDestination(EventDestinationDefinition.builder()
.enabled(true)
@@ -84,8 +110,8 @@ class SesConfigurationSetEventDestinationTest {
@Order(2)
void getEventDestinationsReturnsRoundTrip() {
GetConfigurationSetEventDestinationsResponse response =
ses.getConfigurationSetEventDestinations(GetConfigurationSetEventDestinationsRequest.builder()
.configurationSetName(csName)
sesV2.getConfigurationSetEventDestinations(GetConfigurationSetEventDestinationsRequest.builder()
.configurationSetName(v2CsName)
.build());
assertThat(response.eventDestinations()).hasSize(1);
@@ -99,9 +125,9 @@ class SesConfigurationSetEventDestinationTest {
@Test
@Order(3)
void createDuplicateRejectedWith400() {
assertThatThrownBy(() -> ses.createConfigurationSetEventDestination(
assertThatThrownBy(() -> sesV2.createConfigurationSetEventDestination(
CreateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(csName)
.configurationSetName(v2CsName)
.eventDestinationName(ED_NAME)
.eventDestination(EventDestinationDefinition.builder()
.matchingEventTypes(EventType.SEND)
@@ -116,8 +142,8 @@ class SesConfigurationSetEventDestinationTest {
@Test
@Order(4)
void updateReplacesDefinition() {
ses.updateConfigurationSetEventDestination(UpdateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(csName)
sesV2.updateConfigurationSetEventDestination(UpdateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v2CsName)
.eventDestinationName(ED_NAME)
.eventDestination(EventDestinationDefinition.builder()
.enabled(false)
@@ -127,8 +153,8 @@ class SesConfigurationSetEventDestinationTest {
.build());
GetConfigurationSetEventDestinationsResponse response =
ses.getConfigurationSetEventDestinations(GetConfigurationSetEventDestinationsRequest.builder()
.configurationSetName(csName)
sesV2.getConfigurationSetEventDestinations(GetConfigurationSetEventDestinationsRequest.builder()
.configurationSetName(v2CsName)
.build());
assertThat(response.eventDestinations()).hasSize(1);
assertThat(response.eventDestinations().get(0).enabled()).isFalse();
@@ -139,9 +165,9 @@ class SesConfigurationSetEventDestinationTest {
@Test
@Order(5)
void updateUnknownReturns404() {
assertThatThrownBy(() -> ses.updateConfigurationSetEventDestination(
assertThatThrownBy(() -> sesV2.updateConfigurationSetEventDestination(
UpdateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(csName)
.configurationSetName(v2CsName)
.eventDestinationName("ed-ghost")
.eventDestination(EventDestinationDefinition.builder()
.matchingEventTypes(EventType.SEND)
@@ -156,14 +182,14 @@ class SesConfigurationSetEventDestinationTest {
@Test
@Order(6)
void deleteEventDestination() {
ses.deleteConfigurationSetEventDestination(DeleteConfigurationSetEventDestinationRequest.builder()
.configurationSetName(csName)
sesV2.deleteConfigurationSetEventDestination(DeleteConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v2CsName)
.eventDestinationName(ED_NAME)
.build());
GetConfigurationSetEventDestinationsResponse response =
ses.getConfigurationSetEventDestinations(GetConfigurationSetEventDestinationsRequest.builder()
.configurationSetName(csName)
sesV2.getConfigurationSetEventDestinations(GetConfigurationSetEventDestinationsRequest.builder()
.configurationSetName(v2CsName)
.build());
assertThat(response.eventDestinations()).isEmpty();
}
@@ -171,9 +197,9 @@ class SesConfigurationSetEventDestinationTest {
@Test
@Order(7)
void deleteUnknownReturns404() {
assertThatThrownBy(() -> ses.deleteConfigurationSetEventDestination(
assertThatThrownBy(() -> sesV2.deleteConfigurationSetEventDestination(
DeleteConfigurationSetEventDestinationRequest.builder()
.configurationSetName(csName)
.configurationSetName(v2CsName)
.eventDestinationName("ed-ghost")
.build()))
.isInstanceOf(AwsServiceException.class)
@@ -184,7 +210,7 @@ class SesConfigurationSetEventDestinationTest {
@Test
@Order(8)
void createOnUnknownConfigSetReturns404() {
assertThatThrownBy(() -> ses.createConfigurationSetEventDestination(
assertThatThrownBy(() -> sesV2.createConfigurationSetEventDestination(
CreateConfigurationSetEventDestinationRequest.builder()
.configurationSetName("sdk-ed-cs-missing-" + System.currentTimeMillis())
.eventDestinationName("ed-x")
@@ -197,4 +223,175 @@ class SesConfigurationSetEventDestinationTest {
.extracting(e -> ((AwsServiceException) e).statusCode())
.isEqualTo(404);
}
// ─────────────────────────── V1 (Query/XML) ───────────────────────────
@Test
@Order(10)
void v1_createEventDestination() {
sesV1.createConfigurationSetEventDestination(
software.amazon.awssdk.services.ses.model.CreateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v1CsName)
.eventDestination(software.amazon.awssdk.services.ses.model.EventDestination.builder()
.name(ED_NAME)
.enabled(true)
.matchingEventTypes(
software.amazon.awssdk.services.ses.model.EventType.SEND,
software.amazon.awssdk.services.ses.model.EventType.BOUNCE)
.snsDestination(software.amazon.awssdk.services.ses.model.SNSDestination.builder()
.topicARN(TOPIC_ARN)
.build())
.build())
.build());
}
@Test
@Order(11)
void v1_describeConfigurationSet_withEventDestinationsAttribute_returnsRoundTrip() {
software.amazon.awssdk.services.ses.model.DescribeConfigurationSetResponse resp =
sesV1.describeConfigurationSet(
software.amazon.awssdk.services.ses.model.DescribeConfigurationSetRequest.builder()
.configurationSetName(v1CsName)
.configurationSetAttributeNames(
software.amazon.awssdk.services.ses.model.ConfigurationSetAttribute.EVENT_DESTINATIONS)
.build());
assertThat(resp.eventDestinations()).hasSize(1);
software.amazon.awssdk.services.ses.model.EventDestination ed = resp.eventDestinations().get(0);
assertThat(ed.name()).isEqualTo(ED_NAME);
assertThat(ed.enabled()).isTrue();
assertThat(ed.matchingEventTypes()).contains(
software.amazon.awssdk.services.ses.model.EventType.SEND,
software.amazon.awssdk.services.ses.model.EventType.BOUNCE);
assertThat(ed.snsDestination()).isNotNull();
assertThat(ed.snsDestination().topicARN()).isEqualTo(TOPIC_ARN);
}
@Test
@Order(12)
void v1_describeConfigurationSet_withoutEventDestinationsAttribute_returnsEmptyList() {
software.amazon.awssdk.services.ses.model.DescribeConfigurationSetResponse resp =
sesV1.describeConfigurationSet(
software.amazon.awssdk.services.ses.model.DescribeConfigurationSetRequest.builder()
.configurationSetName(v1CsName)
.build());
assertThat(resp.eventDestinations()).isEmpty();
}
@Test
@Order(13)
void v1_createDuplicateRejected() {
assertThatThrownBy(() -> sesV1.createConfigurationSetEventDestination(
software.amazon.awssdk.services.ses.model.CreateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v1CsName)
.eventDestination(software.amazon.awssdk.services.ses.model.EventDestination.builder()
.name(ED_NAME)
.enabled(true)
.matchingEventTypes(software.amazon.awssdk.services.ses.model.EventType.SEND)
.snsDestination(software.amazon.awssdk.services.ses.model.SNSDestination.builder()
.topicARN(TOPIC_ARN)
.build())
.build())
.build()))
.isInstanceOf(AwsServiceException.class)
.extracting(e -> ((AwsServiceException) e).awsErrorDetails().errorCode())
.isEqualTo("AlreadyExists");
}
@Test
@Order(14)
void v1_updateReplacesDefinition() {
sesV1.updateConfigurationSetEventDestination(
software.amazon.awssdk.services.ses.model.UpdateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v1CsName)
.eventDestination(software.amazon.awssdk.services.ses.model.EventDestination.builder()
.name(ED_NAME)
.enabled(false)
.matchingEventTypes(software.amazon.awssdk.services.ses.model.EventType.COMPLAINT)
.snsDestination(software.amazon.awssdk.services.ses.model.SNSDestination.builder()
.topicARN(TOPIC_ARN_2)
.build())
.build())
.build());
software.amazon.awssdk.services.ses.model.DescribeConfigurationSetResponse resp =
sesV1.describeConfigurationSet(
software.amazon.awssdk.services.ses.model.DescribeConfigurationSetRequest.builder()
.configurationSetName(v1CsName)
.configurationSetAttributeNames(
software.amazon.awssdk.services.ses.model.ConfigurationSetAttribute.EVENT_DESTINATIONS)
.build());
software.amazon.awssdk.services.ses.model.EventDestination ed = resp.eventDestinations().get(0);
assertThat(ed.enabled()).isFalse();
assertThat(ed.matchingEventTypes())
.containsExactly(software.amazon.awssdk.services.ses.model.EventType.COMPLAINT);
assertThat(ed.snsDestination().topicARN()).isEqualTo(TOPIC_ARN_2);
}
@Test
@Order(15)
void v1_updateUnknown_throws() {
assertThatThrownBy(() -> sesV1.updateConfigurationSetEventDestination(
software.amazon.awssdk.services.ses.model.UpdateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v1CsName)
.eventDestination(software.amazon.awssdk.services.ses.model.EventDestination.builder()
.name("ed-ghost")
.enabled(true)
.matchingEventTypes(software.amazon.awssdk.services.ses.model.EventType.SEND)
.snsDestination(software.amazon.awssdk.services.ses.model.SNSDestination.builder()
.topicARN(TOPIC_ARN)
.build())
.build())
.build()))
.isInstanceOf(AwsServiceException.class);
}
@Test
@Order(16)
void v1_partialFirehoseRejected() {
assertThatThrownBy(() -> sesV1.createConfigurationSetEventDestination(
software.amazon.awssdk.services.ses.model.CreateConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v1CsName)
.eventDestination(software.amazon.awssdk.services.ses.model.EventDestination.builder()
.name("ed-firehose-bad")
.enabled(true)
.matchingEventTypes(software.amazon.awssdk.services.ses.model.EventType.SEND)
.kinesisFirehoseDestination(
software.amazon.awssdk.services.ses.model.KinesisFirehoseDestination.builder()
.iamRoleARN("arn:aws:iam::000000000000:role/ses-firehose")
.build())
.build())
.build()))
.isInstanceOf(AwsServiceException.class)
.hasMessageContaining("KinesisFirehoseDestination requires both");
}
@Test
@Order(17)
void v1_deleteEventDestination() {
sesV1.deleteConfigurationSetEventDestination(
software.amazon.awssdk.services.ses.model.DeleteConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v1CsName)
.eventDestinationName(ED_NAME)
.build());
software.amazon.awssdk.services.ses.model.DescribeConfigurationSetResponse resp =
sesV1.describeConfigurationSet(
software.amazon.awssdk.services.ses.model.DescribeConfigurationSetRequest.builder()
.configurationSetName(v1CsName)
.configurationSetAttributeNames(
software.amazon.awssdk.services.ses.model.ConfigurationSetAttribute.EVENT_DESTINATIONS)
.build());
assertThat(resp.eventDestinations()).isEmpty();
}
@Test
@Order(18)
void v1_deleteUnknown_throws() {
assertThatThrownBy(() -> sesV1.deleteConfigurationSetEventDestination(
software.amazon.awssdk.services.ses.model.DeleteConfigurationSetEventDestinationRequest.builder()
.configurationSetName(v1CsName)
.eventDestinationName("ed-ghost")
.build()))
.isInstanceOf(AwsServiceException.class);
}
}