From 5b49f2bc8404d46bf0772f696dd542a227639485 Mon Sep 17 00:00:00 2001 From: Miles Ziemer Date: Tue, 5 Mar 2024 12:16:45 -0500 Subject: [PATCH] Clean up some protocol tests 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 https://github.com/smithy-lang/smithy/pull/2167. --- .../model/rest-xml-extras.smithy | 31 ------------- .../rest-json-extras.smithy | 43 +++---------------- .../typescript/model/pokemon.smithy | 26 +++++------ .../protocol/ServerProtocolTestGenerator.kt | 4 +- 4 files changed, 22 insertions(+), 82 deletions(-) diff --git a/codegen-client-test/model/rest-xml-extras.smithy b/codegen-client-test/model/rest-xml-extras.smithy index 2c18a35e92..b518ad09c6 100644 --- a/codegen-client-test/model/rest-xml-extras.smithy +++ b/codegen-client-test/model/rest-xml-extras.smithy @@ -21,8 +21,6 @@ service RestXmlExtras { StringHeader, CreateFoo, RequiredMember, - // TODO(https://github.com/smithy-lang/smithy-rs/issues/3315) - ZeroAndFalseQueryParams, ] } @@ -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 - } -} diff --git a/codegen-core/common-test-models/rest-json-extras.smithy b/codegen-core/common-test-models/rest-json-extras.smithy index 2667cad6c4..0acfec9f38 100644 --- a/codegen-core/common-test-models/rest-json-extras.smithy +++ b/codegen-core/common-test-models/rest-json-extras.smithy @@ -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" @@ -25,8 +25,8 @@ apply AllQueryStringTypes @httpRequestTests([ queryInteger: 0 queryBoolean: false queryParamsMapOfStringList: { - queryInteger: ["0"] - queryBoolean: ["false"] + "Integer": ["0"] + "Boolean": ["false"] } } } @@ -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] } @@ -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 -} diff --git a/codegen-server-test/typescript/model/pokemon.smithy b/codegen-server-test/typescript/model/pokemon.smithy index 7874a4f322..0a7fa125f0 100644 --- a/codegen-server-test/typescript/model/pokemon.smithy +++ b/codegen-server-test/typescript/model/pokemon.smithy @@ -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 + ] } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index e72ff691dd..b131103d7e 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -805,6 +805,7 @@ 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 = setOf( @@ -812,8 +813,9 @@ class ServerProtocolTestGenerator( 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),