diff --git a/docs/services/ses.md b/docs/services/ses.md index 4475fe558b..3ef790a52a 100644 --- a/docs/services/ses.md +++ b/docs/services/ses.md @@ -311,6 +311,6 @@ ARN handling is uniform across the six types (probe-confirmed against real AWS). The same AWS-compatible validation applies wherever tags are set (including `CreateContactList` and `TagResource`): at most 50 tags, unique keys, keys 1–128 / values 0–256 code points, characters limited to letters, numbers, Unicode whitespace and `_ . : / = + - @`, and the reserved `aws:` key prefix. `TagResource` applies the 50-tag limit to the merged (existing + incoming) set. Violations return `BadRequestException` with AWS's messages. -Identity, identity-policy, template, custom-verification-template, configuration-set, and sent-message state is shared between the v1 Query API and the v2 REST JSON API, so a template created with `CreateTemplate` resolves through `SendEmail` on v2 (and vice versa), a policy written with `PutIdentityPolicy` (v1) is returned by `GetEmailIdentityPolicies` (v2), a custom verification email template created with `CreateCustomVerificationEmailTemplate` (v1) is returned by `GetCustomVerificationEmailTemplate` (v2), a configuration set created with `CreateConfigurationSet` is visible to both `DescribeConfigurationSet` (v1) and `GetConfigurationSet` (v2), and every send appears in the same `GET /_aws/ses` inspection mailbox. +Identity, identity-policy, template, custom-verification-template, configuration-set, and sent-message state is shared between the v1 Query API and the v2 REST JSON API, so a template created with `CreateTemplate` resolves through `SendEmail` on v2 (and vice versa), a policy written with `PutIdentityPolicy` (v1) is returned by `GetEmailIdentityPolicies` (v2), a custom verification email template created with `CreateCustomVerificationEmailTemplate` (v1) is returned by `GetCustomVerificationEmailTemplate` (v2), a configuration set created with `CreateConfigurationSet` is visible to both `DescribeConfigurationSet` (v1) and `GetConfigurationSet` (v2), delivery options written with either `PutConfigurationSetDeliveryOptions` read back through both (v1 spells the policy `Require`/`Optional`, v2 `REQUIRE`/`OPTIONAL`, matching each API), and every send appears in the same `GET /_aws/ses` inspection mailbox. DKIM follows AWS's domain-centric model. A **domain** identity carries DKIM tokens (generated at verification, stable across `VerifyDomainDkim` calls); its `DkimVerificationStatus` tracks **DNS record detection** — it transitions to `Success` when the expected `._domainkey.` CNAMEs are present in the Route53 emulation, not when DKIM is enabled. An **email** identity has no DKIM of its own: its `DkimAttributes` (`SigningEnabled`, `Status`, `Tokens`) are inherited from its parent domain identity when one is registered. The parent is the exact domain after the `@` (verified against AWS): a verified `example.com` covers `user@example.com` but not `user@mail.example.com` unless `mail.example.com` is itself a registered identity. `SetIdentityDkimEnabled` / `PutEmailIdentityDkimAttributes` only toggle the signing flag (they no longer force the verification status); `PutEmailIdentityDkimSigningAttributes` sets the signing origin (`AWS_SES` Easy DKIM — regenerating tokens when the key length changes — or `EXTERNAL` BYODKIM). diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java index e5bb966474..d56e343fa8 100644 --- a/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java +++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java @@ -770,6 +770,12 @@ public class SesQueryHandler { .elem("CustomRedirectDomain", cs.getTrackingOptions().getCustomRedirectDomain()) .end("TrackingOptions"); } + if (attrs.contains("deliveryOptions") && cs.getDeliveryOptions() != null + && cs.getDeliveryOptions().getTlsPolicy() != null) { + xml.start("DeliveryOptions") + .elem("TlsPolicy", toV1TlsPolicy(cs.getDeliveryOptions().getTlsPolicy())) + .end("DeliveryOptions"); + } return Response.ok(AwsQueryResponse.envelope("DescribeConfigurationSet", AwsNamespaces.SES, xml.build())).build(); } @@ -951,6 +957,19 @@ public class SesQueryHandler { "PutConfigurationSetDeliveryOptions", AwsNamespaces.SES)).build(); } + /** + * V1 spells the TLS policy {@code Require}/{@code Optional}; Floci stores the V2 canonical + * {@code REQUIRE}/{@code OPTIONAL} that {@link #handlePutConfigurationSetDeliveryOptions} + * normalises to. Anything unrecognised is passed through unchanged rather than mangled. + */ + private static String toV1TlsPolicy(String stored) { + return switch (stored) { + case "REQUIRE" -> "Require"; + case "OPTIONAL" -> "Optional"; + default -> stored; + }; + } + private Response handleCreateReceiptRuleSet(MultivaluedMap params, String region) { sesService.createReceiptRuleSet(getParam(params, "RuleSetName"), region); return Response.ok(AwsQueryResponse.envelopeEmptyResult( diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetV1IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetV1IntegrationTest.java index 08cbecf3e2..1aa7d01f1c 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetV1IntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetV1IntegrationTest.java @@ -8,6 +8,7 @@ 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 CRUD. @@ -252,4 +253,107 @@ class SesConfigurationSetV1IntegrationTest { .body(containsString("deliveryOptions.tlsPolicy")) .body(containsString("[Optional, Require]")); } + + /** + * The write path already stored the TLS policy — v2 {@code GetConfigurationSet} returned it — + * but the v1 projection never read it back, so the Terraform provider re-added the block on + * every plan. Order 11 above sets a policy and never describes it, which is how the gap + * survived; this covers the read. + */ + @Test + @Order(14) + void describeConfigurationSetReturnsDeliveryOptions() { + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", AUTH) + .formParam("Action", "CreateConfigurationSet") + .formParam("ConfigurationSet.Name", "v1-cs-delivery-readback") + .when() + .post("/") + .then() + .statusCode(200); + + // Never set: AWS omits the member even when it is explicitly requested. + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", AUTH) + .formParam("Action", "DescribeConfigurationSet") + .formParam("ConfigurationSetName", "v1-cs-delivery-readback") + .formParam("ConfigurationSetAttributeNames.member.1", "deliveryOptions") + .when() + .post("/") + .then() + .statusCode(200) + .body(not(containsString(""))); + + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", AUTH) + .formParam("Action", "PutConfigurationSetDeliveryOptions") + .formParam("ConfigurationSetName", "v1-cs-delivery-readback") + .formParam("DeliveryOptions.TlsPolicy", "Require") + .when() + .post("/") + .then() + .statusCode(200); + + // V1 spells it Require, not the V2 REQUIRE that is stored internally. + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", AUTH) + .formParam("Action", "DescribeConfigurationSet") + .formParam("ConfigurationSetName", "v1-cs-delivery-readback") + .formParam("ConfigurationSetAttributeNames.member.1", "deliveryOptions") + .when() + .post("/") + .then() + .statusCode(200) + .body(containsString("")) + .body(containsString("Require")); + + // Gated on the attribute name: without it the member stays out, as AWS does. + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", AUTH) + .formParam("Action", "DescribeConfigurationSet") + .formParam("ConfigurationSetName", "v1-cs-delivery-readback") + .when() + .post("/") + .then() + .statusCode(200) + .body(not(containsString(""))); + + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", AUTH) + .formParam("Action", "PutConfigurationSetDeliveryOptions") + .formParam("ConfigurationSetName", "v1-cs-delivery-readback") + .formParam("DeliveryOptions.TlsPolicy", "Optional") + .when() + .post("/") + .then() + .statusCode(200); + + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", AUTH) + .formParam("Action", "DescribeConfigurationSet") + .formParam("ConfigurationSetName", "v1-cs-delivery-readback") + .formParam("ConfigurationSetAttributeNames.member.1", "deliveryOptions") + .when() + .post("/") + .then() + .statusCode(200) + .body(containsString("Optional")); + + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", AUTH) + .formParam("Action", "DeleteConfigurationSet") + .formParam("ConfigurationSetName", "v1-cs-delivery-readback") + .when() + .post("/") + .then() + .statusCode(200); + } }