Skip to content

Commit

Permalink
Update protocol tests with int enum coverage (#1492)
Browse files Browse the repository at this point in the history
* Add coverage for `intEnum` in all protocol tests

As part of IDL 2.0, the `intEnum` shape was added. The following changes
add several test cases using an `intEnum` shape (and/or aggregates)
under the `awsJson1_*`, *Query, and `RestXml` protocol test suites.
  • Loading branch information
haydenbaker authored Nov 14, 2022
1 parent 33fe7b1 commit c226a57
Show file tree
Hide file tree
Showing 19 changed files with 676 additions and 0 deletions.
46 changes: 46 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use aws.protocoltests.shared#StringList
use aws.protocoltests.shared#StringMap
use aws.protocoltests.shared#GreetingStruct
use aws.protocoltests.shared#FooEnum
use aws.protocoltests.shared#IntegerEnum


/// This operation uses unions for inputs and outputs.
Expand Down Expand Up @@ -38,6 +39,7 @@ union MyUnion {
blobValue: Blob,
timestampValue: Timestamp,
enumValue: FooEnum,
intEnumValue: IntegerEnum,
listValue: StringList,
mapValue: StringMap,
structureValue: GreetingStruct,
Expand Down Expand Up @@ -182,6 +184,29 @@ apply JsonUnions @httpRequestTests([
}
}
},
{
id: "AwsJson10SerializeIntEnumUnionValue",
documentation: "Serializes an intEnum union value",
protocol: awsJson1_0,
method: "POST",
"uri": "/",
body: """
{
"contents": {
"intEnumValue": 1
}
}""",
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/x-amz-json-1.0",
"X-Amz-Target": "JsonRpc10.JsonUnions",
},
params: {
contents: {
intEnumValue: 1
}
}
},
{
id: "AwsJson10SerializeListUnionValue",
documentation: "Serializes a list union value",
Expand Down Expand Up @@ -390,6 +415,27 @@ apply JsonUnions @httpResponseTests([
}
}
},
{
id: "AwsJson10DeserializeIntEnumUnionValue",
documentation: "Deserializes an intEnum union value",
protocol: awsJson1_0,
code: 200,
body: """
{
"contents": {
"intEnumValue": 1
}
}""",
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/x-amz-json-1.0",
},
params: {
contents: {
intEnumValue: 1
}
}
},
{
id: "AwsJson10DeserializeListUnionValue",
documentation: "Deserializes a list union value",
Expand Down
107 changes: 107 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_1/enums.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use aws.protocoltests.shared#FooEnum
use aws.protocoltests.shared#FooEnumList
use aws.protocoltests.shared#FooEnumSet
use aws.protocoltests.shared#FooEnumMap
use aws.protocoltests.shared#IntegerEnum
use aws.protocoltests.shared#IntegerEnumList
use aws.protocoltests.shared#IntegerEnumSet
use aws.protocoltests.shared#IntegerEnumMap
use smithy.test#httpRequestTests
use smithy.test#httpResponseTests

Expand Down Expand Up @@ -109,3 +113,106 @@ structure JsonEnumsInputOutput {
fooEnumSet: FooEnumSet,
fooEnumMap: FooEnumMap,
}

/// This example serializes intEnums as top level properties, in lists, sets, and maps.
@idempotent
operation JsonIntEnums {
input: JsonIntEnumsInputOutput,
output: JsonIntEnumsInputOutput
}

apply JsonIntEnums @httpRequestTests([
{
id: "AwsJson11IntEnums",
documentation: "Serializes simple scalar properties",
protocol: awsJson1_1,
method: "POST",
uri: "/",
body: """
{
"intEnum1": 1,
"intEnum2": 2,
"intEnum3": 3,
"intEnumList": [
1,
2
],
"intEnumSet": [
1,
2
],
"intEnumMap": {
"a": 1,
"b": 2
}
}""",
headers: {
"Content-Type": "application/x-amz-json-1.1",
"X-Amz-Target": "JsonProtocol.JsonIntEnums",
},
bodyMediaType: "application/json",
params: {
intEnum1: 1,
intEnum2: 2,
intEnum3: 3,
intEnumList: [1, 2],
intEnumSet: [1, 2],
intEnumMap: {
"a": 1,
"b": 2
}
}
}
])

apply JsonIntEnums @httpResponseTests([
{
id: "AwsJson11IntEnums",
documentation: "Serializes simple scalar properties",
protocol: awsJson1_1,
code: 200,
body: """
{
"intEnum1": 1,
"intEnum2": 2,
"intEnum3": 3,
"intEnumList": [
1,
2
],
"intEnumSet": [
1,
2
],
"intEnumMap": {
"a": 1,
"b": 2
}
}""",
headers: {
"Content-Type": "application/x-amz-json-1.1",
"X-Amz-Target": "JsonProtocol.JsonIntEnums",
},
bodyMediaType: "application/json",
params: {
intEnum1: 1,
intEnum2: 2,
intEnum3: 3,
intEnumList: [1, 2],
intEnumSet: [1, 2],
intEnumMap: {
"a": 1,
"b": 2
}
}
}
])

structure JsonIntEnumsInputOutput {
intEnum1: IntegerEnum,
intEnum2: IntegerEnum,
intEnum3: IntegerEnum,
intEnumList: IntegerEnumList,
intEnumSet: IntegerEnumSet,
intEnumMap: IntegerEnumMap,
}
20 changes: 20 additions & 0 deletions smithy-aws-protocol-tests/model/awsQuery/input.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace aws.protocoltests.query
use aws.protocols#awsQuery
use aws.protocoltests.shared#EpochSeconds
use aws.protocoltests.shared#FooEnum
use aws.protocoltests.shared#IntegerEnum
use smithy.test#httpRequestTests

/// This test serializes strings, numbers, and boolean values.
Expand Down Expand Up @@ -143,6 +144,24 @@ apply SimpleInputParams @httpRequestTests([
FooEnum: "Foo",
}
},
{
id: "QueryIntEnums",
documentation: "Serializes intEnums in the query string",
protocol: awsQuery,
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
requireHeaders: [
"Content-Length"
],
body: "Action=SimpleInputParams&Version=2020-01-08&IntegerEnum=1",
bodyMediaType: "application/x-www-form-urlencoded",
params: {
IntegerEnum: 1,
}
},
{
id: "AwsQuerySupportsNaNFloatInputs",
documentation: "Supports handling NaN float values.",
Expand Down Expand Up @@ -211,6 +230,7 @@ structure SimpleInputParamsInput {
Boo: Double,
Qux: Blob,
FooEnum: FooEnum,
IntegerEnum: IntegerEnum
}

/// This test serializes timestamps.
Expand Down
1 change: 1 addition & 0 deletions smithy-aws-protocol-tests/model/awsQuery/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ service AwsQuery {
XmlBlobs,
XmlTimestamps,
XmlEnums,
XmlIntEnums,
RecursiveXmlShapes,
RecursiveXmlShapes,
IgnoresWrappingXmlName,
Expand Down
8 changes: 8 additions & 0 deletions smithy-aws-protocol-tests/model/awsQuery/xml-lists.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace aws.protocoltests.query
use aws.protocols#awsQuery
use aws.protocoltests.shared#BooleanList
use aws.protocoltests.shared#FooEnumList
use aws.protocoltests.shared#IntegerEnumList
use aws.protocoltests.shared#IntegerList
use aws.protocoltests.shared#NestedStringList
use aws.protocoltests.shared#StringList
Expand Down Expand Up @@ -61,6 +62,10 @@ apply XmlLists @httpResponseTests([
<member>Foo</member>
<member>0</member>
</enumList>
<intEnumList>
<member>1</member>
<member>2</member>
</intEnumList>
<nestedStringList>
<member>
<member>foo</member>
Expand Down Expand Up @@ -107,6 +112,7 @@ apply XmlLists @httpResponseTests([
booleanList: [true, false],
timestampList: [1398796238, 1398796238],
enumList: ["Foo", "0"],
intEnumList: [1, 2],
nestedStringList: [["foo", "bar"], ["baz", "qux"]],
renamedListMembers: ["foo", "bar"],
flattenedList: ["hi", "bye"],
Expand Down Expand Up @@ -172,6 +178,8 @@ structure XmlListsOutput {

enumList: FooEnumList,

intEnumList: IntegerEnumList,

nestedStringList: NestedStringList,

@xmlName("renamed")
Expand Down
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 @@ -11,6 +11,10 @@ use aws.protocoltests.shared#FooEnum
use aws.protocoltests.shared#FooEnumList
use aws.protocoltests.shared#FooEnumSet
use aws.protocoltests.shared#FooEnumMap
use aws.protocoltests.shared#IntegerEnum
use aws.protocoltests.shared#IntegerEnumList
use aws.protocoltests.shared#IntegerEnumSet
use aws.protocoltests.shared#IntegerEnumMap
use aws.protocoltests.shared#HttpDate
use smithy.test#httpResponseTests

Expand Down Expand Up @@ -459,6 +463,71 @@ structure XmlEnumsOutput {
fooEnumMap: FooEnumMap,
}

/// This example serializes enums as top level properties, in lists, sets, and maps.
operation XmlIntEnums {
output: XmlIntEnumsOutput
}

apply XmlIntEnums @httpResponseTests([
{
id: "QueryXmlIntEnums",
documentation: "Serializes simple scalar properties",
protocol: awsQuery,
code: 200,
body: """
<XmlIntEnumsResponse xmlns="https://example.com/">
<XmlIntEnumsResult>
<intEnum1>1</intEnum1>
<intEnum2>2</intEnum2>
<intEnum3>3</intEnum3>
<intEnumList>
<member>1</member>
<member>2</member>
</intEnumList>
<intEnumSet>
<member>1</member>
<member>2</member>
</intEnumSet>
<intEnumMap>
<entry>
<key>a</key>
<value>1</value>
</entry>
<entry>
<key>b</key>
<value>2</value>
</entry>
</intEnumMap>
</XmlIntEnumsResult>
</XmlIntEnumsResponse>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "text/xml"
},
params: {
intEnum1: 1,
intEnum2: 2,
intEnum3: 3,
intEnumList: [1, 2],
intEnumSet: [1, 2],
intEnumMap: {
"a": 1,
"b": 2
}
}
}
])

structure XmlIntEnumsOutput {
intEnum1: IntegerEnum,
intEnum2: IntegerEnum,
intEnum3: IntegerEnum,
intEnumList: IntegerEnumList,
intEnumSet: IntegerEnumSet,
intEnumMap: IntegerEnumMap,
}

/// Recursive shapes
operation RecursiveXmlShapes {
output: RecursiveXmlShapesOutput
Expand Down
1 change: 1 addition & 0 deletions smithy-aws-protocol-tests/model/ec2Query/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ service AwsEc2 {
XmlBlobs,
XmlTimestamps,
XmlEnums,
XmlIntEnums,
RecursiveXmlShapes,
RecursiveXmlShapes,
IgnoresWrappingXmlName,
Expand Down
Loading

0 comments on commit c226a57

Please sign in to comment.