Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(ses): populate VerificationStatus in v2 ListEmailIdentities (#1722)

Kenshin Okinakaefc9453fd71a
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesIdentityAttributesTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesIdentityAttributesTest.java
index dd9d706629..122c137522 100644
--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesIdentityAttributesTest.java
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesIdentityAttributesTest.java
@@ -28,7 +28,12 @@ import software.amazon.awssdk.services.sesv2.model.CreateEmailIdentityRequest;
import software.amazon.awssdk.services.sesv2.model.DeleteEmailIdentityRequest;
import software.amazon.awssdk.services.sesv2.model.GetEmailIdentityRequest;
import software.amazon.awssdk.services.sesv2.model.GetEmailIdentityResponse;
+import software.amazon.awssdk.services.sesv2.model.IdentityInfo;
+import software.amazon.awssdk.services.sesv2.model.ListEmailIdentitiesRequest;
import software.amazon.awssdk.services.sesv2.model.PutEmailIdentityMailFromAttributesRequest;
+import software.amazon.awssdk.services.sesv2.model.VerificationStatus;
+
+import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -167,4 +172,30 @@ class SesIdentityAttributesTest {
.extracting(e -> ((AwsServiceException) e).statusCode())
.isEqualTo(400);
}
+
+ @Test
+ @Order(12)
+ void listEmailIdentities_populatesVerificationStatus() {
+ String email = TestFixtures.uniqueName("lei") + "@example.com";
+ String domain = TestFixtures.uniqueName("lei") + ".example.com";
+ sesV2.createEmailIdentity(CreateEmailIdentityRequest.builder().emailIdentity(email).build());
+ sesV2.createEmailIdentity(CreateEmailIdentityRequest.builder().emailIdentity(domain).build());
+ try {
+ List<IdentityInfo> identities = sesV2.listEmailIdentities(
+ ListEmailIdentitiesRequest.builder().build()).emailIdentities();
+ IdentityInfo emailIdentity = identities.stream()
+ .filter(i -> email.equals(i.identityName())).findFirst().orElseThrow();
+ IdentityInfo domainIdentity = identities.stream()
+ .filter(i -> domain.equals(i.identityName())).findFirst().orElseThrow();
+ // Regression: VerificationStatus used to be null in the list response.
+ assertThat(emailIdentity.verificationStatus()).isEqualTo(VerificationStatus.SUCCESS);
+ assertThat(domainIdentity.verificationStatus()).isEqualTo(VerificationStatus.PENDING);
+ // SendingEnabled tracks verification status on AWS: SUCCESS -> true, PENDING -> false.
+ assertThat(emailIdentity.sendingEnabled()).isTrue();
+ assertThat(domainIdentity.sendingEnabled()).isFalse();
+ } finally {
+ sesV2.deleteEmailIdentity(DeleteEmailIdentityRequest.builder().emailIdentity(email).build());
+ sesV2.deleteEmailIdentity(DeleteEmailIdentityRequest.builder().emailIdentity(domain).build());
+ }
+ }
}
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.java
index 22c149a996..14529eab89 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
@@ -127,10 +127,20 @@ public class SesController {
ObjectNode result = objectMapper.createObjectNode();
ArrayNode items = result.putArray("EmailIdentities");
for (Identity id : identities) {
+ // Only a not-yet-verified domain can still transition (via its DKIM records),
+ // so refresh just those; refreshing every identity would scan Route53 per call.
+ Identity current = id;
+ if ("Domain".equals(id.getIdentityType()) && !"Success".equals(id.getVerificationStatus())) {
+ Identity refreshed = sesService.getIdentityVerificationAttributes(id.getIdentity(), region);
+ if (refreshed != null) {
+ current = refreshed;
+ }
+ }
ObjectNode item = objectMapper.createObjectNode();
- item.put("IdentityType", toV2IdentityType(id.getIdentityType()));
- item.put("IdentityName", id.getIdentity());
- item.put("SendingEnabled", true);
+ item.put("IdentityType", toV2IdentityType(current.getIdentityType()));
+ item.put("IdentityName", current.getIdentity());
+ item.put("SendingEnabled", "Success".equals(current.getVerificationStatus()));
+ item.put("VerificationStatus", toV2Status(current.getVerificationStatus()));
items.add(item);
}
return Response.ok(result).build();
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.java
index 29aaec4afc..ffcca1bb04 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
@@ -85,7 +85,18 @@ class SesV2IntegrationTest {
.body("EmailIdentities", notNullValue())
.body("EmailIdentities.size()", greaterThanOrEqualTo(2))
.body("EmailIdentities.IdentityName", hasItem("[email protected]"))
- .body("EmailIdentities.IdentityName", hasItem("v2example.com"));
+ .body("EmailIdentities.IdentityName", hasItem("v2example.com"))
+ // VerificationStatus must be populated per identity (never null), matching AWS.
+ .body("EmailIdentities.VerificationStatus", everyItem(notNullValue()))
+ .body("EmailIdentities.find { it.IdentityName == '[email protected]' }.VerificationStatus",
+ equalTo("SUCCESS"))
+ .body("EmailIdentities.find { it.IdentityName == 'v2example.com' }.VerificationStatus",
+ equalTo("PENDING"))
+ // SendingEnabled tracks verification: SUCCESS -> true, PENDING -> false (matches AWS).
+ .body("EmailIdentities.find { it.IdentityName == '[email protected]' }.SendingEnabled",
+ equalTo(true))
+ .body("EmailIdentities.find { it.IdentityName == 'v2example.com' }.SendingEnabled",
+ equalTo(false));
}
@Test