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

* fix(ses): populate VerificationStatus in v2 ListEmailIdentities

ListEmailIdentities built each item with only IdentityType / IdentityName /
SendingEnabled, so VerificationStatus always serialized as null and clients had
to call GetEmailIdentity per identity. Populate it from the identity's stored
status (mapped to the v2 enum via toV2Status), and refresh each identity's
state the same way GetEmailIdentity does so the list stays consistent (e.g. a
domain that transitioned to SUCCESS via its DKIM records).

* fix(ses): derive SendingEnabled from verification status in v2 ListEmailIdentities

SendingEnabled was hard-coded to true, so a not-yet-verified identity was
reported as sendable, which is inconsistent now that VerificationStatus is
populated. AWS returns SendingEnabled=true only when the identity is verified
(VerificationStatus SUCCESS) and false otherwise (PENDING/FAILED), matching the
VerifiedForSendingStatus logic already used by GetEmailIdentity. Derive it the
same way here.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-07-09 23:54:43 -05:00
1 parent 3771c1e9a2
commit efc9453fd7
3 files changed
+56 -4

No files matched your search

@@ -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());
}
}
}