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 for the endpoint trait #708

Merged
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
5 changes: 5 additions & 0 deletions docs/source/1.0/spec/aws/aws-ec2-query-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ that affect serialization:
- Description
* - :ref:`cors <cors-trait>`
- Indicates that the service supports CORS.
* - :ref:`endpoint <endpoint-trait>`
- Configures a custom operation endpoint.
* - :ref:`hostLabel <hostLabel-trait>`
- Binds a top-level operation input structure member to a label in
the hostPrefix of an endpoint trait.
* - :ref:`ec2QueryName <xmlName-trait>`
- By default, the form-urlencoded key segments used in serialized
structures are the same as a structure member name. The ``ec2QueryName``
Expand Down
5 changes: 5 additions & 0 deletions docs/source/1.0/spec/aws/aws-json.rst.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ that affect serialization:
- Description
* - :ref:`cors <cors-trait>`
- Indicates that the service supports CORS.
* - :ref:`endpoint <endpoint-trait>`
- Configures a custom operation endpoint.
* - :ref:`hostLabel <hostLabel-trait>`
- Binds a top-level operation input structure member to a label in
the hostPrefix of an endpoint trait.
* - :ref:`jsonName <jsonName-trait>`
- By default, the JSON property names used in serialized structures are
the same as a structure member name. The ``jsonName`` trait changes
Expand Down
5 changes: 5 additions & 0 deletions docs/source/1.0/spec/aws/aws-query-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ that affect serialization:
- Description
* - :ref:`cors <cors-trait>`
- Indicates that the service supports CORS.
* - :ref:`endpoint <endpoint-trait>`
- Configures a custom operation endpoint.
* - :ref:`hostLabel <hostLabel-trait>`
- Binds a top-level operation input structure member to a label in
the hostPrefix of an endpoint trait.
* - :ref:`xmlAttrubute <xmlAttribute-trait>`
- Serializes an object property as an XML attribute rather than a nested
XML element.
Expand Down
57 changes: 57 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_0/endpoints.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// This file defines tests to ensure that implementations support the endpoint
// trait and other features that modify the host.

$version: "1.0"

namespace aws.protocoltests.json10

use aws.protocols#awsJson1_0
use smithy.test#httpRequestTests

@httpRequestTests([
{
id: "AwsJson10EndpointTrait",
documentation: """
Operations can prepend to the given host if they define the
endpoint trait.""",
protocol: awsJson1_0,
method: "POST",
uri: "/",
body: "{}",
host: "example.com",
resolvedHost: "foo.example.com",
}
])
@endpoint(hostPrefix: "foo.")
operation EndpointOperation {}


@httpRequestTests([
{
id: "AwsJson10EndpointTraitWithHostLabel",
documentation: """
Operations can prepend to the given host if they define the
endpoint trait, and can use the host label trait to define
further customization based on user input.""",
protocol: awsJson1_0,
method: "POST",
uri: "/",
body: "{\"label\": \"bar\"}",
bodyMediaType: "application/json",
host: "example.com",
resolvedHost: "foo.bar.example.com",
params: {
label: "bar",
},
}
])
@endpoint(hostPrefix: "foo.{label}.")
operation EndpointWithHostLabelOperation {
input: HostLabelInput,
}

structure HostLabelInput {
@required
@hostLabel
label: String,
}
4 changes: 4 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_0/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ service JsonRpc10 {
// Errors
GreetingWithErrors,
JsonUnions,

// @endpoint and @hostLabel trait tests
EndpointOperation,
EndpointWithHostLabelOperation,
]
}
57 changes: 57 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_1/endpoints.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// This file defines tests to ensure that implementations support the endpoint
// trait and other features that modify the host.

$version: "1.0"

namespace aws.protocoltests.json

use aws.protocols#awsJson1_1
use smithy.test#httpRequestTests

@httpRequestTests([
{
id: "AwsJson11EndpointTrait",
documentation: """
Operations can prepend to the given host if they define the
endpoint trait.""",
protocol: awsJson1_1,
method: "POST",
uri: "/",
body: "{}",
host: "example.com",
resolvedHost: "foo.example.com",
}
])
@endpoint(hostPrefix: "foo.")
operation EndpointOperation {}


@httpRequestTests([
{
id: "AwsJson11EndpointTraitWithHostLabel",
documentation: """
Operations can prepend to the given host if they define the
endpoint trait, and can use the host label trait to define
further customization based on user input.""",
protocol: awsJson1_1,
method: "POST",
uri: "/",
body: "{\"label\": \"bar\"}",
bodyMediaType: "application/json",
host: "example.com",
resolvedHost: "foo.bar.example.com",
params: {
label: "bar",
},
}
])
@endpoint(hostPrefix: "foo.{label}.")
operation EndpointWithHostLabelOperation {
input: HostLabelInput,
}

structure HostLabelInput {
@required
@hostLabel
label: String,
}
4 changes: 4 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_1/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ service JsonProtocol {
NullOperation,
GreetingWithErrors,
JsonUnions,

// @endpoint and @hostLabel trait tests
EndpointOperation,
EndpointWithHostLabelOperation,
],
}

