From 56f6463f80ddfc522c548096c3f892a141f4d7d1 Mon Sep 17 00:00:00 2001 From: Michael Dowling Date: Fri, 27 Oct 2023 09:42:19 -0500 Subject: [PATCH] Add unknown union malformed request test Addresses #1222 --- .../malformedRequests/malformed-union.smithy | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/smithy-aws-protocol-tests/model/restJson1/malformedRequests/malformed-union.smithy b/smithy-aws-protocol-tests/model/restJson1/malformedRequests/malformed-union.smithy index f5ac1bb447b..cd0ca8cd477 100644 --- a/smithy-aws-protocol-tests/model/restJson1/malformedRequests/malformed-union.smithy +++ b/smithy-aws-protocol-tests/model/restJson1/malformedRequests/malformed-union.smithy @@ -15,14 +15,14 @@ apply MalformedUnion @httpMalformedRequestTests([ { id: "RestJsonMalformedUnionMultipleFieldsSet", documentation: """ - When the union has multiple fields set, the response should be a 400 - SerializationException.""", + When the union has multiple fields set, the response should be a 400 + SerializationException.""", protocol: restJson1, request: { method: "POST", uri: "/MalformedUnion", body: """ - { "union" : { "int": 2, "string": "three" } }""", + { "union" : { "int": 2, "string": "three" } }""", headers: { "content-type": "application/json" } @@ -37,8 +37,8 @@ apply MalformedUnion @httpMalformedRequestTests([ { id: "RestJsonMalformedUnionKnownAndUnknownFieldsSet", documentation: """ - When the union has multiple fields set, even when only one is modeled, - the response should be a 400 SerializationException.""", + When the union has multiple fields set, even when only one is modeled, + the response should be a 400 SerializationException.""", protocol: restJson1, request: { method: "POST", @@ -59,14 +59,14 @@ apply MalformedUnion @httpMalformedRequestTests([ { id: "RestJsonMalformedUnionNoFieldsSet", documentation: """ - When the union has no fields set, the response should be a 400 - SerializationException.""", + When the union has no fields set, the response should be a 400 + SerializationException.""", protocol: restJson1, request: { method: "POST", uri: "/MalformedUnion", body: """ - { "union" : { "int": null } }""", + { "union" : { "int": null } }""", headers: { "content-type": "application/json" } @@ -81,14 +81,14 @@ apply MalformedUnion @httpMalformedRequestTests([ { id: "RestJsonMalformedUnionValueIsArray", documentation: """ - When the union value is actually an array, the response should be a 400 - SerializationException.""", + When the union value is actually an array, the response should be a 400 + SerializationException.""", protocol: restJson1, request: { method: "POST", uri: "/MalformedUnion", body: """ - { "union" : ["int"] }""", + { "union" : ["int"] }""", headers: { "content-type": "application/json" } @@ -99,7 +99,33 @@ apply MalformedUnion @httpMalformedRequestTests([ "x-amzn-errortype": "SerializationException" } } - }, + } + { + id: "RestJsonMalformedUnionUnknownMember", + documentation: """ + When an unknown union member is received, the response should be a 400 + SerializationException.""" + protocol: restJson1 + request: { + method: "POST" + uri: "/MalformedUnion" + body: """ + { + "union": { + "unknown": "hello" + } + }""", + headers: { + "content-type": "application/json" + } + } + response: { + code: 400 + headers: { + "x-amzn-errortype": "SerializationException" + } + } + } ]) structure MalformedUnionInput { @@ -111,4 +137,3 @@ union SimpleUnion { string: String } -