Skip to content

Commit 06f93a5

Browse files
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.
1 parent 2e1cdc4 commit 06f93a5

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

smithy-aws-protocol-tests/model/restJson1/main.smithy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ service RestJson {
107107
MalformedLong,
108108
MalformedFloat,
109109
MalformedDouble,
110+
MalformedString,
110111
MalformedTimestampPathDefault,
111112
MalformedTimestampPathHttpDate,
112113
MalformedTimestampPathEpoch,

smithy-aws-protocol-tests/model/restJson1/malformedRequests/malformed-blob.smithy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ apply MalformedBlob @httpMalformedRequestTests([
3434
},
3535
testParameters: {
3636
value: ["blob", "\"xyz\"", "\"YmxvYg=\"", "[98, 108, 11, 98]",
37-
"[\"b\", \"l\",\"o\",\"b\"]", "981081198", "true"]
37+
"[\"b\", \"l\",\"o\",\"b\"]", "981081198", "true", "[][]", "-_=="]
3838
}
3939
},
4040
])
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
$version: "1.0"
2+
3+
namespace aws.protocoltests.restjson
4+
5+
use aws.protocols#restJson1
6+
use smithy.test#httpMalformedRequestTests
7+
8+
@http(uri: "/MalformedString", method: "POST")
9+
operation MalformedString {
10+
input: MalformedStringInput
11+
}
12+
13+
apply MalformedString @httpMalformedRequestTests([
14+
{
15+
id: "RestJsonHeaderMalformedStringInvalidBase64MediaType",
16+
documentation: """
17+
When string with the mediaType trait is bound to a header, its value
18+
must be base64 encoded. The server should reject values that aren't
19+
valid base64 out of hand.""",
20+
protocol: restJson1,
21+
request: {
22+
method: "POST",
23+
uri: "/MalformedString",
24+
body: """
25+
{ "blob" : $value:L }""",
26+
headers: {
27+
"content-type": "application/json",
28+
"amz-media-typed-header": "$value:L",
29+
}
30+
},
31+
response: {
32+
code: 400,
33+
headers: {
34+
"x-amzn-errortype": "SerializationException"
35+
}
36+
},
37+
testParameters: {
38+
value: [
39+
// Insufficient padding
40+
"xyz",
41+
// Extant, but also insufficient padding
42+
"YmxvYg=",
43+
// Invalid characters
44+
"[][]",
45+
// Invalid characters which are commonly used as filename-safe
46+
// alternatives to + and /
47+
"-_=="
48+
]
49+
}
50+
},
51+
])
52+
53+
structure MalformedStringInput {
54+
@httpHeader("x-media-typed-header")
55+
blob: JsonHeaderString,
56+
}
57+
58+
@mediaType("application/json")
59+
string JsonHeaderString

0 commit comments

Comments
 (0)