Light, fluffy, and always free - The AWS Local Emulator alternative
fix(ses): answer SES v2 wire-type errors with AWS's messages (#6330)
Kenshin Okinakaeea87ca998f5
diff --git a/docs/services/ses.md b/docs/services/ses.mdindex 856cedab2f..d8968e7b0f 100644--- a/docs/services/ses.md+++ b/docs/services/ses.md@@ -511,12 +511,15 @@ The operations whose body nests a structure in a structure, or holds a list of s|---|---|---|| string, blob | number or boolean | `NUMBER_VALUE can not be converted to a String` (`TRUE_VALUE` / `FALSE_VALUE`; `a Blob` for a blob) || string, blob | object / array | `Start of structure or map found where not expected.` / `Start of list found where not expected` |-| structure, map | array / any other non-object | `Start of list found where not expected` / `Expected null` |+| structure | array / any other non-object | `Start of list found where not expected` / `Expected null` |+| map | array / any other non-object | `Start of list found where not expected` / `Expected map or null` || list | object / any other non-array | `Start of structure or map found where not expected.` / `Expected list or null` |A JSON `null` member counts as absent. A `null` address list element passes this check and fails later, as on AWS: `SendEmail` answers `Invalid email address null.` after its content and sender checks and before the tenant lookup, and `SendBulkEmail` reports it as the `INVALID_PARAMETER` status of the entry it belongs to (of every entry for a `null` Reply-To), or as `Destination cannot be empty` when no entry of the request has a non-null recipient. A `null` element of `Topics` (`CreateContactList`, `UpdateContactList`) or `TopicPreferences` (`CreateContact`, `UpdateContact`) also passes this check, but there AWS answers it with a `500 InternalFailure`, which Floci replaces with `BadRequestException` naming the element ("1 validation error detected: Value at 'topics.1.member.topicName' failed to satisfy constraint: Member must not be null"). The account-level sending switch is still checked first, so a paused account answers `SendingPausedException` even for a malformed body. Likewise `BatchGetMetricData` checks that Virtual Deliverability Manager is enabled before it reads the body.-The other operations check their members one at a time, and some of them still answer a wrong JSON type with `BadRequestException`.+The other operations check their members one at a time, and some of them still answer a wrong JSON type with `BadRequestException`. The list operations' map `Filter` answers as in the table. Their integer `PageSize`, like `CreateExportJob`'s `MaxResults`, answers a string with `STRING_VALUE can not be converted to an Integer` (`TRUE_VALUE` / `FALSE_VALUE` for a boolean, and as in the table for an object or an array), while a number is read as an int first, as on AWS: `1.5` is accepted, and a value above the int range is checked against the page-size bounds as `2147483647`.++A body that is not a JSON object is a `SerializationException`, before any member is read: `Start of list found where not expected` for an array, and no message for a string, a number or `null`. `CreateEmailIdentity`, `CreateEmailTemplate`, `UpdateEmailTemplate`, `CreateCustomVerificationEmailTemplate`, `UpdateCustomVerificationEmailTemplate` and `TagResource` do not check this yet and read such a body as one without members.The body shapes are vendored in `src/main/resources/aws/sesv2-request-shapes.json`, generated by `tools/aws/regen_sesv2_shapes.py` from the botocore release pinned in `tools/aws/requirements.txt`.diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesExportFilters.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesExportFilters.javaindex 525ba942d4..aefbfb6454 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesExportFilters.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesExportFilters.java@@ -10,6 +10,7 @@ import java.util.Locale;import java.util.Set;import java.util.function.Function;+import static io.github.hectorvent.floci.services.ses.SesV2Json.intMemberOrAbsent;import static io.github.hectorvent.floci.services.ses.SesV2Json.stringArrayOrAbsent;/**@@ -46,9 +47,9 @@ final class SesExportFilters {}// The service validated the range at create time; this stays defensive so a stored job// written by an older build cannot slice with a negative bound.- JsonNode maxResults = insights.path("MaxResults");- if (maxResults.isInt() && maxResults.intValue() > 0 && kept.size() > maxResults.intValue()) {- return kept.subList(0, maxResults.intValue());+ Integer maxResults = intMemberOrAbsent(insights, "MaxResults");+ if (maxResults != null && maxResults > 0 && kept.size() > maxResults) {+ return kept.subList(0, maxResults);}return kept;}diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesExportJobService.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesExportJobService.javaindex a8b5d5ccdd..f3a0f10089 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesExportJobService.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesExportJobService.java@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;import com.fasterxml.jackson.core.type.TypeReference;import com.fasterxml.jackson.databind.JsonNode;import com.fasterxml.jackson.databind.ObjectMapper;+import com.fasterxml.jackson.databind.node.ObjectNode;import io.github.hectorvent.floci.config.EmulatorConfig;import io.github.hectorvent.floci.core.common.AwsException;import io.github.hectorvent.floci.core.common.PaginatedResult;@@ -546,10 +547,11 @@ public class SesExportJobService implements Resettable {/*** The model bounds {@code MaxResults} at 1 to 10000. An unchecked negative value reached- * {@code subList} inside the filter and surfaced as a 500.+ * {@code subList} inside the filter and surfaced as a 500. The value is stored as the int it+ * was checked as, so a job created with 1.5 is described and filtered with 1.*/private static void requireMaxResults(JsonNode insights) {- // intMemberOrAbsent answers SerializationException for a value that is not an integer, so+ // intMemberOrAbsent answers SerializationException for a value that is not a number, so// a wrong type is not reported as a value out of range.Integer maxResults = intMemberOrAbsent(insights, "MaxResults");if (maxResults == null) {@@ -562,6 +564,9 @@ public class SesExportJobService implements Resettable {+ "satisfy constraint: Member must be between 1 and " + MAX_RESULTS+ ", inclusive");}+ if (insights instanceof ObjectNode node) {+ node.put("MaxResults", maxResults);+ }}private static Instant requireDate(JsonNode source, String field) {diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesIdentityController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesIdentityController.javaindex 6050c1f31d..75f50b2c08 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesIdentityController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesIdentityController.java@@ -436,9 +436,7 @@ public class SesIdentityController {// clear). Within a valid object, an omitted or explicit-null ConfigurationSetName// clears the association (as does an empty body / {}).JsonNode request = objectMapper.readTree(body);- if (request == null || !request.isObject()) {- throw new AwsException("SerializationException", null, 400);- }+ requireJsonObject(request);JsonNode node = request.path("ConfigurationSetName");if (!node.isMissingNode() && !node.isNull()) {if (!node.isTextual()) {diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesTenantController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesTenantController.javaindex 365820c87c..e6edcc3e2a 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesTenantController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesTenantController.java@@ -227,14 +227,8 @@ public class SesTenantController {: objectMapper.readTree(body);requireJsonObject(request);String tenantName = stringMemberOrAbsent(request, "TenantName");- String resourceTypeFilter = null;- JsonNode filter = request.path("Filter");- if (!filter.isMissingNode() && !filter.isNull()) {- if (!filter.isObject()) {- throw new AwsException("SerializationException", null, 400);- }- resourceTypeFilter = stringMemberOrAbsent(filter, "RESOURCE_TYPE");- }+ Map<String, String> filter = stringMapMemberOrAbsent(request, "Filter");+ String resourceTypeFilter = filter == null ? null : filter.get("RESOURCE_TYPE");Integer pageSize = intMemberOrAbsent(request, "PageSize");String nextToken = stringMemberOrAbsent(request, "NextToken");PaginatedResult<TenantResourceAssociation> page = tenantService.listTenantResources(diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesV2Json.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesV2Json.javaindex b8b36cfa88..53ca71aaaf 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesV2Json.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesV2Json.java@@ -27,7 +27,9 @@ final class SesV2Json {/** The deserializer's wording, which {@link SesV2RequestShapes}' walk of the body shapes shares. */static final String SERIALIZATION_EXCEPTION = "SerializationException";static final String CONVERSION = "%s can not be converted to a %s";+ static final String INTEGER_CONVERSION = "%s can not be converted to an Integer";static final String EXPECTED_NULL = "Expected null";+ static final String EXPECTED_MAP = "Expected map or null";static final String EXPECTED_LIST = "Expected list or null";static final String LIST_NOT_EXPECTED = "Start of list found where not expected";static final String OBJECT_NOT_EXPECTED = "Start of structure or map found where not expected.";@@ -52,11 +54,15 @@ final class SesV2Json {};}+ /** A request body that is not a JSON object: AWS names a list and answers anything else without a message. */static void requireJsonObject(JsonNode root) {- if (root == null || !root.isObject()) {- throw new AwsException("BadRequestException",- "Request body must be a JSON object.", 400);+ if (root != null && root.isObject()) {+ return;+ }+ if (root != null && root.isArray()) {+ throw unexpectedStartError(root);}+ throw new AwsException(SERIALIZATION_EXCEPTION, null, 400);}static JsonNode requireObjectOrAbsent(JsonNode parent, String fieldName) {@@ -152,21 +158,6 @@ final class SesV2Json {throw scalarTypeError(node, "Boolean");}- /**- * A structure member as the AWS deserializer reads it: absent or null is returned as is, an- * array is "Start of list found where not expected" and any other non-object "Expected null".- */- private static JsonNode structureMemberOrAbsent(JsonNode parent, String field) {- JsonNode node = parent.path(field);- if (node.isMissingNode() || node.isNull() || node.isObject()) {- return node;- }- if (node.isArray()) {- throw unexpectedStartError(node);- }- throw expectedNullError();- }-/** A string member with the AWS deserializer's message for each wrong JSON type. */private static String typedStringMemberOrAbsent(JsonNode parent, String field) {JsonNode node = parent.path(field);@@ -185,10 +176,16 @@ final class SesV2Json {* JSON type gets the deserializer's message for it.*/static Map<String, String> stringMapMemberOrAbsent(JsonNode parent, String field) {- JsonNode node = structureMemberOrAbsent(parent, field);+ JsonNode node = parent.path(field);if (node.isMissingNode() || node.isNull()) {return null;}+ if (node.isArray()) {+ throw unexpectedStartError(node);+ }+ if (!node.isObject()) {+ throw expectedMapError();+ }Map<String, String> values = new LinkedHashMap<>();for (Map.Entry<String, JsonNode> entry : node.properties()) {values.put(entry.getKey(), typedStringMemberOrAbsent(node, entry.getKey()));@@ -240,11 +237,16 @@ final class SesV2Json {return unexpectedStartError(node);}- /** The deserializer's message for a structure or map member given a scalar. */+ /** The deserializer's message for a structure member given a scalar. */static AwsException expectedNullError() {return new AwsException(SERIALIZATION_EXCEPTION, EXPECTED_NULL, 400);}+ /** The deserializer's message for a map member given a scalar. */+ static AwsException expectedMapError() {+ return new AwsException(SERIALIZATION_EXCEPTION, EXPECTED_MAP, 400);+ }+/** The deserializer's message for a list member given a scalar. */static AwsException expectedListError() {return new AwsException(SERIALIZATION_EXCEPTION, EXPECTED_LIST, 400);@@ -291,18 +293,26 @@ final class SesV2Json {return values;}- // Integer variant of stringMemberOrAbsent: absent/null returns null, non-integral JSON is- // rejected rather than coerced, and so is an integral value outside the int range (intValue- // would silently truncate it).+ // Integer variant of stringMemberOrAbsent: absent/null returns null and a string, a boolean, an+ // object or a list gets the deserializer's message for it. A number is narrowed to an int: AWS+ // accepts 1.5 and range-checks 4294967296 as 2147483647, which a double-to-int cast reproduces+ // where intValue would truncate 4294967296 to 0.static Integer intMemberOrAbsent(JsonNode parent, String field) {JsonNode n = parent.path(field);if (n.isMissingNode() || n.isNull()) {return null;}- if (!n.isIntegralNumber() || !n.canConvertToInt()) {- throw new AwsException(SERIALIZATION_EXCEPTION, null, 400);+ if (n.isTextual()) {+ throw new AwsException(SERIALIZATION_EXCEPTION, INTEGER_CONVERSION.formatted("STRING_VALUE"), 400);+ }+ if (n.isBoolean()) {+ throw new AwsException(SERIALIZATION_EXCEPTION,+ INTEGER_CONVERSION.formatted(n.booleanValue() ? "TRUE_VALUE" : "FALSE_VALUE"), 400);+ }+ if (n.isContainerNode()) {+ throw unexpectedStartError(n);}- return n.intValue();+ return (int) n.doubleValue();}static String readRequiredStringField(JsonNode request, String fieldName) {diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesV2RequestShapes.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesV2RequestShapes.javaindex aec5b6115a..511851b2e9 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesV2RequestShapes.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesV2RequestShapes.java@@ -20,10 +20,11 @@ import java.util.Set;* a list operation's map {@code Filter} keep the {@link SesV2Json} member helpers.** <p>AWS reads the body in order and reports the first bad member, without naming it. A map- * container answers like a structure, as the list operations' {@code Filter} already does. Only the- * string, blob, list and structure messages have been probed, so a number, boolean or timestamp- * member is still checked by its controller. The probes sent integers only: a non-integral number- * is reported as {@code NUMBER_VALUE} too, although AWS may name it differently.+ * container answers like a structure, except that a scalar for it is "Expected map or null". Only+ * the string, blob, list, structure and map messages have been probed, so a number, boolean or+ * timestamp member is still checked by its controller. The probes sent integers only: a+ * non-integral number is reported as {@code NUMBER_VALUE} too, although AWS may name it+ * differently.*/final class SesV2RequestShapes {@@ -31,15 +32,13 @@ final class SesV2RequestShapes {private static final Logger LOG = Logger.getLogger(SesV2RequestShapes.class);- private static final ByPosition EXPECTED_NULL = ByPosition.same(SesV2Json.EXPECTED_NULL);-private static final RequestShapeCheck.Messages MESSAGES = new RequestShapeCheck.Messages(SesV2Json.SERIALIZATION_EXCEPTION,SesV2Json.OBJECT_NOT_EXPECTED,SesV2Json.LIST_NOT_EXPECTED,- EXPECTED_NULL,+ ByPosition.same(SesV2Json.EXPECTED_NULL),ByPosition.same(SesV2Json.EXPECTED_LIST),- EXPECTED_NULL,+ ByPosition.same(SesV2Json.EXPECTED_MAP),SesV2Json.CONVERSION,false,null,diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesAccountMemberTypeIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesAccountMemberTypeIntegrationTest.javaindex e15f11174a..1ae309eb81 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesAccountMemberTypeIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesAccountMemberTypeIntegrationTest.java@@ -63,7 +63,8 @@ class SesAccountMemberTypeIntegrationTest {@ParameterizedTest(name = "{0}")@MethodSource("nonObjectBodyPaths")void nonObjectBody_isRejectedBeforeTheShapeCheck(String path) {- assertError("PUT", path, "[]", "BadRequestException", "Request body must be a JSON object.");+ assertError("PUT", path, "[]", "SerializationException", LIST);+ assertError("PUT", path, "\"x\"", "SerializationException", null);}static Stream<String> nonObjectBodyPaths() {diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesBooleanCoercionV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesBooleanCoercionV2IntegrationTest.javaindex f0a35e358d..6fa83c5c7c 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesBooleanCoercionV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesBooleanCoercionV2IntegrationTest.java@@ -66,7 +66,7 @@ class SesBooleanCoercionV2IntegrationTest {String readField = suffix.equals("/dkim") ? "DkimAttributes.SigningEnabled" : "FeedbackForwardingStatus";String path = "/v2/email/identities/" + DOMAIN + suffix;send("PUT", path, "{\"" + member + "\":true}").statusCode(200);- send("PUT", path, "[]").statusCode(400).body("__type", equalTo("BadRequestException"));+ send("PUT", path, "[]").statusCode(400).body("__type", equalTo("SerializationException"));get("/v2/email/identities/" + DOMAIN).body(readField, equalTo(true));}}diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesBulkV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesBulkV2IntegrationTest.javaindex b92234cb3f..015ad3d760 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesBulkV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesBulkV2IntegrationTest.java@@ -333,8 +333,24 @@ class SesBulkV2IntegrationTest {}@ParameterizedTest(name = "{0}")- @MethodSource("wrongTypeSendBulkEmailBodies")+ @MethodSource("io.github.hectorvent.floci.services.ses.SesV2SerializationErrors#nonObjectBodies")@Order(12)+ void sendBulkEmail_nonObjectBody_isASerializationException(String body, String message) {+ given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body(body)+ .when()+ .post("/v2/email/outbound-bulk-emails")+ .then()+ .statusCode(400)+ .body("__type", equalTo("SerializationException"))+ .body("message", equalTo(message));+ }++ @ParameterizedTest(name = "{0}")+ @MethodSource("wrongTypeSendBulkEmailBodies")+ @Order(13)void sendBulkEmail_wrongMemberType_returnsSerializationException(String label, String body) {given().contentType("application/json")@@ -350,9 +366,6 @@ class SesBulkV2IntegrationTest {static Stream<Arguments> malformedSendBulkEmailBodies() {String validDefaultTemplate = "\"DefaultContent\": {\"Template\": {\"TemplateName\": \"v2-bulk-welcome\", \"TemplateData\": \"{\\\"team\\\":\\\"floci\\\",\\\"name\\\":\\\"X\\\"}\"}}";return Stream.of(- Arguments.of("body is array", "[1,2,3]"),- Arguments.of("body is JSON null literal", "null"),- Arguments.of("body is JSON string", "\"hello\""),Arguments.of("BulkEmailEntries element is null", """{"FromEmailAddress": "[email protected]",diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetMemberTypeIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetMemberTypeIntegrationTest.javaindex 328b5c4216..e0ad565c42 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetMemberTypeIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetMemberTypeIntegrationTest.java@@ -30,7 +30,6 @@ class SesConfigurationSetMemberTypeIntegrationTest {private static final String MISSING_CS_PATH = CREATE + "/" + MISSING_CS;private static final String DESTINATIONS = MISSING_CS_PATH + "/event-destinations";private static final String UPDATE = "/v2/email/update-configuration-sets";- private static final String NOT_AN_OBJECT = "Request body must be a JSON object.";static Stream<Arguments> createConfigurationSetCases() {return Stream.of(@@ -180,7 +179,8 @@ class SesConfigurationSetMemberTypeIntegrationTest {@ParameterizedTest(name = "{0} {1}")@MethodSource("nonObjectBodyEndpoints")void nonObjectBody_isRejectedBeforeTheShapeCheck(String method, String path) {- assertError(method, path, "[]", "BadRequestException", NOT_AN_OBJECT);+ assertError(method, path, "[]", "SerializationException", LIST);+ assertError(method, path, "\"x\"", "SerializationException", null);}@ParameterizedTest(name = "{0} {1}")diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesContactV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesContactV2IntegrationTest.javaindex 9c70ce7272..c7b2697516 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesContactV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesContactV2IntegrationTest.java@@ -260,7 +260,8 @@ class SesContactV2IntegrationTest {given().contentType("application/json").header("Authorization", SES_AUTH).body("[]").when().post(CONTACTS + "/list").then().statusCode(400)- .body("__type", equalTo("BadRequestException"));+ .body("__type", equalTo("SerializationException"))+ .body("message", equalTo("Start of list found where not expected"));}// Type coercion, verified against real AWS: a JSON string coerces to the Boolean UnsubscribeAlldiff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesDkimSigningActionsIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesDkimSigningActionsIntegrationTest.javaindex 88a759e91b..9a08cdbde7 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesDkimSigningActionsIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesDkimSigningActionsIntegrationTest.java@@ -207,7 +207,8 @@ class SesDkimSigningActionsIntegrationTest {void putDkimSigningAttributes_nonObjectBody_returns400() {given().contentType("application/json").header("Authorization", V2_AUTH).body("[]").when().put("/v2/email/identities/dkim-nonobj.floci.test/dkim/signing")- .then().statusCode(400).body("__type", equalTo("BadRequestException"));+ .then().statusCode(400).body("__type", equalTo("SerializationException"))+ .body("message", equalTo("Start of list found where not expected"));}@Testdiff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesEmailIdentityConfigurationSetV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesEmailIdentityConfigurationSetV2IntegrationTest.javaindex c85bc6488d..2aec275c21 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesEmailIdentityConfigurationSetV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesEmailIdentityConfigurationSetV2IntegrationTest.java@@ -245,7 +245,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {@Test@Order(9)- void putConfigurationSet_whitespaceOnlyBody_returnsSerializationExceptionAndKeepsAssociation() {+ void putConfigurationSet_whitespaceOnlyOrArrayBody_returnsSerializationExceptionAndKeepsAssociation() {// Re-associate so we can confirm a whitespace-only body does NOT clear.given().contentType("application/json").header("Authorization", SES_AUTH).body("{\"ConfigurationSetName\":\"" + CS + "\"}")@@ -258,8 +258,14 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {.when().put("/v2/email/identities/" + IDENTITY + "/configuration-set").then().statusCode(400).body("__type", equalTo("SerializationException"));+ given().contentType("application/json").header("Authorization", SES_AUTH)+ .body("[]")+ .when().put("/v2/email/identities/" + IDENTITY + "/configuration-set")+ .then().statusCode(400)+ .body("__type", equalTo("SerializationException"))+ .body("message", equalTo("Start of list found where not expected"));- // The association is unchanged (the invalid body neither cleared nor updated it).+ // The association is unchanged (the invalid bodies neither cleared nor updated it).given().header("Authorization", SES_AUTH).when().get("/v2/email/identities/" + IDENTITY).then().statusCode(200)diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesExportFiltersTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesExportFiltersTest.javaindex 6ee2915d4d..d5d8aa5d11 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesExportFiltersTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesExportFiltersTest.java@@ -98,4 +98,12 @@ class SesExportFiltersTest {assertEquals(List.of("[email protected]"), destinations(kept));}++ @Test+ void fractionalMaxResultsIsReadAsTheIntTheRequestWasValidatedWith() {+ List<SesExportPayloads.InsightsRow> kept = SesExportFilters.apply(ROWS,+ source("{\"Exclude\": {\"TenantName\": [\"blue\"]}, \"MaxResults\": 1.5}"));++ assertEquals(List.of("[email protected]"), destinations(kept));+ }}diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesExportJobV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesExportJobV2IntegrationTest.javaindex 9d2ccfd2f3..142df154ff 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesExportJobV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesExportJobV2IntegrationTest.java@@ -403,7 +403,8 @@ class SesExportJobV2IntegrationTest {given().contentType("application/json").header("Authorization", AUTH).body("{\"PageSize\": \"ten\"}").when().post("/v2/email/list-export-jobs").then().statusCode(400)- .body("__type", equalTo("SerializationException"));+ .body("__type", equalTo("SerializationException"))+ .body("message", equalTo("STRING_VALUE can not be converted to an Integer"));// The body is deserialized before any member is validated, so a mistyped member wins.given().contentType("application/json").header("Authorization", AUTH).body("{\"JobStatus\": \"BOGUS\", \"PageSize\": \"ten\"}")@@ -527,7 +528,8 @@ class SesExportJobV2IntegrationTest {// A MaxResults of the wrong type is a deserialization error, not a value out of range.insightsWith("\"MaxResults\": \"100\",")- .then().statusCode(400).body("__type", equalTo("SerializationException"));+ .then().statusCode(400).body("__type", equalTo("SerializationException"))+ .body("message", equalTo("STRING_VALUE can not be converted to an Integer"));}@Test@@ -549,6 +551,17 @@ class SesExportJobV2IntegrationTest {.then().statusCode(200);}+ @Test+ @Order(19)+ void createExportJob_keepsAFractionalMaxResultsAsTheIntItWasCheckedAs() {+ String jobId = insightsWith("\"MaxResults\": 1.5,").then().statusCode(200).extract().path("JobId");++ given().header("Authorization", AUTH)+ .when().get("/v2/email/export-jobs/" + jobId)+ .then().statusCode(200)+ .body("ExportDataSource.MessageInsightsDataSource.MaxResults", equalTo(1));+ }+/** A message-insights export request carrying the given extra members. */private static Response insightsWith(String members) {return create("""@@ -559,7 +572,7 @@ class SesExportJobV2IntegrationTest {}@Test- @Order(19)+ @Order(20)void cleanUpVdmAndIdentity() {given().contentType("application/json").header("Authorization", AUTH).body("{\"VdmAttributes\":{\"VdmEnabled\":\"DISABLED\"}}")diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.javaindex 5a84fc037e..621463d257 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java@@ -154,7 +154,8 @@ class SesIdentityAttributesV2IntegrationTest {.put("/v2/email/identities/v2-attrs.floci.test/mail-from").then().statusCode(400)- .body("__type", equalTo("BadRequestException"));+ .body("__type", equalTo("SerializationException"))+ .body("message", equalTo("Start of list found where not expected"));}@Testdiff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesListMemberTypeIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesListMemberTypeIntegrationTest.javanew file mode 100644index 0000000000..2f2d80bb00--- /dev/null+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesListMemberTypeIntegrationTest.java@@ -0,0 +1,112 @@+package io.github.hectorvent.floci.services.ses;++import io.quarkus.test.junit.QuarkusTest;+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_MAP;+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.STRING_FOR_INTEGER;+import static io.github.hectorvent.floci.services.ses.SesV2SerializationErrors.assertError;+import static io.github.hectorvent.floci.services.ses.SesV2SerializationErrors.assertSerializationException;+import static io.github.hectorvent.floci.services.ses.SesV2SerializationErrors.authFor;+import static io.restassured.RestAssured.given;+import static org.hamcrest.Matchers.hasSize;+import static org.hamcrest.Matchers.notNullValue;++/**+ * The list operations read a map {@code Filter} and an integer {@code PageSize} through the+ * SesV2Json member helpers rather than the shape check, so each endpoint is covered here: a scalar+ * filter is "Expected map or null", a string page size names the Integer target and any other+ * number is narrowed to an int before the range check. Every refused case fails before anything is+ * looked up.+ */+@QuarkusTest+class SesListMemberTypeIntegrationTest {++ private static final String NARROW_REGION_AUTH = authFor("ap-south-2");++ static Stream<Arguments> scalarFilterCases() {+ return Stream.of(+ Arguments.of("listEmailIdentities", "/v2/email/list-identities", "{\"Filter\": \"x\"}"),+ Arguments.of("listConfigurationSets", "/v2/email/list-configuration-sets", "{\"Filter\": \"x\"}"),+ Arguments.of("listTenants", "/v2/email/tenants/list", "{\"Filter\": 1}"),+ Arguments.of("listTenantResources", "/v2/email/tenants/resources/list",+ "{\"TenantName\": \"ghost\", \"Filter\": \"x\"}"));+ }++ static Stream<Arguments> stringPageSizeCases() {+ String pageSize = "{\"PageSize\": \"1\"}";+ return Stream.of(+ Arguments.of("listEmailIdentities", "/v2/email/list-identities", pageSize),+ Arguments.of("listConfigurationSets", "/v2/email/list-configuration-sets", pageSize),+ Arguments.of("listContacts", "/v2/email/contact-lists/ghost/contacts/list", pageSize),+ Arguments.of("listImportJobs", "/v2/email/import-jobs/list", pageSize),+ Arguments.of("listExportJobs", "/v2/email/list-export-jobs", pageSize),+ Arguments.of("listEmailIdentityCertificates", "/v2/email/identity/certificates/list",+ "{\"EmailIdentity\": \"ghost.example.com\", \"PageSize\": \"1\"}"),+ Arguments.of("listTenants", "/v2/email/tenants/list", pageSize),+ Arguments.of("listTenantResources", "/v2/email/tenants/resources/list",+ "{\"TenantName\": \"ghost\", \"PageSize\": \"1\"}"),+ Arguments.of("listResourceTenants", "/v2/email/resources/tenants/list",+ "{\"ResourceArn\": \"ghost\", \"PageSize\": \"1\"}"));+ }++ @ParameterizedTest(name = "{0}")+ @MethodSource("scalarFilterCases")+ void scalarFilter_isExpectedMap(String caseName, String path, String body) {+ assertSerializationException("POST", path, body, EXPECTED_MAP);+ }++ @ParameterizedTest(name = "{0}")+ @MethodSource("stringPageSizeCases")+ void stringPageSize_namesTheIntegerTarget(String caseName, String path, String body) {+ assertSerializationException("POST", path, body, STRING_FOR_INTEGER);+ }++ @Test+ void nonObjectBody_isASerializationException() {+ assertSerializationException("POST", "/v2/email/list-identities", "[]", LIST);+ for (String body : List.of("\"x\"", "1", "null")) {+ assertSerializationException("POST", "/v2/email/list-identities", body, null);+ }+ }++ @Test+ void pageSize_isNarrowedBeforeTheRangeCheck() {+ for (String identity : List.of("[email protected]", "[email protected]")) {+ given()+ .contentType("application/json")+ .header("Authorization", NARROW_REGION_AUTH)+ .body("{\"EmailIdentity\": \"" + identity + "\"}")+ .when()+ .post("/v2/email/identities")+ .then()+ .statusCode(200);+ }+ given()+ .contentType("application/json")+ .header("Authorization", NARROW_REGION_AUTH)+ .body("{\"PageSize\": 1.5}")+ .when()+ .post("/v2/email/list-identities")+ .then()+ .statusCode(200)+ .body("EmailIdentities", hasSize(1))+ .body("NextToken", notNullValue());+ assertError("POST", "/v2/email/list-identities", "{\"PageSize\": 4294967296}", "BadRequestException",+ "Value 2147483647 for parameter PageSize is invalid. PageSize must be between 1 and 1000.");+ }++ @Test+ void listTenantResources_filterValueNamesTheStringTarget() {+ assertSerializationException("POST", "/v2/email/tenants/resources/list",+ "{\"TenantName\": \"ghost\", \"Filter\": {\"RESOURCE_TYPE\": 1}}", NUMBER);+ }+}diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesMetricsJobsMemberTypeIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesMetricsJobsMemberTypeIntegrationTest.javaindex ec20e86b4b..631fba15d0 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesMetricsJobsMemberTypeIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesMetricsJobsMemberTypeIntegrationTest.java@@ -9,6 +9,7 @@ import org.junit.jupiter.params.provider.MethodSource;import java.util.stream.Stream;import static io.github.hectorvent.floci.services.ses.SesV2SerializationErrors.EXPECTED_LIST;+import static io.github.hectorvent.floci.services.ses.SesV2SerializationErrors.EXPECTED_MAP;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;@@ -40,6 +41,7 @@ class SesMetricsJobsMemberTypeIntegrationTest {Arguments.of("stringQuery", "{\"Queries\": [\"x\"]}", EXPECTED_NULL),Arguments.of("numericId", "{\"Queries\": [{\"Id\": 1}]}", NUMBER),Arguments.of("arrayDimensions", "{\"Queries\": [{\"Dimensions\": []}]}", LIST),+ Arguments.of("stringDimensions", "{\"Queries\": [{\"Dimensions\": \"x\"}]}", EXPECTED_MAP),Arguments.of("numericDimensionValue", "{\"Queries\": [{\"Dimensions\": {\"ISP\": 1}}]}", NUMBER));}@@ -62,6 +64,8 @@ class SesMetricsJobsMemberTypeIntegrationTest {"{\"ExportDataSource\": {\"MetricsDataSource\": {\"Metrics\": \"SEND\"}}}", EXPECTED_LIST),Arguments.of("arrayDimensions","{\"ExportDataSource\": {\"MetricsDataSource\": {\"Dimensions\": []}}}", LIST),+ Arguments.of("stringDimensions",+ "{\"ExportDataSource\": {\"MetricsDataSource\": {\"Dimensions\": \"x\"}}}", EXPECTED_MAP),Arguments.of("numericDimensionValue","{\"ExportDataSource\": {\"MetricsDataSource\": {\"Dimensions\": {\"ISP\": [1]}}}}", NUMBER),Arguments.of("objectIncludeFilter",diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesSuppressionV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesSuppressionV2IntegrationTest.javaindex 5ccded4d12..005a2afd6b 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesSuppressionV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesSuppressionV2IntegrationTest.java@@ -275,7 +275,8 @@ class SesSuppressionV2IntegrationTest {.put("/v2/email/suppression/addresses").then().statusCode(400)- .body("__type", equalTo("BadRequestException"));+ .body("__type", equalTo("SerializationException"))+ .body("message", equalTo("Start of list found where not expected"));}@Testdiff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesTemplateV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesTemplateV2IntegrationTest.javaindex 0fef98dd0a..4295cd69ab 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesTemplateV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesTemplateV2IntegrationTest.java@@ -685,8 +685,24 @@ class SesTemplateV2IntegrationTest {}@ParameterizedTest(name = "{0}")- @MethodSource("wrongTypeSendEmailBodies")+ @MethodSource("io.github.hectorvent.floci.services.ses.SesV2SerializationErrors#nonObjectBodies")@Order(51)+ void sendEmail_nonObjectBody_isASerializationException(String body, String message) {+ given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body(body)+ .when()+ .post("/v2/email/outbound-emails")+ .then()+ .statusCode(400)+ .body("__type", equalTo("SerializationException"))+ .body("message", equalTo(message));+ }++ @ParameterizedTest(name = "{0}")+ @MethodSource("wrongTypeSendEmailBodies")+ @Order(52)void sendEmail_wrongMemberType_returnsSerializationException(String label, String body) {given().contentType("application/json")@@ -701,9 +717,6 @@ class SesTemplateV2IntegrationTest {static Stream<Arguments> malformedSendEmailBodies() {return Stream.of(- Arguments.of("body is array", "[1,2,3]"),- Arguments.of("body is JSON null literal", "null"),- Arguments.of("body is JSON string", "\"hello\""),Arguments.of("TemplateData as invalid JSON string", """{"FromEmailAddress": "[email protected]",diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesTenantAssociationV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesTenantAssociationV2IntegrationTest.javaindex 4cfa19db8f..f9b0056340 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesTenantAssociationV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesTenantAssociationV2IntegrationTest.java@@ -178,11 +178,11 @@ class SesTenantAssociationV2IntegrationTest {v2().body("{\"TenantName\":\"" + TENANT + "\",\"NextToken\":\"garbage-token\"}").when().post("/v2/email/tenants/resources/list").then().statusCode(400).body("message", equalTo("Invalid Next Token"));- // An integral value outside the int range must be rejected, not silently truncated- // (4294967296 would truncate to 0 and produce the wrong Smithy message).+ // A value outside the int range saturates, as AWS reads it, rather than truncating to 0.v2().body("{\"TenantName\":\"" + TENANT + "\",\"PageSize\":4294967296}").when().post("/v2/email/tenants/resources/list").then().statusCode(400)- .body("__type", equalTo("SerializationException"));+ .body("message", equalTo("1 validation error detected: Value '2147483647' at 'pageSize' failed "+ + "to satisfy constraint: Member must have value less than or equal to 100"));v2().body("{\"TenantName\":\"ghost-tenant\"}").when().post("/v2/email/tenants/resources/list").then().statusCode(404).body("__type", equalTo("NotFoundException"));diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesTestRenderV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesTestRenderV2IntegrationTest.javaindex fb03958208..8aa440d800 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesTestRenderV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesTestRenderV2IntegrationTest.java@@ -134,11 +134,25 @@ class SesTestRenderV2IntegrationTest {static Stream<Arguments> malformedRenderBodies() {return Stream.of(Arguments.of("null body", null),- Arguments.of("non-object body (array)", "[1,2,3]"),Arguments.of("TemplateData as object", "{\"TemplateData\": {\"name\": \"Alice\"}}"));}+ @Test+ @Order(8)+ void testRenderEmailTemplate_arrayBody_isASerializationException() {+ given()+ .contentType("application/json")+ .header("Authorization", AUTH_HEADER)+ .body("[1,2,3]")+ .when()+ .post("/v2/email/templates/v2-render-welcome/render")+ .then()+ .statusCode(400)+ .body("__type", equalTo("SerializationException"))+ .body("message", equalTo("Start of list found where not expected"));+ }+@Test@Order(10)void testRenderEmailTemplate_dateHeaderIsUtc() {diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2JsonTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2JsonTest.javaindex 4dfbe4d369..fb176860d4 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2JsonTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2JsonTest.java@@ -70,9 +70,14 @@ class SesV2JsonTest {@Testvoid requireJsonObject_rejectsNullAndNonObjects() {- assertEquals("Request body must be a JSON object.", assertAws("BadRequestException", 400,+ assertNull(assertAws("SerializationException", 400,() -> SesV2Json.requireJsonObject(null)).getMessage());- assertAws("BadRequestException", 400, () -> SesV2Json.requireJsonObject(json("[]")));+ assertEquals("Start of list found where not expected", assertAws("SerializationException", 400,+ () -> SesV2Json.requireJsonObject(json("[]"))).getMessage());+ for (String body : List.of("\"x\"", "1", "true", "null")) {+ assertNull(assertAws("SerializationException", 400,+ () -> SesV2Json.requireJsonObject(json(body))).getMessage(), body);+ }SesV2Json.requireJsonObject(json("{}"));}@@ -116,8 +121,10 @@ class SesV2JsonTest {assertTrue(SesV2Json.readOptionBody(MAPPER, " ").isObject());assertEquals("REQUIRE", SesV2Json.readOptionBody(MAPPER, "{\"HttpsPolicy\":\"REQUIRE\"}").path("HttpsPolicy").asText());- assertEquals("Request body must be a JSON object.", assertAws("BadRequestException", 400,+ assertEquals("Start of list found where not expected", assertAws("SerializationException", 400,() -> SesV2Json.readOptionBody(MAPPER, "[1]")).getMessage());+ assertNull(assertAws("SerializationException", 400,+ () -> SesV2Json.readOptionBody(MAPPER, "null")).getMessage());assertAws("BadRequestException", 400, () -> SesV2Json.readOptionBody(MAPPER, "{not json"));}@@ -172,9 +179,9 @@ class SesV2JsonTest {assertNull(SesV2Json.stringMapMemberOrAbsent(node, "missing"));assertEquals("Start of list found where not expected", assertAws("SerializationException", 400,() -> SesV2Json.stringMapMemberOrAbsent(node, "a")).getMessage());- assertEquals("Expected null", assertAws("SerializationException", 400,+ assertEquals("Expected map or null", assertAws("SerializationException", 400,() -> SesV2Json.stringMapMemberOrAbsent(node, "s")).getMessage());- assertEquals("Expected null", assertAws("SerializationException", 400,+ assertEquals("Expected map or null", assertAws("SerializationException", 400,() -> SesV2Json.stringMapMemberOrAbsent(node, "i")).getMessage());}@@ -228,14 +235,29 @@ class SesV2JsonTest {}@Test- void intMemberOrAbsent_rejectsNonIntegralAndOutOfRange() {- JsonNode node = json("{\"i\":5,\"f\":1.5,\"big\":1099511627776,\"s\":\"5\",\"z\":null}");+ void intMemberOrAbsent_truncatesAFractionAndSaturatesOutOfRange() {+ JsonNode node = json("{\"i\":5,\"f\":1.5,\"big\":4294967296,\"neg\":-4294967296,\"z\":null}");assertEquals(5, SesV2Json.intMemberOrAbsent(node, "i"));+ assertEquals(1, SesV2Json.intMemberOrAbsent(node, "f"));+ assertEquals(Integer.MAX_VALUE, SesV2Json.intMemberOrAbsent(node, "big"));+ assertEquals(Integer.MIN_VALUE, SesV2Json.intMemberOrAbsent(node, "neg"));assertNull(SesV2Json.intMemberOrAbsent(node, "z"));assertNull(SesV2Json.intMemberOrAbsent(node, "missing"));- assertAws("SerializationException", 400, () -> SesV2Json.intMemberOrAbsent(node, "f"));- assertAws("SerializationException", 400, () -> SesV2Json.intMemberOrAbsent(node, "big"));- assertAws("SerializationException", 400, () -> SesV2Json.intMemberOrAbsent(node, "s"));+ }++ @Test+ void intMemberOrAbsent_namesTheWrongJsonType() {+ JsonNode node = json("{\"s\":\"5\",\"t\":true,\"f\":false,\"o\":{},\"a\":[]}");+ assertEquals("STRING_VALUE can not be converted to an Integer", assertAws("SerializationException", 400,+ () -> SesV2Json.intMemberOrAbsent(node, "s")).getMessage());+ assertEquals("TRUE_VALUE can not be converted to an Integer", assertAws("SerializationException", 400,+ () -> SesV2Json.intMemberOrAbsent(node, "t")).getMessage());+ assertEquals("FALSE_VALUE can not be converted to an Integer", assertAws("SerializationException", 400,+ () -> SesV2Json.intMemberOrAbsent(node, "f")).getMessage());+ assertEquals("Start of structure or map found where not expected.", assertAws("SerializationException",+ 400, () -> SesV2Json.intMemberOrAbsent(node, "o")).getMessage());+ assertEquals("Start of list found where not expected", assertAws("SerializationException", 400,+ () -> SesV2Json.intMemberOrAbsent(node, "a")).getMessage());}@Testdiff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2RequestShapesTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2RequestShapesTest.javaindex a8a78bff0d..13c0005b39 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2RequestShapesTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2RequestShapesTest.java@@ -49,10 +49,11 @@ class SesV2RequestShapesTest {}@Test- void mapMemberReadsLikeAStructure() {+ void mapMemberReadsLikeAStructureButExpectsAMap() {assertAccepted("ListTenantResources", "{\"Filter\":{\"RESOURCE_TYPE\":\"x\"}}");assertRejected("ListTenantResources", "{\"Filter\":[]}", LIST);- assertRejected("ListTenantResources", "{\"Filter\":\"x\"}", "Expected null");+ assertRejected("ListTenantResources", "{\"Filter\":\"x\"}", "Expected map or null");+ assertRejected("ListTenantResources", "{\"Filter\":1}", "Expected map or null");assertRejected("ListTenantResources", "{\"Filter\":{\"RESOURCE_TYPE\":1}}","NUMBER_VALUE can not be converted to a String");}diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2SerializationErrors.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2SerializationErrors.javaindex ce74053d70..1612e59f37 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2SerializationErrors.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2SerializationErrors.java@@ -1,5 +1,9 @@package io.github.hectorvent.floci.services.ses;+import org.junit.jupiter.params.provider.Arguments;++import java.util.stream.Stream;+import static io.restassured.RestAssured.given;import static org.hamcrest.Matchers.equalTo;@@ -17,10 +21,20 @@ final class SesV2SerializationErrors {static final String NUMBER = "NUMBER_VALUE can not be converted to a String";static final String EXPECTED_NULL = "Expected null";static final String EXPECTED_LIST = "Expected list or null";+ static final String EXPECTED_MAP = "Expected map or null";+ static final String STRING_FOR_INTEGER = "STRING_VALUE can not be converted to an Integer";private SesV2SerializationErrors() {}+ /** A body that is not a JSON object, with the message AWS answers it with. */+ static Stream<Arguments> nonObjectBodies() {+ return Stream.of(+ Arguments.of("[1,2,3]", LIST),+ Arguments.of("null", null),+ Arguments.of("\"hello\"", null));+ }+/** An Authorization header signed for {@code region}, for a test that needs its own region state. */static String authFor(String region) {return "AWS4-HMAC-SHA256 Credential=AKID/20260101/" + region + "/email/aws4_request";