Skip to content
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

Sort query maps in protocol tests #507

Merged
merged 1 commit into from
Jul 22, 2020
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
Sort query maps in protocol tests
Query maps have order, but not all languages have ordered maps.
Those languages may choose to sort by key on serialization to
have a stable payload. Go does this, for instance. This updates
the query protocol tests to have maps in their params and bodies
be sorted to facilitate this strategy while keeping languages with
insertion ordered maps from having to do any extra work.
  • Loading branch information
JordonPhillips committed Jul 22, 2020
commit be8d79a11078a80e672f3daab9948db40c90ecbc
75 changes: 41 additions & 34 deletions smithy-aws-protocol-tests/model/awsQuery/input-maps.smithy
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// This file defines test cases that test map query serialization.
// Query maps have order, but not all languages have maps that
// guarantee insertion order and those that do may choose not to
// enforce their usage. Those languages may choose to sort entries
// by key at serialization time, and so to facilitate that strategy
// all maps in this file should be sorted by key. Alternatively,
// a language implementing these tests may choose to implement a
// query body parser that understands query maps and/or lists.

$version: "1.0"

Expand Down Expand Up @@ -28,15 +35,15 @@ apply QueryMaps @httpRequestTests([
body: """
Action=QueryMaps
&Version=2020-01-08
&MapArg.entry.1.key=foo
&MapArg.entry.1.value=Foo
&MapArg.entry.2.key=bar
&MapArg.entry.2.value=Bar""",
&MapArg.entry.1.key=bar
&MapArg.entry.1.value=Bar
&MapArg.entry.2.key=foo
&MapArg.entry.2.value=Foo""",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
MapArg: {
bar: "Bar",
foo: "Foo",
bar: "Bar"
}
}
},
Expand Down Expand Up @@ -73,19 +80,19 @@ apply QueryMaps @httpRequestTests([
body: """
Action=QueryMaps
&Version=2020-01-08
&ComplexMapArg.entry.1.key=foo
&ComplexMapArg.entry.1.value.hi=Foo
&ComplexMapArg.entry.2.key=bar
&ComplexMapArg.entry.2.value.hi=Bar""",
&ComplexMapArg.entry.1.key=bar
&ComplexMapArg.entry.1.value.hi=Bar
&ComplexMapArg.entry.2.key=foo
&ComplexMapArg.entry.2.value.hi=Foo""",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
ComplexMapArg: {
bar: {
hi: "Bar"
},
foo: {
hi: "Foo",
},
bar: {
hi: "Bar"
}
}
}
},
Expand Down Expand Up @@ -118,15 +125,15 @@ apply QueryMaps @httpRequestTests([
body: """
Action=QueryMaps
&Version=2020-01-08
&MapWithXmlMemberName.entry.1.K=foo
&MapWithXmlMemberName.entry.1.V=Foo
&MapWithXmlMemberName.entry.2.K=bar
&MapWithXmlMemberName.entry.2.V=Bar""",
&MapWithXmlMemberName.entry.1.K=bar
&MapWithXmlMemberName.entry.1.V=Bar
&MapWithXmlMemberName.entry.2.K=foo
&MapWithXmlMemberName.entry.2.V=Foo""",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
MapWithXmlMemberName: {
bar: "Bar",
foo: "Foo",
bar: "Bar"
}
}
},
Expand All @@ -142,15 +149,15 @@ apply QueryMaps @httpRequestTests([
body: """
Action=QueryMaps
&Version=2020-01-08
&FlattenedMap.1.key=foo
&FlattenedMap.1.value=Foo
&FlattenedMap.2.key=bar
&FlattenedMap.2.value=Bar""",
&FlattenedMap.1.key=bar
&FlattenedMap.1.value=Bar
&FlattenedMap.2.key=foo
&FlattenedMap.2.value=Foo""",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
FlattenedMap: {
bar: "Bar",
foo: "Foo",
bar: "Bar"
}
}
},
Expand All @@ -166,15 +173,15 @@ apply QueryMaps @httpRequestTests([
body: """
Action=QueryMaps
&Version=2020-01-08
&Hi.1.K=foo
&Hi.1.V=Foo
&Hi.2.K=bar
&Hi.2.V=Bar""",
&Hi.1.K=bar
&Hi.1.V=Bar
&Hi.2.K=foo
&Hi.2.V=Foo""",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
FlattenedMapWithXmlName: {
bar: "Bar",
foo: "Foo",
bar: "Bar"
}
}
},
Expand All @@ -190,17 +197,17 @@ apply QueryMaps @httpRequestTests([
body: """
Action=QueryMaps
&Version=2020-01-08
&MapOfLists.entry.1.key=foo
&MapOfLists.entry.1.value.member.1=A
&MapOfLists.entry.1.value.member.2=B
&MapOfLists.entry.2.key=bar
&MapOfLists.entry.2.value.member.1=C
&MapOfLists.entry.2.value.member.2=D""",
&MapOfLists.entry.1.key=bar
&MapOfLists.entry.1.value.member.1=C
&MapOfLists.entry.1.value.member.2=D
&MapOfLists.entry.2.key=foo
&MapOfLists.entry.2.value.member.1=A
&MapOfLists.entry.2.value.member.2=B""",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
MapOfLists: {
foo: ["A", "B"],
bar: ["C", "D"],
foo: ["A", "B"],
}
}
},
Expand Down