-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more base64 malformed request tests
This adds more base64 tests, including ones for strings that use mediaType in places where they need to be encoded.
- Loading branch information
1 parent
bc8939b
commit fdf5340
Showing
3 changed files
with
61 additions
and
1 deletion.
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
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
59 changes: 59 additions & 0 deletions
59
smithy-aws-protocol-tests/model/restJson1/malformedRequests/malformed-string.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,59 @@ | ||
$version: "1.0" | ||
|
||
namespace aws.protocoltests.restjson | ||
|
||
use aws.protocols#restJson1 | ||
use smithy.test#httpMalformedRequestTests | ||
|
||
@http(uri: "/MalformedString", method: "POST") | ||
operation MalformedString { | ||
input: MalformedStringInput | ||
} | ||
|
||
apply MalformedString @httpMalformedRequestTests([ | ||
{ | ||
id: "RestJsonHeaderMalformedStringInvalidBase64MediaType", | ||
documentation: """ | ||
When string with the mediaType trait is bound to a header, its value | ||
must be base64 encoded. The server should reject values that aren't | ||
valid base64 out of hand.""", | ||
protocol: restJson1, | ||
request: { | ||
method: "POST", | ||
uri: "/MalformedString", | ||
body: """ | ||
{ "blob" : $value:L }""", | ||
headers: { | ||
"content-type": "application/json", | ||
"amz-media-typed-header": "$value:L", | ||
} | ||
}, | ||
response: { | ||
code: 400, | ||
headers: { | ||
"x-amzn-errortype": "SerializationException" | ||
} | ||
}, | ||
testParameters: { | ||
value: [ | ||
// Insufficient padding | ||
"xyz", | ||
// Extant, but also insufficient padding | ||
"YmxvYg=", | ||
// Invalid characters | ||
"[][]", | ||
// Invalid characters which are commonly used as filename-safe | ||
// alternatives to + and / | ||
"-_==" | ||
] | ||
} | ||
}, | ||
]) | ||
|
||
structure MalformedStringInput { | ||
@httpHeader("x-media-typed-header") | ||
blob: JsonHeaderString, | ||
} | ||
|
||
@mediaType("application/json") | ||
string JsonHeaderString |