Skip to content

Commit

Permalink
Add aws.ec2 protocol tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Jan 14, 2020
1 parent 6b00bcb commit 01b2746
Show file tree
Hide file tree
Showing 13 changed files with 1,409 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// This file defines test cases that test the basics of empty input and
// output shape serialization.

$version: "0.5.0"

namespace aws.protocols.tests.ec2

use smithy.test#httpRequestTests
use smithy.test#httpResponseTests

/// The example tests how requests and responses are serialized when there's
/// no request payload or response members.
///
/// While this should be rare, code generators must support this.
operation NoInputAndOutput {
output: NoInputAndOutputOutput
}

apply NoInputAndOutput @httpRequestTests([
{
id: "Ec2QueryNoInputAndOutput",
description: "No input serializes no payload",
protocol: "aws.ec2",
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: """
Action=NoInputAndOutput
&Version=2020-01-08""",
bodyMediaType: "application/x-www-form-urlencoded"
}
])

apply NoInputAndOutput @httpResponseTests([
{
id: "Ec2QueryNoInputAndOutput",
description: "Empty output",
protocol: "aws.ec2",
code: 200,
headers: {
"Content-Type": "text/xml;charset=UTF-8"
},
body: """
<NoInputAndOutputResponse xmlns="https://example.com/">
<RequestId>requestid</RequestId>
</NoInputAndOutputResponse>
""",
bodyMediaType: "application/xml",
}
])

structure NoInputAndOutputOutput {}

/// The example tests how requests and responses are serialized when there's
/// no request or response members.
///
/// While this should be rare, code generators must support this.
operation EmptyInputAndEmptyOutput {
input: EmptyInputAndEmptyOutputInput,
output: EmptyInputAndEmptyOutputOutput
}

apply EmptyInputAndEmptyOutput @httpRequestTests([
{
id: "Ec2QueryEmptyInputAndEmptyOutput",
description: "Empty input serializes no extra query params",
protocol: "aws.ec2",
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: """
Action=EmptyInputAndEmptyOutput
&Version=2020-01-08""",
bodyMediaType: "application/x-www-form-urlencoded"
},
])

apply EmptyInputAndEmptyOutput @httpResponseTests([
{
id: "Ec2QueryEmptyInputAndEmptyOutput",
description: "Empty output",
protocol: "aws.ec2",
code: 200,
headers: {
"Content-Type": "text/xml;charset=UTF-8"
},
body: """
<EmptyInputAndEmptyOutputResponse xmlns="https://example.com/">
<RequestId>requestid</RequestId>
</EmptyInputAndEmptyOutputResponse>
""",
bodyMediaType: "application/xml",
},
])

structure EmptyInputAndEmptyOutputInput {}
structure EmptyInputAndEmptyOutputOutput {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// This file defines test cases that test list query serialization.

$version: "0.5.0"

namespace aws.protocols.tests.ec2

use aws.protocols.tests.shared#EpochSeconds
use aws.protocols.tests.shared#FooEnum
use aws.protocols.tests.shared#GreetingList
use aws.protocols.tests.shared#StringList
use smithy.test#httpRequestTests

/// This test serializes simple and complex lists.
operation QueryLists {
input: QueryListsInput
}

apply QueryLists @httpRequestTests([
{
id: "Ec2Lists",
description: "Serializes query lists. All EC2 lists are flattened.",
protocol: "aws.ec2",
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: """
Action=QueryLists
&Version=2020-01-08
&ListArg.1=foo
&ListArg.2=bar
&ListArg.3=baz
&ComplexListArg.1.hi=hello
&ComplexListArg.2.hi=hola""",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
ListArg: ["foo", "bar", "baz"],
ComplexListArg: [
{
hi: "hello"
},
{
hi: "hola"
}
]
}
},
{
id: "Ec2EmptyQueryLists",
description: "Does not serialize empty query lists",
protocol: "aws.ec2",
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: """
Action=QueryLists
&Version=2020-01-08""",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
ListArg: []
}
},
{
id: "Ec2ListArgWithXmlNameMember",
description: "An xmlName trait in the member of a list has no effect on the list serialization.",
protocol: "aws.ec2",
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: """
Action=QueryLists
&Version=2020-01-08
&ListArgWithXmlNameMember.1=A
&ListArgWithXmlNameMember.2=B""",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
ListArgWithXmlNameMember: ["A", "B"]
}
},
{
id: "Ec2ListMemberWithXmlName",
description: "Changes the name of the list using the xmlName trait",
protocol: "aws.ec2",
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: """
Action=QueryLists
&Version=2020-01-08
&Hi.1=A
&Hi.2=B""",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
ListArgWithXmlName: ["A", "B"]
}
},
])

structure QueryListsInput {
ListArg: StringList,
ComplexListArg: GreetingList,

// Notice that the xmlName on the targeted list member is ignored.
ListArgWithXmlNameMember: ListWithXmlName,

@xmlName("Hi")
ListArgWithXmlName: ListWithXmlName,
}

list ListWithXmlName {
@xmlName("item")
member: String
}
Loading

0 comments on commit 01b2746

Please sign in to comment.