feat(ses): add ConfigurationSet CRUD on v1 Query and v2 REST JSON (#631)

* feat(ses): add ConfigurationSet CRUD on v1 Query and v2 REST JSON

Adds Configuration Set name management on both protocols:

- v1 Query: CreateConfigurationSet, DescribeConfigurationSet,
  ListConfigurationSets, DeleteConfigurationSet
- v2 REST JSON: POST/GET (single)/GET (list)/DELETE under
  /v2/email/configuration-sets[/{name}]

Storage is region-scoped and shared across both protocols, with name as
the primary key. Tags are persisted on v2 create and returned on v2 get;
v1 only round-trips the name (real SES v1 has no tags on configuration
sets). Errors map ConfigurationSetAlreadyExists / ConfigurationSetDoesNotExist
(v1) onto AlreadyExistsException 400 and NotFoundException 404 (v2)
via the existing SesController remap helper.

Field validation (per AWS limits): ConfigurationSetName must match
^[A-Za-z0-9_-]{1,64}$; each Tag Key is 1-128 chars and each Tag Value is
0-256 chars; non-array Tags are rejected with BadRequestException.

Out of scope (future PRs): SendingOptions / EventDestinations /
TrackingOptions / DeliveryOptions / ReputationOptions / SuppressionOptions /
VdmOptions, and ConfigurationSetName validation in the Send* APIs.

* fix(ses): allow Tag without Value on ConfigurationSet create

AWS SDKs commonly omit Tag.Value when only the key matters
(Tag.builder().key("env").build()), serialising the request without a
Value field. Floci was rejecting these calls with "Tag Value is
required", diverging from typical SDK and LocalStack behaviour. Drop
the required-value check; the 0-256 length constraint still applies
when a value is present.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-04-28 20:21:07 -05:00
1 parent e3368e014c
commit cd42caa254
10 files changed
+995 -4

No files matched your search

@@ -0,0 +1,192 @@
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;
/**
* Integration tests for SES V1 Query-protocol ConfigurationSet CRUD.
*/
@QuarkusTest
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class SesConfigurationSetV1IntegrationTest {
private static final String AUTH =
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request";
@Test
@Order(1)
void createConfigurationSet() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "CreateConfigurationSet")
.formParam("ConfigurationSet.Name", "v1-cs-alpha")
.when()
.post("/")
.then()
.statusCode(200)
.body(containsString("CreateConfigurationSetResponse"));
}
@Test
@Order(2)
void createConfigurationSet_duplicateRejected() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "CreateConfigurationSet")
.formParam("ConfigurationSet.Name", "v1-cs-alpha")
.when()
.post("/")
.then()
.statusCode(400)
.body(containsString("<Code>ConfigurationSetAlreadyExists</Code>"));
}
@Test
@Order(3)
void describeConfigurationSet() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "DescribeConfigurationSet")
.formParam("ConfigurationSetName", "v1-cs-alpha")
.when()
.post("/")
.then()
.statusCode(200)
.body(containsString("<Name>v1-cs-alpha</Name>"));
}
@Test
@Order(4)
void describeConfigurationSet_unknownReturns400() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "DescribeConfigurationSet")
.formParam("ConfigurationSetName", "v1-cs-ghost")
.when()
.post("/")
.then()
.statusCode(400)
.body(containsString("<Code>ConfigurationSetDoesNotExist</Code>"));
}
@Test
@Order(5)
void listConfigurationSets() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "CreateConfigurationSet")
.formParam("ConfigurationSet.Name", "v1-cs-beta")
.when()
.post("/")
.then()
.statusCode(200);
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "ListConfigurationSets")
.when()
.post("/")
.then()
.statusCode(200)
.body(containsString("<Name>v1-cs-alpha</Name>"))
.body(containsString("<Name>v1-cs-beta</Name>"));
}
@Test
@Order(6)
void deleteConfigurationSet() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "DeleteConfigurationSet")
.formParam("ConfigurationSetName", "v1-cs-alpha")
.when()
.post("/")
.then()
.statusCode(200)
.body(containsString("DeleteConfigurationSetResponse"));
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "DescribeConfigurationSet")
.formParam("ConfigurationSetName", "v1-cs-alpha")
.when()
.post("/")
.then()
.statusCode(400)
.body(containsString("<Code>ConfigurationSetDoesNotExist</Code>"));
}
@Test
@Order(7)
void deleteConfigurationSet_unknownReturns400() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "DeleteConfigurationSet")
.formParam("ConfigurationSetName", "v1-cs-ghost")
.when()
.post("/")
.then()
.statusCode(400)
.body(containsString("<Code>ConfigurationSetDoesNotExist</Code>"));
}
@Test
@Order(8)
void createConfigurationSet_missingName() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "CreateConfigurationSet")
.when()
.post("/")
.then()
.statusCode(400)
.body(containsString("<Code>InvalidParameterValue</Code>"));
}
@Test
@Order(9)
void createConfigurationSet_invalidNameCharacters() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "CreateConfigurationSet")
.formParam("ConfigurationSet.Name", "bad name!")
.when()
.post("/")
.then()
.statusCode(400)
.body(containsString("<Code>InvalidParameterValue</Code>"));
}
@Test
@Order(10)
void createConfigurationSet_nameTooLong() {
String longName = "a".repeat(65);
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", AUTH)
.formParam("Action", "CreateConfigurationSet")
.formParam("ConfigurationSet.Name", longName)
.when()
.post("/")
.then()
.statusCode(400)
.body(containsString("<Code>InvalidParameterValue</Code>"));
}
}
@@ -0,0 +1,287 @@
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.equalTo;
import static org.hamcrest.Matchers.hasItem;
/**
* Integration tests for SES V2 ConfigurationSet endpoints under /v2/email/configuration-sets.
*/
@QuarkusTest
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class SesConfigurationSetV2IntegrationTest {
private static final String AUTH_HEADER =
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
@Test
@Order(1)
void createConfigurationSet() {
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("""
{
"ConfigurationSetName": "v2-cs-alpha",
"Tags": [{"Key": "env", "Value": "test"}]
}
""")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
}
@Test
@Order(2)
void createConfigurationSet_duplicateRejected() {
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("""
{"ConfigurationSetName": "v2-cs-alpha"}
""")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(400)
.body("__type", equalTo("AlreadyExistsException"));
}
@Test
@Order(3)
void createConfigurationSet_tagsNotArray() {
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("""
{
"ConfigurationSetName": "v2-cs-bad-tags",
"Tags": "not-an-array"
}
""")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(400)
.body("__type", equalTo("BadRequestException"));
}
@Test
@Order(4)
void createConfigurationSet_missingName() {
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("{}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(400)
.body("__type", equalTo("BadRequestException"));
}
@Test
@Order(5)
void getConfigurationSet_returnsRoundTrip() {
given()
.header("Authorization", AUTH_HEADER)
.when()
.get("/v2/email/configuration-sets/v2-cs-alpha")
.then()
.statusCode(200)
.body("ConfigurationSetName", equalTo("v2-cs-alpha"))
.body("Tags[0].Key", equalTo("env"))
.body("Tags[0].Value", equalTo("test"));
}
@Test
@Order(6)
void getConfigurationSet_unknownReturns404() {
given()
.header("Authorization", AUTH_HEADER)
.when()
.get("/v2/email/configuration-sets/v2-cs-ghost")
.then()
.statusCode(404)
.body("__type", equalTo("NotFoundException"));
}
@Test
@Order(7)
void listConfigurationSets() {
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("""
{"ConfigurationSetName": "v2-cs-beta"}
""")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.header("Authorization", AUTH_HEADER)
.when()
.get("/v2/email/configuration-sets")
.then()
.statusCode(200)
.body("ConfigurationSets", hasItem("v2-cs-alpha"))
.body("ConfigurationSets", hasItem("v2-cs-beta"));
}
@Test
@Order(8)
void deleteConfigurationSet() {
given()
.header("Authorization", AUTH_HEADER)
.when()
.delete("/v2/email/configuration-sets/v2-cs-alpha")
.then()
.statusCode(200);
given()
.header("Authorization", AUTH_HEADER)
.when()
.get("/v2/email/configuration-sets/v2-cs-alpha")
.then()
.statusCode(404);
}
@Test
@Order(9)
void deleteConfigurationSet_unknownReturns404() {
given()
.header("Authorization", AUTH_HEADER)
.when()
.delete("/v2/email/configuration-sets/v2-cs-ghost")
.then()
.statusCode(404)
.body("__type", equalTo("NotFoundException"));
}
@Test
@Order(10)
void createConfigurationSet_invalidNameCharacters() {
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("""
{"ConfigurationSetName": "bad name!"}
""")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(400)
.body("__type", equalTo("BadRequestException"));
}
@Test
@Order(11)
void createConfigurationSet_nameTooLong() {
String longName = "a".repeat(65);
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("""
{"ConfigurationSetName": "%s"}
""".formatted(longName))
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(400)
.body("__type", equalTo("BadRequestException"));
}
@Test
@Order(12)
void createConfigurationSet_tagWithMissingValue_roundTripsAsAbsent() {
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("""
{
"ConfigurationSetName": "v2-cs-tag-no-value",
"Tags": [{"Key": "env"}]
}
""")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.header("Authorization", AUTH_HEADER)
.when()
.get("/v2/email/configuration-sets/v2-cs-tag-no-value")
.then()
.statusCode(200)
.body("Tags[0].Key", equalTo("env"));
}
@Test
@Order(13)
void createConfigurationSet_tagWithMissingKey_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("""
{
"ConfigurationSetName": "v2-cs-bad-tag-key",
"Tags": [{"Value": "v"}]
}
""")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(400)
.body("__type", equalTo("BadRequestException"));
}
@Test
@Order(14)
void createConfigurationSet_tagKeyTooLong() {
String longKey = "k".repeat(129);
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("""
{
"ConfigurationSetName": "v2-cs-long-tag-key",
"Tags": [{"Key": "%s", "Value": "v"}]
}
""".formatted(longKey))
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(400)
.body("__type", equalTo("BadRequestException"));
}
@Test
@Order(15)
void createConfigurationSet_tagValueTooLong() {
String longValue = "v".repeat(257);
given()
.contentType("application/json")
.header("Authorization", AUTH_HEADER)
.body("""
{
"ConfigurationSetName": "v2-cs-long-tag-value",
"Tags": [{"Key": "k", "Value": "%s"}]
}
""".formatted(longValue))
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(400)
.body("__type", equalTo("BadRequestException"));
}
}
@@ -1,6 +1,7 @@
package io.github.hectorvent.floci.services.ses;
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;
import io.github.hectorvent.floci.services.ses.model.EmailTemplate;
import io.github.hectorvent.floci.services.ses.model.Identity;
import io.github.hectorvent.floci.services.ses.model.SentEmail;
@@ -31,6 +32,7 @@ class SesServiceSmtpTest {
emailStore,
new InMemoryStorage<String, Boolean>(),
new InMemoryStorage<String, EmailTemplate>(),
new InMemoryStorage<String, ConfigurationSet>(),
smtpRelay);
}