Light, fluffy, and always free - The AWS Local Emulator alternative
feat(ses): implement custom verification email templates for v1 and v2 (#1840)
Kenshin Okinakaaed50cc2b218
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesCustomVerificationEmailTemplateTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesCustomVerificationEmailTemplateTest.javanew file mode 100644index 0000000000..8f1ca0b803--- /dev/null+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesCustomVerificationEmailTemplateTest.java@@ -0,0 +1,121 @@+package com.floci.test;++import org.junit.jupiter.api.AfterAll;+import org.junit.jupiter.api.BeforeAll;+import org.junit.jupiter.api.DisplayName;+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 software.amazon.awssdk.services.ses.SesClient;+import software.amazon.awssdk.services.ses.model.CreateCustomVerificationEmailTemplateRequest;++import software.amazon.awssdk.services.sesv2.SesV2Client;+import software.amazon.awssdk.services.sesv2.model.AlreadyExistsException;+import software.amazon.awssdk.services.sesv2.model.CreateEmailIdentityRequest;+import software.amazon.awssdk.services.sesv2.model.DeleteEmailIdentityRequest;+import software.amazon.awssdk.services.sesv2.model.GetCustomVerificationEmailTemplateResponse;+import software.amazon.awssdk.services.sesv2.model.NotFoundException;++import static org.assertj.core.api.Assertions.assertThat;+import static org.assertj.core.api.Assertions.assertThatThrownBy;++/**+ * SDK compatibility test for the SES custom-verification-email-template APIs across both protocols+ * against a live Floci instance: v2 Create/Get/List/Update/Delete plus the duplicate/not-found+ * errors, and the shared store (a v1-written template is visible via the v2 Get).+ */+@DisplayName("SES custom verification email templates (v1 + v2)")+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)+class SesCustomVerificationEmailTemplateTest {++ private static final String FROM = "[email protected]";+ private static final String NAME = "cvet-sdk-a";++ private static SesClient sesV1;+ private static SesV2Client sesV2;++ @BeforeAll+ static void setup() {+ sesV1 = TestFixtures.sesClient();+ sesV2 = TestFixtures.sesV2Client();+ sesV2.createEmailIdentity(CreateEmailIdentityRequest.builder().emailIdentity(FROM).build());+ }++ @AfterAll+ static void cleanup() {+ if (sesV2 != null) {+ for (String n : new String[] {NAME, "cvet-sdk-shared"}) {+ try {+ sesV2.deleteCustomVerificationEmailTemplate(b -> b.templateName(n));+ } catch (Exception ignored) {+ // Best-effort cleanup: the template may already be gone.+ }+ }+ try {+ sesV2.deleteEmailIdentity(DeleteEmailIdentityRequest.builder().emailIdentity(FROM).build());+ } catch (Exception ignored) {+ // Best-effort cleanup.+ }+ sesV2.close();+ }+ if (sesV1 != null) {+ sesV1.close();+ }+ }++ @Test+ @Order(1)+ void v2_createGetListUpdate() {+ sesV2.createCustomVerificationEmailTemplate(b -> b+ .templateName(NAME).fromEmailAddress(FROM).templateSubject("Verify")+ .templateContent("<html><body>verify</body></html>")+ .successRedirectionURL("https://example.com/ok")+ .failureRedirectionURL("https://example.com/fail"));++ GetCustomVerificationEmailTemplateResponse got =+ sesV2.getCustomVerificationEmailTemplate(b -> b.templateName(NAME));+ assertThat(got.templateName()).isEqualTo(NAME);+ assertThat(got.fromEmailAddress()).isEqualTo(FROM);+ assertThat(got.templateContent()).contains("verify");++ assertThat(sesV2.listCustomVerificationEmailTemplates(b -> {})+ .customVerificationEmailTemplates())+ .anyMatch(t -> NAME.equals(t.templateName()));++ sesV2.updateCustomVerificationEmailTemplate(b -> b+ .templateName(NAME).fromEmailAddress(FROM).templateSubject("Updated")+ .templateContent("<html><body>verify</body></html>")+ .successRedirectionURL("https://example.com/ok2")+ .failureRedirectionURL("https://example.com/fail"));+ assertThat(sesV2.getCustomVerificationEmailTemplate(b -> b.templateName(NAME)).templateSubject())+ .isEqualTo("Updated");+ }++ @Test+ @Order(2)+ void v2_duplicateAndMissingErrors() {+ assertThatThrownBy(() -> sesV2.createCustomVerificationEmailTemplate(b -> b+ .templateName(NAME).fromEmailAddress(FROM).templateSubject("x")+ .templateContent("c").successRedirectionURL("https://e.com/o")+ .failureRedirectionURL("https://e.com/f")))+ .isInstanceOf(AlreadyExistsException.class);++ assertThatThrownBy(() -> sesV2.getCustomVerificationEmailTemplate(b -> b.templateName("nope-sdk")))+ .isInstanceOf(NotFoundException.class);+ }++ @Test+ @Order(3)+ void v1WrittenTemplate_isVisibleViaV2() {+ sesV1.createCustomVerificationEmailTemplate(CreateCustomVerificationEmailTemplateRequest.builder()+ .templateName("cvet-sdk-shared").fromEmailAddress(FROM).templateSubject("Shared")+ .templateContent("<html><body>verify</body></html>")+ .successRedirectionURL("https://example.com/ok")+ .failureRedirectionURL("https://example.com/fail").build());++ assertThat(sesV2.getCustomVerificationEmailTemplate(b -> b.templateName("cvet-sdk-shared"))+ .templateSubject()).isEqualTo("Shared");+ }+}diff --git a/docs/services/ses.md b/docs/services/ses.mdindex b3695b0282..aa1a5e6529 100644--- a/docs/services/ses.md+++ b/docs/services/ses.md@@ -25,6 +25,11 @@ Floci exposes the classic Amazon SES Query API used by `aws ses ...` commands an| `DeleteTemplate` | Remove a stored template || `ListTemplates` | List stored templates || `TestRenderTemplate` | Render a stored template against supplied data, returning the MIME message |+| `CreateCustomVerificationEmailTemplate` | Create a custom verification email template |+| `GetCustomVerificationEmailTemplate` | Return a custom verification email template |+| `ListCustomVerificationEmailTemplates` | List custom verification email templates (no content) |+| `UpdateCustomVerificationEmailTemplate` | Replace a custom verification email template |+| `DeleteCustomVerificationEmailTemplate` | Delete a custom verification email template || `GetSendQuota` | Return local send quota counters || `GetSendStatistics` | Return aggregate delivery stats for sent messages || `GetAccountSendingEnabled` | Report whether sending is enabled |@@ -168,6 +173,7 @@ curl $AWS_ENDPOINT_URL/_aws/ses- `SetIdentityNotificationTopic` publishes to the configured topic on a Bounce/Complaint/Delivery event (triggered via the mailbox simulator addresses or the suppression list), independent of any configuration set. The payload uses the legacy format (`notificationType`, no `mail.tags`, headers only when `SetIdentityHeadersInNotificationsEnabled` is on).- Identity (sending authorization) policies are stored and returned as metadata: the policy document, the per-identity limit of 20, and the create/update/delete error shapes match AWS, but Floci does not evaluate policy authorization (Principal-account existence, Resource-ARN match) or gate sending on it.- Receipt rule sets are stored inertly: Floci has no inbound-mail endpoint, so a rule set never holds any receipt rules and routes no mail. `CreateReceiptRuleSet` / `DescribeReceiptRuleSet` (Rules always empty) / `ListReceiptRuleSets` / `DeleteReceiptRuleSet` (idempotent) and `SetActiveReceiptRuleSet` / `DescribeActiveReceiptRuleSet` round-trip so tools like Terraform (`aws_ses_receipt_rule_set`, `aws_ses_active_receipt_rule_set`) can declare a rule set during bootstrap. Individual receipt rules and receipt filters are not implemented.+- Custom verification email templates are stored and returned; `Create`/`Update` require the `FromEmailAddress` to be a verified identity (or a verified domain) and reject an invalid redirection URL, matching AWS. `SendCustomVerificationEmail` is not yet implemented.- For the REST JSON API see [SES v2](#v2) below.## SES v2 (REST JSON) {#v2}@@ -204,6 +210,11 @@ Alongside the classic Query API, Floci implements a subset of the SES v2 REST JS| `PUT` | `/v2/email/templates/{templateName}` | `UpdateEmailTemplate` || `DELETE` | `/v2/email/templates/{templateName}` | `DeleteEmailTemplate` || `POST` | `/v2/email/templates/{templateName}/render` | `TestRenderEmailTemplate` |+| `POST` | `/v2/email/custom-verification-email-templates` | `CreateCustomVerificationEmailTemplate` |+| `GET` | `/v2/email/custom-verification-email-templates` | `ListCustomVerificationEmailTemplates` |+| `GET` | `/v2/email/custom-verification-email-templates/{templateName}` | `GetCustomVerificationEmailTemplate` |+| `PUT` | `/v2/email/custom-verification-email-templates/{templateName}` | `UpdateCustomVerificationEmailTemplate` |+| `DELETE` | `/v2/email/custom-verification-email-templates/{templateName}` | `DeleteCustomVerificationEmailTemplate` || `POST` | `/v2/email/configuration-sets` | `CreateConfigurationSet` || `GET` | `/v2/email/configuration-sets` | `ListConfigurationSets` || `GET` | `/v2/email/configuration-sets/{name}` | `GetConfigurationSet` |@@ -266,4 +277,4 @@ For a **single-recipient** list-managed send, Floci injects a functional unsubscTag operations support these ARN forms: `arn:aws:ses:<region>:<account>:configuration-set/<name>`, `arn:aws:ses:<region>:<account>:template/<name>`, and `arn:aws:ses:<region>:<account>:identity/<email-or-domain>`. Tags supplied to `CreateConfigurationSet`, `CreateEmailTemplate`, and `CreateEmailIdentity` are reachable through `ListTagsForResource`; `UpdateEmailTemplate` does not modify tags. Other resource types return `NotFoundException`.-Identity, identity-policy, 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 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), and every send appears in the same `GET /_aws/ses` inspection mailbox.diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.javaindex 7c364bd7ec..37e1954b79 100644--- a/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java@@ -395,6 +395,9 @@ public class AwsQueryController {"CreateTemplate", "UpdateTemplate", "GetTemplate", "DeleteTemplate","ListTemplates", "SendTemplatedEmail", "SendBulkTemplatedEmail","TestRenderTemplate",+ "CreateCustomVerificationEmailTemplate", "GetCustomVerificationEmailTemplate",+ "ListCustomVerificationEmailTemplates", "UpdateCustomVerificationEmailTemplate",+ "DeleteCustomVerificationEmailTemplate","CreateConfigurationSet", "DescribeConfigurationSet","ListConfigurationSets", "DeleteConfigurationSet","CreateConfigurationSetEventDestination",diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesController.javaindex 46ecf7c356..ab9011020f 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java@@ -11,6 +11,7 @@ import io.github.hectorvent.floci.services.ses.model.BulkEmailEntryResult;import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.Contact;import io.github.hectorvent.floci.services.ses.model.ContactList;+import io.github.hectorvent.floci.services.ses.model.CustomVerificationEmailTemplate;import io.github.hectorvent.floci.services.ses.model.DedicatedIpPool;import io.github.hectorvent.floci.services.ses.model.Topic;import io.github.hectorvent.floci.services.ses.model.TopicPreference;@@ -629,6 +630,104 @@ public class SesController {// ──────────────────────────── Templates ────────────────────────────+ // ──────────────── Custom verification email templates ────────────────++ @POST+ @Path("/custom-verification-email-templates")+ public Response createCustomVerificationEmailTemplate(@Context HttpHeaders headers, String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ CustomVerificationEmailTemplate t = parseCvet(objectMapper.readTree(body));+ sesService.createCustomVerificationEmailTemplate(t, region);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ } catch (com.fasterxml.jackson.core.JsonProcessingException e) {+ throw new AwsException("BadRequestException", e.getMessage(), 400);+ }+ }++ @GET+ @Path("/custom-verification-email-templates")+ public Response listCustomVerificationEmailTemplates(@Context HttpHeaders headers) {+ String region = regionResolver.resolveRegion(headers);+ ObjectNode result = objectMapper.createObjectNode();+ ArrayNode items = result.putArray("CustomVerificationEmailTemplates");+ for (CustomVerificationEmailTemplate t : sesService.listCustomVerificationEmailTemplates(region)) {+ items.add(cvetJson(t, false));+ }+ return Response.ok(result).build();+ }++ @GET+ @Path("/custom-verification-email-templates/{templateName}")+ public Response getCustomVerificationEmailTemplate(@Context HttpHeaders headers,+ @PathParam("templateName") String templateName) {+ String region = regionResolver.resolveRegion(headers);+ try {+ return Response.ok(+ cvetJson(sesService.getCustomVerificationEmailTemplate(templateName, region), true)).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ @PUT+ @Path("/custom-verification-email-templates/{templateName}")+ public Response updateCustomVerificationEmailTemplate(@Context HttpHeaders headers,+ @PathParam("templateName") String templateName, String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ CustomVerificationEmailTemplate t = parseCvet(objectMapper.readTree(body));+ t.setTemplateName(templateName);+ sesService.updateCustomVerificationEmailTemplate(t, region);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ } catch (com.fasterxml.jackson.core.JsonProcessingException e) {+ throw new AwsException("BadRequestException", e.getMessage(), 400);+ }+ }++ @DELETE+ @Path("/custom-verification-email-templates/{templateName}")+ public Response deleteCustomVerificationEmailTemplate(@Context HttpHeaders headers,+ @PathParam("templateName") String templateName) {+ String region = regionResolver.resolveRegion(headers);+ try {+ sesService.deleteCustomVerificationEmailTemplate(templateName, region);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ private CustomVerificationEmailTemplate parseCvet(JsonNode request) {+ requireJsonObject(request);+ CustomVerificationEmailTemplate t = new CustomVerificationEmailTemplate();+ t.setTemplateName(request.path("TemplateName").asText(null));+ t.setFromEmailAddress(request.path("FromEmailAddress").asText(null));+ t.setTemplateSubject(request.path("TemplateSubject").asText(null));+ t.setTemplateContent(request.path("TemplateContent").asText(null));+ t.setSuccessRedirectionURL(request.path("SuccessRedirectionURL").asText(null));+ t.setFailureRedirectionURL(request.path("FailureRedirectionURL").asText(null));+ return t;+ }++ // List omits TemplateContent (matches AWS); Get includes it.+ private ObjectNode cvetJson(CustomVerificationEmailTemplate t, boolean includeContent) {+ ObjectNode o = objectMapper.createObjectNode();+ o.put("TemplateName", t.getTemplateName());+ o.put("FromEmailAddress", t.getFromEmailAddress());+ o.put("TemplateSubject", t.getTemplateSubject());+ if (includeContent) {+ o.put("TemplateContent", t.getTemplateContent());+ }+ o.put("SuccessRedirectionURL", t.getSuccessRedirectionURL());+ o.put("FailureRedirectionURL", t.getFailureRedirectionURL());+ return o;+ }+@POST@Path("/templates")public Response createEmailTemplate(@Context HttpHeaders headers, String body) {@@ -2250,9 +2349,11 @@ public class SesController {case "InvalidParameterValue", "InvalidTemplate", "ValidationError","InvalidRenderingParameter", "MissingRenderingAttribute" ->new AwsException("BadRequestException", e.getMessage(), 400);- case "TemplateDoesNotExist", "ConfigurationSetDoesNotExist" ->+ case "TemplateDoesNotExist", "ConfigurationSetDoesNotExist",+ "CustomVerificationEmailTemplateDoesNotExist", "FromEmailAddressNotVerified" ->new AwsException("NotFoundException", e.getMessage(), 404);- case "AlreadyExists", "ConfigurationSetAlreadyExists" ->+ case "AlreadyExists", "ConfigurationSetAlreadyExists",+ "CustomVerificationEmailTemplateAlreadyExists" ->new AwsException("AlreadyExistsException", e.getMessage(), 400);case "ConfigurationSetSendingPausedException" ->new AwsException("SendingPausedException", e.getMessage(), 400);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.javaindex 3b665f38b6..f1ec30b82d 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@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.services.ses.model.BulkEmailEntryResult;import io.github.hectorvent.floci.services.ses.model.CloudWatchDestination;import io.github.hectorvent.floci.services.ses.model.CloudWatchDimensionConfiguration;import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;+import io.github.hectorvent.floci.services.ses.model.CustomVerificationEmailTemplate;import io.github.hectorvent.floci.services.ses.model.DeliveryOptions;import io.github.hectorvent.floci.services.ses.model.EmailTemplate;import io.github.hectorvent.floci.services.ses.model.EventDestination;@@ -86,6 +87,16 @@ public class SesQueryHandler {case "SendTemplatedEmail" -> handleSendTemplatedEmail(params, region);case "SendBulkTemplatedEmail" -> handleSendBulkTemplatedEmail(params, region);case "TestRenderTemplate" -> handleTestRenderTemplate(params, region);+ case "CreateCustomVerificationEmailTemplate" ->+ handleCreateCustomVerificationEmailTemplate(params, region);+ case "GetCustomVerificationEmailTemplate" ->+ handleGetCustomVerificationEmailTemplate(params, region);+ case "ListCustomVerificationEmailTemplates" ->+ handleListCustomVerificationEmailTemplates(region);+ case "UpdateCustomVerificationEmailTemplate" ->+ handleUpdateCustomVerificationEmailTemplate(params, region);+ case "DeleteCustomVerificationEmailTemplate" ->+ handleDeleteCustomVerificationEmailTemplate(params, region);case "CreateConfigurationSet" -> handleCreateConfigurationSet(params, region);case "DescribeConfigurationSet" -> handleDescribeConfigurationSet(params, region);case "ListConfigurationSets" -> handleListConfigurationSets(region);@@ -549,6 +560,68 @@ public class SesQueryHandler {return Response.ok(AwsQueryResponse.envelope("TestRenderTemplate", AwsNamespaces.SES, result)).build();}+ // --- Custom verification email templates ---++ private Response handleCreateCustomVerificationEmailTemplate(MultivaluedMap<String, String> params, String region) {+ sesService.createCustomVerificationEmailTemplate(readCvetParams(params), region);+ return Response.ok(AwsQueryResponse.envelopeEmptyResult(+ "CreateCustomVerificationEmailTemplate", AwsNamespaces.SES)).build();+ }++ private Response handleUpdateCustomVerificationEmailTemplate(MultivaluedMap<String, String> params, String region) {+ sesService.updateCustomVerificationEmailTemplate(readCvetParams(params), region);+ return Response.ok(AwsQueryResponse.envelopeEmptyResult(+ "UpdateCustomVerificationEmailTemplate", AwsNamespaces.SES)).build();+ }++ private Response handleGetCustomVerificationEmailTemplate(MultivaluedMap<String, String> params, String region) {+ CustomVerificationEmailTemplate t = sesService.getCustomVerificationEmailTemplate(+ requireParam(params, "TemplateName"), region);+ String xml = new XmlBuilder()+ .elem("TemplateName", t.getTemplateName())+ .elem("FromEmailAddress", t.getFromEmailAddress())+ .elem("TemplateSubject", t.getTemplateSubject())+ .elem("TemplateContent", t.getTemplateContent())+ .elem("SuccessRedirectionURL", t.getSuccessRedirectionURL())+ .elem("FailureRedirectionURL", t.getFailureRedirectionURL())+ .build();+ return Response.ok(AwsQueryResponse.envelope(+ "GetCustomVerificationEmailTemplate", AwsNamespaces.SES, xml)).build();+ }++ private Response handleListCustomVerificationEmailTemplates(String region) {+ XmlBuilder xml = new XmlBuilder().start("CustomVerificationEmailTemplates");+ for (CustomVerificationEmailTemplate t : sesService.listCustomVerificationEmailTemplates(region)) {+ xml.start("member")+ .elem("TemplateName", t.getTemplateName())+ .elem("FromEmailAddress", t.getFromEmailAddress())+ .elem("TemplateSubject", t.getTemplateSubject())+ .elem("SuccessRedirectionURL", t.getSuccessRedirectionURL())+ .elem("FailureRedirectionURL", t.getFailureRedirectionURL())+ .end("member");+ }+ xml.end("CustomVerificationEmailTemplates");+ return Response.ok(AwsQueryResponse.envelope(+ "ListCustomVerificationEmailTemplates", AwsNamespaces.SES, xml.build())).build();+ }++ private Response handleDeleteCustomVerificationEmailTemplate(MultivaluedMap<String, String> params, String region) {+ sesService.deleteCustomVerificationEmailTemplate(requireParam(params, "TemplateName"), region);+ return Response.ok(AwsQueryResponse.envelopeEmptyResult(+ "DeleteCustomVerificationEmailTemplate", AwsNamespaces.SES)).build();+ }++ private CustomVerificationEmailTemplate readCvetParams(MultivaluedMap<String, String> params) {+ CustomVerificationEmailTemplate t = new CustomVerificationEmailTemplate();+ t.setTemplateName(params.getFirst("TemplateName"));+ t.setFromEmailAddress(params.getFirst("FromEmailAddress"));+ t.setTemplateSubject(params.getFirst("TemplateSubject"));+ t.setTemplateContent(params.getFirst("TemplateContent"));+ t.setSuccessRedirectionURL(params.getFirst("SuccessRedirectionURL"));+ t.setFailureRedirectionURL(params.getFirst("FailureRedirectionURL"));+ return t;+ }+private Response handleSendBulkTemplatedEmail(MultivaluedMap<String, String> params, String region) {if (!sesService.isAccountSendingEnabled(region)) {throw new AwsException("AccountSendingPausedException",diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.javaindex a5378e333e..c513a84471 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java@@ -17,6 +17,7 @@ import io.github.hectorvent.floci.services.ses.model.CloudWatchDimensionConfigurimport io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.Contact;import io.github.hectorvent.floci.services.ses.model.ContactList;+import io.github.hectorvent.floci.services.ses.model.CustomVerificationEmailTemplate;import io.github.hectorvent.floci.services.ses.model.DedicatedIpPool;import io.github.hectorvent.floci.services.ses.model.DeliveryOptions;import io.github.hectorvent.floci.services.ses.model.EmailTemplate;@@ -95,6 +96,8 @@ public class SesService {// value the (normalized) policy JSON. One store shared by the v1 and v2 policy APIs.private final StorageBackend<String, String> policyStore;private final StorageBackend<String, ReceiptRuleSet> receiptRuleSetStore;+ // Custom verification email templates (key cvet::<region>::<name>), shared by the v1 and v2 APIs.+ private final StorageBackend<String, CustomVerificationEmailTemplate> cvetStore;// Guards the one-list-per-account check-then-create so concurrent creates can't both pass.private final Object contactListCreateLock = new Object();// Serializes contact create/update against contact-list deletion so a concurrent delete@@ -106,6 +109,10 @@ public class SesService {// Serializes receipt-rule-set create (check-then-put) and set-active (clear-then-set) so the// one-active-per-region invariant and duplicate-name rejection hold under concurrency.private final Object receiptRuleSetLock = new Object();+ // Serializes custom-verification-template create/update/delete check-then-write so concurrent+ // creates for the same name can't both succeed and an update can't resurrect a concurrently+ // deleted template.+ private final Object cvetMutationLock = new Object();private final SmtpRelay smtpRelay;private final ObjectMapper objectMapper;private final SesEventPublisher eventPublisher;@@ -145,6 +152,8 @@ public class SesService {new TypeReference<Map<String, String>>() {});this.receiptRuleSetStore = storageFactory.create("ses", "ses-receipt-rule-sets.json",new TypeReference<Map<String, ReceiptRuleSet>>() {});+ this.cvetStore = storageFactory.create("ses", "ses-custom-verification-templates.json",+ new TypeReference<Map<String, CustomVerificationEmailTemplate>>() {});this.smtpRelay = smtpRelay;this.objectMapper = objectMapper;this.eventPublisher = eventPublisher;@@ -166,12 +175,13 @@ public class SesService {StorageBackend<String, Contact> contactStore,StorageBackend<String, String> policyStore,StorageBackend<String, ReceiptRuleSet> receiptRuleSetStore,+ StorageBackend<String, CustomVerificationEmailTemplate> cvetStore,SmtpRelay smtpRelay,ObjectMapper objectMapper,Clock clock) {this(identityStore, emailStore, accountSettingsStore, templateStore, configSetStore, suppressionStore,accountSuppressionStore, dedicatedIpPoolStore, contactListStore, contactStore, policyStore,- receiptRuleSetStore, smtpRelay, objectMapper, null, clock);+ receiptRuleSetStore, cvetStore, smtpRelay, objectMapper, null, clock);}SesService(StorageBackend<String, Identity> identityStore,@@ -186,6 +196,7 @@ public class SesService {StorageBackend<String, Contact> contactStore,StorageBackend<String, String> policyStore,StorageBackend<String, ReceiptRuleSet> receiptRuleSetStore,+ StorageBackend<String, CustomVerificationEmailTemplate> cvetStore,SmtpRelay smtpRelay,ObjectMapper objectMapper,Route53Service route53Service,@@ -202,6 +213,7 @@ public class SesService {this.contactStore = contactStore;this.policyStore = policyStore;this.receiptRuleSetStore = receiptRuleSetStore;+ this.cvetStore = cvetStore;this.smtpRelay = smtpRelay;this.objectMapper = objectMapper;this.eventPublisher = null;@@ -1068,6 +1080,143 @@ public class SesService {return all;}+ // ──────────── Custom verification email templates (v1 + v2 shared store) ────────────+ // Verified against real AWS: the From address must be a verified identity, redirection URLs+ // must be valid, and the template body is not content-validated. Floci enforces the+ // From-verified check against its own identity store (it does track verified identities).++ public void createCustomVerificationEmailTemplate(CustomVerificationEmailTemplate template, String region) {+ validateCustomVerificationTemplate(template, region);+ String key = cvetKey(region, template.getTemplateName());+ // Lock only the check-then-put so concurrent creates for the same name can't both observe+ // the key as absent; validation and logging stay outside the lock.+ synchronized (cvetMutationLock) {+ if (cvetStore.get(key).isPresent()) {+ // v1-native code (verified: CustomVerificationEmailTemplateAlreadyExists / 400);+ // remapV1Exception translates it to AlreadyExistsException / 400 for the v2 boundary.+ throw new AwsException("CustomVerificationEmailTemplateAlreadyExists",+ "Custom verification email template <" + template.getTemplateName() + "> already exists", 400);+ }+ cvetStore.put(key, template);+ }+ LOG.infov("Created custom verification email template {0} in region {1}",+ template.getTemplateName(), region);+ }++ public CustomVerificationEmailTemplate getCustomVerificationEmailTemplate(String templateName, String region) {+ return cvetStore.get(cvetKey(region, templateName)).orElseThrow(() -> cvetNotFound(templateName));+ }++ public List<CustomVerificationEmailTemplate> listCustomVerificationEmailTemplates(String region) {+ String prefix = "cvet::" + region + "::";+ return cvetStore.scan(k -> k.startsWith(prefix)).stream()+ .sorted(Comparator.comparing(CustomVerificationEmailTemplate::getTemplateName,+ Comparator.nullsFirst(Comparator.naturalOrder())))+ .toList();+ }++ public void updateCustomVerificationEmailTemplate(CustomVerificationEmailTemplate template, String region) {+ // Validate required fields (including TemplateName) before the existence check so a missing or+ // blank name yields the required-field InvalidParameterValue rather than NotFoundException,+ // matching createCustomVerificationEmailTemplate.+ validateCustomVerificationTemplate(template, region);+ String key = cvetKey(region, template.getTemplateName());+ // Guard the existence check and the put together so a concurrent delete can't slip between+ // them and have the update resurrect the just-deleted template.+ synchronized (cvetMutationLock) {+ if (cvetStore.get(key).isEmpty()) {+ throw cvetNotFound(template.getTemplateName());+ }+ cvetStore.put(key, template);+ }+ LOG.infov("Updated custom verification email template {0} in region {1}",+ template.getTemplateName(), region);+ }++ public void deleteCustomVerificationEmailTemplate(String templateName, String region) {+ String key = cvetKey(region, templateName);+ // Guard the check-then-delete on the same lock as create/update so the three mutations+ // serialize against each other.+ synchronized (cvetMutationLock) {+ if (cvetStore.get(key).isEmpty()) {+ throw cvetNotFound(templateName);+ }+ cvetStore.delete(key);+ }+ LOG.infov("Deleted custom verification email template {0} in region {1}", templateName, region);+ }++ private void validateCustomVerificationTemplate(CustomVerificationEmailTemplate t, String region) {+ requireCvetField(t.getTemplateName(), "TemplateName");+ requireCvetField(t.getFromEmailAddress(), "FromEmailAddress");+ requireCvetField(t.getTemplateSubject(), "TemplateSubject");+ requireCvetField(t.getTemplateContent(), "TemplateContent");+ requireCvetField(t.getSuccessRedirectionURL(), "SuccessRedirectionURL");+ requireCvetField(t.getFailureRedirectionURL(), "FailureRedirectionURL");+ if (!isVerifiedSender(t.getFromEmailAddress(), region)) {+ // v1-native code (verified: FromEmailAddressNotVerified / 400); remapV1Exception+ // translates it to NotFoundException / 404 for the v2 boundary.+ throw new AwsException("FromEmailAddressNotVerified",+ "The from email address <" + t.getFromEmailAddress() + "> is not verified", 400);+ }+ if (!isValidRedirectUrl(t.getSuccessRedirectionURL())) {+ throw new AwsException("InvalidParameterValue", "The success redirection URL is invalid", 400);+ }+ if (!isValidRedirectUrl(t.getFailureRedirectionURL())) {+ throw new AwsException("InvalidParameterValue", "The failure redirection URL is invalid", 400);+ }+ }++ private boolean isVerifiedSender(String fromEmail, String region) {+ if (fromEmail == null) {+ return false;+ }+ if (isIdentityVerified(fromEmail, region)) {+ return true;+ }+ int at = fromEmail.indexOf('@');+ return at >= 0 && at < fromEmail.length() - 1+ && isIdentityVerified(fromEmail.substring(at + 1), region);+ }++ private boolean isIdentityVerified(String identity, String region) {+ Identity id = getIdentityVerificationAttributes(identity, region);+ return id != null && "Success".equals(id.getVerificationStatus());+ }++ private static boolean isValidRedirectUrl(String url) {+ if (url == null || url.isBlank()) {+ return false;+ }+ try {+ java.net.URI uri = java.net.URI.create(url);+ String scheme = uri.getScheme();+ return uri.getHost() != null+ && ("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme));+ } catch (IllegalArgumentException e) {+ return false;+ }+ }++ private static void requireCvetField(String value, String name) {+ if (value == null || value.isBlank()) {+ // v1-native code; the v2 controller remaps it to BadRequestException via remapV1Exception,+ // so the Query API stays consistent with requireParam and v2 behavior is unchanged.+ throw new AwsException("InvalidParameterValue", name + " is required.", 400);+ }+ }++ private static AwsException cvetNotFound(String templateName) {+ // v1-native code (verified: CustomVerificationEmailTemplateDoesNotExist / 400).+ // SesController.remapV1Exception translates it to NotFoundException / 404 for the v2 boundary.+ return new AwsException("CustomVerificationEmailTemplateDoesNotExist",+ "Custom verification email template <" + templateName + "> does not exist", 400);+ }++ private static String cvetKey(String region, String templateName) {+ return "cvet::" + region + "::" + templateName;+ }+public ConfigurationSet createConfigurationSet(ConfigurationSet configSet, String region) {if (configSet == null) {throw new AwsException("InvalidParameterValue",diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/model/CustomVerificationEmailTemplate.java b/src/main/java/io/github/hectorvent/floci/services/ses/model/CustomVerificationEmailTemplate.javanew file mode 100644index 0000000000..7cde112ca2--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/ses/model/CustomVerificationEmailTemplate.java@@ -0,0 +1,57 @@+package io.github.hectorvent.floci.services.ses.model;++import com.fasterxml.jackson.annotation.JsonIgnoreProperties;+import com.fasterxml.jackson.annotation.JsonProperty;+import io.quarkus.runtime.annotations.RegisterForReflection;++/**+ * A custom verification email template: the branded email SES sends when verifying a new+ * sender email address (as opposed to {@link EmailTemplate}, which is for the emails a caller+ * sends to recipients). Shared by the v1 and v2 custom-verification-template APIs.+ */+@RegisterForReflection+@JsonIgnoreProperties(ignoreUnknown = true)+public class CustomVerificationEmailTemplate {++ @JsonProperty("TemplateName")+ private String templateName;++ @JsonProperty("FromEmailAddress")+ private String fromEmailAddress;++ @JsonProperty("TemplateSubject")+ private String templateSubject;++ @JsonProperty("TemplateContent")+ private String templateContent;++ @JsonProperty("SuccessRedirectionURL")+ private String successRedirectionURL;++ @JsonProperty("FailureRedirectionURL")+ private String failureRedirectionURL;++ public CustomVerificationEmailTemplate() {}++ public String getTemplateName() { return templateName; }+ public void setTemplateName(String templateName) { this.templateName = templateName; }++ public String getFromEmailAddress() { return fromEmailAddress; }+ public void setFromEmailAddress(String fromEmailAddress) { this.fromEmailAddress = fromEmailAddress; }++ public String getTemplateSubject() { return templateSubject; }+ public void setTemplateSubject(String templateSubject) { this.templateSubject = templateSubject; }++ public String getTemplateContent() { return templateContent; }+ public void setTemplateContent(String templateContent) { this.templateContent = templateContent; }++ public String getSuccessRedirectionURL() { return successRedirectionURL; }+ public void setSuccessRedirectionURL(String successRedirectionURL) {+ this.successRedirectionURL = successRedirectionURL;+ }++ public String getFailureRedirectionURL() { return failureRedirectionURL; }+ public void setFailureRedirectionURL(String failureRedirectionURL) {+ this.failureRedirectionURL = failureRedirectionURL;+ }+}diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesCustomVerificationEmailTemplateV1IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesCustomVerificationEmailTemplateV1IntegrationTest.javanew file mode 100644index 0000000000..2697aacb40--- /dev/null+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesCustomVerificationEmailTemplateV1IntegrationTest.java@@ -0,0 +1,179 @@+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;+import static org.hamcrest.Matchers.equalTo;++/**+ * Integration tests for the SES V1 Query-protocol custom-verification-email-template APIs.+ * Verifies CRUD and that templates are shared with the V2 store (a v1 template is visible via V2).+ */+@QuarkusTest+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)+class SesCustomVerificationEmailTemplateV1IntegrationTest {++ private static final String AUTH =+ "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request";+ private static final String V2_AUTH =+ "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";+ private static final String FROM = "[email protected]";+ private static final String NAME = "cvet-v1-a";++ private static io.restassured.specification.RequestSpecification query(String action) {+ return given().contentType("application/x-www-form-urlencoded").header("Authorization", AUTH)+ .formParam("Action", action);+ }++ private static io.restassured.specification.RequestSpecification create(String name, String subject) {+ return query("CreateCustomVerificationEmailTemplate")+ .formParam("TemplateName", name)+ .formParam("FromEmailAddress", FROM)+ .formParam("TemplateSubject", subject)+ .formParam("TemplateContent", "<html><body>verify</body></html>")+ .formParam("SuccessRedirectionURL", "https://example.com/ok")+ .formParam("FailureRedirectionURL", "https://example.com/fail");+ }++ @Test+ @Order(0)+ void setup_verifyFromIdentity() {+ query("VerifyEmailIdentity").formParam("EmailAddress", FROM).when().post("/").then().statusCode(200);+ }++ @Test+ @Order(10)+ void get_missing_returnsDoesNotExistOnV1() {+ // v1 returns CustomVerificationEmailTemplateDoesNotExist / 400 (verified against AWS), so the+ // v1 SDK's typed exception fires — not the v2 NotFoundException / 404.+ query("GetCustomVerificationEmailTemplate").formParam("TemplateName", "cvet-v1-ghost")+ .when().post("/").then().statusCode(400)+ .body(containsString("<Code>CustomVerificationEmailTemplateDoesNotExist</Code>"));+ }++ @Test+ @Order(11)+ void create_unverifiedFromAddress_returnsFromEmailAddressNotVerifiedOnV1() {+ // An unverified FromEmailAddress is FromEmailAddressNotVerified / 400 on v1 (verified against+ // AWS), not the v2 NotFoundException / 404.+ query("CreateCustomVerificationEmailTemplate")+ .formParam("TemplateName", "cvet-v1-unverified-from")+ .formParam("FromEmailAddress", "[email protected]")+ .formParam("TemplateSubject", "Verify your email")+ .formParam("TemplateContent", "<html><body>verify</body></html>")+ .formParam("SuccessRedirectionURL", "https://example.com/ok")+ .formParam("FailureRedirectionURL", "https://example.com/fail")+ .when().post("/").then().statusCode(400)+ .body(containsString("<Code>FromEmailAddressNotVerified</Code>"));+ }++ @Test+ @Order(1)+ void create() {+ create(NAME, "Verify your email").when().post("/").then().statusCode(200)+ .body(containsString("CreateCustomVerificationEmailTemplateResponse"));+ }++ @Test+ @Order(2)+ void get() {+ query("GetCustomVerificationEmailTemplate").formParam("TemplateName", NAME)+ .when().post("/").then().statusCode(200)+ .body(containsString("<TemplateName>" + NAME + "</TemplateName>"))+ .body(containsString("<FromEmailAddress>" + FROM + "</FromEmailAddress>"))+ .body(containsString("<TemplateSubject>Verify your email</TemplateSubject>"));+ }++ @Test+ @Order(3)+ void list() {+ query("ListCustomVerificationEmailTemplates")+ .when().post("/").then().statusCode(200)+ .body(containsString("<TemplateName>" + NAME + "</TemplateName>"));+ }++ @Test+ @Order(4)+ void update() {+ // create dup fails with the v1-native code (verified against AWS), not the v2 AlreadyExistsException+ create(NAME, "Updated via v1").when().post("/").then().statusCode(400)+ .body(containsString("<Code>CustomVerificationEmailTemplateAlreadyExists</Code>"));+ query("UpdateCustomVerificationEmailTemplate")+ .formParam("TemplateName", NAME).formParam("FromEmailAddress", FROM)+ .formParam("TemplateSubject", "Updated via v1")+ .formParam("TemplateContent", "<html><body>verify</body></html>")+ .formParam("SuccessRedirectionURL", "https://example.com/ok")+ .formParam("FailureRedirectionURL", "https://example.com/fail")+ .when().post("/").then().statusCode(200);++ query("GetCustomVerificationEmailTemplate").formParam("TemplateName", NAME)+ .when().post("/").then().statusCode(200)+ .body(containsString("<TemplateSubject>Updated via v1</TemplateSubject>"));+ }++ @Test+ @Order(5)+ void delete() {+ query("DeleteCustomVerificationEmailTemplate").formParam("TemplateName", NAME)+ .when().post("/").then().statusCode(200)+ .body(containsString("DeleteCustomVerificationEmailTemplateResponse"));+ }++ @Test+ @Order(7)+ void create_missingRequiredField_returnsInvalidParameterValueOnV1() {+ // A required-field failure must surface the v1-native InvalidParameterValue code in the+ // Query XML (not the v2-style BadRequestException), consistent with requireParam.+ query("CreateCustomVerificationEmailTemplate")+ .formParam("TemplateName", "cvet-v1-missing")+ .formParam("FromEmailAddress", FROM)+ // TemplateSubject omitted+ .formParam("TemplateContent", "<html><body>verify</body></html>")+ .formParam("SuccessRedirectionURL", "https://example.com/ok")+ .formParam("FailureRedirectionURL", "https://example.com/fail")+ .when().post("/").then().statusCode(400)+ .body(containsString("<Code>InvalidParameterValue</Code>"))+ .body(containsString("TemplateSubject is required."));+ }++ @Test+ @Order(8)+ void update_missingTemplateName_returnsInvalidParameterValueOnV1() {+ // TemplateName is validated before the existence check, so omitting it yields the required-field+ // InvalidParameterValue rather than a NotFoundException for a null-named template.+ query("UpdateCustomVerificationEmailTemplate")+ // TemplateName omitted+ .formParam("FromEmailAddress", FROM)+ .formParam("TemplateSubject", "Updated via v1")+ .formParam("TemplateContent", "<html><body>verify</body></html>")+ .formParam("SuccessRedirectionURL", "https://example.com/ok")+ .formParam("FailureRedirectionURL", "https://example.com/fail")+ .when().post("/").then().statusCode(400)+ .body(containsString("<Code>InvalidParameterValue</Code>"))+ .body(containsString("TemplateName is required."));+ }++ @Test+ @Order(6)+ void v1Template_isVisibleViaV2() {+ create("cvet-v1-shared", "Shared").when().post("/").then().statusCode(200);++ given().header("Authorization", V2_AUTH)+ .when().get("/v2/email/custom-verification-email-templates/cvet-v1-shared")+ .then().statusCode(200)+ .body("TemplateSubject", equalTo("Shared"))+ .body("FromEmailAddress", equalTo(FROM));+ }++ @Test+ @Order(9)+ void cleanup_deleteSharedTemplate() {+ query("DeleteCustomVerificationEmailTemplate").formParam("TemplateName", "cvet-v1-shared")+ .when().post("/").then().statusCode(200);+ }+}diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesCustomVerificationEmailTemplateV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesCustomVerificationEmailTemplateV2IntegrationTest.javanew file mode 100644index 0000000000..dee96e5572--- /dev/null+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesCustomVerificationEmailTemplateV2IntegrationTest.java@@ -0,0 +1,158 @@+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;+import static org.hamcrest.Matchers.nullValue;++/**+ * Integration tests for the SES V2 REST JSON custom-verification-email-template APIs. Behaviour and+ * error shapes are verified against real AWS: the From address must be a verified identity, the+ * redirection URLs must be valid, List omits TemplateContent, and duplicate/not-found error shapes.+ */+@QuarkusTest+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)+class SesCustomVerificationEmailTemplateV2IntegrationTest {++ private static final String AUTH =+ "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";+ private static final String FROM = "[email protected]";+ private static final String BASE = "/v2/email/custom-verification-email-templates";+ private static final String NAME = "cvet-v2-a";++ private static String body(String name, String from, String subject, String successUrl) {+ return """+ {+ "TemplateName": "%s",+ "FromEmailAddress": "%s",+ "TemplateSubject": "%s",+ "TemplateContent": "<html><body>verify</body></html>",+ "SuccessRedirectionURL": "%s",+ "FailureRedirectionURL": "https://example.com/fail"+ }+ """.formatted(name, from, subject, successUrl);+ }++ @Test+ @Order(0)+ void setup_verifyFromIdentity() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body("{\"EmailIdentity\":\"" + FROM + "\"}")+ .when().post("/v2/email/identities").then().statusCode(200);+ }++ @Test+ @Order(1)+ void createThenGet() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body(body(NAME, FROM, "Verify your email", "https://example.com/ok"))+ .when().post(BASE).then().statusCode(200);++ given().header("Authorization", AUTH)+ .when().get(BASE + "/" + NAME)+ .then().statusCode(200)+ .body("TemplateName", equalTo(NAME))+ .body("FromEmailAddress", equalTo(FROM))+ .body("TemplateSubject", equalTo("Verify your email"))+ .body("TemplateContent", equalTo("<html><body>verify</body></html>"))+ .body("SuccessRedirectionURL", equalTo("https://example.com/ok"))+ .body("FailureRedirectionURL", equalTo("https://example.com/fail"));+ }++ @Test+ @Order(2)+ void list_omitsTemplateContent() {+ given().header("Authorization", AUTH)+ .when().get(BASE)+ .then().statusCode(200)+ .body("CustomVerificationEmailTemplates.TemplateName", hasItem(NAME))+ .body("CustomVerificationEmailTemplates.find { it.TemplateName == '" + NAME + "' }.TemplateContent",+ nullValue());+ }++ @Test+ @Order(3)+ void createDuplicate_throwsAlreadyExists() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body(body(NAME, FROM, "x", "https://example.com/ok"))+ .when().post(BASE).then().statusCode(400)+ .body("__type", equalTo("AlreadyExistsException"))+ .body("message", equalTo("Custom verification email template <" + NAME + "> already exists"));+ }++ @Test+ @Order(4)+ void getMissing_throwsNotFound() {+ given().header("Authorization", AUTH)+ .when().get(BASE + "/nope")+ .then().statusCode(404)+ .body("__type", equalTo("NotFoundException"))+ .body("message", equalTo("Custom verification email template <nope> does not exist"));+ }++ @Test+ @Order(5)+ void update_replaces() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body(body(NAME, FROM, "Updated subject", "https://example.com/ok2"))+ .when().put(BASE + "/" + NAME).then().statusCode(200);++ given().header("Authorization", AUTH)+ .when().get(BASE + "/" + NAME)+ .then().statusCode(200)+ .body("TemplateSubject", equalTo("Updated subject"))+ .body("SuccessRedirectionURL", equalTo("https://example.com/ok2"));+ }++ @Test+ @Order(6)+ void updateMissing_throwsNotFound() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body(body("nope", FROM, "x", "https://example.com/ok"))+ .when().put(BASE + "/nope").then().statusCode(404)+ .body("__type", equalTo("NotFoundException"));+ }++ @Test+ @Order(7)+ void deleteThenGone() {+ given().header("Authorization", AUTH)+ .when().delete(BASE + "/" + NAME).then().statusCode(200);+ given().header("Authorization", AUTH)+ .when().get(BASE + "/" + NAME).then().statusCode(404);+ }++ @Test+ @Order(8)+ void deleteMissing_throwsNotFound() {+ given().header("Authorization", AUTH)+ .when().delete(BASE + "/nope").then().statusCode(404)+ .body("__type", equalTo("NotFoundException"));+ }++ @Test+ @Order(9)+ void createWithUnverifiedFrom_throwsNotFound() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body(body("cvet-unverified", "[email protected]", "x", "https://example.com/ok"))+ .when().post(BASE).then().statusCode(404)+ .body("__type", equalTo("NotFoundException"))+ .body("message", equalTo("The from email address <[email protected]> is not verified"));+ }++ @Test+ @Order(10)+ void createWithInvalidRedirectUrl_throwsBadRequest() {+ given().contentType("application/json").header("Authorization", AUTH)+ .body(body("cvet-badurl", FROM, "x", "not-a-url"))+ .when().post(BASE).then().statusCode(400)+ .body("__type", equalTo("BadRequestException"))+ .body("message", equalTo("The success redirection URL is invalid"));+ }+}diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceDkimLookupCacheTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceDkimLookupCacheTest.javaindex 8b0cb275b1..7dc344d0f4 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceDkimLookupCacheTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceDkimLookupCacheTest.java@@ -11,6 +11,7 @@ import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.ContactList;import io.github.hectorvent.floci.services.ses.model.Contact;import io.github.hectorvent.floci.services.ses.model.ReceiptRuleSet;+import io.github.hectorvent.floci.services.ses.model.CustomVerificationEmailTemplate;import io.github.hectorvent.floci.services.ses.model.DedicatedIpPool;import io.github.hectorvent.floci.services.ses.model.EmailTemplate;import io.github.hectorvent.floci.services.ses.model.Identity;@@ -60,6 +61,7 @@ class SesServiceDkimLookupCacheTest {new InMemoryStorage<String, Contact>(),new InMemoryStorage<String, String>(),new InMemoryStorage<String, ReceiptRuleSet>(),+ new InMemoryStorage<String, CustomVerificationEmailTemplate>(),mock(SmtpRelay.class),new ObjectMapper(),route53Service,diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceLegacyDkimTokensTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceLegacyDkimTokensTest.javaindex cb280cfd5c..5fa99c2502 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceLegacyDkimTokensTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceLegacyDkimTokensTest.java@@ -7,6 +7,7 @@ import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.ContactList;import io.github.hectorvent.floci.services.ses.model.Contact;import io.github.hectorvent.floci.services.ses.model.ReceiptRuleSet;+import io.github.hectorvent.floci.services.ses.model.CustomVerificationEmailTemplate;import io.github.hectorvent.floci.services.ses.model.DedicatedIpPool;import io.github.hectorvent.floci.services.ses.model.EmailTemplate;import io.github.hectorvent.floci.services.ses.model.Identity;@@ -49,6 +50,7 @@ class SesServiceLegacyDkimTokensTest {new InMemoryStorage<String, Contact>(),new InMemoryStorage<String, String>(),new InMemoryStorage<String, ReceiptRuleSet>(),+ new InMemoryStorage<String, CustomVerificationEmailTemplate>(),mock(SmtpRelay.class),new ObjectMapper(),Clock.systemUTC());diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.javaindex 78fb9fd620..453addfa0b 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.java@@ -7,6 +7,7 @@ import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.ContactList;import io.github.hectorvent.floci.services.ses.model.Contact;import io.github.hectorvent.floci.services.ses.model.ReceiptRuleSet;+import io.github.hectorvent.floci.services.ses.model.CustomVerificationEmailTemplate;import io.github.hectorvent.floci.services.ses.model.DedicatedIpPool;import io.github.hectorvent.floci.services.ses.model.EmailTemplate;import io.github.hectorvent.floci.services.ses.model.Identity;@@ -48,6 +49,7 @@ class SesServiceSmtpTest {new InMemoryStorage<String, Contact>(),new InMemoryStorage<String, String>(),new InMemoryStorage<String, ReceiptRuleSet>(),+ new InMemoryStorage<String, CustomVerificationEmailTemplate>(),smtpRelay,new ObjectMapper(),Clock.systemUTC());diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionLegacyKeyTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionLegacyKeyTest.javaindex 2b28c48e47..130f688e6a 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionLegacyKeyTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionLegacyKeyTest.java@@ -7,6 +7,7 @@ import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.ContactList;import io.github.hectorvent.floci.services.ses.model.Contact;import io.github.hectorvent.floci.services.ses.model.ReceiptRuleSet;+import io.github.hectorvent.floci.services.ses.model.CustomVerificationEmailTemplate;import io.github.hectorvent.floci.services.ses.model.DedicatedIpPool;import io.github.hectorvent.floci.services.ses.model.EmailTemplate;import io.github.hectorvent.floci.services.ses.model.Identity;@@ -56,6 +57,7 @@ class SesServiceSuppressionLegacyKeyTest {new InMemoryStorage<String, Contact>(),new InMemoryStorage<String, String>(),new InMemoryStorage<String, ReceiptRuleSet>(),+ new InMemoryStorage<String, CustomVerificationEmailTemplate>(),mock(SmtpRelay.class),new ObjectMapper(),Clock.systemUTC());diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionReasonTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionReasonTest.javaindex 6d26871e05..407ff60822 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionReasonTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSuppressionReasonTest.java@@ -7,6 +7,7 @@ import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;import io.github.hectorvent.floci.services.ses.model.ContactList;import io.github.hectorvent.floci.services.ses.model.Contact;import io.github.hectorvent.floci.services.ses.model.ReceiptRuleSet;+import io.github.hectorvent.floci.services.ses.model.CustomVerificationEmailTemplate;import io.github.hectorvent.floci.services.ses.model.DedicatedIpPool;import io.github.hectorvent.floci.services.ses.model.EmailTemplate;import io.github.hectorvent.floci.services.ses.model.Identity;@@ -56,6 +57,7 @@ class SesServiceSuppressionReasonTest {new InMemoryStorage<String, Contact>(),new InMemoryStorage<String, String>(),new InMemoryStorage<String, ReceiptRuleSet>(),+ new InMemoryStorage<String, CustomVerificationEmailTemplate>(),mock(SmtpRelay.class),new ObjectMapper(),Clock.systemUTC());