Light, fluffy, and always free - The AWS Local Emulator alternative
fix(ses): align /_aws/ses inspection endpoint with LocalStack behavior (#512)
Kenshin Okinaka4719269df431
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 1547fde1b5..8b264e42cb 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@@ -201,6 +201,7 @@ public class SesController {List<String> toAddresses = jsonArrayToList(destination.path("ToAddresses"));List<String> ccAddresses = jsonArrayToList(destination.path("CcAddresses"));List<String> bccAddresses = jsonArrayToList(destination.path("BccAddresses"));+ List<String> replyToAddresses = jsonArrayToList(request.path("ReplyToAddresses"));JsonNode content = request.path("Content");String messageId;@@ -223,12 +224,12 @@ public class SesController {String bodyText = simple.path("Body").path("Text").path("Data").asText(null);String bodyHtml = simple.path("Body").path("Html").path("Data").asText(null);messageId = sesService.sendEmail(fromEmailAddress, toAddresses, ccAddresses,- bccAddresses, subject, bodyText, bodyHtml, region);+ bccAddresses, replyToAddresses, subject, bodyText, bodyHtml, region);} else if (content.has("Template")) {String subject = content.path("Template").path("TemplateName").asText("(template)");String templateData = content.path("Template").path("TemplateData").asText("");messageId = sesService.sendEmail(fromEmailAddress, toAddresses, ccAddresses,- bccAddresses, subject, templateData, null, region);+ bccAddresses, replyToAddresses, subject, templateData, null, region);} else {throw new AwsException("BadRequestException","Content must contain Raw, Simple, or Template.", 400);diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesInspectionController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesInspectionController.javaindex aac1219e5b..e94ea64b3d 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesInspectionController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesInspectionController.java@@ -1,6 +1,5 @@package io.github.hectorvent.floci.services.ses;-import io.github.hectorvent.floci.core.common.RegionResolver;import io.github.hectorvent.floci.services.ses.model.SentEmail;import com.fasterxml.jackson.databind.ObjectMapper;import com.fasterxml.jackson.databind.node.ArrayNode;@@ -25,21 +24,17 @@ import java.util.List;public class SesInspectionController {private final SesService sesService;- private final RegionResolver regionResolver;private final ObjectMapper objectMapper;@Inject- public SesInspectionController(SesService sesService, RegionResolver regionResolver,- ObjectMapper objectMapper) {+ public SesInspectionController(SesService sesService, ObjectMapper objectMapper) {this.sesService = sesService;- this.regionResolver = regionResolver;this.objectMapper = objectMapper;}@GETpublic Response getEmails(@QueryParam("id") String messageId) {- String region = regionResolver.getDefaultRegion();- List<SentEmail> emails = sesService.getEmails(region);+ List<SentEmail> emails = sesService.getEmails();ArrayNode messages = objectMapper.createArrayNode();for (SentEmail email : emails) {@@ -48,28 +43,51 @@ public class SesInspectionController {}ObjectNode node = objectMapper.createObjectNode();node.put("Id", email.getMessageId());- node.put("Region", region);+ if (email.getRegion() != null) {+ node.put("Region", email.getRegion());+ } else {+ node.putNull("Region");+ }node.put("Source", email.getSource());- ObjectNode destination = node.putObject("Destination");- if (email.getToAddresses() != null) {- ArrayNode toArr = destination.putArray("ToAddresses");- email.getToAddresses().forEach(toArr::add);- }- if (email.getCcAddresses() != null) {- ArrayNode ccArr = destination.putArray("CcAddresses");- email.getCcAddresses().forEach(ccArr::add);- }- if (email.getBccAddresses() != null) {- ArrayNode bccArr = destination.putArray("BccAddresses");- email.getBccAddresses().forEach(bccArr::add);- }+ if (email.isRaw()) {+ // LocalStack returns RawData for raw emails, without+ // Destination / Subject / Body fields.+ node.put("RawData", email.getRawData());+ } else {+ ObjectNode destination = node.putObject("Destination");+ if (email.getToAddresses() != null && !email.getToAddresses().isEmpty()) {+ ArrayNode toArr = destination.putArray("ToAddresses");+ email.getToAddresses().forEach(toArr::add);+ }+ if (email.getCcAddresses() != null && !email.getCcAddresses().isEmpty()) {+ ArrayNode ccArr = destination.putArray("CcAddresses");+ email.getCcAddresses().forEach(ccArr::add);+ }+ if (email.getBccAddresses() != null && !email.getBccAddresses().isEmpty()) {+ ArrayNode bccArr = destination.putArray("BccAddresses");+ email.getBccAddresses().forEach(bccArr::add);+ }++ if (email.getReplyToAddresses() != null && !email.getReplyToAddresses().isEmpty()) {+ ArrayNode replyTo = node.putArray("ReplyToAddresses");+ email.getReplyToAddresses().forEach(replyTo::add);+ }- node.put("Subject", email.getSubject());+ node.put("Subject", email.getSubject());- ObjectNode body = node.putObject("Body");- body.put("text_part", email.getBody() != null ? email.getBody() : "");- body.put("html_part", email.getBody() != null ? email.getBody() : "");+ ObjectNode body = node.putObject("Body");+ if (email.getBodyText() != null) {+ body.put("text_part", email.getBodyText());+ } else {+ body.putNull("text_part");+ }+ if (email.getBodyHtml() != null) {+ body.put("html_part", email.getBodyHtml());+ } else {+ body.putNull("html_part");+ }+ }if (email.getSentAt() != null) {node.put("Timestamp", email.getSentAt().toString());@@ -85,8 +103,7 @@ public class SesInspectionController {@DELETEpublic Response clearEmails() {- String region = regionResolver.getDefaultRegion();- sesService.clearEmails(region);+ sesService.clearEmails();return Response.ok().build();}}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 a8cd2140e4..c181fa2ccc 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@@ -125,12 +125,13 @@ public class SesQueryHandler {List<String> toAddresses = extractMembers(params, "Destination.ToAddresses");List<String> ccAddresses = extractMembers(params, "Destination.CcAddresses");List<String> bccAddresses = extractMembers(params, "Destination.BccAddresses");+ List<String> replyToAddresses = extractMembers(params, "ReplyToAddresses");String subject = getParam(params, "Message.Subject.Data");String bodyText = getParam(params, "Message.Body.Text.Data");String bodyHtml = getParam(params, "Message.Body.Html.Data");String messageId = sesService.sendEmail(source, toAddresses, ccAddresses, bccAddresses,- subject, bodyText, bodyHtml, region);+ replyToAddresses, subject, bodyText, bodyHtml, region);String result = new XmlBuilder().elem("MessageId", messageId).build();return Response.ok(AwsQueryResponse.envelope("SendEmail", AwsNamespaces.SES, result)).build();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 6e3c2c9858..d1eda41a2d 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@@ -1,8 +1,6 @@package io.github.hectorvent.floci.services.ses;-import io.github.hectorvent.floci.config.EmulatorConfig;import io.github.hectorvent.floci.core.common.AwsException;-import io.github.hectorvent.floci.core.common.RegionResolver;import io.github.hectorvent.floci.core.storage.StorageBackend;import io.github.hectorvent.floci.core.storage.StorageFactory;import io.github.hectorvent.floci.services.ses.model.Identity;@@ -26,28 +24,23 @@ public class SesService {private final StorageBackend<String, Identity> identityStore;private final StorageBackend<String, SentEmail> emailStore;private final StorageBackend<String, Boolean> accountSettingsStore;- private final RegionResolver regionResolver;@Inject- public SesService(StorageFactory storageFactory, EmulatorConfig config,- RegionResolver regionResolver) {+ public SesService(StorageFactory storageFactory) {this.identityStore = storageFactory.create("ses", "ses-identities.json",new TypeReference<Map<String, Identity>>() {});this.emailStore = storageFactory.create("ses", "ses-emails.json",new TypeReference<Map<String, SentEmail>>() {});this.accountSettingsStore = storageFactory.create("ses", "ses-account-settings.json",new TypeReference<Map<String, Boolean>>() {});- this.regionResolver = regionResolver;}SesService(StorageBackend<String, Identity> identityStore,StorageBackend<String, SentEmail> emailStore,- StorageBackend<String, Boolean> accountSettingsStore,- RegionResolver regionResolver) {+ StorageBackend<String, Boolean> accountSettingsStore) {this.identityStore = identityStore;this.emailStore = emailStore;this.accountSettingsStore = accountSettingsStore;- this.regionResolver = regionResolver;}public Identity verifyEmailIdentity(String emailAddress, String region) {@@ -101,8 +94,8 @@ public class SesService {}public String sendEmail(String source, List<String> toAddresses, List<String> ccAddresses,- List<String> bccAddresses, String subject, String bodyText,- String bodyHtml, String region) {+ List<String> bccAddresses, List<String> replyToAddresses,+ String subject, String bodyText, String bodyHtml, String region) {if (source == null || source.isBlank()) {throw new AwsException("InvalidParameterValue", "Source email is required.", 400);}@@ -114,8 +107,8 @@ public class SesService {}String messageId = UUID.randomUUID().toString();- String body = bodyHtml != null ? bodyHtml : bodyText;- SentEmail email = new SentEmail(messageId, source, toAddresses, ccAddresses, bccAddresses, subject, body);+ SentEmail email = new SentEmail(messageId, region, source, toAddresses, ccAddresses,+ bccAddresses, replyToAddresses, subject, bodyText, bodyHtml);emailStore.put("email::" + region + "::" + messageId, email);LOG.infov("SES email sent: from={0}, to={1}, subject={2}, messageId={3}",@@ -124,10 +117,16 @@ public class SesService {}public String sendRawEmail(String source, List<String> destinations, String rawMessage, String region) {+ if (source == null || source.isBlank()) {+ throw new AwsException("InvalidParameterValue", "Source email is required.", 400);+ }+ if (rawMessage == null || rawMessage.isBlank()) {+ throw new AwsException("InvalidParameterValue", "RawMessage.Data is required.", 400);+ }String messageId = UUID.randomUUID().toString();- SentEmail email = new SentEmail(messageId, source,+ SentEmail email = new SentEmail(messageId, region, source,destinations != null ? destinations : Collections.emptyList(),- null, null, "(raw)", rawMessage);+ rawMessage);emailStore.put("email::" + region + "::" + messageId, email);LOG.infov("SES raw email sent: from={0}, messageId={1}", source, messageId);@@ -196,18 +195,13 @@ public class SesService {return emails;}- public List<SentEmail> getEmails(String region) {- String prefix = "email::" + region + "::";- return emailStore.scan(k -> k.startsWith(prefix));+ public List<SentEmail> getEmails() {+ return emailStore.scan(k -> k.startsWith("email::"));}- public void clearEmails(String region) {- String prefix = "email::" + region + "::";- List<String> keys = new ArrayList<>(emailStore.keys().stream()- .filter(k -> k.startsWith(prefix))- .toList());- keys.forEach(emailStore::delete);- LOG.infov("Cleared all SES emails in region {0}", region);+ public void clearEmails() {+ emailStore.clear();+ LOG.info("Cleared all SES emails");}public boolean isAccountSendingEnabled(String region) {diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/model/SentEmail.java b/src/main/java/io/github/hectorvent/floci/services/ses/model/SentEmail.javaindex 123e32a9e5..5ab7faefde 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/model/SentEmail.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/model/SentEmail.java@@ -1,5 +1,6 @@package io.github.hectorvent.floci.services.ses.model;+import com.fasterxml.jackson.annotation.JsonAlias;import com.fasterxml.jackson.annotation.JsonIgnoreProperties;import com.fasterxml.jackson.annotation.JsonProperty;import io.quarkus.runtime.annotations.RegisterForReflection;@@ -14,6 +15,9 @@ public class SentEmail {@JsonProperty("MessageId")private String messageId;+ @JsonProperty("Region")+ private String region;+@JsonProperty("Source")private String source;@@ -29,30 +33,59 @@ public class SentEmail {@JsonProperty("Subject")private String subject;- @JsonProperty("Body")- private String body;+ @JsonProperty("ReplyToAddresses")+ private List<String> replyToAddresses;++ @JsonProperty("BodyText")+ @JsonAlias("Body")+ private String bodyText;++ @JsonProperty("BodyHtml")+ private String bodyHtml;++ @JsonProperty("RawData")+ private String rawData;@JsonProperty("SentAt")private Instant sentAt;public SentEmail() {}- public SentEmail(String messageId, String source, List<String> toAddresses,- List<String> ccAddresses, List<String> bccAddresses,- String subject, String body) {+ /** Constructor for Simple / Template content. */+ public SentEmail(String messageId, String region, String source,+ List<String> toAddresses, List<String> ccAddresses,+ List<String> bccAddresses, List<String> replyToAddresses,+ String subject, String bodyText, String bodyHtml) {this.messageId = messageId;+ this.region = region;this.source = source;this.toAddresses = toAddresses;this.ccAddresses = ccAddresses;this.bccAddresses = bccAddresses;+ this.replyToAddresses = replyToAddresses;this.subject = subject;- this.body = body;+ this.bodyText = bodyText;+ this.bodyHtml = bodyHtml;+ this.sentAt = Instant.now();+ }++ /** Constructor for Raw content. */+ public SentEmail(String messageId, String region, String source,+ List<String> destinations, String rawData) {+ this.messageId = messageId;+ this.region = region;+ this.source = source;+ this.toAddresses = destinations;+ this.rawData = rawData;this.sentAt = Instant.now();}public String getMessageId() { return messageId; }public void setMessageId(String messageId) { this.messageId = messageId; }+ public String getRegion() { return region; }+ public void setRegion(String region) { this.region = region; }+public String getSource() { return source; }public void setSource(String source) { this.source = source; }@@ -68,8 +101,19 @@ public class SentEmail {public String getSubject() { return subject; }public void setSubject(String subject) { this.subject = subject; }- public String getBody() { return body; }- public void setBody(String body) { this.body = body; }+ public List<String> getReplyToAddresses() { return replyToAddresses; }+ public void setReplyToAddresses(List<String> replyToAddresses) { this.replyToAddresses = replyToAddresses; }++ public String getBodyText() { return bodyText; }+ public void setBodyText(String bodyText) { this.bodyText = bodyText; }++ public String getBodyHtml() { return bodyHtml; }+ public void setBodyHtml(String bodyHtml) { this.bodyHtml = bodyHtml; }++ public String getRawData() { return rawData; }+ public void setRawData(String rawData) { this.rawData = rawData; }++ public boolean isRaw() { return rawData != null; }public Instant getSentAt() { return sentAt; }public void setSentAt(Instant sentAt) { this.sentAt = sentAt; }diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesIntegrationTest.javaindex 372ccb1d30..22d75a4439 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesIntegrationTest.java@@ -357,6 +357,34 @@ class SesIntegrationTest {@Test@Order(20)+ void sendEmailV1_replyToAddressesStoredInInspection() {+ given().delete("/_aws/ses").then().statusCode(200);++ given()+ .contentType("application/x-www-form-urlencoded")+ .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request")+ .formParam("Action", "SendEmail")+ .formParam("Source", "[email protected]")+ .formParam("Destination.ToAddresses.member.1", "[email protected]")+ .formParam("ReplyToAddresses.member.1", "[email protected]")+ .formParam("Message.Subject.Data", "V1 ReplyTo")+ .formParam("Message.Body.Text.Data", "body")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(containsString("<MessageId>"));++ given()+ .when()+ .get("/_aws/ses")+ .then()+ .statusCode(200)+ .body("messages[0].ReplyToAddresses", hasItem("[email protected]"));+ }++ @Test+ @Order(21)void unsupportedAction_returns400() {given().contentType("application/x-www-form-urlencoded")diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.javaindex 508ed61b1d..1ad9faa6e4 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java@@ -617,6 +617,321 @@ class SesV2IntegrationTest {.body("__type", equalTo("BadRequestException"));}+ // ──────────────── Inspection endpoint (/_aws/ses) ────────────────++ @Test+ @Order(70)+ void inspectionEndpoint_textAndHtmlAreStoredSeparately() {+ // Create identity+ given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body("""+ {"EmailIdentity": "[email protected]"}+ """)+ .when()+ .post("/v2/email/identities")+ .then()+ .statusCode(200);++ // Clear any previous messages+ given().delete("/_aws/ses").then().statusCode(200);++ // Send with distinct Text and Html bodies+ String messageId = given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body("""+ {+ "FromEmailAddress": "[email protected]",+ "Destination": {+ "ToAddresses": ["[email protected]"]+ },+ "Content": {+ "Simple": {+ "Subject": {"Data": "Inspect Test"},+ "Body": {+ "Text": {"Data": "plain text body"},+ "Html": {"Data": "<p>html body</p>"}+ }+ }+ }+ }+ """)+ .when()+ .post("/v2/email/outbound-emails")+ .then()+ .statusCode(200)+ .extract()+ .path("MessageId");++ // Verify via inspection endpoint+ given()+ .when()+ .get("/_aws/ses?id=" + messageId)+ .then()+ .statusCode(200)+ .body("messages[0].Body.text_part", equalTo("plain text body"))+ .body("messages[0].Body.html_part", equalTo("<p>html body</p>"));+ }++ @Test+ @Order(71)+ void inspectionEndpoint_textOnlyEmail() {+ given().delete("/_aws/ses").then().statusCode(200);++ given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body("""+ {+ "FromEmailAddress": "[email protected]",+ "Destination": {+ "ToAddresses": ["[email protected]"]+ },+ "Content": {+ "Simple": {+ "Subject": {"Data": "Text Only"},+ "Body": {+ "Text": {"Data": "only text"}+ }+ }+ }+ }+ """)+ .when()+ .post("/v2/email/outbound-emails")+ .then()+ .statusCode(200);++ given()+ .when()+ .get("/_aws/ses")+ .then()+ .statusCode(200)+ .body("messages[0].Body.text_part", equalTo("only text"))+ .body("messages[0].Body.html_part", nullValue());+ }++ @Test+ @Order(72)+ void inspectionEndpoint_htmlOnlyEmail() {+ given().delete("/_aws/ses").then().statusCode(200);++ given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body("""+ {+ "FromEmailAddress": "[email protected]",+ "Destination": {+ "ToAddresses": ["[email protected]"]+ },+ "Content": {+ "Simple": {+ "Subject": {"Data": "Html Only"},+ "Body": {+ "Html": {"Data": "<b>only html</b>"}+ }+ }+ }+ }+ """)+ .when()+ .post("/v2/email/outbound-emails")+ .then()+ .statusCode(200);++ given()+ .when()+ .get("/_aws/ses")+ .then()+ .statusCode(200)+ .body("messages[0].Body.text_part", nullValue())+ .body("messages[0].Body.html_part", equalTo("<b>only html</b>"));+ }++ @Test+ @Order(73)+ void inspectionEndpoint_replyToAddressesAreStored() {+ given().delete("/_aws/ses").then().statusCode(200);++ given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body("""+ {+ "FromEmailAddress": "[email protected]",+ "Destination": {+ "ToAddresses": ["[email protected]"]+ },+ "ReplyToAddresses": ["[email protected]", "[email protected]"],+ "Content": {+ "Simple": {+ "Subject": {"Data": "ReplyTo Test"},+ "Body": {"Text": {"Data": "hello"}}+ }+ }+ }+ """)+ .when()+ .post("/v2/email/outbound-emails")+ .then()+ .statusCode(200);++ given()+ .when()+ .get("/_aws/ses")+ .then()+ .statusCode(200)+ .body("messages[0].ReplyToAddresses", hasItems("[email protected]", "[email protected]"));+ }++ @Test+ @Order(74)+ void inspectionEndpoint_noReplyToOmitsField() {+ given().delete("/_aws/ses").then().statusCode(200);++ given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body("""+ {+ "FromEmailAddress": "[email protected]",+ "Destination": {+ "ToAddresses": ["[email protected]"]+ },+ "Content": {+ "Simple": {+ "Subject": {"Data": "No ReplyTo"},+ "Body": {"Text": {"Data": "hello"}}+ }+ }+ }+ """)+ .when()+ .post("/v2/email/outbound-emails")+ .then()+ .statusCode(200);++ given()+ .when()+ .get("/_aws/ses")+ .then()+ .statusCode(200)+ .body("messages[0]", not(hasKey("ReplyToAddresses")));+ }++ @Test+ @Order(75)+ void inspectionEndpoint_rawEmailReturnsRawData() {+ given().delete("/_aws/ses").then().statusCode(200);++ given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body("""+ {+ "FromEmailAddress": "[email protected]",+ "Destination": {+ "ToAddresses": ["[email protected]"]+ },+ "Content": {+ "Raw": {+ "Data": "Subject: Raw\\r\\n\\r\\nRaw body"+ }+ }+ }+ """)+ .when()+ .post("/v2/email/outbound-emails")+ .then()+ .statusCode(200);++ given()+ .when()+ .get("/_aws/ses")+ .then()+ .statusCode(200)+ .body("messages[0].RawData", notNullValue())+ .body("messages[0].RawData", containsString("Raw body"))+ .body("messages[0]", not(hasKey("Destination")))+ .body("messages[0]", not(hasKey("Subject")))+ .body("messages[0]", not(hasKey("Body")));+ }++ @Test+ @Order(80)+ void inspectionEndpoint_returnsEmailsFromAllRegions() {+ given().delete("/_aws/ses").then().statusCode(200);++ // Create identity usable in both regions (domain covers all addresses)+ given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body("""+ {"EmailIdentity": "example.com"}+ """)+ .when()+ .post("/v2/email/identities")+ .then()+ .statusCode(200);++ // Send from us-east-1+ given()+ .contentType("application/json")+ .header("Authorization",+ "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request")+ .body("""+ {+ "FromEmailAddress": "[email protected]",+ "Destination": {"ToAddresses": ["[email protected]"]},+ "Content": {+ "Simple": {+ "Subject": {"Data": "US East"},+ "Body": {"Text": {"Data": "from us-east-1"}}+ }+ }+ }+ """)+ .when()+ .post("/v2/email/outbound-emails")+ .then()+ .statusCode(200);++ // Send from ap-northeast-1+ given()+ .contentType("application/json")+ .header("Authorization",+ "AWS4-HMAC-SHA256 Credential=AKID/20260101/ap-northeast-1/ses/aws4_request")+ .body("""+ {+ "FromEmailAddress": "[email protected]",+ "Destination": {"ToAddresses": ["[email protected]"]},+ "Content": {+ "Simple": {+ "Subject": {"Data": "AP NE"},+ "Body": {"Text": {"Data": "from ap-northeast-1"}}+ }+ }+ }+ """)+ .when()+ .post("/v2/email/outbound-emails")+ .then()+ .statusCode(200);++ // Inspection returns both, each with correct Region+ given()+ .when()+ .get("/_aws/ses")+ .then()+ .statusCode(200)+ .body("messages.size()", equalTo(2))+ .body("messages.find { it.Subject == 'US East' }.Region", equalTo("us-east-1"))+ .body("messages.find { it.Subject == 'AP NE' }.Region", equalTo("ap-northeast-1"));+ }+// ──────────────── GetEmailIdentity full response ────────────────@Test