mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(ses): implement SendCustomVerificationEmail for v1 and v2 (#2191)
* feat(ses): implement SendCustomVerificationEmail for v1 and v2
Add the SendCustomVerificationEmail action on both the v1 Query API and the v2 REST
JSON API (POST /v2/email/outbound-custom-verification-emails). The service renders the
stored custom-verification-email template into the inspection mailbox and the SMTP
relay, returns a MessageId, and registers the recipient as a pending-verification
identity, matching AWS. A missing template is the v1-native
CustomVerificationEmailTemplateDoesNotExist (remapped to NotFoundException on v2), with
the v1 send message ("Template <name> does not exist") verified against AWS.
* test(ses): log custom-verification compat cleanup failures instead of swallowing them
The @AfterAll cleanup deleted templates and identities in best-effort try/catch
blocks that swallowed every exception, so a real deletion failure would leave
state behind with no diagnostic. Log the affected template/identity and the
exception message, per AGENTS.md's rule against silently discarding exceptions.
This commit is contained in:
1 parent
ac4b865a34
commit
bd01c1a70b
8 files changed
+576
-8
No files matched your search
+28
-6
@@ -31,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
class SesCustomVerificationEmailTemplateTest {
|
||||
|
||||
private static final String FROM = "cvet-sdk-sender@floci-cvet.test";
|
||||
private static final String RECIPIENT = "cvet-sdk-recipient@floci-cvet.test";
|
||||
private static final String NAME = "cvet-sdk-a";
|
||||
|
||||
private static SesClient sesV1;
|
||||
@@ -49,14 +50,19 @@ class SesCustomVerificationEmailTemplateTest {
|
||||
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.
|
||||
} catch (Exception e) {
|
||||
// Best-effort cleanup (the template may already be gone); log so a real failure
|
||||
// is diagnosable rather than silently leaving state behind.
|
||||
System.out.println("Cleanup: failed to delete template " + n + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
try {
|
||||
sesV2.deleteEmailIdentity(DeleteEmailIdentityRequest.builder().emailIdentity(FROM).build());
|
||||
} catch (Exception ignored) {
|
||||
// Best-effort cleanup.
|
||||
for (String id : new String[] {FROM, RECIPIENT}) {
|
||||
try {
|
||||
sesV2.deleteEmailIdentity(DeleteEmailIdentityRequest.builder().emailIdentity(id).build());
|
||||
} catch (Exception e) {
|
||||
// Best-effort cleanup; log so a real deletion failure is diagnosable.
|
||||
System.out.println("Cleanup: failed to delete identity " + id + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
sesV2.close();
|
||||
}
|
||||
@@ -118,4 +124,20 @@ class SesCustomVerificationEmailTemplateTest {
|
||||
assertThat(sesV2.getCustomVerificationEmailTemplate(b -> b.templateName("cvet-sdk-shared"))
|
||||
.templateSubject()).isEqualTo("Shared");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void v2_sendCustomVerificationEmail() {
|
||||
String messageId = sesV2.sendCustomVerificationEmail(b -> b
|
||||
.emailAddress(RECIPIENT).templateName(NAME)).messageId();
|
||||
assertThat(messageId).isNotBlank();
|
||||
|
||||
// The recipient is registered as a pending-verification identity by the send.
|
||||
assertThat(sesV2.getEmailIdentity(b -> b.emailIdentity(RECIPIENT)).verifiedForSendingStatus())
|
||||
.isFalse();
|
||||
|
||||
assertThatThrownBy(() -> sesV2.sendCustomVerificationEmail(b -> b
|
||||
.emailAddress(RECIPIENT).templateName("nope-sdk")))
|
||||
.isInstanceOf(NotFoundException.class);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user