Skip to content

Commit

Permalink
Add tests for quoted strings in headers
Browse files Browse the repository at this point in the history
RFC 7230 sec 3.2.6 defines header values as potentially quoted strings, which
makes commas in header values unambiguous. It's also the only way to escape a
reserved character. This adds a test for list values with a comma and for list
values with escaped double quotes.
  • Loading branch information
adamthom-amzn authored and JordonPhillips committed Nov 23, 2021
1 parent 54659b3 commit a230d73
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions smithy-aws-protocol-tests/model/restJson1/http-headers.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ apply InputAndOutputWithHeaders @httpRequestTests([
headerStringSet: ["a", "b", "c"],
}
},
{
id: "RestJsonInputAndOutputWithQuotedStringHeaders",
documentation: "Tests requests with string list header bindings that require quoting",
protocol: restJson1,
method: "POST",
uri: "/InputAndOutputWithHeaders",
headers: {
"X-StringList": """
"b,c","\"def\"",a"""
},
body: "",
params: {
headerStringList: ["b,c", "\"def\"", "a"]
}
},
{
id: "RestJsonInputAndOutputWithNumericHeaders",
documentation: "Tests requests with numeric header bindings",
Expand Down Expand Up @@ -97,7 +112,7 @@ apply InputAndOutputWithHeaders @httpRequestTests([
method: "POST",
uri: "/InputAndOutputWithHeaders",
headers: {
"X-TimestampList": "Mon, 16 Dec 2019 23:48:18 GMT, Mon, 16 Dec 2019 23:48:18 GMT"
"X-TimestampList": "\"Mon, 16 Dec 2019 23:48:18 GMT\", \"Mon, 16 Dec 2019 23:48:18 GMT\""
},
body: "",
params: {
Expand Down Expand Up @@ -187,6 +202,19 @@ apply InputAndOutputWithHeaders @httpResponseTests([
headerStringSet: ["a", "b", "c"],
}
},
{
id: "RestJsonInputAndOutputWithQuotedStringHeaders",
documentation: "Tests responses with string list header bindings that require quoting",
protocol: restJson1,
code: 200,
headers: {
"X-StringList": """
"b,c","\"def\"",a"""
},
params: {
headerStringList: ["a", "b,c", "\"def\""]
}
},
{
id: "RestJsonInputAndOutputWithNumericHeaders",
documentation: "Tests responses with numeric header bindings",
Expand Down Expand Up @@ -233,7 +261,7 @@ apply InputAndOutputWithHeaders @httpResponseTests([
protocol: restJson1,
code: 200,
headers: {
"X-TimestampList": "Mon, 16 Dec 2019 23:48:18 GMT, Mon, 16 Dec 2019 23:48:18 GMT"
"X-TimestampList": "\"Mon, 16 Dec 2019 23:48:18 GMT\", \"Mon, 16 Dec 2019 23:48:18 GMT\""
},
params: {
headerTimestampList: [1576540098, 1576540098]
Expand Down

0 comments on commit a230d73

Please sign in to comment.