Skip to content

Commit 206a1ea

Browse files
ianbotsfJordonPhillips
authored andcommitted
Add protocol tests of timestampFormat on target shapes
1 parent 040caba commit 206a1ea

File tree

4 files changed

+393
-0
lines changed

4 files changed

+393
-0
lines changed

smithy-aws-protocol-tests/model/awsQuery/xml-structs.smithy

+75
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,26 @@ apply XmlTimestamps @httpResponseTests([
270270
dateTime: 1398796238
271271
}
272272
},
273+
{
274+
id: "QueryXmlTimestampsWithDateTimeOnTargetFormat",
275+
documentation: "Ensures that the timestampFormat of date-time on the target shape works like normal timestamps",
276+
protocol: awsQuery,
277+
code: 200,
278+
body: """
279+
<XmlTimestampsResponse xmlns="https://example.com/">
280+
<XmlTimestampsResult>
281+
<dateTimeOnTarget>2014-04-29T18:30:38Z</dateTimeOnTarget>
282+
</XmlTimestampsResult>
283+
</XmlTimestampsResponse>
284+
""",
285+
bodyMediaType: "application/xml",
286+
headers: {
287+
"Content-Type": "text/xml"
288+
},
289+
params: {
290+
dateTimeOnTarget: 1398796238
291+
}
292+
},
273293
{
274294
id: "QueryXmlTimestampsWithEpochSecondsFormat",
275295
documentation: "Ensures that the timestampFormat of epoch-seconds works",
@@ -290,6 +310,26 @@ apply XmlTimestamps @httpResponseTests([
290310
epochSeconds: 1398796238
291311
}
292312
},
313+
{
314+
id: "QueryXmlTimestampsWithEpochSecondsOnTargetFormat",
315+
documentation: "Ensures that the timestampFormat of epoch-seconds on the target shape works",
316+
protocol: awsQuery,
317+
code: 200,
318+
body: """
319+
<XmlTimestampsResponse xmlns="https://example.com/">
320+
<XmlTimestampsResult>
321+
<epochSecondsOnTarget>1398796238</epochSecondsOnTarget>
322+
</XmlTimestampsResult>
323+
</XmlTimestampsResponse>
324+
""",
325+
bodyMediaType: "application/xml",
326+
headers: {
327+
"Content-Type": "text/xml"
328+
},
329+
params: {
330+
epochSecondsOnTarget: 1398796238
331+
}
332+
},
293333
{
294334
id: "QueryXmlTimestampsWithHttpDateFormat",
295335
documentation: "Ensures that the timestampFormat of http-date works",
@@ -310,19 +350,54 @@ apply XmlTimestamps @httpResponseTests([
310350
httpDate: 1398796238
311351
}
312352
},
353+
{
354+
id: "QueryXmlTimestampsWithHttpDateOnTargetFormat",
355+
documentation: "Ensures that the timestampFormat of http-date on the target shape works",
356+
protocol: awsQuery,
357+
code: 200,
358+
body: """
359+
<XmlTimestampsResponse xmlns="https://example.com/">
360+
<XmlTimestampsResult>
361+
<httpDateOnTarget>Tue, 29 Apr 2014 18:30:38 GMT</httpDateOnTarget>
362+
</XmlTimestampsResult>
363+
</XmlTimestampsResponse>
364+
""",
365+
bodyMediaType: "application/xml",
366+
headers: {
367+
"Content-Type": "text/xml"
368+
},
369+
params: {
370+
httpDateOnTarget: 1398796238
371+
}
372+
},
313373
])
314374

375+
@timestampFormat("date-time")
376+
timestamp DateTimeTimestamp
377+
378+
@timestampFormat("epoch-seconds")
379+
timestamp EpochSecondsTimestamp
380+
381+
@timestampFormat("http-date")
382+
timestamp HttpDateTimestamp
383+
315384
structure XmlTimestampsOutput {
316385
normal: Timestamp,
317386

318387
@timestampFormat("date-time")
319388
dateTime: Timestamp,
320389

390+
dateTimeOnTarget: DateTimeTimestamp,
391+
321392
@timestampFormat("epoch-seconds")
322393
epochSeconds: Timestamp,
323394

395+
epochSecondsOnTarget: EpochSecondsTimestamp,
396+
324397
@timestampFormat("http-date")
325398
httpDate: Timestamp,
399+
400+
httpDateOnTarget: HttpDateTimestamp,
326401
}
327402

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

smithy-aws-protocol-tests/model/ec2Query/xml-structs.smithy

