mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -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
+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