mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ses): check PutEmailIdentityDkimSigningAttributes against the SES v2 shapes (#7084)
A SigningAttributes member that is not a JSON object answered a Floci-only BadRequestException. The operation now runs the shared SES v2 shape check first, so a member of the wrong JSON type is a SerializationException with AWS's deserializer message, ahead of the origin check and the identity lookup, as AWS answers it. A missing identity now answers AWS's "The specified email identity, <id>, does not exist."
This commit is contained in:
1 parent
5e9df931e3
commit
f40d784f66
7 files changed
+49
-30
No files matched your search
+38
-1
@@ -5,9 +5,18 @@ import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.Response;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2SerializationErrors.EXPECTED_NULL;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2SerializationErrors.LIST;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2SerializationErrors.NUMBER;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2SerializationErrors.STRUCTURE;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2SerializationErrors.assertSerializationException;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@@ -128,7 +137,9 @@ class SesDkimSigningActionsIntegrationTest {
|
||||
given().contentType("application/json").header("Authorization", V2_AUTH)
|
||||
.body("{\"SigningAttributesOrigin\":\"AWS_SES\"}")
|
||||
.when().put("/v2/email/identities/ghost-signing.floci.test/dkim/signing")
|
||||
.then().statusCode(404).body("__type", equalTo("NotFoundException"));
|
||||
.then().statusCode(404).body("__type", equalTo("NotFoundException"))
|
||||
.body("message", equalTo(
|
||||
"The specified email identity, ghost-signing.floci.test, does not exist."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -212,6 +223,32 @@ class SesDkimSigningActionsIntegrationTest {
|
||||
.body("message", equalTo("Start of list found where not expected"));
|
||||
}
|
||||
|
||||
// The identity does not exist and some cases send an invalid origin: AWS reads the body
|
||||
// against the shapes before either check.
|
||||
static Stream<Arguments> putDkimSigningAttributesWrongMemberTypeCases() {
|
||||
return Stream.of(
|
||||
Arguments.of("stringSigningAttributes",
|
||||
"{\"SigningAttributesOrigin\": \"AWS_SES\", \"SigningAttributes\": \"x\"}", EXPECTED_NULL),
|
||||
Arguments.of("stringSigningAttributesWithInvalidOrigin",
|
||||
"{\"SigningAttributesOrigin\": \"BAD\", \"SigningAttributes\": \"x\"}", EXPECTED_NULL),
|
||||
Arguments.of("arraySigningAttributes",
|
||||
"{\"SigningAttributesOrigin\": \"AWS_SES\", \"SigningAttributes\": []}", LIST),
|
||||
Arguments.of("arrayNextSigningKeyLength",
|
||||
"{\"SigningAttributesOrigin\": \"AWS_SES\", "
|
||||
+ "\"SigningAttributes\": {\"NextSigningKeyLength\": []}}", LIST),
|
||||
Arguments.of("objectDomainSigningSelector",
|
||||
"{\"SigningAttributesOrigin\": \"EXTERNAL\", "
|
||||
+ "\"SigningAttributes\": {\"DomainSigningSelector\": {}}}", STRUCTURE),
|
||||
Arguments.of("numericOrigin", "{\"SigningAttributesOrigin\": 1}", NUMBER));
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0}")
|
||||
@MethodSource("putDkimSigningAttributesWrongMemberTypeCases")
|
||||
void putDkimSigningAttributes_wrongMemberType(String caseName, String body, String message) {
|
||||
assertSerializationException("PUT", "/v2/email/identities/dkim-missing.floci.test/dkim/signing",
|
||||
body, message);
|
||||
}
|
||||
|
||||
@Test
|
||||
void putEmailIdentityDkimAttributes_existingEmailWithRegisteredDomain_isNoOp() {
|
||||
String domain = "dkim-emailtoggle.floci.test";
|
||||
|
||||
@@ -81,17 +81,6 @@ class SesV2JsonTest {
|
||||
SesV2Json.requireJsonObject(json("{}"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void requireObjectOrAbsent_returnsChild_rejectsScalars() {
|
||||
assertTrue(SesV2Json.requireObjectOrAbsent(json("{}"), "Options").isMissingNode());
|
||||
assertTrue(SesV2Json.requireObjectOrAbsent(json("{\"Options\":null}"), "Options").isNull());
|
||||
JsonNode nested = json("{\"Options\":{\"a\":\"x\"}}");
|
||||
assertEquals("x", SesV2Json.requireObjectOrAbsent(nested, "Options").path("a").asText());
|
||||
assertEquals("Options must be a JSON object.",
|
||||
assertAws("BadRequestException", 400, () -> SesV2Json.requireObjectOrAbsent(
|
||||
json("{\"Options\":1}"), "Options")).getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseTagsArray_absentIsNull_shapeErrorsAreWireErrors() {
|
||||
assertNull(SesV2Json.parseTagsArray(json("{}").path("Tags")));
|
||||
|
||||
Reference in new issue
Block a user