mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ses): align V2 identity error responses with AWS (#723)
PutEmailIdentityDkimAttributes, CreateEmailIdentity, and DeleteEmailIdentity
now return the same error codes and messages as real AWS SES v2:
- PutEmailIdentityDkimAttributes on unknown identity -> 400 BadRequestException
("Domain X is not verified for DKIM signing.")
- PutEmailIdentityDkimAttributes on email-format identity whose parent
domain is registered -> 200 OK no-op (DKIM is a domain-level concept)
- CreateEmailIdentity on duplicate identity -> 400 AlreadyExistsException
- DeleteEmailIdentity on unknown identity -> 404 NotFoundException
V1 idempotent semantics (VerifyEmailIdentity / VerifyDomainIdentity /
DeleteIdentity) are preserved -- strict checks are added at the V2
controller level only.
Integration tests assert the exact AWS error messages (with trailing
period) and, for the email-with-registered-parent no-op case, verify
that the parent domain's DkimAttributes are unchanged before and after.
This commit is contained in:
1 parent
692d665734
commit
59faf568fc
4 files changed
+141
-20
No files matched your search
+118
-1
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@QuarkusTest
|
||||
@@ -196,9 +197,125 @@ class SesIdentityAttributesV2IntegrationTest {
|
||||
.when()
|
||||
.put("/v2/email/identities/v2-attrs.floci.test/mail-from")
|
||||
.then()
|
||||
.body("message", org.hamcrest.Matchers.containsString(
|
||||
.body("message", containsString(
|
||||
"Member must satisfy enum value set: [REJECT_MESSAGE, USE_DEFAULT_VALUE]"))
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
void putEmailIdentityDkimAttributes_unknownIdentity_returnsBadRequest() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("""
|
||||
{"SigningEnabled": true}
|
||||
""")
|
||||
.when()
|
||||
.put("/v2/email/identities/ghost-dkim.floci.test/dkim")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo(
|
||||
"Domain ghost-dkim.floci.test is not verified for DKIM signing."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(21)
|
||||
void putEmailIdentityDkimAttributes_emailFormatWithUnregisteredParent_returnsBadRequest() {
|
||||
// Real SES v2 reports the parent domain (not the full email identity)
|
||||
// in the error message even when the input is email-formatted.
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("""
|
||||
{"SigningEnabled": true}
|
||||
""")
|
||||
.when()
|
||||
.put("/v2/email/identities/orphan@no-such-parent.floci.test/dkim")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo(
|
||||
"Domain no-such-parent.floci.test is not verified for DKIM signing."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(22)
|
||||
void putEmailIdentityDkimAttributes_emailWithRegisteredParentDomain_returnsNoOp() {
|
||||
// Real SES v2 accepts the call (200 OK) for an email-format identity
|
||||
// whose parent domain is registered, but persists nothing — DKIM is a
|
||||
// domain-level concept. The parent domain's DkimAttributes must remain
|
||||
// untouched, and no email identity is auto-created.
|
||||
Object parentDkimBefore = given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.get("/v2/email/identities/v2-attrs.floci.test")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("DkimAttributes");
|
||||
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("""
|
||||
{"SigningEnabled": true}
|
||||
""")
|
||||
.when()
|
||||
.put("/v2/email/identities/orphan@v2-attrs.floci.test/dkim")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.get("/v2/email/identities/v2-attrs.floci.test")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DkimAttributes", equalTo(parentDkimBefore));
|
||||
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.get("/v2/email/identities/orphan@v2-attrs.floci.test")
|
||||
.then()
|
||||
.statusCode(404);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(23)
|
||||
void createEmailIdentity_duplicate_returnsAlreadyExists() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("""
|
||||
{"EmailIdentity": "v2-attrs.floci.test"}
|
||||
""")
|
||||
.when()
|
||||
.post("/v2/email/identities")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("AlreadyExistsException"))
|
||||
.body("message", equalTo(
|
||||
"Email identity v2-attrs.floci.test already exist."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(24)
|
||||
void deleteEmailIdentity_unknownIdentity_returnsNotFound() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.delete("/v2/email/identities/ghost-delete.floci.test")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.body("__type", equalTo("NotFoundException"))
|
||||
.body("message", equalTo(
|
||||
"Email identity ghost-delete.floci.test does not exist."));
|
||||
}
|
||||
}
|
||||
@@ -395,22 +395,6 @@ class SesV2IntegrationTest {
|
||||
.body("DkimAttributes.Status", equalTo("NOT_STARTED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(22)
|
||||
void putDkimAttributes_notFound() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("""
|
||||
{"SigningEnabled": true}
|
||||
""")
|
||||
.when()
|
||||
.put("/v2/email/identities/nonexistent@example.com/dkim")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.body("__type", equalTo("NotFoundException"));
|
||||
}
|
||||
|
||||
// ──────────────── Feedback Attributes ────────────────
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user