mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ses): match SES v1 on a missing custom verification template and an absent MAIL FROM domain (#9081)
This commit is contained in:
1 parent
a3c45a4ce2
commit
7c4ed46223
10 files changed
+177
-44
No files matched your search
+29
-2
@@ -25,6 +25,8 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest {
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String FROM = "cvet-v1-sender@floci.test";
|
||||
private static final String NAME = "cvet-v1-a";
|
||||
private static final String MISSING_MESSAGE =
|
||||
"Provided custom verification email template name does not exist.";
|
||||
|
||||
private static RequestSpecification query(String action) {
|
||||
return given().contentType("application/x-www-form-urlencoded").header("Authorization", AUTH)
|
||||
@@ -51,10 +53,35 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest {
|
||||
@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.
|
||||
// v1 SDK's typed exception fires, not the v2 NotFoundException / 404. The message is a
|
||||
// fixed sentence that does not name the template, unlike the v2 one.
|
||||
query("GetCustomVerificationEmailTemplate").formParam("TemplateName", "cvet-v1-ghost")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>CustomVerificationEmailTemplateDoesNotExist</Code>"));
|
||||
.body(containsString("<Code>CustomVerificationEmailTemplateDoesNotExist</Code>"))
|
||||
.body(containsString("<Message>" + MISSING_MESSAGE + "</Message>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
void update_missing_returnsTheSameFixedSentenceOnV1() {
|
||||
query("UpdateCustomVerificationEmailTemplate")
|
||||
.formParam("TemplateName", "cvet-v1-ghost").formParam("FromEmailAddress", FROM)
|
||||
.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>CustomVerificationEmailTemplateDoesNotExist</Code>"))
|
||||
.body(containsString("<Message>" + MISSING_MESSAGE + "</Message>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(13)
|
||||
void delete_missing_succeedsOnV1() {
|
||||
// Probed: v1 answers 200 for a name the account does not hold, where v2 answers 404.
|
||||
query("DeleteCustomVerificationEmailTemplate").formParam("TemplateName", "cvet-v1-ghost")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body(containsString("DeleteCustomVerificationEmailTemplateResponse"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-2
@@ -119,7 +119,8 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
|
||||
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"));
|
||||
.body("__type", equalTo("NotFoundException"))
|
||||
.body("message", equalTo("Custom verification email template <nope> does not exist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,7 +137,8 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
|
||||
void deleteMissing_throwsNotFound() {
|
||||
given().header("Authorization", AUTH)
|
||||
.when().delete(BASE + "/nope").then().statusCode(404)
|
||||
.body("__type", equalTo("NotFoundException"));
|
||||
.body("__type", equalTo("NotFoundException"))
|
||||
.body("message", equalTo("Custom verification email template <nope> does not exist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.junit.jupiter.api.Test;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@@ -58,6 +59,12 @@ class SesCvetServiceTest {
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
() -> service.getCustomVerificationEmailTemplate("ghost", REGION));
|
||||
assertEquals("CustomVerificationEmailTemplateDoesNotExist", e.getErrorCode());
|
||||
assertEquals("Provided custom verification email template name does not exist.", e.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void delete_unknown_reportsAbsenceWithoutThrowing() {
|
||||
assertFalse(service.deleteCustomVerificationEmailTemplate("ghost", REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,7 +72,7 @@ class SesCvetServiceTest {
|
||||
service.createCustomVerificationEmailTemplate(template("t1"), REGION);
|
||||
assertTrue(service.find("t1", REGION).isPresent());
|
||||
|
||||
service.deleteCustomVerificationEmailTemplate("t1", REGION);
|
||||
assertTrue(service.deleteCustomVerificationEmailTemplate("t1", REGION));
|
||||
assertTrue(service.find("t1", REGION).isEmpty());
|
||||
}
|
||||
|
||||
@@ -97,5 +104,6 @@ class SesCvetServiceTest {
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
() -> service.updateCustomVerificationEmailTemplate(template("ghost"), REGION));
|
||||
assertEquals("CustomVerificationEmailTemplateDoesNotExist", e.getErrorCode());
|
||||
assertEquals("Provided custom verification email template name does not exist.", e.getMessage());
|
||||
}
|
||||
}
|
||||
+62
-5
@@ -89,8 +89,41 @@ class SesIdentityAttributesV1IntegrationTest {
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<MailFromDomain></MailFromDomain>"))
|
||||
.body(containsString("<MailFromDomainStatus>Pending</MailFromDomainStatus>"));
|
||||
.body(containsString("<key>v1-attrs.floci.test</key>"))
|
||||
.body(containsString("<BehaviorOnMXFailure>UseDefaultValue</BehaviorOnMXFailure>"))
|
||||
.body(not(containsString("MailFromDomain>")))
|
||||
.body(not(containsString("MailFromDomainStatus")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdentityMailFromDomainAttributes_unknownIdentity_hasNoEntry() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "GetIdentityMailFromDomainAttributes")
|
||||
.formParam("Identities.member.1", "v1-attrs-unknown.floci.test")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("MailFromDomainAttributes"))
|
||||
.body(not(containsString("<entry>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdentityMailFromDomainAttributes_skipsOnlyTheUnknownIdentity() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "GetIdentityMailFromDomainAttributes")
|
||||
.formParam("Identities.member.1", "v1-attrs-unknown.floci.test")
|
||||
.formParam("Identities.member.2", "v1-attrs.floci.test")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<key>v1-attrs.floci.test</key>"))
|
||||
.body(not(containsString("v1-attrs-unknown.floci.test")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,7 +178,19 @@ class SesIdentityAttributesV1IntegrationTest {
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void setIdentityMailFromDomain_missingMailFromDomain_returnsInvalidParameterValue() {
|
||||
void setIdentityMailFromDomain_missingMailFromDomain_clears() {
|
||||
// Probed: SES takes an absent MailFromDomain as the request to clear the domain.
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "SetIdentityMailFromDomain")
|
||||
.formParam("Identity", "v1-attrs.floci.test")
|
||||
.formParam("MailFromDomain", "mail.v1-attrs.floci.test")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
@@ -154,8 +199,20 @@ class SesIdentityAttributesV1IntegrationTest {
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidParameterValue"));
|
||||
.statusCode(200)
|
||||
.body(containsString("SetIdentityMailFromDomainResponse"));
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", "GetIdentityMailFromDomainAttributes")
|
||||
.formParam("Identities.member.1", "v1-attrs.floci.test")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<BehaviorOnMXFailure>UseDefaultValue</BehaviorOnMXFailure>"))
|
||||
.body(not(containsString("MailFromDomain>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -64,10 +64,28 @@ class SesV2JsonTest {
|
||||
assertEquals("SendingPausedException", SesV2Json.remapV1Exception(new AwsException(
|
||||
"ConfigurationSetSendingPausedException", "m", 400)).getErrorCode());
|
||||
|
||||
AwsException restatedByCallers = new AwsException(
|
||||
"CustomVerificationEmailTemplateDoesNotExist", "v1 sentence", 400);
|
||||
assertSame(restatedByCallers, SesV2Json.remapV1Exception(restatedByCallers));
|
||||
|
||||
AwsException untouched = new AwsException("NotFoundException", "already v2", 404);
|
||||
assertSame(untouched, SesV2Json.remapV1Exception(untouched));
|
||||
}
|
||||
|
||||
@Test
|
||||
void remapCvetException_restatesAMissingTemplateAndRemapsTheRest() {
|
||||
AwsException missing = SesV2Json.remapCvetException(new AwsException(
|
||||
"CustomVerificationEmailTemplateDoesNotExist", "v1 sentence", 400), "welcome");
|
||||
assertEquals("NotFoundException", missing.getErrorCode());
|
||||
assertEquals(404, missing.getHttpStatus());
|
||||
assertEquals("Custom verification email template <welcome> does not exist", missing.getMessage());
|
||||
|
||||
AwsException other = SesV2Json.remapCvetException(
|
||||
new AwsException("InvalidParameterValue", "m", 400), "welcome");
|
||||
assertEquals("BadRequestException", other.getErrorCode());
|
||||
assertEquals("m", other.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void requireJsonObject_rejectsNullAndNonObjects() {
|
||||
assertNull(assertAws("SerializationException", 400,
|
||||
|
||||
Reference in new issue
Block a user