Skip to content

Commit d633e5d

Browse files
committed
Add malformed request tests for more set types
Sets of blobs, dates, structures and documents are all valid, and may not be easily supported in all targeted server languages.
1 parent b0b5213 commit d633e5d

File tree

1 file changed

+139
-2
lines changed

1 file changed

+139
-2
lines changed

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

Lines changed: 139 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,117 @@ apply MalformedSet @httpMalformedRequestTests([
3434
}
3535
}
3636
},
37+
{
38+
id: "RestJsonMalformedSetDuplicateDocuments",
39+
documentation: """
40+
When the set has duplicated documents, the response should be a 400
41+
SerializationException.""",
42+
protocol: restJson1,
43+
request: {
44+
method: "POST",
45+
uri: "/MalformedSet",
46+
body: """
47+
{ "docSet" : [{"a": 1}, {"b": 2, "c": 3}, {"c": 3, "b": 2}] }""",
48+
headers: {
49+
"content-type": "application/json"
50+
}
51+
},
52+
response: {
53+
code: 400,
54+
headers: {
55+
"x-amzn-errortype": "SerializationException"
56+
}
57+
}
58+
},
59+
{
60+
id: "RestJsonMalformedSetDuplicateTimestamps",
61+
documentation: """
62+
When the set has duplicated timestamps, the response should be a 400
63+
SerializationException.""",
64+
protocol: restJson1,
65+
request: {
66+
method: "POST",
67+
uri: "/MalformedSet",
68+
body: """
69+
{ "tsSet" : [1515531081, 1423235322, 1515531081] }""",
70+
headers: {
71+
"content-type": "application/json"
72+
}
73+
},
74+
response: {
75+
code: 400,
76+
headers: {
77+
"x-amzn-errortype": "SerializationException"
78+
}
79+
}
80+
},
81+
{
82+
id: "RestJsonMalformedSetDuplicateBlobs",
83+
documentation: """
84+
When the set has duplicated blobs, the response should be a 400
85+
SerializationException.""",
86+
protocol: restJson1,
87+
request: {
88+
method: "POST",
89+
uri: "/MalformedSet",
90+
body: """
91+
{ "blobSet" : ["YmxvYg==", "b3RoZXJibG9i", "YmxvYg=="] }""",
92+
headers: {
93+
"content-type": "application/json"
94+
}
95+
},
96+
response: {
97+
code: 400,
98+
headers: {
99+
"x-amzn-errortype": "SerializationException"
100+
}
101+
}
102+
},
103+
{
104+
id: "RestJsonMalformedSetDuplicateStructures",
105+
documentation: """
106+
When the set has duplicated structures, the response should be a 400
107+
SerializationException.""",
108+
protocol: restJson1,
109+
request: {
110+
method: "POST",
111+
uri: "/MalformedSet",
112+
body: """
113+
{ "structSet" : [{"foo": "baz", "bar": 1}, {"foo": "quux", "bar": 2}, {"bar": 1, "foo": "baz"}] }""",
114+
headers: {
115+
"content-type": "application/json"
116+
}
117+
},
118+
response: {
119+
code: 400,
120+
headers: {
121+
"x-amzn-errortype": "SerializationException"
122+
}
123+
}
124+
},
125+
{
126+
id: "RestJsonMalformedSetDuplicateStructuresWithNullValues",
127+
documentation: """
128+
When the set has duplicated structures, where one structure has an
129+
explicit null value and the other leaves the member undefined,
130+
the response should be a 400 SerializationException.""",
131+
protocol: restJson1,
132+
request: {
133+
method: "POST",
134+
uri: "/MalformedSet",
135+
body: """
136+
{ "structSet" : [{"foo": null, "bar": 1}, {"foo": "quux", "bar": 2}, {"bar": 1}] }""",
137+
headers: {
138+
"content-type": "application/json"
139+
}
140+
},
141+
response: {
142+
code: 400,
143+
headers: {
144+
"x-amzn-errortype": "SerializationException"
145+
}
146+
}
147+
},
37148
{
38149
id: "RestJsonMalformedSetNullItem",
39150
documentation: """
@@ -59,11 +170,37 @@ apply MalformedSet @httpMalformedRequestTests([
59170
])
60171

61172
structure MalformedSetInput {
62-
set: SimpleSet
173+
set: SimpleSet,
174+
docSet: DocumentSet,
175+
tsSet: TimestampSet,
176+
blobSet: BlobSet,
177+
structSet: StructSet
63178
}
64179

65-
66180
set SimpleSet {
67181
member: String
68182
}
69183

184+
set DocumentSet {
185+
member: Document
186+
}
187+
188+
set TimestampSet {
189+
member: Timestamp
190+
}
191+
192+
set BlobSet {
193+
member: Blob
194+
}
195+
196+
set StructSet {
197+
member: StructForSet
198+
}
199+
200+
structure StructForSet {
201+
foo: String,
202+
bar: Integer
203+
}
204+
205+
document Document
206+

0 commit comments

Comments
 (0)