mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(ses): add UpdateConfigurationSet and MessageSecurityOptions (#5092)
The SES v2 model release of 2026-09-01 (botocore 1.43.86) added UpdateConfigurationSet, a partial update whose only member is MessageSecurityOptions, the S/MIME signing scheme of a configuration set. CreateConfigurationSet accepts the same member and GetConfigurationSet returns it. Floci stores and returns the setting but never signs a message. Where the API reference is silent, the request handling follows what SES answered in us-west-2: an absent SigningScheme leaves the stored value alone, an empty one resets it to DefaultScheme, both union members store SmimeScheme, and a missing SignatureFormat stores DETACHED.
This commit is contained in:
1 parent
4d9585583d
commit
1d44b5fc7c
10 files changed
+509
No files matched your search
+61
@@ -15,12 +15,14 @@ import software.amazon.awssdk.services.sesv2.model.DashboardOptions;
|
||||
import software.amazon.awssdk.services.sesv2.model.GuardianOptions;
|
||||
import software.amazon.awssdk.services.sesv2.model.CreateConfigurationSetRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.CreateDedicatedIpPoolRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.DefaultSigningScheme;
|
||||
import software.amazon.awssdk.services.sesv2.model.DeleteConfigurationSetRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.DeleteDedicatedIpPoolRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.DeleteEmailIdentityRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.DeliveryOptions;
|
||||
import software.amazon.awssdk.services.sesv2.model.GetConfigurationSetRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.GetConfigurationSetResponse;
|
||||
import software.amazon.awssdk.services.sesv2.model.MessageSecurityOptions;
|
||||
import software.amazon.awssdk.services.sesv2.model.NotFoundException;
|
||||
import software.amazon.awssdk.services.sesv2.model.PutConfigurationSetArchivingOptionsRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.PutConfigurationSetDeliveryOptionsRequest;
|
||||
@@ -28,7 +30,10 @@ import software.amazon.awssdk.services.sesv2.model.PutConfigurationSetReputation
|
||||
import software.amazon.awssdk.services.sesv2.model.PutConfigurationSetTrackingOptionsRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.ReputationOptions;
|
||||
import software.amazon.awssdk.services.sesv2.model.PutConfigurationSetVdmOptionsRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.SignatureFormat;
|
||||
import software.amazon.awssdk.services.sesv2.model.SigningScheme;
|
||||
import software.amazon.awssdk.services.sesv2.model.TrackingOptions;
|
||||
import software.amazon.awssdk.services.sesv2.model.UpdateConfigurationSetRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.VdmOptions;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -41,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
* - {@code putConfigurationSetTrackingOptions} / {@code TrackingOptions}
|
||||
* - {@code putConfigurationSetDeliveryOptions} / {@code DeliveryOptions}
|
||||
* - {@code putConfigurationSetArchivingOptions} / {@code ArchivingOptions}
|
||||
* - {@code updateConfigurationSet} / {@code MessageSecurityOptions}
|
||||
* and the {@code GetConfigurationSet} response carrying each block, plus the
|
||||
* server-side validation errors surfaced as {@link BadRequestException} /
|
||||
* {@link NotFoundException}.
|
||||
@@ -52,6 +58,7 @@ class SesConfigurationSetOptionsTest {
|
||||
private static final String CS_NAME = "compat-cs-options";
|
||||
private static final String CREATE_CS = "compat-cs-options-create";
|
||||
private static final String CREATE_CS_BAD = "compat-cs-options-create-bad";
|
||||
private static final String CREATE_CS_SMIME = "compat-cs-options-create-smime";
|
||||
private static final String TRACK_DOMAIN = "compat-track.example.com";
|
||||
private static final String ARCHIVE_ARN =
|
||||
"arn:aws:ses:us-east-1:123456789012:mailmanager-archive/a-abcdefghijklmnopqrstuvwx";
|
||||
@@ -64,6 +71,7 @@ class SesConfigurationSetOptionsTest {
|
||||
deleteConfigSetQuietly(CS_NAME);
|
||||
deleteConfigSetQuietly(CREATE_CS);
|
||||
deleteConfigSetQuietly(CREATE_CS_BAD);
|
||||
deleteConfigSetQuietly(CREATE_CS_SMIME);
|
||||
sesV2.createConfigurationSet(CreateConfigurationSetRequest.builder()
|
||||
.configurationSetName(CS_NAME).build());
|
||||
TestFixtures.verifySesDomainIdentityViaRoute53(sesV2, TRACK_DOMAIN);
|
||||
@@ -75,6 +83,7 @@ class SesConfigurationSetOptionsTest {
|
||||
deleteConfigSetQuietly(CS_NAME);
|
||||
deleteConfigSetQuietly(CREATE_CS);
|
||||
deleteConfigSetQuietly(CREATE_CS_BAD);
|
||||
deleteConfigSetQuietly(CREATE_CS_SMIME);
|
||||
try {
|
||||
sesV2.deleteEmailIdentity(DeleteEmailIdentityRequest.builder()
|
||||
.emailIdentity(TRACK_DOMAIN).build());
|
||||
@@ -258,4 +267,56 @@ class SesConfigurationSetOptionsTest {
|
||||
sesV2.deleteDedicatedIpPool(DeleteDedicatedIpPoolRequest.builder().poolName(pool).build());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(13)
|
||||
void updateConfigurationSet_signingScheme_roundTrips() {
|
||||
assertThat(getConfigSet().messageSecurityOptions()).isNull();
|
||||
|
||||
sesV2.updateConfigurationSet(UpdateConfigurationSetRequest.builder()
|
||||
.configurationSetName(CS_NAME)
|
||||
.messageSecurityOptions(MessageSecurityOptions.builder()
|
||||
.signingScheme(SigningScheme.fromSmimeScheme(s -> s.signatureFormat(SignatureFormat.DETACHED)))
|
||||
.build())
|
||||
.build());
|
||||
SigningScheme stored = getConfigSet().messageSecurityOptions().signingScheme();
|
||||
assertThat(stored.type()).isEqualTo(SigningScheme.Type.SMIME_SCHEME);
|
||||
assertThat(stored.smimeScheme().signatureFormat()).isEqualTo(SignatureFormat.DETACHED);
|
||||
|
||||
sesV2.updateConfigurationSet(UpdateConfigurationSetRequest.builder()
|
||||
.configurationSetName(CS_NAME)
|
||||
.messageSecurityOptions(MessageSecurityOptions.builder()
|
||||
.signingScheme(SigningScheme.fromDefaultScheme(DefaultSigningScheme.builder().build()))
|
||||
.build())
|
||||
.build());
|
||||
assertThat(getConfigSet().messageSecurityOptions().signingScheme().type())
|
||||
.isEqualTo(SigningScheme.Type.DEFAULT_SCHEME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void createConfigurationSet_withSigningScheme_roundTrips() {
|
||||
sesV2.createConfigurationSet(CreateConfigurationSetRequest.builder()
|
||||
.configurationSetName(CREATE_CS_SMIME)
|
||||
.messageSecurityOptions(MessageSecurityOptions.builder()
|
||||
.signingScheme(SigningScheme.fromSmimeScheme(s -> s.signatureFormat(SignatureFormat.DETACHED)))
|
||||
.build())
|
||||
.build());
|
||||
SigningScheme stored = sesV2.getConfigurationSet(GetConfigurationSetRequest.builder()
|
||||
.configurationSetName(CREATE_CS_SMIME).build()).messageSecurityOptions().signingScheme();
|
||||
assertThat(stored.type()).isEqualTo(SigningScheme.Type.SMIME_SCHEME);
|
||||
assertThat(stored.smimeScheme().signatureFormat()).isEqualTo(SignatureFormat.DETACHED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void updateConfigurationSet_missingSet_throwsNotFound() {
|
||||
assertThatThrownBy(() -> sesV2.updateConfigurationSet(UpdateConfigurationSetRequest.builder()
|
||||
.configurationSetName("compat-cs-options-missing")
|
||||
.messageSecurityOptions(MessageSecurityOptions.builder()
|
||||
.signingScheme(SigningScheme.fromDefaultScheme(DefaultSigningScheme.builder().build()))
|
||||
.build())
|
||||
.build()))
|
||||
.isInstanceOf(NotFoundException.class);
|
||||
}
|
||||
}
|
||||
@@ -385,11 +385,14 @@ Alongside the classic Query API, Floci implements a subset of the SES v2 REST JS
|
||||
| `GET` | `/v2/email/export-jobs/{JobId}` | `GetExportJob` |
|
||||
| `POST` | `/v2/email/list-export-jobs` | `ListExportJobs` |
|
||||
| `PUT` | `/v2/email/export-jobs/{JobId}/cancel` | `CancelExportJob` |
|
||||
| `POST` | `/v2/email/update-configuration-sets` | `UpdateConfigurationSet` |
|
||||
|
||||
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`).
|
||||
|
||||
Configuration set event destinations are stored as configuration. The target is not validated for existence; missing targets cause Floci to log a warning and skip that destination. Each event destination must specify exactly one destination type and at least one matching event type. A CloudWatch destination requires a non-empty dimension configuration list, and a Pinpoint destination requires an application ARN.
|
||||
|
||||
A configuration set's `MessageSecurityOptions`, set with `CreateConfigurationSet` or the partial update [`UpdateConfigurationSet`](https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_UpdateConfigurationSet.html) and read back by `GetConfigurationSet`, is stored as configuration only: Floci never adds an S/MIME signature to a message. Where the API reference is silent, Floci follows what real SES answered (probed 2026-10-04): an empty `SigningScheme` resets the set to `DefaultScheme`, a request naming both union members stores `SmimeScheme`, and an `SmimeScheme` without a `SignatureFormat` stores `DETACHED`.
|
||||
|
||||
Floci publishes SES events to `SnsDestination`, `KinesisFirehoseDestination`, `EventBridgeDestination`, and `CloudWatchDestination`. `PinpointDestination` logs a warning and skips. The published payload follows the [AWS SES SNS notification format](https://docs.aws.amazon.com/ses/latest/dg/event-publishing-retrieving-sns-contents.html) with an outer `eventType` plus `mail` and event-type-specific blocks. Events fire whenever a configuration set has at least one event destination matching the event type — disable per-destination via `EventDestination.Enabled=false`, or remove the destination entirely.
|
||||
|
||||
Floci recognises the AWS [mailbox simulator addresses](https://docs.aws.amazon.com/ses/latest/dg/send-an-email-from-console.html#send-email-simulator) for deterministic event-type emission:
|
||||
|
||||
+63
@@ -14,6 +14,8 @@ import io.github.hectorvent.floci.services.ses.model.DashboardOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.DeliveryOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.EventDestination;
|
||||
import io.github.hectorvent.floci.services.ses.model.GuardianOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.MessageSecurityOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.SigningScheme;
|
||||
import io.github.hectorvent.floci.services.ses.model.SuppressionOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.Tag;
|
||||
import io.github.hectorvent.floci.services.ses.model.TrackingOptions;
|
||||
@@ -61,6 +63,7 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.stringMemberOrAb
|
||||
public class SesConfigurationSetController {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(SesConfigurationSetController.class);
|
||||
private static final String SIGNATURE_FORMAT_DETACHED = "DETACHED";
|
||||
|
||||
private final SesConfigurationSetService configSetService;
|
||||
private final SesService sesService;
|
||||
@@ -135,6 +138,10 @@ public class SesConfigurationSetController {
|
||||
if (!vdmNode.isMissingNode() && !vdmNode.isNull()) {
|
||||
cs.setVdmOptions(parseVdmOptions(vdmNode));
|
||||
}
|
||||
JsonNode messageSecurityNode = request.path("MessageSecurityOptions");
|
||||
if (!messageSecurityNode.isMissingNode() && !messageSecurityNode.isNull()) {
|
||||
cs.setMessageSecurityOptions(parseMessageSecurityOptions(messageSecurityNode));
|
||||
}
|
||||
sesService.createConfigurationSet(cs, region);
|
||||
LOG.infov("SES V2 CreateConfigurationSet: {0}", name);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
@@ -231,6 +238,10 @@ public class SesConfigurationSetController {
|
||||
if (cs.getVdmOptions() != null) {
|
||||
result.set("VdmOptions", objectMapper.valueToTree(cs.getVdmOptions()));
|
||||
}
|
||||
if (cs.getMessageSecurityOptions() != null) {
|
||||
result.set("MessageSecurityOptions",
|
||||
objectMapper.valueToTree(cs.getMessageSecurityOptions()));
|
||||
}
|
||||
return Response.ok(result).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
@@ -363,6 +374,27 @@ public class SesConfigurationSetController {
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/update-configuration-sets")
|
||||
public Response updateConfigurationSet(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
JsonNode request = readOptionBody(objectMapper, body);
|
||||
String name = stringMemberOrAbsent(request, "ConfigurationSetName");
|
||||
if (name == null || name.isBlank()) {
|
||||
throw new AwsException("BadRequestException", "ConfigurationSetName is required.", 400);
|
||||
}
|
||||
JsonNode messageSecurityNode = request.path("MessageSecurityOptions");
|
||||
MessageSecurityOptions options = (messageSecurityNode.isMissingNode() || messageSecurityNode.isNull())
|
||||
? null : parseMessageSecurityOptions(messageSecurityNode);
|
||||
configSetService.updateMessageSecurityOptions(name, options, region);
|
||||
LOG.infov("SES V2 UpdateConfigurationSet on {0}", name);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
/** Reject a non-object option block, mirroring the AWS deserialization layer. */
|
||||
private static void requireOptionObject(JsonNode node) {
|
||||
if (!node.isObject()) {
|
||||
@@ -426,6 +458,37 @@ public class SesConfigurationSetController {
|
||||
return a;
|
||||
}
|
||||
|
||||
// Probed 2026-10-04: SES leaves the stored value alone when SigningScheme is absent, resets an
|
||||
// empty union to DefaultScheme, lets SmimeScheme win when both members are sent, and stores a
|
||||
// missing SignatureFormat as DETACHED. Returns null for "no change".
|
||||
private static MessageSecurityOptions parseMessageSecurityOptions(JsonNode node) {
|
||||
requireOptionObject(node);
|
||||
JsonNode schemeNode = node.path("SigningScheme");
|
||||
if (schemeNode.isMissingNode() || schemeNode.isNull()) {
|
||||
return null;
|
||||
}
|
||||
requireOptionObject(schemeNode);
|
||||
JsonNode defaultNode = schemeNode.path("DefaultScheme");
|
||||
if (!defaultNode.isMissingNode() && !defaultNode.isNull()) {
|
||||
requireOptionObject(defaultNode);
|
||||
}
|
||||
JsonNode smimeNode = schemeNode.path("SmimeScheme");
|
||||
if (smimeNode.isMissingNode() || smimeNode.isNull()) {
|
||||
return new MessageSecurityOptions(SigningScheme.defaultScheme());
|
||||
}
|
||||
requireOptionObject(smimeNode);
|
||||
String format = stringMemberOrAbsent(smimeNode, "SignatureFormat");
|
||||
if (format == null) {
|
||||
format = SIGNATURE_FORMAT_DETACHED;
|
||||
} else if (!SIGNATURE_FORMAT_DETACHED.equals(format)) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"1 validation error detected: Value at "
|
||||
+ "'messageSecurityOptions.signingScheme.smimeScheme.signatureFormat' failed to "
|
||||
+ "satisfy constraint: Member must satisfy enum value set: [DETACHED]", 400);
|
||||
}
|
||||
return new MessageSecurityOptions(SigningScheme.smime(format));
|
||||
}
|
||||
|
||||
private static VdmOptions parseVdmOptions(JsonNode node) {
|
||||
requireOptionObject(node);
|
||||
VdmOptions v = new VdmOptions();
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;
|
||||
import io.github.hectorvent.floci.services.ses.model.DeliveryOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.EventBridgeDestination;
|
||||
import io.github.hectorvent.floci.services.ses.model.EventDestination;
|
||||
import io.github.hectorvent.floci.services.ses.model.MessageSecurityOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.TrackingOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.SuppressionOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.Tag;
|
||||
@@ -422,6 +423,22 @@ public class SesConfigurationSetService {
|
||||
LOG.infov("Updated ArchivingOptions on configuration set {0} in region {1}", configSetName, region);
|
||||
}
|
||||
|
||||
/**
|
||||
* UpdateConfigurationSet: a partial update, so a null {@code options} keeps the stored value
|
||||
* while the set must still exist.
|
||||
*/
|
||||
public void updateMessageSecurityOptions(String configSetName, MessageSecurityOptions options,
|
||||
String region) {
|
||||
ConfigurationSet cs = get(configSetName, region);
|
||||
if (options == null) {
|
||||
return;
|
||||
}
|
||||
cs.setMessageSecurityOptions(options);
|
||||
configSetStore.put(configSetKey(region, configSetName), cs);
|
||||
LOG.infov("Updated MessageSecurityOptions on configuration set {0} in region {1}",
|
||||
configSetName, region);
|
||||
}
|
||||
|
||||
public void setVdmOptions(String configSetName, VdmOptions options, String region) {
|
||||
ConfigurationSet cs = get(configSetName, region);
|
||||
validateVdmOptions(options);
|
||||
|
||||
@@ -46,6 +46,9 @@ public class ConfigurationSet {
|
||||
@JsonProperty("VdmOptions")
|
||||
private VdmOptions vdmOptions;
|
||||
|
||||
@JsonProperty("MessageSecurityOptions")
|
||||
private MessageSecurityOptions messageSecurityOptions;
|
||||
|
||||
public ConfigurationSet() {}
|
||||
|
||||
public ConfigurationSet(String name) {
|
||||
@@ -122,4 +125,9 @@ public class ConfigurationSet {
|
||||
public void setVdmOptions(VdmOptions vdmOptions) {
|
||||
this.vdmOptions = vdmOptions;
|
||||
}
|
||||
|
||||
public MessageSecurityOptions getMessageSecurityOptions() { return messageSecurityOptions; }
|
||||
public void setMessageSecurityOptions(MessageSecurityOptions messageSecurityOptions) {
|
||||
this.messageSecurityOptions = messageSecurityOptions;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package io.github.hectorvent.floci.services.ses.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
/**
|
||||
* Per-configuration-set message security settings. Mirrors the AWS SES V2
|
||||
* {@code MessageSecurityOptions} shape, whose only member is the {@code SigningScheme} union.
|
||||
* Floci stores and returns the setting but never signs a message.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class MessageSecurityOptions {
|
||||
|
||||
@JsonProperty("SigningScheme")
|
||||
private SigningScheme signingScheme;
|
||||
|
||||
public MessageSecurityOptions() {}
|
||||
|
||||
public MessageSecurityOptions(SigningScheme signingScheme) {
|
||||
this.signingScheme = signingScheme;
|
||||
}
|
||||
|
||||
public SigningScheme getSigningScheme() { return signingScheme; }
|
||||
public void setSigningScheme(SigningScheme signingScheme) { this.signingScheme = signingScheme; }
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package io.github.hectorvent.floci.services.ses.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The AWS SES V2 {@code SigningScheme} union: exactly one of {@code DefaultScheme} (an empty
|
||||
* structure) or {@code SmimeScheme} is set.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class SigningScheme {
|
||||
|
||||
@JsonProperty("DefaultScheme")
|
||||
private Map<String, String> defaultScheme;
|
||||
|
||||
@JsonProperty("SmimeScheme")
|
||||
private SmimeSigningScheme smimeScheme;
|
||||
|
||||
public SigningScheme() {}
|
||||
|
||||
public static SigningScheme defaultScheme() {
|
||||
SigningScheme scheme = new SigningScheme();
|
||||
scheme.defaultScheme = Map.of();
|
||||
return scheme;
|
||||
}
|
||||
|
||||
public static SigningScheme smime(String signatureFormat) {
|
||||
SigningScheme scheme = new SigningScheme();
|
||||
scheme.smimeScheme = new SmimeSigningScheme(signatureFormat);
|
||||
return scheme;
|
||||
}
|
||||
|
||||
public Map<String, String> getDefaultScheme() { return defaultScheme; }
|
||||
public void setDefaultScheme(Map<String, String> defaultScheme) { this.defaultScheme = defaultScheme; }
|
||||
|
||||
public SmimeSigningScheme getSmimeScheme() { return smimeScheme; }
|
||||
public void setSmimeScheme(SmimeSigningScheme smimeScheme) { this.smimeScheme = smimeScheme; }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package io.github.hectorvent.floci.services.ses.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
/** The AWS SES V2 {@code SmimeSigningScheme} shape, the S/MIME member of the {@code SigningScheme} union. */
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class SmimeSigningScheme {
|
||||
|
||||
@JsonProperty("SignatureFormat")
|
||||
private String signatureFormat;
|
||||
|
||||
public SmimeSigningScheme() {}
|
||||
|
||||
public SmimeSigningScheme(String signatureFormat) {
|
||||
this.signatureFormat = signatureFormat;
|
||||
}
|
||||
|
||||
public String getSignatureFormat() { return signatureFormat; }
|
||||
public void setSignatureFormat(String signatureFormat) { this.signatureFormat = signatureFormat; }
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
package io.github.hectorvent.floci.services.ses;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
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.anEmptyMap;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasKey;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
/**
|
||||
* UpdateConfigurationSet ({@code POST /v2/email/update-configuration-sets}) and the
|
||||
* {@code MessageSecurityOptions} member of Create/GetConfigurationSet. The signing-scheme
|
||||
* semantics and the error messages were measured against SES in us-west-2 on 2026-10-04; the
|
||||
* missing-name and type-mismatch cases follow the other configuration-set operations, and the
|
||||
* order of body validation before the existence check is unmeasured.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesConfigurationSetMessageSecurityV2IntegrationTest {
|
||||
|
||||
private static final String AUTH_HEADER =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String CS = "cs-message-security";
|
||||
private static final String SMIME = "{\"SigningScheme\":{\"SmimeScheme\":{\"SignatureFormat\":\"DETACHED\"}}}";
|
||||
private static final String DEFAULT = "{\"SigningScheme\":{\"DefaultScheme\":{}}}";
|
||||
private static final String BAD_FORMAT_MESSAGE = "1 validation error detected: Value at "
|
||||
+ "'messageSecurityOptions.signingScheme.smimeScheme.signatureFormat' failed to satisfy "
|
||||
+ "constraint: Member must satisfy enum value set: [DETACHED]";
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void createWithoutOptions_getOmitsMessageSecurityOptions() {
|
||||
create("{\"ConfigurationSetName\":\"" + CS + "\"}").statusCode(200);
|
||||
|
||||
get(CS).body("$", not(hasKey("MessageSecurityOptions")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void updateWithoutOptions_keepsTheSetUnchanged() {
|
||||
update("{\"ConfigurationSetName\":\"" + CS + "\"}").statusCode(200);
|
||||
|
||||
get(CS).body("$", not(hasKey("MessageSecurityOptions")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void updateSmime_isReturnedByGet() {
|
||||
update(withOptions(SMIME)).statusCode(200);
|
||||
|
||||
get(CS).body("MessageSecurityOptions.SigningScheme.SmimeScheme.SignatureFormat", equalTo("DETACHED"))
|
||||
.body("MessageSecurityOptions.SigningScheme", not(hasKey("DefaultScheme")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void updateWithEmptyOptionsBlock_keepsTheStoredScheme() {
|
||||
update(withOptions("{}")).statusCode(200);
|
||||
|
||||
get(CS).body("MessageSecurityOptions.SigningScheme.SmimeScheme.SignatureFormat", equalTo("DETACHED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void updateWithEmptySigningScheme_resetsToDefaultScheme() {
|
||||
update(withOptions("{\"SigningScheme\":{}}")).statusCode(200);
|
||||
|
||||
get(CS).body("MessageSecurityOptions.SigningScheme.DefaultScheme", anEmptyMap())
|
||||
.body("MessageSecurityOptions.SigningScheme", not(hasKey("SmimeScheme")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void updateWithBothUnionMembers_storesSmime() {
|
||||
update(withOptions("{\"SigningScheme\":{\"DefaultScheme\":{},"
|
||||
+ "\"SmimeScheme\":{\"SignatureFormat\":\"DETACHED\"}}}")).statusCode(200);
|
||||
|
||||
get(CS).body("MessageSecurityOptions.SigningScheme.SmimeScheme.SignatureFormat", equalTo("DETACHED"))
|
||||
.body("MessageSecurityOptions.SigningScheme", not(hasKey("DefaultScheme")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void updateDefault_replacesSmime() {
|
||||
update(withOptions(DEFAULT)).statusCode(200);
|
||||
|
||||
get(CS).body("MessageSecurityOptions.SigningScheme.DefaultScheme", anEmptyMap());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void updateSmimeWithoutFormat_storesDetached() {
|
||||
update(withOptions("{\"SigningScheme\":{\"SmimeScheme\":{}}}")).statusCode(200);
|
||||
|
||||
get(CS).body("MessageSecurityOptions.SigningScheme.SmimeScheme.SignatureFormat", equalTo("DETACHED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void updateWithUnknownFormat_isRejectedAndKeepsTheStoredScheme() {
|
||||
update(withOptions(DEFAULT)).statusCode(200);
|
||||
|
||||
update(withOptions("{\"SigningScheme\":{\"SmimeScheme\":{\"SignatureFormat\":\"ATTACHED\"}}}"))
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo(BAD_FORMAT_MESSAGE));
|
||||
update(withOptions("{\"SigningScheme\":{\"SmimeScheme\":{\"SignatureFormat\":\"detached\"}}}"))
|
||||
.statusCode(400)
|
||||
.body("message", equalTo(BAD_FORMAT_MESSAGE));
|
||||
|
||||
get(CS).body("MessageSecurityOptions.SigningScheme.DefaultScheme", anEmptyMap());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void updateMissingSet_isNotFound() {
|
||||
update("{\"ConfigurationSetName\":\"cs-message-security-missing\",\"MessageSecurityOptions\":"
|
||||
+ SMIME + "}")
|
||||
.statusCode(404)
|
||||
.body("__type", equalTo("NotFoundException"))
|
||||
.body("message", equalTo("Configuration set <cs-message-security-missing> does not exist."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void updateWithoutName_isBadRequest() {
|
||||
update("{\"MessageSecurityOptions\":" + SMIME + "}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
void createWithSmime_isReturnedByGet() {
|
||||
create("{\"ConfigurationSetName\":\"cs-message-security-created\",\"MessageSecurityOptions\":"
|
||||
+ SMIME + "}").statusCode(200);
|
||||
|
||||
get("cs-message-security-created")
|
||||
.body("MessageSecurityOptions.SigningScheme.SmimeScheme.SignatureFormat", equalTo("DETACHED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(13)
|
||||
void createWithUnknownFormat_isRejectedAndNotCreated() {
|
||||
create("{\"ConfigurationSetName\":\"cs-message-security-bad\",\"MessageSecurityOptions\":"
|
||||
+ "{\"SigningScheme\":{\"SmimeScheme\":{\"SignatureFormat\":\"ATTACHED\"}}}}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo(BAD_FORMAT_MESSAGE));
|
||||
|
||||
given().header("Authorization", AUTH_HEADER)
|
||||
.when().get("/v2/email/configuration-sets/cs-message-security-bad")
|
||||
.then().statusCode(404);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void updateWithNonObjectOptions_isSerializationError() {
|
||||
update("{\"ConfigurationSetName\":\"" + CS + "\",\"MessageSecurityOptions\":\"SMIME\"}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void updateWithNonObjectDefaultScheme_isSerializationError() {
|
||||
update(withOptions("{\"SigningScheme\":{\"DefaultScheme\":\"x\"}}"))
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
void updateWithNonStringSignatureFormat_isSerializationError() {
|
||||
update(withOptions("{\"SigningScheme\":{\"SmimeScheme\":{\"SignatureFormat\":5}}}"))
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
|
||||
private static String withOptions(String options) {
|
||||
return "{\"ConfigurationSetName\":\"" + CS + "\",\"MessageSecurityOptions\":" + options + "}";
|
||||
}
|
||||
|
||||
private static ValidatableResponse create(String body) {
|
||||
return given().contentType("application/json").header("Authorization", AUTH_HEADER).body(body)
|
||||
.when().post("/v2/email/configuration-sets")
|
||||
.then();
|
||||
}
|
||||
|
||||
private static ValidatableResponse update(String body) {
|
||||
return given().contentType("application/json").header("Authorization", AUTH_HEADER).body(body)
|
||||
.when().post("/v2/email/update-configuration-sets")
|
||||
.then();
|
||||
}
|
||||
|
||||
private static ValidatableResponse get(String name) {
|
||||
return given().header("Authorization", AUTH_HEADER)
|
||||
.when().get("/v2/email/configuration-sets/" + name)
|
||||
.then().statusCode(200);
|
||||
}
|
||||
}
|
||||
+52
@@ -1,19 +1,27 @@
|
||||
package io.github.hectorvent.floci.services.ses;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.core.storage.PersistentStorage;
|
||||
import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;
|
||||
import io.github.hectorvent.floci.services.ses.model.DeliveryOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.MessageSecurityOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.SigningScheme;
|
||||
import io.github.hectorvent.floci.services.ses.model.TrackingOptions;
|
||||
import io.github.hectorvent.floci.services.ses.model.Tag;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@@ -178,4 +186,48 @@ class SesConfigurationSetServiceTest {
|
||||
"example.com", domain -> false)).getMessage());
|
||||
service.requireVerifiedRedirectDomain("example.com", domain -> true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateMessageSecurityOptions_nullKeepsTheStoredValue() {
|
||||
service.create(cs("my-cs"), REGION);
|
||||
service.updateMessageSecurityOptions("my-cs",
|
||||
new MessageSecurityOptions(SigningScheme.smime("DETACHED")), REGION);
|
||||
|
||||
service.updateMessageSecurityOptions("my-cs", null, REGION);
|
||||
|
||||
assertEquals("DETACHED", service.get("my-cs", REGION).getMessageSecurityOptions()
|
||||
.getSigningScheme().getSmimeScheme().getSignatureFormat());
|
||||
}
|
||||
|
||||
@Test
|
||||
void messageSecurityOptions_surviveAPersistentStorageReload(@TempDir Path dir) {
|
||||
Path file = dir.resolve("ses-config-sets.json");
|
||||
SesConfigurationSetService writer = new SesConfigurationSetService(
|
||||
new PersistentStorage<>(file, new TypeReference<Map<String, ConfigurationSet>>() {}));
|
||||
writer.create(cs("smime-cs"), REGION);
|
||||
writer.create(cs("default-cs"), REGION);
|
||||
writer.updateMessageSecurityOptions("smime-cs",
|
||||
new MessageSecurityOptions(SigningScheme.smime("DETACHED")), REGION);
|
||||
writer.updateMessageSecurityOptions("default-cs",
|
||||
new MessageSecurityOptions(SigningScheme.defaultScheme()), REGION);
|
||||
|
||||
PersistentStorage<String, ConfigurationSet> reloaded =
|
||||
new PersistentStorage<>(file, new TypeReference<Map<String, ConfigurationSet>>() {});
|
||||
reloaded.load();
|
||||
SesConfigurationSetService reader = new SesConfigurationSetService(reloaded);
|
||||
|
||||
SigningScheme smime = reader.get("smime-cs", REGION).getMessageSecurityOptions().getSigningScheme();
|
||||
assertEquals("DETACHED", smime.getSmimeScheme().getSignatureFormat());
|
||||
assertNull(smime.getDefaultScheme());
|
||||
SigningScheme defaultScheme = reader.get("default-cs", REGION).getMessageSecurityOptions().getSigningScheme();
|
||||
assertEquals(Map.of(), defaultScheme.getDefaultScheme());
|
||||
assertNull(defaultScheme.getSmimeScheme());
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateMessageSecurityOptions_missingSetThrowsEvenWithoutOptions() {
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
() -> service.updateMessageSecurityOptions("ghost", null, REGION));
|
||||
assertEquals("ConfigurationSetDoesNotExist", e.getErrorCode());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user