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

Clarify request test host settings #951

Merged
merged 1 commit into from
Oct 25, 2021
Merged
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
38 changes: 33 additions & 5 deletions docs/source/1.0/spec/http-protocol-compliance-tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,26 @@ that support the following members:
the query string (for example, "/foo/bar").
* - host
- ``string``
- The host / endpoint provided to the client (for example, "example.com").
- The host or endpoint provided as input used to generate the HTTP
request (for example, "example.com").

``host`` MAY contain a path to indicate a base path from which each
operation in the service is appended to. For example, given a ``host``
of ``example.com/foo/bar`` and an operation path of ``/MyOperation``,
the resolved host of the operation is ``example.com`` and the resolved
path is ``/foo/bar/MyOperation``.
* - resolvedHost
- ``string``
- The host / endpoint that the client should send to, not including the
path or scheme (for example, "prefix.example.com").
- The expected host present in the ``Host`` header of the request, not
including the path or scheme (for example, "prefix.example.com"). If no
resolvedHost is defined, then no assertions are made about the resolved
host for the request.

This can differ from the ``host`` provided to the client if the
operation has a member with the :ref:`endpoint-trait`.

This can differ from the host provided to the client if, for instance,
the operation has a member with the :ref:`endpoint-trait`.
Server implementations SHOULD ignore discrepancies in paths when
comparing the ``host`` and ``resolvedHost`` properties.
* - authScheme
- shape ID
- A shape ID that specifies the optional authentication scheme to
Expand Down Expand Up @@ -258,17 +265,21 @@ that uses :ref:`HTTP binding traits <http-traits>`.

use smithy.test#httpRequestTests

@endpoint(hostPrefix: "{hostLabel}.prefix.")
@http(method: "POST", uri: "/")
@httpRequestTests([
{
id: "say_hello",
protocol: exampleProtocol,
params: {
"hostLabel": "foo",
"greeting": "Hi",
"name": "Teddy",
"query": "Hello there"
},
method: "POST",
host: "example.com",
resolvedHost: "foo.prefix.example.com",
uri: "/",
queryParams: [
"Hi=Hello%20there"
Expand All @@ -285,6 +296,10 @@ that uses :ref:`HTTP binding traits <http-traits>`.
}

structure SayHelloInput {
@required
@hostLabel
hostLabel: String,

@httpHeader("X-Greeting")
greeting: String,

Expand All @@ -305,6 +320,9 @@ that uses :ref:`HTTP binding traits <http-traits>`.
"target": "smithy.example#SayHelloInput"
},
"traits": {
"smithy.api#endpoint": {
"hostPrefix": "{hostLabel}.prefix."
},
"smithy.api#http": {
"method": "POST",
"uri": "/",
Expand All @@ -315,6 +333,8 @@ that uses :ref:`HTTP binding traits <http-traits>`.
"id": "say_hello",
"protocol": "smithy.example#exampleProtocol",
"method": "POST",
"host": "example.com",
"resolvedHost": "foo.prefix.example.com",
"uri": "/",
"headers": {
"X-Greeting": "Hi"
Expand All @@ -325,6 +345,7 @@ that uses :ref:`HTTP binding traits <http-traits>`.
"body": "{\"name\": \"Teddy\"}",
"bodyMediaType": "application/json"
"params": {
"hostLabel": "foo",
"greeting": "Hi",
"name": "Teddy",
"query": "Hello there"
Expand All @@ -336,6 +357,13 @@ that uses :ref:`HTTP binding traits <http-traits>`.
"smithy.example#SayHelloInput": {
"type": "structure",
"members": {
"hostLabel": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": {},
"smithy.api#hostLabel": {}
}
},
"greeting": {
"target": "smithy.api#String",
"traits": {
Expand Down