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

Add protocol tests of timestampFormat on target shapes #1440

Merged
merged 2 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
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
69 changes: 69 additions & 0 deletions smithy-aws-protocol-tests/model/awsQuery/xml-structs.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ $version: "2.0"
namespace aws.protocoltests.query

use aws.protocols#awsQuery
use aws.protocoltests.shared#DateTime
use aws.protocoltests.shared#EpochSeconds
use aws.protocoltests.shared#FooEnum
use aws.protocoltests.shared#FooEnumList
use aws.protocoltests.shared#FooEnumSet
use aws.protocoltests.shared#FooEnumMap
use aws.protocoltests.shared#HttpDate
use smithy.test#httpResponseTests

// This example serializes simple scalar types in the top level XML document.
Expand Down Expand Up @@ -270,6 +273,26 @@ apply XmlTimestamps @httpResponseTests([
dateTime: 1398796238
}
},
{
id: "QueryXmlTimestampsWithDateTimeOnTargetFormat",
documentation: "Ensures that the timestampFormat of date-time on the target shape works like normal timestamps",
protocol: awsQuery,
code: 200,
body: """
<XmlTimestampsResponse xmlns="https://example.com/">
<XmlTimestampsResult>
<dateTimeOnTarget>2014-04-29T18:30:38Z</dateTimeOnTarget>
</XmlTimestampsResult>
</XmlTimestampsResponse>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml"
},
params: {
dateTimeOnTarget: 1398796238
}
},
{
id: "QueryXmlTimestampsWithEpochSecondsFormat",
documentation: "Ensures that the timestampFormat of epoch-seconds works",
Expand All @@ -290,6 +313,26 @@ apply XmlTimestamps @httpResponseTests([
epochSeconds: 1398796238
}
},
{
id: "QueryXmlTimestampsWithEpochSecondsOnTargetFormat",
documentation: "Ensures that the timestampFormat of epoch-seconds on the target shape works",
protocol: awsQuery,
code: 200,
body: """
<XmlTimestampsResponse xmlns="https://example.com/">
<XmlTimestampsResult>
<epochSecondsOnTarget>1398796238</epochSecondsOnTarget>
</XmlTimestampsResult>
</XmlTimestampsResponse>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml"
},
params: {
epochSecondsOnTarget: 1398796238
}
},
{
id: "QueryXmlTimestampsWithHttpDateFormat",
documentation: "Ensures that the timestampFormat of http-date works",
Expand All @@ -310,6 +353,26 @@ apply XmlTimestamps @httpResponseTests([
httpDate: 1398796238
}
},
{
id: "QueryXmlTimestampsWithHttpDateOnTargetFormat",
documentation: "Ensures that the timestampFormat of http-date on the target shape works",
protocol: awsQuery,
code: 200,
body: """
<XmlTimestampsResponse xmlns="https://example.com/">
<XmlTimestampsResult>
<httpDateOnTarget>Tue, 29 Apr 2014 18:30:38 GMT</httpDateOnTarget>
</XmlTimestampsResult>
</XmlTimestampsResponse>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml"
},
params: {
httpDateOnTarget: 1398796238
}
},
])

structure XmlTimestampsOutput {
Expand All @@ -318,11 +381,17 @@ structure XmlTimestampsOutput {
@timestampFormat("date-time")
dateTime: Timestamp,

dateTimeOnTarget: DateTime,

@timestampFormat("epoch-seconds")
epochSeconds: Timestamp,

epochSecondsOnTarget: EpochSeconds,

@timestampFormat("http-date")
httpDate: Timestamp,

httpDateOnTarget: HttpDate,
}

/// This example serializes enums as top level properties, in lists, sets, and maps.
Expand Down
66 changes: 66 additions & 0 deletions smithy-aws-protocol-tests/model/ec2Query/xml-structs.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ namespace aws.protocoltests.ec2

use aws.protocols#ec2QueryName
use aws.protocols#ec2Query
use aws.protocoltests.shared#DateTime
use aws.protocoltests.shared#EpochSeconds
use aws.protocoltests.shared#FooEnum
use aws.protocoltests.shared#FooEnumList
use aws.protocoltests.shared#FooEnumSet
use aws.protocoltests.shared#FooEnumMap
use aws.protocoltests.shared#HttpDate
use smithy.test#httpResponseTests

// This example serializes simple scalar types in the top level XML document.
Expand Down Expand Up @@ -262,6 +265,25 @@ apply XmlTimestamps @httpResponseTests([
dateTime: 1398796238
}
},
{
id: "Ec2XmlTimestampsWithDateTimeOnTargetFormat",
documentation: "Ensures that the timestampFormat of date-time on the target shape works like normal timestamps",
protocol: ec2Query,
code: 200,
body: """
<XmlTimestampsResponse xmlns="https://example.com/">
<dateTimeOnTarget>2014-04-29T18:30:38Z</dateTimeOnTarget>
<RequestId>requestid</RequestId>
</XmlTimestampsResponse>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml;charset=UTF-8"
},
params: {
dateTimeOnTarget: 1398796238
}
},
{
id: "Ec2XmlTimestampsWithEpochSecondsFormat",
documentation: "Ensures that the timestampFormat of epoch-seconds works",
Expand All @@ -281,6 +303,25 @@ apply XmlTimestamps @httpResponseTests([
epochSeconds: 1398796238
}
},
{
id: "Ec2XmlTimestampsWithEpochSecondsOnTargetFormat",
documentation: "Ensures that the timestampFormat of epoch-seconds on the target shape works",
protocol: ec2Query,
code: 200,
body: """
<XmlTimestampsResponse xmlns="https://example.com/">
<epochSecondsOnTarget>1398796238</epochSecondsOnTarget>
<RequestId>requestid</RequestId>
</XmlTimestampsResponse>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml;charset=UTF-8"
},
params: {
epochSecondsOnTarget: 1398796238
}
},
{
id: "Ec2XmlTimestampsWithHttpDateFormat",
documentation: "Ensures that the timestampFormat of http-date works",
Expand All @@ -300,6 +341,25 @@ apply XmlTimestamps @httpResponseTests([
httpDate: 1398796238
}
},
{
id: "Ec2XmlTimestampsWithHttpDateOnTargetFormat",
documentation: "Ensures that the timestampFormat of http-date on the target shape works",
protocol: ec2Query,
code: 200,
body: """
<XmlTimestampsResponse xmlns="https://example.com/">
<httpDateOnTarget>Tue, 29 Apr 2014 18:30:38 GMT</httpDateOnTarget>
<RequestId>requestid</RequestId>
</XmlTimestampsResponse>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml;charset=UTF-8"
},
params: {
httpDateOnTarget: 1398796238
}
},
])

structure XmlTimestampsOutput {
Expand All @@ -308,11 +368,17 @@ structure XmlTimestampsOutput {
@timestampFormat("date-time")
dateTime: Timestamp,

dateTimeOnTarget: DateTime,

@timestampFormat("epoch-seconds")
epochSeconds: Timestamp,

epochSecondsOnTarget: EpochSeconds,

@timestampFormat("http-date")
httpDate: Timestamp,

httpDateOnTarget: HttpDate,
}

/// This example serializes enums as top level properties, in lists, sets, and maps.
Expand Down
Loading