Skip to content

Commit

Permalink
Add client-only fractional second response tests (#1627)
Browse files Browse the repository at this point in the history
* Add client-only fractional second response tests
  • Loading branch information
srchase authored Feb 23, 2023
1 parent 4ca6b94 commit ff9df7d
Show file tree
Hide file tree
Showing 18 changed files with 312 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace aws.protocoltests.json

use aws.protocols#awsJson1_1
use aws.protocoltests.shared#DateTime
use smithy.test#httpRequestTests
use smithy.test#httpResponseTests

// These tests are for verifying the client can correctly parse
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
$version: "2.0"

namespace aws.protocoltests.json

use aws.protocols#awsJson1_1
use aws.protocoltests.shared#DateTime
use aws.protocoltests.shared#HttpDate
use smithy.test#httpResponseTests

// These tests are for verifying the client can correctly parse
// the `DateTime` and `HttpDate` timestamps with fractional seconds
@tags(["client-only"])
@http(uri: "/FractionalSeconds", method: "POST")
operation FractionalSeconds {
output: FractionalSecondsOutput
}

apply FractionalSeconds @httpResponseTests([
{
id: "AwsJson11DateTimeWithFractionalSeconds",
documentation: """
Ensures that clients can correctly parse datetime timestamps with fractional seconds""",
protocol: awsJson1_1,
code: 200,
body:
"""
{
"datetime": "2000-01-02T20:34:56.123Z"
}
""",
params: { datetime: 946845296.123 }
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/x-amz-json-1.1"
},
appliesTo: "client"
},
{
id: "AwsJson11HttpDateWithFractionalSeconds",
documentation: """
Ensures that clients can correctly parse http-date timestamps with fractional seconds""",
protocol: awsJson1_1,
code: 200,
body:
"""
{
"httpdate": "Sun, 02 Jan 2000 20:34:56.456 GMT"
}
""",
params: { httpdate: 946845296.456 }
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/x-amz-json-1.1"
},
appliesTo: "client"
}
])

structure FractionalSecondsOutput {
datetime: DateTime
httpdate: HttpDate
}
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ use smithy.test#httpResponseTests
id: "parses_iso8601_timestamps",
protocol: awsJson1_1,
documentation: "Parses iso8601 timestamps",
body: "{\"Iso8601Timestamp\":\"2000-01-02T20:34:56.000Z\"}",
body: "{\"Iso8601Timestamp\":\"2000-01-02T20:34:56Z\"}",
bodyMediaType: "application/json",
headers: {"Content-Type": "application/x-amz-json-1.1"},
params: {
Expand All @@ -763,7 +763,7 @@ use smithy.test#httpResponseTests
id: "parses_httpdate_timestamps",
protocol: awsJson1_1,
documentation: "Parses httpdate timestamps",
body: "{\"HttpdateTimestamp\":\"Sun, 02 Jan 2000 20:34:56.000 GMT\"}",
body: "{\"HttpdateTimestamp\":\"Sun, 02 Jan 2000 20:34:56 GMT\"}",
bodyMediaType: "application/json",
headers: {"Content-Type": "application/x-amz-json-1.1"},
params: {
Expand Down
2 changes: 2 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_1/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ service JsonProtocol {
// custom endpoints with paths
HostWithPathOperation,

// client-only timestamp parsing tests
DatetimeOffsets,
FractionalSeconds
],
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace aws.protocoltests.query

use aws.protocols#awsQuery
use aws.protocoltests.shared#DateTime
use smithy.test#httpRequestTests
use smithy.test#httpResponseTests

// These tests are for verifying the client can correctly parse
Expand Down
63 changes: 63 additions & 0 deletions smithy-aws-protocol-tests/model/awsQuery/fractional-seconds.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
$version: "2.0"

namespace aws.protocoltests.query

use aws.protocols#awsQuery
use aws.protocoltests.shared#DateTime
use aws.protocoltests.shared#HttpDate
use smithy.test#httpResponseTests

// These tests are for verifying the client can correctly parse
// the `DateTime` and `HttpDate` timestamps with fractional seconds
@tags(["client-only"])
operation FractionalSeconds {
output: FractionalSecondsOutput
}

apply FractionalSeconds @httpResponseTests([
{
id: "AwsQueryDateTimeWithFractionalSeconds",
documentation: """
Ensures that clients can correctly parse datetime timestamps with fractional seconds""",
protocol: awsQuery,
code: 200,
body: """
<FractionalSecondsResponse xmlns="https://example.com/">
<FractionalSecondsResult>
<datetime>2000-01-02T20:34:56.123Z</datetime>
</FractionalSecondsResult>
</FractionalSecondsResponse>
""",
params: { datetime: 946845296.123 }
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml"
},
appliesTo: "client"
}
{
id: "AwsQueryHttpDateWithFractionalSeconds",
documentation: """
Ensures that clients can correctly parse http-date timestamps with fractional seconds""",
protocol: awsQuery,
code: 200,
body: """
<FractionalSecondsResponse xmlns="https://example.com/">
<FractionalSecondsResult>
<httpdate>Sun, 02 Jan 2000 20:34:56.456 GMT</httpdate>
</FractionalSecondsResult>
</FractionalSecondsResponse>
""",
params: { httpdate: 946845296.456 }
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml"
},
appliesTo: "client"
}
])

