-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some initial malformed request tests
- Loading branch information
1 parent
bdc32a2
commit 5c8af3e
Showing
14 changed files
with
1,723 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
smithy-aws-protocol-tests/model/restJson1/malformedRequests/malformed-blob.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
$version: "1.0" | ||
|
||
namespace aws.protocoltests.restjson | ||
|
||
use aws.protocols#restJson1 | ||
use smithy.test#httpMalformedRequestTests | ||
|
||
@http(uri: "/MalformedBlob", method: "POST") | ||
operation MalformedBlob { | ||
input: MalformedBlobInput | ||
} | ||
|
||
apply MalformedBlob @httpMalformedRequestTests([ | ||
{ | ||
id: "RestJsonBodyMalformedBlobInvalidBase64", | ||
documentation: """ | ||
When a blob member is not properly base64 encoded, or not encoded at | ||
all, the response should be a 400 SerializationException.""", | ||
protocol: restJson1, | ||
request: { | ||
method: "POST", | ||
uri: "/MalformedBlob", | ||
body: """ | ||
{ "blob" : $value:L }""", | ||
headers: { | ||
"content-type": "application/json" | ||
} | ||
}, | ||
response: { | ||
code: 400, | ||
headers: { | ||
"x-amzn-errortype": "SerializationException" | ||
} | ||
}, | ||
testParameters: { | ||
value: ["blob", "\"xyz\"", "\"YmxvYg=\"", "[98, 108, 11, 98]", | ||
"[\"b\", \"l\",\"o\",\"b\"]", "981081198", "true"] | ||
} | ||
}, | ||
]) | ||
|
||
structure MalformedBlobInput { | ||
blob: Blob, | ||
} | ||
|
||
|
145 changes: 145 additions & 0 deletions
145
smithy-aws-protocol-tests/model/restJson1/malformedRequests/malformed-boolean.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
$version: "1.0" | ||
|
||
namespace aws.protocoltests.restjson | ||
|
||
use aws.protocols#restJson1 | ||
use smithy.test#httpMalformedRequestTests | ||
|
||
@http(uri: "/MalformedBoolean/{booleanInPath}", method: "POST") | ||
operation MalformedBoolean { | ||
input: MalformedBooleanInput | ||
} | ||
|
||
apply MalformedBoolean @httpMalformedRequestTests([ | ||
{ | ||
id: "RestJsonBodyBooleanStringCoercion", | ||
documentation: """ | ||
Attempted string coercion should result in SerializationException""", | ||
protocol: restJson1, | ||
request: { | ||
method: "POST", | ||
uri: "/MalformedBoolean/true", | ||
body: """ | ||
{ "booleanInBody" : $value:S }""", | ||
headers: { | ||
"content-type": "application/json" | ||
} | ||
}, | ||
response: { | ||
code: 400, | ||
headers: { | ||
"x-amzn-errortype": "SerializationException" | ||
} | ||
}, | ||
testParameters: { | ||
"value" : ["true", "True", "TRUE", "y", "Y", "yes", "Yes", "YES", "1", "on", "On", "ON", | ||
"false", "False", "FALSE", "n", "N", "no", "No", "NO", "0", "off", "Off", "OFF"] | ||
} | ||
}, | ||
{ | ||
id: "RestJsonBodyBooleanBadLiteral", | ||
documentation: """ | ||
YAML-style alternate boolean literals should result in SerializationException""", | ||
protocol: restJson1, | ||
request: { | ||
method: "POST", | ||
uri: "/MalformedBoolean/true", | ||
body: """ | ||
{ "booleanInBody" : $value:L }""", | ||
headers: { | ||
"content-type": "application/json" | ||
} | ||
}, | ||
response: { | ||
code: 400, | ||
headers: { | ||
"x-amzn-errortype": "SerializationException" | ||
} | ||
}, | ||
testParameters: { | ||
"value" : ["True", "TRUE", "y", "Y", "yes", "Yes", "YES", "1", "on", "On", "ON", | ||
"False", "FALSE", "n", "N", "no", "No", "NO", "0", "off", "Off", "OFF"] | ||
} | ||
}, | ||
{ | ||
id: "RestJsonPathBooleanStringCoercion", | ||
documentation: """ | ||
Attempted string coercion should result in SerializationException""", | ||
protocol: restJson1, | ||
request: { | ||
method: "POST", | ||
uri: "/MalformedBoolean/$value:L" | ||
}, | ||
response: { | ||
code: 400, | ||
headers: { | ||
"x-amzn-errortype": "SerializationException" | ||
} | ||
}, | ||
testParameters: { | ||
"value" : ["True", "TRUE", "y", "Y", "yes", "Yes", "YES", "1", "on", "On", "ON", | ||
"False", "FALSE", "n", "N", "no", "No", "NO", "0", "off", "Off", "OFF"] | ||
} | ||
}, | ||
{ | ||
id: "RestJsonQueryBooleanStringCoercion", | ||
documentation: """ | ||
Attempted string coercion should result in SerializationException""", | ||
protocol: restJson1, | ||
request: { | ||
method: "POST", | ||
uri: "/MalformedBoolean/true", | ||
queryParams: [ | ||
"booleanInQuery=$value:L" | ||
] | ||
}, | ||
response: { | ||
code: 400, | ||
headers: { | ||
"x-amzn-errortype": "SerializationException" | ||
} | ||
}, | ||
testParameters: { | ||
"value" : ["True", "TRUE", "y", "Y", "yes", "Yes", "YES", "1", "on", "On", "ON", | ||
"False", "FALSE", "n", "N", "no", "No", "NO", "0", "off", "Off", "OFF"] | ||
} | ||
}, | ||
{ | ||
id: "RestJsonHeaderBooleanStringCoercion", | ||
documentation: """ | ||
Attempted string coercion should result in SerializationException""", | ||
protocol: restJson1, | ||
request: { | ||
method: "POST", | ||
uri: "/MalformedBoolean/true", | ||
headers: { | ||
"booleanInHeader" : "$value:L" | ||
} | ||
}, | ||
response: { | ||
code: 400, | ||
headers: { | ||
"x-amzn-errortype": "SerializationException" | ||
} | ||
}, | ||
testParameters: { | ||
"value" : ["True", "TRUE", "y", "Y", "yes", "Yes", "YES", "1", "on", "On", "ON", | ||
"False", "FALSE", "n", "N", "no", "No", "NO", "0", "off", "Off", "OFF"] | ||
} | ||
} | ||
]) | ||
|
||
structure MalformedBooleanInput { | ||
booleanInBody: Boolean, | ||
|
||
@httpLabel | ||
@required | ||
booleanInPath: Boolean, | ||
|
||
@httpQuery("booleanInQuery") | ||
booleanInQuery: Boolean, | ||
|
||
@httpHeader("booleanInHeader") | ||
booleanInHeader: Boolean | ||
} | ||
|
Oops, something went wrong.