mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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:
1 parent
35211adc4a
commit
2c9e0bce7c
6 files changed
+921
-50
No files matched your search
+321
@@ -0,0 +1,321 @@
|
||||
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.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
/**
|
||||
* Integration tests for SES V1 Query-protocol ConfigurationSet EventDestination CRUD —
|
||||
* {@code CreateConfigurationSetEventDestination} / {@code UpdateConfigurationSetEventDestination} /
|
||||
* {@code DeleteConfigurationSetEventDestination}. The DescribeConfigurationSet response is
|
||||
* exercised with {@code ConfigurationSetAttributeNames.member.1=eventDestinations} to verify
|
||||
* the stored event destination round-trips through the V1 XML response shape.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesConfigurationSetEventDestinationV1IntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request";
|
||||
private static final String CS = "v1-evt-cs";
|
||||
private static final String ED = "v1-ed-sns";
|
||||
private static final String TOPIC_ARN_A = "arn:aws:sns:us-east-1:000000000000:topic-a";
|
||||
private static final String TOPIC_ARN_B = "arn:aws:sns:us-east-1:000000000000:topic-b";
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void setupConfigurationSet() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "CreateConfigurationSet")
|
||||
.formParam("ConfigurationSet.Name", CS)
|
||||
.when().post("/")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void createConfigurationSetEventDestination() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "CreateConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestination.Name", ED)
|
||||
.formParam("EventDestination.Enabled", "true")
|
||||
.formParam("EventDestination.MatchingEventTypes.member.1", "send")
|
||||
.formParam("EventDestination.MatchingEventTypes.member.2", "delivery")
|
||||
.formParam("EventDestination.SNSDestination.TopicARN", TOPIC_ARN_A)
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("CreateConfigurationSetEventDestinationResponse"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void describeConfigurationSet_withEventDestinationsAttribute_returnsEventDestination() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "DescribeConfigurationSet")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("ConfigurationSetAttributeNames.member.1", "eventDestinations")
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<Name>" + ED + "</Name>"))
|
||||
.body(containsString("<Enabled>true</Enabled>"))
|
||||
.body(containsString("<member>send</member>"))
|
||||
.body(containsString("<member>delivery</member>"))
|
||||
.body(containsString("<TopicARN>" + TOPIC_ARN_A + "</TopicARN>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void describeConfigurationSet_withoutEventDestinationsAttribute_omitsEventDestinations() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "DescribeConfigurationSet")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<Name>" + CS + "</Name>"))
|
||||
.body(not(containsString("<EventDestinations>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void createConfigurationSetEventDestination_duplicateRejected() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "CreateConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestination.Name", ED)
|
||||
.formParam("EventDestination.Enabled", "true")
|
||||
.formParam("EventDestination.MatchingEventTypes.member.1", "send")
|
||||
.formParam("EventDestination.SNSDestination.TopicARN", TOPIC_ARN_A)
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("<Code>AlreadyExists</Code>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void updateConfigurationSetEventDestination_changesFields() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "UpdateConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestination.Name", ED)
|
||||
.formParam("EventDestination.Enabled", "false")
|
||||
.formParam("EventDestination.MatchingEventTypes.member.1", "bounce")
|
||||
.formParam("EventDestination.SNSDestination.TopicARN", TOPIC_ARN_B)
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("UpdateConfigurationSetEventDestinationResponse"));
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "DescribeConfigurationSet")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("ConfigurationSetAttributeNames.member.1", "eventDestinations")
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<Enabled>false</Enabled>"))
|
||||
.body(containsString("<member>bounce</member>"))
|
||||
.body(containsString("<TopicARN>" + TOPIC_ARN_B + "</TopicARN>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void updateConfigurationSetEventDestination_unknownName_returnsNotFound() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "UpdateConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestination.Name", "v1-ed-ghost")
|
||||
.formParam("EventDestination.Enabled", "true")
|
||||
.formParam("EventDestination.MatchingEventTypes.member.1", "send")
|
||||
.formParam("EventDestination.SNSDestination.TopicARN", TOPIC_ARN_A)
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.body(containsString("<Code>NotFoundException</Code>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void deleteConfigurationSetEventDestination() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "DeleteConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestinationName", ED)
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("DeleteConfigurationSetEventDestinationResponse"));
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "DescribeConfigurationSet")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("ConfigurationSetAttributeNames.member.1", "eventDestinations")
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(not(containsString("<Name>" + ED + "</Name>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void deleteConfigurationSetEventDestination_unknownName_returnsNotFound() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "DeleteConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestinationName", "v1-ed-ghost")
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.body(containsString("<Code>NotFoundException</Code>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void createConfigurationSetEventDestination_routedViaActionFallback_whenAuthHeaderAbsent() {
|
||||
// Exercises AwsQueryController.inferServiceFromAction → SES_ACTIONS dispatch
|
||||
// when no Authorization header is present (no SigV4 credential scope to resolve).
|
||||
String edFallback = "v1-ed-routing-fallback";
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestination.Name", edFallback)
|
||||
.formParam("EventDestination.Enabled", "true")
|
||||
.formParam("EventDestination.MatchingEventTypes.member.1", "send")
|
||||
.formParam("EventDestination.SNSDestination.TopicARN", TOPIC_ARN_A)
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("CreateConfigurationSetEventDestinationResponse"));
|
||||
|
||||
// Clean up so the cleanup test in @Order(99) doesn't fight a lingering ED.
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "DeleteConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestinationName", edFallback)
|
||||
.when().post("/")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void describeConfigurationSet_eventDestinationsAttribute_returnsEmptyContainerWhenNoDestinations() {
|
||||
// After the @Order(8) delete the CS has no event destinations. The attribute was
|
||||
// requested, so an empty <EventDestinations/> container should still be returned.
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "DescribeConfigurationSet")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("ConfigurationSetAttributeNames.member.1", "eventDestinations")
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<EventDestinations"))
|
||||
.body(not(containsString("<member>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
void createConfigurationSetEventDestination_partialFirehose_rejected() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "CreateConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestination.Name", "v1-ed-firehose-bad")
|
||||
.formParam("EventDestination.Enabled", "true")
|
||||
.formParam("EventDestination.MatchingEventTypes.member.1", "send")
|
||||
.formParam("EventDestination.KinesisFirehoseDestination.IAMRoleARN",
|
||||
"arn:aws:iam::000000000000:role/x")
|
||||
// DeliveryStreamARN intentionally omitted.
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("KinesisFirehoseDestination requires both IamRoleArn and DeliveryStreamArn"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(13)
|
||||
void createConfigurationSetEventDestination_partialCloudWatchDimension_rejected() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "CreateConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestination.Name", "v1-ed-cw-bad")
|
||||
.formParam("EventDestination.Enabled", "true")
|
||||
.formParam("EventDestination.MatchingEventTypes.member.1", "send")
|
||||
.formParam("EventDestination.CloudWatchDestination.DimensionConfigurations.member.1.DimensionName",
|
||||
"MyDim")
|
||||
// DimensionValueSource and DefaultDimensionValue intentionally omitted.
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("CloudWatchDestination dimension configurations require"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void createConfigurationSetEventDestination_blankSnsTopicArn_rejected() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "CreateConfigurationSetEventDestination")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.formParam("EventDestination.Name", "v1-ed-sns-blank")
|
||||
.formParam("EventDestination.Enabled", "true")
|
||||
.formParam("EventDestination.MatchingEventTypes.member.1", "send")
|
||||
.formParam("EventDestination.SNSDestination.TopicARN", "")
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("SnsDestination requires a non-blank TopicArn"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(99)
|
||||
void cleanup() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "DeleteConfigurationSet")
|
||||
.formParam("ConfigurationSetName", CS)
|
||||
.when().post("/")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
}
|
||||
+110
@@ -4,6 +4,7 @@ import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.services.ses.model.CloudWatchDestination;
|
||||
import io.github.hectorvent.floci.services.ses.model.CloudWatchDimensionConfiguration;
|
||||
import io.github.hectorvent.floci.services.ses.model.EventDestination;
|
||||
import io.github.hectorvent.floci.services.ses.model.KinesisFirehoseDestination;
|
||||
import io.github.hectorvent.floci.services.ses.model.PinpointDestination;
|
||||
import io.github.hectorvent.floci.services.ses.model.SnsDestination;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -144,6 +145,115 @@ class SesServiceEventDestinationTest {
|
||||
assertDoesNotThrow(() -> SesService.validateEventDestination(ed));
|
||||
}
|
||||
|
||||
@Test
|
||||
void snsBlankTopicArn_throws() {
|
||||
EventDestination ed = new EventDestination();
|
||||
ed.setMatchingEventTypes(List.of("SEND"));
|
||||
SnsDestination sns = new SnsDestination();
|
||||
sns.setTopicArn("");
|
||||
ed.setSnsDestination(sns);
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> SesService.validateEventDestination(ed));
|
||||
assertEquals("InvalidParameterValue", ex.getErrorCode());
|
||||
assertEquals("SnsDestination requires a non-blank TopicArn.", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void snsNullTopicArn_throws() {
|
||||
EventDestination ed = new EventDestination();
|
||||
ed.setMatchingEventTypes(List.of("SEND"));
|
||||
ed.setSnsDestination(new SnsDestination()); // TopicArn left null
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> SesService.validateEventDestination(ed));
|
||||
assertEquals("InvalidParameterValue", ex.getErrorCode());
|
||||
assertEquals("SnsDestination requires a non-blank TopicArn.", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void firehoseMissingDeliveryStream_throws() {
|
||||
EventDestination ed = new EventDestination();
|
||||
ed.setMatchingEventTypes(List.of("SEND"));
|
||||
KinesisFirehoseDestination fh = new KinesisFirehoseDestination();
|
||||
fh.setIamRoleArn("arn:aws:iam::000000000000:role/ses-firehose");
|
||||
// DeliveryStreamArn left null
|
||||
ed.setKinesisFirehoseDestination(fh);
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> SesService.validateEventDestination(ed));
|
||||
assertEquals("InvalidParameterValue", ex.getErrorCode());
|
||||
assertEquals("KinesisFirehoseDestination requires both IamRoleArn and DeliveryStreamArn.",
|
||||
ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void firehoseMissingIamRole_throws() {
|
||||
EventDestination ed = new EventDestination();
|
||||
ed.setMatchingEventTypes(List.of("SEND"));
|
||||
KinesisFirehoseDestination fh = new KinesisFirehoseDestination();
|
||||
fh.setDeliveryStreamArn("arn:aws:firehose:us-east-1:000000000000:deliverystream/ses");
|
||||
// IamRoleArn left null
|
||||
ed.setKinesisFirehoseDestination(fh);
|
||||
assertThrows(AwsException.class, () -> SesService.validateEventDestination(ed));
|
||||
}
|
||||
|
||||
@Test
|
||||
void firehoseValid_passes() {
|
||||
EventDestination ed = new EventDestination();
|
||||
ed.setMatchingEventTypes(List.of("SEND"));
|
||||
KinesisFirehoseDestination fh = new KinesisFirehoseDestination();
|
||||
fh.setIamRoleArn("arn:aws:iam::000000000000:role/ses-firehose");
|
||||
fh.setDeliveryStreamArn("arn:aws:firehose:us-east-1:000000000000:deliverystream/ses");
|
||||
ed.setKinesisFirehoseDestination(fh);
|
||||
assertDoesNotThrow(() -> SesService.validateEventDestination(ed));
|
||||
}
|
||||
|
||||
@Test
|
||||
void cloudWatchDimensionMissingName_throws() {
|
||||
EventDestination ed = new EventDestination();
|
||||
ed.setMatchingEventTypes(List.of("SEND"));
|
||||
CloudWatchDestination cw = new CloudWatchDestination();
|
||||
CloudWatchDimensionConfiguration dim = new CloudWatchDimensionConfiguration();
|
||||
// DimensionName left null
|
||||
dim.setDimensionValueSource("MESSAGE_TAG");
|
||||
dim.setDefaultDimensionValue("default");
|
||||
cw.setDimensionConfigurations(List.of(dim));
|
||||
ed.setCloudWatchDestination(cw);
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> SesService.validateEventDestination(ed));
|
||||
assertEquals("InvalidParameterValue", ex.getErrorCode());
|
||||
// Member index 1-based for callers, included in the error message.
|
||||
assertEquals("CloudWatchDestination dimension configurations require "
|
||||
+ "DimensionName, DimensionValueSource, and DefaultDimensionValue "
|
||||
+ "(missing on member 1).", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void cloudWatchDimensionBlankValueSource_throws() {
|
||||
EventDestination ed = new EventDestination();
|
||||
ed.setMatchingEventTypes(List.of("SEND"));
|
||||
CloudWatchDestination cw = new CloudWatchDestination();
|
||||
CloudWatchDimensionConfiguration dim = new CloudWatchDimensionConfiguration();
|
||||
dim.setDimensionName("dim");
|
||||
dim.setDimensionValueSource("");
|
||||
dim.setDefaultDimensionValue("default");
|
||||
cw.setDimensionConfigurations(List.of(dim));
|
||||
ed.setCloudWatchDestination(cw);
|
||||
assertThrows(AwsException.class, () -> SesService.validateEventDestination(ed));
|
||||
}
|
||||
|
||||
@Test
|
||||
void cloudWatchDimensionMissingDefaultValue_throws() {
|
||||
EventDestination ed = new EventDestination();
|
||||
ed.setMatchingEventTypes(List.of("SEND"));
|
||||
CloudWatchDestination cw = new CloudWatchDestination();
|
||||
CloudWatchDimensionConfiguration dim = new CloudWatchDimensionConfiguration();
|
||||
dim.setDimensionName("dim");
|
||||
dim.setDimensionValueSource("MESSAGE_TAG");
|
||||
// DefaultDimensionValue left null
|
||||
cw.setDimensionConfigurations(List.of(dim));
|
||||
ed.setCloudWatchDestination(cw);
|
||||
assertThrows(AwsException.class, () -> SesService.validateEventDestination(ed));
|
||||
}
|
||||
|
||||
private static CloudWatchDestination cloudWatch() {
|
||||
CloudWatchDestination cw = new CloudWatchDestination();
|
||||
CloudWatchDimensionConfiguration dim = new CloudWatchDimensionConfiguration();
|
||||
|
||||
Reference in new issue
Block a user