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 Content-Type params #2296

Merged
merged 2 commits into from
Jun 3, 2024
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
44 changes: 44 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_0/content-type.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// This file defines test cases that test Content-Type headers.

$version: "2.0"

namespace aws.protocoltests.json10

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

/// The example tests how servers must support requests
/// containing a `Content-Type` header with parameters.
operation ContentTypeParameters {
input: ContentTypeParametersInput,
output: ContentTypeParametersOutput
}

apply ContentTypeParameters @httpRequestTests([
{
id: "AwsJson10MustSupportParametersInContentType",
documentation: "A server should ignore parameters added to the content type",
protocol: awsJson1_0,
method: "POST",
headers: {
"Content-Type": "application/x-amz-json-1.0; charset=utf-8",
"X-Amz-Target": "JsonRpc10.ContentTypeParameters",
},
uri: "/",
body: "{\"value\":5}",
bodyMediaType: "application/json",
params: {
value: 5,
},
appliesTo: "server"
}
])

@input
structure ContentTypeParametersInput {
value: Integer,
}

@output
structure ContentTypeParametersOutput {}
3 changes: 3 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_0/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ service JsonRpc10 {
// requestCompression trait tests
PutWithContentEncoding,

// Content-Type header tests
ContentTypeParameters,

OperationWithDefaults,
OperationWithRequiredMembers,
OperationWithNestedStructure
Expand Down
44 changes: 44 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_1/content-type.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// This file defines test cases that test Content-Type headers.

$version: "2.0"

namespace aws.protocoltests.json

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

/// The example tests how servers must support requests
/// containing a `Content-Type` header with parameters.
operation ContentTypeParameters {
input: ContentTypeParametersInput,
output: ContentTypeParametersOutput
}

apply ContentTypeParameters @httpRequestTests([
{
id: "AwsJson11MustSupportParametersInContentType",
documentation: "A server should ignore parameters added to the content type",
protocol: awsJson1_1,
method: "POST",
headers: {
"Content-Type": "application/x-amz-json-1.1; charset=utf-8",
"X-Amz-Target": "JsonProtocol.ContentTypeParameters",
},
uri: "/",
body: "{\"value\":5}",
bodyMediaType: "application/json",
params: {
value: 5,
},
appliesTo: "server"
}
])

@input
structure ContentTypeParametersInput {
value: Integer,
}

@output
structure ContentTypeParametersOutput {}
3 changes: 3 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_1/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ service JsonProtocol {

// requestCompression trait tests
PutWithContentEncoding

// Content-Type header tests
ContentTypeParameters,
],
}

Expand Down
41 changes: 41 additions & 0 deletions smithy-aws-protocol-tests/model/restJson1/content-type.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This file defines test cases that test Content-Type headers.

$version: "2.0"

namespace aws.protocoltests.restjson

use aws.protocols#restJson1
use aws.protocoltests.shared#DateTime
use smithy.test#httpRequestTests

/// The example tests how servers must support requests
/// containing a `Content-Type` header with parameters.
@http(uri: "/ContentTypeParameters", method: "POST")
operation ContentTypeParameters {
input: ContentTypeParametersInput,
output: ContentTypeParametersOutput,
}

apply ContentTypeParameters @httpRequestTests([
{
id: "RestJsonMustSupportParametersInContentType",
documentation: "A server should ignore parameters added to the content type",
uri: "/ContentTypeParameters",
method: "POST",
protocol: "aws.protocols#restJson1",
body: "{\"value\":5}",
headers: { "Content-Type": "application/json; charset=utf-8" },
params: {
value: 5,
},
appliesTo: "server",
},
])

@input
structure ContentTypeParametersInput {
value: Integer,
}

@output
structure ContentTypeParametersOutput {}
5 changes: 4 additions & 1 deletion smithy-aws-protocol-tests/model/restJson1/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ service RestJson {
FractionalSeconds,

// requestCompression trait tests
PutWithContentEncoding
PutWithContentEncoding,

// Content-Type header tests
ContentTypeParameters,

// defaults
OperationWithDefaults
Expand Down
44 changes: 44 additions & 0 deletions smithy-aws-protocol-tests/model/restXml/content-type.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// This file defines test cases that test Content-Type headers.

$version: "2.0"

namespace aws.protocoltests.restxml

use aws.protocols#restXml
use aws.protocoltests.shared#DateTime
use smithy.test#httpRequestTests

/// The example tests how servers must support requests
/// containing a `Content-Type` header with parameters.
@http(uri: "/ContentTypeParameters", method: "PUT")
operation ContentTypeParameters {
input: ContentTypeParametersInput,
output: ContentTypeParametersOutput
}

apply ContentTypeParameters @httpRequestTests([
{
id: "RestXmlMustSupportParametersInContentType",
documentation: "A server should ignore parameters added to the content type",
protocol: restXml,
method: "PUT",
headers: {
"Content-Type": "application/xml; charset=utf-8"
},
uri: "/ContentTypeParameters",
body: "<ContentTypeParametersInput><value>5</value></ContentTypeParametersInput>",
bodyMediaType: "application/xml",
params: {
value: 5,
},
appliesTo: "server"
}
])

@input
structure ContentTypeParametersInput {
value: Integer,
}

@output
structure ContentTypeParametersOutput {}
5 changes: 4 additions & 1 deletion smithy-aws-protocol-tests/model/restXml/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ service RestXml {
FractionalSeconds,

// requestCompression trait tests
PutWithContentEncoding
PutWithContentEncoding,

// Content-Type header tests
ContentTypeParameters,
]
}
Loading