Skip to content

Commit

Permalink
Clean up some protocol tests
Browse files Browse the repository at this point in the history
A few protocol tests that were added to smithy-rs have been added
to smithy upstream, so can be removed. Some smithy-rs protocol
tests were also not being generated because they weren't attached
to the model, which has been fixed. One of these test cases,
RestJsonZeroAndFalseQueryValuesFixed, was also fixed in the same
manner as smithy-lang/smithy#2167.
  • Loading branch information
milesziemer committed Mar 5, 2024
1 parent fceb914 commit 5b49f2b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 82 deletions.
31 changes: 0 additions & 31 deletions codegen-client-test/model/rest-xml-extras.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ service RestXmlExtras {
StringHeader,
CreateFoo,
RequiredMember,
// TODO(https://github.com/smithy-lang/smithy-rs/issues/3315)
ZeroAndFalseQueryParams,
]
}

Expand Down Expand Up @@ -256,32 +254,3 @@ structure RequiredMemberInputOutput {
@required
requiredString: String
}

@httpRequestTests([
{
id: "RestXmlZeroAndFalseQueryParamsAreSerialized"
protocol: restXml
code: 200
method: "GET"
uri: "/ZeroAndFalseQueryParams"
body: ""
queryParams: [
"Zero=0",
"False=false"
]
params: {
zeroValue: 0
falseValue: false
}
}
])
@http(uri: "/ZeroAndFalseQueryParams", method: "GET")
operation ZeroAndFalseQueryParams {
input := {
@httpQuery("Zero")
zeroValue: Integer

@httpQuery("False")
falseValue: Boolean
}
}
43 changes: 5 additions & 38 deletions codegen-core/common-test-models/rest-json-extras.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use smithy.test#httpRequestTests
use smithy.test#httpResponseTests
use smithy.framework#ValidationException

// TODO(https://github.com/smithy-lang/smithy/pull/2132): Remove this test once it's fixed in Smithy
// TODO(https://github.com/smithy-lang/smithy/pull/2167): Remove this test once it's fixed in Smithy
apply AllQueryStringTypes @httpRequestTests([
{
id: "RestJsonZeroAndFalseQueryValuesFixed"
Expand All @@ -25,8 +25,8 @@ apply AllQueryStringTypes @httpRequestTests([
queryInteger: 0
queryBoolean: false
queryParamsMapOfStringList: {
queryInteger: ["0"]
queryBoolean: ["false"]
"Integer": ["0"]
"Boolean": ["false"]
}
}
}
Expand Down Expand Up @@ -89,11 +89,8 @@ service RestJsonExtras {
NullInNonSparse,
CaseInsensitiveErrorOperation,
EmptyStructWithContentOnWireOp,
// TODO(https://github.com/smithy-lang/smithy-rs/issues/2968): Remove the following once these tests are included in Smithy
// They're being added in https://github.com/smithy-lang/smithy/pull/1908
HttpPayloadWithUnion,
// TODO(https://github.com/smithy-lang/smithy-rs/issues/3315)
ZeroAndFalseQueryParams,
AllQueryStringTypes,
QueryPrecedence
],
errors: [ExtraError]
}
Expand Down Expand Up @@ -377,33 +374,3 @@ structure EmptyStructWithContentOnWireOpOutput {
operation EmptyStructWithContentOnWireOp {
output: EmptyStructWithContentOnWireOpOutput,
}
@http(uri: "/zero-and-false-query-params", method: "GET")
@httpRequestTests([
{
id: "RestJsonZeroAndFalseQueryParamsAreSerialized",
protocol: restJson1,
code: 200,
method: "GET",
uri: "/zero-and-false-query-params",
body: "",
queryParams: [
"Zero=0",
"False=false"
],
params: {
zeroValue: 0,
falseValue: false
}
}
])
operation ZeroAndFalseQueryParams {
input: ZeroAndFalseQueryParamsInput
}

structure ZeroAndFalseQueryParamsInput {
@httpQuery("Zero")
zeroValue: Integer

@httpQuery("False")
falseValue: Boolean
}
26 changes: 14 additions & 12 deletions codegen-server-test/typescript/model/pokemon.smithy
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
/// TODO(https://github.com/smithy-lang/smithy-rs/issues/1508)
/// reconcile this model with the main one living inside codegen-server-test/model/pokemon.smithy
/// once the Typescript implementation supports Streaming and Union shapes.
// TODO(https://github.com/smithy-lang/smithy-rs/issues/1508)
// reconcile this model with the main one living inside codegen-server-test/model/pokemon.smithy
// once the Typescript implementation supports Streaming and Union shapes.
$version: "1.0"

namespace com.aws.example.ts

use aws.protocols#restJson1
use com.aws.example#PokemonSpecies
use com.aws.example#GetServerStatistics
use com.aws.example#DoNothing
use com.aws.example#CheckHealth
use com.aws.example#DoNothing
use com.aws.example#GetServerStatistics
use com.aws.example#PokemonSpecies

/// The Pokémon Service allows you to retrieve information about Pokémon species.
@title("Pokémon Service")
@restJson1
service PokemonService {
version: "2021-12-01",
resources: [PokemonSpecies],
version: "2021-12-01"
resources: [
PokemonSpecies
]
operations: [
GetServerStatistics,
DoNothing,
CheckHealth,
],
GetServerStatistics
DoNothing
CheckHealth
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -805,15 +805,17 @@ class ServerProtocolTestGenerator(
private const val AwsJson11 = "aws.protocoltests.json#JsonProtocol"
private const val AwsJson10 = "aws.protocoltests.json10#JsonRpc10"
private const val RestJson = "aws.protocoltests.restjson#RestJson"
private const val RestJsonExtras = "aws.protocoltests.restjson#RestJsonExtras"
private const val RestJsonValidation = "aws.protocoltests.restjson.validation#RestJsonValidation"
private val ExpectFail: Set<FailingTest> =
setOf(
// Endpoint trait is not implemented yet, see https://github.com/smithy-lang/smithy-rs/issues/950.
FailingTest(RestJson, "RestJsonEndpointTrait", TestType.Request),
FailingTest(RestJson, "RestJsonEndpointTraitWithHostLabel", TestType.Request),
FailingTest(RestJson, "RestJsonOmitsEmptyListQueryValues", TestType.Request),
// TODO(https://github.com/smithy-lang/smithy/pull/2132): Remove this failing test once it's fixed in Smithy
// TODO(https://github.com/smithy-lang/smithy/pull/2167): Remove these failing tests once it's fixed in Smithy
FailingTest(RestJson, "RestJsonZeroAndFalseQueryValues", TestType.Request),
FailingTest(RestJsonExtras, "RestJsonZeroAndFalseQueryValues", TestType.Request),
// Tests involving `@range` on floats.
// Pending resolution from the Smithy team, see https://github.com/smithy-lang/smithy-rs/issues/2007.
FailingTest(RestJsonValidation, "RestJsonMalformedRangeFloat_case0", TestType.MalformedRequest),
Expand Down

0 comments on commit 5b49f2b

Please sign in to comment.