Skip to content

Add malformed request tests for more set types #1094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,117 @@ apply MalformedSet @httpMalformedRequestTests([
}
}
},
{
id: "RestJsonMalformedSetDuplicateDocuments",
documentation: """
When the set has duplicated documents, the response should be a 400
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not indent long strings to make it easier to see key value pairs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copy and pasted the same mistake as the test above

SerializationException.""",
protocol: restJson1,
request: {
method: "POST",
uri: "/MalformedSet",
body: """
{ "docSet" : [{"a": 1}, {"b": 2, "c": 3}, {"c": 3, "b": 2}] }""",
headers: {
"content-type": "application/json"
}
},
response: {
code: 400,
headers: {
"x-amzn-errortype": "SerializationException"
}
}
},
{
id: "RestJsonMalformedSetDuplicateTimestamps",
documentation: """
When the set has duplicated timestamps, the response should be a 400
SerializationException.""",
protocol: restJson1,
request: {
method: "POST",
uri: "/MalformedSet",
body: """
{ "tsSet" : [1515531081, 1423235322, 1515531081] }""",
headers: {
"content-type": "application/json"
}
},
response: {
code: 400,
headers: {
"x-amzn-errortype": "SerializationException"
}
}
},
{
id: "RestJsonMalformedSetDuplicateBlobs",
documentation: """
When the set has duplicated blobs, the response should be a 400
SerializationException.""",
protocol: restJson1,
request: {
method: "POST",
uri: "/MalformedSet",
body: """
{ "blobSet" : ["YmxvYg==", "b3RoZXJibG9i", "YmxvYg=="] }""",
headers: {
"content-type": "application/json"
}
},
response: {
code: 400,
headers: {
"x-amzn-errortype": "SerializationException"
}
}
},
{
id: "RestJsonMalformedSetDuplicateStructures",
documentation: """
When the set has duplicated structures, the response should be a 400
SerializationException.""",
protocol: restJson1,
request: {
method: "POST",
uri: "/MalformedSet",
body: """
{ "structSet" : [{"foo": "baz", "bar": 1}, {"foo": "quux", "bar": 2}, {"bar": 1, "foo": "baz"}] }""",
headers: {
"content-type": "application/json"
}
},
response: {
code: 400,
headers: {
"x-amzn-errortype": "SerializationException"
}
}
},
{
id: "RestJsonMalformedSetDuplicateStructuresWithNullValues",
documentation: """
When the set has duplicated structures, where one structure has an
explicit null value and the other leaves the member undefined,
the response should be a 400 SerializationException.""",
protocol: restJson1,
request: {
method: "POST",
uri: "/MalformedSet",
body: """
{ "structSet" : [{"foo": null, "bar": 1}, {"foo": "quux", "bar": 2}, {"bar": 1}] }""",
headers: {
"content-type": "application/json"
}
},
response: {
code: 400,
headers: {
"x-amzn-errortype": "SerializationException"
}
}
},
{
id: "RestJsonMalformedSetNullItem",
documentation: """
Expand All @@ -59,11 +170,37 @@ apply MalformedSet @httpMalformedRequestTests([
])

structure MalformedSetInput {
set: SimpleSet
set: SimpleSet,
docSet: DocumentSet,
tsSet: TimestampSet,
blobSet: BlobSet,
structSet: StructSet
}


set SimpleSet {
member: String
}

set DocumentSet {
member: Document
}

set TimestampSet {
member: Timestamp
}

set BlobSet {
member: Blob
}

set StructSet {
member: StructForSet
}

structure StructForSet {
foo: String,
bar: Integer
}

document Document