feat(ses): support v1 ConfigurationSet tracking and reputation-metrics options (#1479)

* feat(ses): support v1 ConfigurationSet tracking and reputation-metrics options

Implement the SES v1 (Query) ConfigurationSet option operations that previously
returned UnsupportedOperation: CreateConfigurationSetTrackingOptions,
UpdateConfigurationSetTrackingOptions, DeleteConfigurationSetTrackingOptions, and
UpdateConfigurationSetReputationMetricsEnabled.

Tracking options require a verified domain identity, matching real AWS: an
unverified CustomRedirectDomain yields InvalidTrackingOptions, checked before
configuration-set existence. The domain-verification check is shared with the v2
PutConfigurationSetTrackingOptions path so the two surfaces stay aligned. Lifecycle
conflicts surface as TrackingOptionsAlreadyExistsException /
TrackingOptionsDoesNotExistException, matching the AWS SDK error mapping.

A v1-created configuration set now defaults reputation metrics to disabled, matching
real AWS (the v2 create path leaves them enabled). DescribeConfigurationSet now
returns ReputationMetricsEnabled and the trackingOptions block.

Add integration and AWS SDK v2 compatibility tests.

* fix(ses): match AWS errors for missing/blank tracking-options redirect domain

CreateConfigurationSetTrackingOptions / UpdateConfigurationSetTrackingOptions now
distinguish the two AWS validation outcomes instead of returning a single
InvalidParameterValue: an absent CustomRedirectDomain (no TrackingOptions member on
the wire) yields a framework ValidationError ("Member must not be null"), while a
present-but-empty CustomRedirectDomain yields InvalidTrackingOptions ("At least one
field of TrackingOptions must contain a value."). The Smithy member is optional, so
the previous required-field rejection was incorrect.

Add integration coverage for both cases.

* test(ses): renumber tracking-options test order to match source order

Align the @Order values so file order equals execution order (the missing/blank
domain validation cases now run at 11-12, the reputation-metrics cases at 13-14),
making the intended sequence easier to follow.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-06-21 09:57:45 -05:00
1 parent e8b54e45e9
commit 7c04e8824c
6 files changed
+555 -9

No files matched your search

@@ -362,7 +362,11 @@ public class AwsQueryController {
"CreateConfigurationSetEventDestination",
"UpdateConfigurationSetEventDestination",
"DeleteConfigurationSetEventDestination",
"UpdateConfigurationSetSendingEnabled"
"UpdateConfigurationSetSendingEnabled",
"CreateConfigurationSetTrackingOptions",
"UpdateConfigurationSetTrackingOptions",
"DeleteConfigurationSetTrackingOptions",
"UpdateConfigurationSetReputationMetricsEnabled"
);
private static final Set<String> COGNITO_ACTIONS = Set.of(
@@ -90,6 +90,14 @@ public class SesQueryHandler {
handleDeleteConfigurationSetEventDestination(params, region);
case "UpdateConfigurationSetSendingEnabled" ->
handleUpdateConfigurationSetSendingEnabled(params, region);
case "CreateConfigurationSetTrackingOptions" ->
handleCreateConfigurationSetTrackingOptions(params, region);
case "UpdateConfigurationSetTrackingOptions" ->
handleUpdateConfigurationSetTrackingOptions(params, region);
case "DeleteConfigurationSetTrackingOptions" ->
handleDeleteConfigurationSetTrackingOptions(params, region);
case "UpdateConfigurationSetReputationMetricsEnabled" ->
handleUpdateConfigurationSetReputationMetricsEnabled(params, region);
default -> AwsQueryResponse.error("UnsupportedOperation",
"Operation " + action + " is not supported by SES.", AwsNamespaces.SES, 400);
};
@@ -549,7 +557,9 @@ public class SesQueryHandler {
if (name == null || name.isBlank()) {
throw new AwsException("InvalidParameterValue", "ConfigurationSet.Name is required.", 400);
}
sesService.createConfigurationSet(new ConfigurationSet(name), region);
ConfigurationSet configSet = new ConfigurationSet(name);
configSet.setReputationMetricsEnabled(false);
sesService.createConfigurationSet(configSet, region);
return Response.ok(AwsQueryResponse.envelopeEmptyResult("CreateConfigurationSet", AwsNamespaces.SES)).build();
}
@@ -579,8 +589,15 @@ public class SesQueryHandler {
if (attrs.contains("reputationOptions")) {
xml.start("ReputationOptions")
.elem("SendingEnabled", String.valueOf(cs.isSendingEnabledEffective()))
.elem("ReputationMetricsEnabled", String.valueOf(cs.isReputationMetricsEnabledEffective()))
.end("ReputationOptions");
}
if (attrs.contains("trackingOptions") && cs.getTrackingOptions() != null
&& cs.getTrackingOptions().getCustomRedirectDomain() != null) {
xml.start("TrackingOptions")
.elem("CustomRedirectDomain", cs.getTrackingOptions().getCustomRedirectDomain())
.end("TrackingOptions");
}
return Response.ok(AwsQueryResponse.envelope("DescribeConfigurationSet",
AwsNamespaces.SES, xml.build())).build();
}
@@ -701,6 +718,41 @@ public class SesQueryHandler {
"UpdateConfigurationSetSendingEnabled", AwsNamespaces.SES)).build();
}
private Response handleCreateConfigurationSetTrackingOptions(MultivaluedMap<String, String> params,
String region) {
String configSet = requireParam(params, "ConfigurationSetName");
String domain = getParam(params, "TrackingOptions.CustomRedirectDomain");
sesService.createConfigurationSetTrackingOptions(configSet, domain, region);
return Response.ok(AwsQueryResponse.envelopeEmptyResult(
"CreateConfigurationSetTrackingOptions", AwsNamespaces.SES)).build();
}
private Response handleUpdateConfigurationSetTrackingOptions(MultivaluedMap<String, String> params,
String region) {
String configSet = requireParam(params, "ConfigurationSetName");
String domain = getParam(params, "TrackingOptions.CustomRedirectDomain");
sesService.updateConfigurationSetTrackingOptions(configSet, domain, region);
return Response.ok(AwsQueryResponse.envelopeEmptyResult(
"UpdateConfigurationSetTrackingOptions", AwsNamespaces.SES)).build();
}
private Response handleDeleteConfigurationSetTrackingOptions(MultivaluedMap<String, String> params,
String region) {
String configSet = requireParam(params, "ConfigurationSetName");
sesService.deleteConfigurationSetTrackingOptions(configSet, region);
return Response.ok(AwsQueryResponse.envelopeEmptyResult(
"DeleteConfigurationSetTrackingOptions", AwsNamespaces.SES)).build();
}
private Response handleUpdateConfigurationSetReputationMetricsEnabled(MultivaluedMap<String, String> params,
String region) {
String configSet = requireParam(params, "ConfigurationSetName");
boolean enabled = parseRequiredBoolean(params, "Enabled");
sesService.setConfigurationSetReputationOptions(configSet, enabled, region);
return Response.ok(AwsQueryResponse.envelopeEmptyResult(
"UpdateConfigurationSetReputationMetricsEnabled", AwsNamespaces.SES)).build();
}
/**
* AWS V1 SES uses lowercased event-type names on the wire (e.g. {@code send},
* {@code complaint}, {@code renderingFailure}) while V2 uses
@@ -695,6 +695,67 @@ public class SesService {
configSetName, region, metricsEnabled);
}
private boolean isVerifiedDomainIdentity(String domain, String region) {
Identity identity = getIdentityVerificationAttributes(domain, region);
return identity != null && "Success".equals(identity.getVerificationStatus())
&& "Domain".equals(identity.getIdentityType());
}
private void requireVerifiedRedirectDomain(String domain, String region) {
if (domain == null) {
throw new AwsException("ValidationError",
"1 validation error detected: Value at 'trackingOptions' failed to satisfy constraint: "
+ "Member must not be null", 400);
}
if (domain.isBlank()) {
throw new AwsException("InvalidTrackingOptions",
"At least one field of TrackingOptions must contain a value.", 400);
}
if (!isVerifiedDomainIdentity(domain, region)) {
throw new AwsException("InvalidTrackingOptions",
"Domain <" + domain + "> is not verified under this account.", 400);
}
}
public void createConfigurationSetTrackingOptions(String configSetName, String customRedirectDomain,
String region) {
requireVerifiedRedirectDomain(customRedirectDomain, region);
ConfigurationSet cs = getConfigurationSet(configSetName, region);
if (cs.getTrackingOptions() != null && cs.getTrackingOptions().getCustomRedirectDomain() != null) {
throw new AwsException("TrackingOptionsAlreadyExistsException",
"Configuration set <" + configSetName + "> already has tracking options.", 400);
}
TrackingOptions options = new TrackingOptions();
options.setCustomRedirectDomain(customRedirectDomain);
cs.setTrackingOptions(options);
configSetStore.put(configSetKey(region, configSetName), cs);
LOG.infov("Created TrackingOptions on configuration set {0} in region {1}", configSetName, region);
}
public void updateConfigurationSetTrackingOptions(String configSetName, String customRedirectDomain,
String region) {
requireVerifiedRedirectDomain(customRedirectDomain, region);
ConfigurationSet cs = getConfigurationSet(configSetName, region);
if (cs.getTrackingOptions() == null || cs.getTrackingOptions().getCustomRedirectDomain() == null) {
throw new AwsException("TrackingOptionsDoesNotExistException",
"There are no tracking options for configuration set <" + configSetName + ">", 400);
}
cs.getTrackingOptions().setCustomRedirectDomain(customRedirectDomain);
configSetStore.put(configSetKey(region, configSetName), cs);
LOG.infov("Updated TrackingOptions on configuration set {0} in region {1}", configSetName, region);
}
public void deleteConfigurationSetTrackingOptions(String configSetName, String region) {
ConfigurationSet cs = getConfigurationSet(configSetName, region);
if (cs.getTrackingOptions() == null || cs.getTrackingOptions().getCustomRedirectDomain() == null) {
throw new AwsException("TrackingOptionsDoesNotExistException",
"There are no tracking options for configuration set <" + configSetName + ">", 400);
}
cs.setTrackingOptions(null);
configSetStore.put(configSetKey(region, configSetName), cs);
LOG.infov("Deleted TrackingOptions on configuration set {0} in region {1}", configSetName, region);
}
public void setConfigurationSetArchivingOptions(String configSetName, ArchivingOptions options, String region) {
ConfigurationSet cs = getConfigurationSet(configSetName, region);
cs.setArchivingOptions(options);
@@ -752,13 +813,9 @@ public class SesService {
throw new AwsException("BadRequestException",
"CustomRedirectDomain must be specified.", 400);
}
if (domain != null) {
Identity identity = getIdentityVerificationAttributes(domain, region);
if (identity == null || !"Success".equals(identity.getVerificationStatus())
|| !"Domain".equals(identity.getIdentityType())) {
throw new AwsException("BadRequestException",
"Domain <" + domain + "> is not verified under this account.", 400);
}
if (domain != null && !isVerifiedDomainIdentity(domain, region)) {
throw new AwsException("BadRequestException",
"Domain <" + domain + "> is not verified under this account.", 400);
}
if (httpsPolicy != null && !HTTPS_POLICIES.contains(httpsPolicy)) {
throw new AwsException("BadRequestException",