structure FractionalSecondsOutput {
datetime: DateTime
httpdate: HttpDate
}
2 changes: 2 additions & 0 deletions smithy-aws-protocol-tests/model/awsQuery/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ service AwsQuery {
// custom endpoints with paths
HostWithPathOperation,

// client-only timestamp parsing tests
DatetimeOffsets,
FractionalSeconds,
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace aws.protocoltests.ec2

use aws.protocols#ec2Query
use aws.protocoltests.shared#DateTime
use smithy.test#httpRequestTests
use smithy.test#httpResponseTests

// These tests are for verifying the client can correctly parse
Expand Down
59 changes: 59 additions & 0 deletions smithy-aws-protocol-tests/model/ec2Query/fractional-seconds.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
$version: "2.0"

namespace aws.protocoltests.ec2

use aws.protocols#ec2Query
use aws.protocoltests.shared#DateTime
use aws.protocoltests.shared#HttpDate
use smithy.test#httpResponseTests

// These tests are for verifying the client can correctly parse
// the `DateTime` and `HttpDate` timestamps with fractional seconds
@tags(["client-only"])
operation FractionalSeconds {
output: FractionalSecondsOutput
}

apply FractionalSeconds @httpResponseTests([
{
id: "Ec2QueryDateTimeWithFractionalSeconds",
documentation: """
Ensures that clients can correctly parse datetime timestamps with fractional seconds""",
protocol: ec2Query,
code: 200,
body: """
<FractionalSecondsOutput xmlns="https://example.com/">
<datetime>2000-01-02T20:34:56.123Z</datetime>
<RequestId>requestid</RequestId>
</FractionalSecondsOutput>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml;charset=UTF-8"
},
params: { datetime: 1398796238.789 }
},
{
id: "Ec2QueryHttpDateWithFractionalSeconds",
documentation: """
Ensures that clients can correctly parse http-date timestamps with fractional seconds""",
protocol: ec2Query,
code: 200,
body: """
<FractionalSecondsOutput xmlns="https://example.com/">
<httpdate>Sun, 02 Jan 2000 20:34:56.456 GMT</httpdate>
<RequestId>requestid</RequestId>
</FractionalSecondsOutput>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml;charset=UTF-8"
},
params: { httpdate: 946845296.456 }
}
])

structure FractionalSecondsOutput {
datetime: DateTime
httpdate: HttpDate
}
2 changes: 2 additions & 0 deletions smithy-aws-protocol-tests/model/ec2Query/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ service AwsEc2 {
// custom endpoints with paths
HostWithPathOperation,

// client-only timestamp parsing tests
DatetimeOffsets,
FractionalSeconds,
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ apply XmlTimestamps @httpResponseTests([
params: {
httpDateOnTarget: 1398796238
}
},
}
])

structure XmlTimestampsOutput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace aws.protocoltests.restjson

use aws.protocols#restJson1
use aws.protocoltests.shared#DateTime
use smithy.test#httpRequestTests
use smithy.test#httpResponseTests

// These tests are for verifying the client can correctly parse
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
$version: "2.0"

namespace aws.protocoltests.restjson

use aws.protocols#restJson1
use aws.protocoltests.shared#DateTime
use aws.protocoltests.shared#HttpDate
use smithy.test#httpResponseTests

// These tests are for verifying the client can correctly parse
// the `DateTime` and `HttpDate` timestamps with fractional seconds
@tags(["client-only"])
@http(uri: "/FractionalSeconds", method: "POST")
operation FractionalSeconds {
output: FractionalSecondsOutput
}

apply FractionalSeconds @httpResponseTests([
{
id: "RestJsonDateTimeWithFractionalSeconds",
documentation: """
Ensures that clients can correctly parse datetime timestamps with fractional seconds""",
protocol: restJson1,
code: 200,
body:
"""
{
"datetime": "2000-01-02T20:34:56.123Z"
}
""",
params: { datetime: 946845296.123 }
bodyMediaType: "application/json",
appliesTo: "client"
},
{
id: "RestJsonHttpDateWithFractionalSeconds",
documentation: """
Ensures that clients can correctly parse http-date timestamps with fractional seconds""",
protocol: restJson1,
code: 200,
body:
"""
{
"httpdate": "Sun, 02 Jan 2000 20:34:56.456 GMT"
}
""",
params: { httpdate: 946845296.456 }
bodyMediaType: "application/json",
appliesTo: "client"
}
])

structure FractionalSecondsOutput {
datetime: DateTime
httpdate: HttpDate
}
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ apply JsonTimestamps @httpResponseTests([
params: {
httpDateOnTarget: 1398796238
}
},
}
])

structure JsonTimestampsInputOutput {
Expand Down
2 changes: 2 additions & 0 deletions smithy-aws-protocol-tests/model/restJson1/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ service RestJson {
TestPayloadBlob,
TestNoPayload,

// client-only timestamp parsing tests
DatetimeOffsets,
FractionalSeconds,
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace aws.protocoltests.restxml

use aws.protocols#restXml
use aws.protocoltests.shared#DateTime
use smithy.test#httpRequestTests
use smithy.test#httpResponseTests

// These tests are for verifying the client can correctly parse
Expand Down
Loading

0 comments on commit ff9df7d

Please sign in to comment.