Expand Down
69 changes: 69 additions & 0 deletions smithy-aws-protocol-tests/model/awsQuery/endpoints.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// This file defines tests to ensure that implementations support the endpoint
// trait and other features that modify the host.

$version: "1.0"

namespace aws.protocoltests.query

use aws.protocols#awsQuery
use smithy.test#httpRequestTests

@httpRequestTests([
{
id: "AwsQueryEndpointTrait",
documentation: """
Operations can prepend to the given host if they define the
endpoint trait.""",
protocol: awsQuery,
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: """
Action=EndpointOperation
&Version=2020-01-08""",
bodyMediaType: "application/x-www-form-urlencoded",
host: "example.com",
resolvedHost: "foo.example.com",
}
])
@endpoint(hostPrefix: "foo.")
operation EndpointOperation {}


@httpRequestTests([
{
id: "AwsQueryEndpointTraitWithHostLabel",
documentation: """
Operations can prepend to the given host if they define the
endpoint trait, and can use the host label trait to define
further customization based on user input.""",
protocol: awsQuery,
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: """
Action=EndpointWithHostLabelOperation
&Version=2020-01-08
&label=bar""",
bodyMediaType: "application/x-www-form-urlencoded",
host: "example.com",
resolvedHost: "foo.bar.example.com",
params: {
label: "bar",
},
}
])
@endpoint(hostPrefix: "foo.{label}.")
operation EndpointWithHostLabelOperation {
input: HostLabelInput,
}

structure HostLabelInput {
@required
@hostLabel
label: String,
}
4 changes: 4 additions & 0 deletions smithy-aws-protocol-tests/model/awsQuery/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,9 @@ service AwsQuery {

// Output error tests
GreetingWithErrors,

// @endpoint and @hostLabel trait tests
EndpointOperation,
EndpointWithHostLabelOperation,
]
}
69 changes: 69 additions & 0 deletions smithy-aws-protocol-tests/model/ec2Query/endpoints.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// This file defines tests to ensure that implementations support the endpoint
// trait and other features that modify the host.

$version: "1.0"

namespace aws.protocoltests.ec2

use aws.protocols#ec2Query
use smithy.test#httpRequestTests

@httpRequestTests([
{
id: "Ec2QueryEndpointTrait",
documentation: """
Operations can prepend to the given host if they define the
endpoint trait.""",
protocol: ec2Query,
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: """
Action=EndpointOperation
&Version=2020-01-08""",
bodyMediaType: "application/x-www-form-urlencoded",
host: "example.com",
resolvedHost: "foo.example.com",
}
])
@endpoint(hostPrefix: "foo.")
operation EndpointOperation {}


@httpRequestTests([
{
id: "Ec2QueryEndpointTraitWithHostLabel",
documentation: """
Operations can prepend to the given host if they define the
endpoint trait, and can use the host label trait to define
further customization based on user input.""",
protocol: ec2Query,
method: "POST",
uri: "/",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: """
Action=EndpointWithHostLabelOperation
&Version=2020-01-08
&label=bar""",
bodyMediaType: "application/x-www-form-urlencoded",
host: "example.com",
resolvedHost: "foo.bar.example.com",
params: {
label: "bar",
},
}
])
@endpoint(hostPrefix: "foo.{label}.")
operation EndpointWithHostLabelOperation {
input: HostLabelInput,
}

structure HostLabelInput {
@required
@hostLabel
label: String,
}
4 changes: 4 additions & 0 deletions smithy-aws-protocol-tests/model/ec2Query/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,9 @@ service AwsEc2 {

// Output error tests
GreetingWithErrors,

// @endpoint and @hostLabel trait tests
EndpointOperation,
EndpointWithHostLabelOperation,
]
}
59 changes: 59 additions & 0 deletions smithy-aws-protocol-tests/model/restJson1/endpoints.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// This file defines tests to ensure that implementations support the endpoint
// trait and other features that modify the host.

$version: "1.0"

namespace aws.protocoltests.restjson

use aws.protocols#restJson1
use smithy.test#httpRequestTests

@httpRequestTests([
{
id: "RestJsonEndpointTrait",
documentation: """
Operations can prepend to the given host if they define the
endpoint trait.""",
protocol: restJson1,
method: "POST",
uri: "/EndpointOperation",
body: "",
host: "example.com",
resolvedHost: "foo.example.com",
}
])
@endpoint(hostPrefix: "foo.")
@http(uri: "/EndpointOperation", method: "POST")
operation EndpointOperation {}


@httpRequestTests([
{
id: "RestJsonEndpointTraitWithHostLabel",
documentation: """
Operations can prepend to the given host if they define the
endpoint trait, and can use the host label trait to define
further customization based on user input.""",
protocol: restJson1,
method: "POST",
uri: "/EndpointOperation",
body: "{\"label\": \"bar\"}",
bodyMediaType: "application/json",
host: "example.com",
resolvedHost: "foo.bar.example.com",
params: {
label: "bar",
},
}
])
@endpoint(hostPrefix: "foo.{label}.")
@http(uri: "/EndpointWithHostLabelOperation", method: "POST")
operation EndpointWithHostLabelOperation {
input: HostLabelInput,
}

structure HostLabelInput {
@required
@hostLabel
label: String,
}
Loading