+72
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,25 @@ apply XmlTimestamps @httpResponseTests([
262262
dateTime: 1398796238
263263
}
264264
},
265+
{
266+
id: "Ec2XmlTimestampsWithDateTimeOnTargetFormat",
267+
documentation: "Ensures that the timestampFormat of date-time on the target shape works like normal timestamps",
268+
protocol: ec2Query,
269+
code: 200,
270+
body: """
271+
<XmlTimestampsResponse xmlns="https://example.com/">
272+
<dateTimeOnTarget>2014-04-29T18:30:38Z</dateTimeOnTarget>
273+
<RequestId>requestid</RequestId>
274+
</XmlTimestampsResponse>
275+
""",
276+
bodyMediaType: "application/xml",
277+
headers: {
278+
"Content-Type": "text/xml;charset=UTF-8"
279+
},
280+
params: {
281+
dateTimeOnTarget: 1398796238
282+
}
283+
},
265284
{
266285
id: "Ec2XmlTimestampsWithEpochSecondsFormat",
267286
documentation: "Ensures that the timestampFormat of epoch-seconds works",
@@ -281,6 +300,25 @@ apply XmlTimestamps @httpResponseTests([
281300
epochSeconds: 1398796238
282301
}
283302
},
303+
{
304+
id: "Ec2XmlTimestampsWithEpochSecondsOnTargetFormat",
305+
documentation: "Ensures that the timestampFormat of epoch-seconds on the target shape works",
306+
protocol: ec2Query,
307+
code: 200,
308+
body: """
309+
<XmlTimestampsResponse xmlns="https://example.com/">
310+
<epochSecondsOnTarget>1398796238</epochSecondsOnTarget>
311+
<RequestId>requestid</RequestId>
312+
</XmlTimestampsResponse>
313+
""",
314+
bodyMediaType: "application/xml",
315+
headers: {
316+
"Content-Type": "text/xml;charset=UTF-8"
317+
},
318+
params: {
319+
epochSecondsOnTarget: 1398796238
320+
}
321+
},
284322
{
285323
id: "Ec2XmlTimestampsWithHttpDateFormat",
286324
documentation: "Ensures that the timestampFormat of http-date works",
@@ -300,19 +338,53 @@ apply XmlTimestamps @httpResponseTests([
300338
httpDate: 1398796238
301339
}
302340
},
341+
{
342+
id: "Ec2XmlTimestampsWithHttpDateOnTargetFormat",
343+
documentation: "Ensures that the timestampFormat of http-date on the target shape works",
344+
protocol: ec2Query,
345+
code: 200,
346+
body: """
347+
<XmlTimestampsResponse xmlns="https://example.com/">
348+
<httpDateOnTarget>Tue, 29 Apr 2014 18:30:38 GMT</httpDateOnTarget>
349+
<RequestId>requestid</RequestId>
350+
</XmlTimestampsResponse>
351+
""",
352+
bodyMediaType: "application/xml",
353+
headers: {
354+
"Content-Type": "text/xml;charset=UTF-8"
355+
},
356+
params: {
357+
httpDateOnTarget: 1398796238
358+
}
359+
},
303360
])
304361

362+
@timestampFormat("date-time")
363+
timestamp DateTimeTimestamp
364+
365+
@timestampFormat("epoch-seconds")
366+
timestamp EpochSecondsTimestamp
367+
368+
@timestampFormat("http-date")
369+
timestamp HttpDateTimestamp
370+
305371
structure XmlTimestampsOutput {
306372
normal: Timestamp,
307373

308374
@timestampFormat("date-time")
309375
dateTime: Timestamp,
310376

377+
dateTimeOnTarget: DateTimeTimestamp,
378+
311379
@timestampFormat("epoch-seconds")
312380
epochSeconds: Timestamp,
313381

382+
epochSecondsOnTarget: EpochSecondsTimestamp,
383+
314384
@timestampFormat("http-date")
315385
httpDate: Timestamp,
386+
387+
httpDateOnTarget: HttpDateTimestamp,
316388
}
317389

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

smithy-aws-protocol-tests/model/restJson1/json-structs.smithy

+120
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,24 @@ apply JsonTimestamps @httpRequestTests([
395395
dateTime: 1398796238
396396
}
397397
},
398+
{
399+
id: "RestJsonJsonTimestampsWithDateTimeOnTargetFormat",
400+
documentation: "Ensures that the timestampFormat of date-time on the target shape works like normal timestamps",
401+
protocol: restJson1,
402+
method: "POST",
403+
uri: "/JsonTimestamps",
404+
body: """
405+
{
406+
"dateTimeOnTarget": "2014-04-29T18:30:38Z"
407+
}""",
408+
bodyMediaType: "application/json",
409+
headers: {
410+
"Content-Type": "application/json"
411+
},
412+
params: {
413+
dateTimeOnTarget: 1398796238
414+
}
415+
},
398416
{
399417
id: "RestJsonJsonTimestampsWithEpochSecondsFormat",
400418
documentation: "Ensures that the timestampFormat of epoch-seconds works",
@@ -413,6 +431,24 @@ apply JsonTimestamps @httpRequestTests([
413431
epochSeconds: 1398796238
414432
}
415433
},
434+
{
435+
id: "RestJsonJsonTimestampsWithEpochSecondsOnTargetFormat",
436+
documentation: "Ensures that the timestampFormat of epoch-seconds on the target shape works",
437+
protocol: restJson1,
438+
method: "POST",
439+
uri: "/JsonTimestamps",
440+
body: """
441+
{
442+
"epochSecondsOnTarget": 1398796238
443+
}""",
444+
bodyMediaType: "application/json",
445+
headers: {
446+
"Content-Type": "application/json"
447+
},
448+
params: {
449+
epochSecondsOnTarget: 1398796238
450+
}
451+
},
416452
{
417453
id: "RestJsonJsonTimestampsWithHttpDateFormat",
418454
documentation: "Ensures that the timestampFormat of http-date works",
@@ -431,6 +467,24 @@ apply JsonTimestamps @httpRequestTests([
431467
httpDate: 1398796238
432468
}
433469
},
470+
{
471+
id: "RestJsonJsonTimestampsWithHttpDateOnTargetFormat",
472+
documentation: "Ensures that the timestampFormat of http-date on the target shape works",
473+
protocol: restJson1,
474+
method: "POST",
475+
uri: "/JsonTimestamps",
476+
body: """
477+
{
478+
"httpDateOnTarget": "Tue, 29 Apr 2014 18:30:38 GMT"
479+
}""",
480+
bodyMediaType: "application/json",
481+
headers: {
482+
"Content-Type": "application/json"
483+
},
484+
params: {
485+
httpDateOnTarget: 1398796238
486+
}
487+
},
434488
])
435489

436490
apply JsonTimestamps @httpResponseTests([
@@ -468,6 +522,23 @@ apply JsonTimestamps @httpResponseTests([
468522
dateTime: 1398796238
469523
}
470524
},
525+
{
526+
id: "RestJsonJsonTimestampsWithDateTimeOnTargetFormat",
527+
documentation: "Ensures that the timestampFormat of date-time on the target shape works like normal timestamps",
528+
protocol: restJson1,
529+
code: 200,
530+
body: """
531+
{
532+
"dateTimeOnTarget": "2014-04-29T18:30:38Z"
533+
}""",
534+
bodyMediaType: "application/json",
535+
headers: {
536+
"Content-Type": "application/json"
537+
},
538+
params: {
539+
dateTimeOnTarget: 1398796238
540+
}
541+
},
471542
{
472543
id: "RestJsonJsonTimestampsWithEpochSecondsFormat",
473544
documentation: "Ensures that the timestampFormat of epoch-seconds works",
@@ -485,6 +556,23 @@ apply JsonTimestamps @httpResponseTests([
485556
epochSeconds: 1398796238
486557
}
487558
},
559+
{
560+
id: "RestJsonJsonTimestampsWithEpochSecondsOnTargetFormat",
561+
documentation: "Ensures that the timestampFormat of epoch-seconds on the target shape works",
562+
protocol: restJson1,
563+
code: 200,
564+
body: """
565+
{
566+
"epochSecondsOnTarget": 1398796238
567+
}""",
568+
bodyMediaType: "application/json",
569+
headers: {
570+
"Content-Type": "application/json"
571+
},
572+
params: {
573+
epochSecondsOnTarget: 1398796238
574+
}
575+
},
488576
{
489577
id: "RestJsonJsonTimestampsWithHttpDateFormat",
490578
documentation: "Ensures that the timestampFormat of http-date works",
@@ -502,19 +590,51 @@ apply JsonTimestamps @httpResponseTests([
502590
httpDate: 1398796238
503591
}
504592
},
593+
{
594+
id: "RestJsonJsonTimestampsWithHttpDateOnTargetFormat",
595+
documentation: "Ensures that the timestampFormat of http-date on the target shape works",
596+
protocol: restJson1,
597+
code: 200,
598+
body: """
599+
{
600+
"httpDateOnTarget": "Tue, 29 Apr 2014 18:30:38 GMT"
601+
}""",
602+
bodyMediaType: "application/json",
603+
headers: {
604+
"Content-Type": "application/json"
605+
},
606+
params: {
607+
httpDateOnTarget: 1398796238
608+
}
609+
},
505610
])
506611

612+
@timestampFormat("date-time")
613+
timestamp DateTimeTimestamp
614+
615+
@timestampFormat("epoch-seconds")
616+
timestamp EpochSecondsTimestamp
617+
618+
@timestampFormat("http-date")
619+
timestamp HttpDateTimestamp
620+
507621
structure JsonTimestampsInputOutput {
508622
normal: Timestamp,
509623

510624
@timestampFormat("date-time")
511625
dateTime: Timestamp,
512626

627+
dateTimeOnTarget: DateTimeTimestamp,
628+
513629
@timestampFormat("epoch-seconds")
514630
epochSeconds: Timestamp,
515631

632+
epochSecondsOnTarget: EpochSecondsTimestamp,
633+
516634
@timestampFormat("http-date")
517635
httpDate: Timestamp,
636+
637+
httpDateOnTarget: HttpDateTimestamp,
518638
}
519639

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

0 commit comments

Comments
 (0)