Unverified Commit 71c40d11 authored by Landon James's avatar Landon James Committed by GitHub
Browse files

Upgrade to Smithy 1.59 (#4185)

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->

Needed to bump our Smithy version to enable the work in
https://github.com/smithy-lang/smithy-rs/pull/4186.

## Description
<!--- Describe your changes in detail -->
Various changes, mostly to protocol tests, to align with the new Smithy
version. Discovered https://github.com/smithy-lang/smithy-rs/issues/4184


while working on this, which is a deeper bug that will be fixed in a
separate PR.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] For changes to the smithy-rs codegen or runtime crates, I have
created a changelog entry Markdown file in the `.changelog` directory,
specifying "client," "server," or both in the `applies_to` key.
- [ ] For changes to the AWS SDK, generated SDK code, or SDK runtime
crates, I have created a changelog entry Markdown file in the
`.changelog` directory, specifying "aws-sdk-rust" in the `applies_to`
key.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: default avatarysaito1001 <awsaito@amazon.com>
parent 36a82ddd
Loading
Loading
Loading
Loading
+5564 −2633

File changed and moved.

Preview size limit exceeded, changes collapsed.

+16 −50
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.Broke
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.FailingTest
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTestGenerator
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId.AWS_JSON_10
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId.REST_JSON
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId.REST_XML
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId.RPC_V2_CBOR
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.TestCase
import software.amazon.smithy.rust.codegen.core.util.PANIC
@@ -73,64 +73,30 @@ class ClientProtocolTestGenerator(
        private val ExpectFail =
            setOf<FailingTest>(
                // Failing because we don't serialize default values if they match the default.
                FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ClientPopulatesDefaultsValuesWhenMissingInResponse"),
                FailingTest.ResponseTest(AWS_JSON_10, "AwsJson10ClientPopulatesDefaultsValuesWhenMissingInResponse"),
                FailingTest.ResponseTest(
                    AWS_JSON_10,
                    "AwsJson10ClientErrorCorrectsWithDefaultValuesWhenServerFailsToSerializeRequiredValues",
                ),
                FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ClientUsesExplicitlyProvidedMemberValuesOverDefaults"),
                FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ClientPopulatesDefaultValuesInInput"),
                FailingTest.RequestTest(REST_JSON, "RestJsonClientPopulatesDefaultValuesInInput"),
                FailingTest.RequestTest(REST_JSON, "RestJsonClientUsesExplicitlyProvidedMemberValuesOverDefaults"),
                FailingTest.ResponseTest(REST_JSON, "RestJsonClientPopulatesDefaultsValuesWhenMissingInResponse"),
                FailingTest.RequestTest(RPC_V2_CBOR, "RpcV2CborClientPopulatesDefaultValuesInInput"),
                FailingTest.ResponseTest(
                    RPC_V2_CBOR,
                    "RpcV2CborClientPopulatesDefaultsValuesWhenMissingInResponse",
                ),
                FailingTest.RequestTest(RPC_V2_CBOR, "RpcV2CborClientUsesExplicitlyProvidedMemberValuesOverDefaults"),
                // Failing due to bug in httpPreficHeaders serialization
                // https://github.com/smithy-lang/smithy-rs/issues/4184
                FailingTest.RequestTest(REST_XML, "HttpEmptyPrefixHeadersRequestClient"),
                FailingTest.RequestTest(REST_JSON, "RestJsonHttpEmptyPrefixHeadersRequestClient"),
            )

        private val BrokenTests:
            Set<BrokenTest> =
            // The two tests below were fixed in "https://github.com/smithy-lang/smithy/pull/2423", but the fixes didn't make
            // it into the build artifact for 1.52
            setOf(
                BrokenTest.ResponseTest(
                    ServiceShapeId.REST_XML,
                    "NestedXmlMapWithXmlNameDeserializes",
                    howToFixItFn = ::fixRestXMLInvalidRootNodeResponse,
                    inAtLeast = setOf("1.52.0"),
                    trackedIn =
                        setOf(
                            "https://github.com/smithy-lang/smithy/pull/2423",
                        ),
                ),
                BrokenTest.RequestTest(
                    ServiceShapeId.REST_XML,
                    "NestedXmlMapWithXmlNameSerializes",
                    howToFixItFn = ::fixRestXMLInvalidRootNodeRequest,
                    inAtLeast = setOf("1.52.0"),
                    trackedIn =
                        setOf(
                            "https://github.com/smithy-lang/smithy/pull/2423",
                        ),
                ),
            )

        private fun fixRestXMLInvalidRootNodeResponse(testCase: TestCase.ResponseTest): TestCase.ResponseTest {
            val fixedBody =
                testCase.testCase.body.get()
                    .replace("NestedXmlMapWithXmlNameResponse", "NestedXmlMapWithXmlNameInputOutput")
            return TestCase.ResponseTest(
                testCase.testCase.toBuilder()
                    .body(fixedBody)
                    .build(),
                testCase.targetShape,
            )
        }

        private fun fixRestXMLInvalidRootNodeRequest(testCase: TestCase.RequestTest): TestCase.RequestTest {
            val fixedBody =
                testCase.testCase.body.get()
                    .replace("NestedXmlMapWithXmlNameRequest", "NestedXmlMapWithXmlNameInputOutput")
            return TestCase.RequestTest(
                testCase.testCase.toBuilder()
                    .body(fixedBody)
                    .build(),
            )
        }
            Set<BrokenTest> = setOf()
    }

    override val appliesTo: AppliesTo
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ use smithy.rules#endpointTests
        {
            "params": {
                "bar": "a b",
                "endpoint": "asdf",
            }
            "operationInputs": [{
                "operationName": "GetThing",
+15 −4
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ class ServerProtocolTestGenerator(
                FailingTest.RequestTest(REST_JSON, "RestJsonEndpointTrait"),
                FailingTest.RequestTest(REST_JSON, "RestJsonEndpointTraitWithHostLabel"),
                FailingTest.RequestTest(REST_JSON, "RestJsonOmitsEmptyListQueryValues"),
                FailingTest.ResponseTest(REST_JSON, "RestJsonNullAndEmptyHeaders"),
                FailingTest.ResponseTest(REST_JSON, "RestJsonHttpPayloadWithStructureAndEmptyResponseBody"),
                // Tests involving `@range` on floats.
                // Pending resolution from the Smithy team, see https://github.com/smithy-lang/smithy-rs/issues/2007.
                FailingTest.MalformedRequestTest(REST_JSON_VALIDATION, "RestJsonMalformedRangeFloat_case0"),
@@ -137,9 +139,14 @@ class ServerProtocolTestGenerator(
                // TODO(https://github.com/awslabs/smithy/issues/1737): Specs on @internal, @tags, and enum values need to be clarified
                FailingTest.MalformedRequestTest(REST_JSON_VALIDATION, "RestJsonMalformedEnumTraitString_case0"),
                FailingTest.MalformedRequestTest(REST_JSON_VALIDATION, "RestJsonMalformedEnumTraitString_case1"),
                FailingTest.MalformedRequestTest(
                    REST_JSON,
                    "RestJsonWithoutBodyEmptyInputExpectsEmptyContentType",
                ),
                // These tests are broken because they are missing a target header.
                FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ServerPopulatesNestedDefaultsWhenMissingInRequestBody"),
                FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ServerPopulatesDefaultsWhenMissingInRequestBody"),
                FailingTest.ResponseTest(AWS_JSON_11, "AwsJson11IntEnums"),
                // For the following 4 tests, response defaults are not set when builders are not used
                // https://github.com/smithy-lang/smithy-rs/issues/3339
                FailingTest.ResponseTest(AWS_JSON_10, "AwsJson10ServerPopulatesDefaultsInResponseWhenMissingInParams"),
@@ -152,12 +159,17 @@ class ServerProtocolTestGenerator(
                // TODO(https://github.com/smithy-lang/smithy-rs/issues/3339)
                FailingTest.ResponseTest(RPC_V2_CBOR, "RpcV2CborServerPopulatesDefaultsInResponseWhenMissingInParams"),
                FailingTest.ResponseTest(REST_JSON, "RestJsonServerPopulatesDefaultsInResponseWhenMissingInParams"),
                FailingTest.ResponseTest(REST_JSON, "RestJsonServerPopulatesNestedDefaultValuesWhenMissingInInResponseParams"),
                FailingTest.ResponseTest(
                    REST_JSON,
                    "RestJsonServerPopulatesNestedDefaultValuesWhenMissingInInResponseParams",
                ),
                // TODO(https://github.com/smithy-lang/smithy-rs/issues/3743): We need to be able to configure
                //  instantiator so that it uses default _modeled_ values; `""` is not a valid enum value for `defaultEnum`.
                FailingTest.RequestTest(RPC_V2_CBOR, "RpcV2CborServerPopulatesDefaultsWhenMissingInRequestBody"),
                // TODO(https://github.com/smithy-lang/smithy-rs/issues/3735): Null `Document` may come through a request even though its shape is `@required`
                FailingTest.RequestTest(REST_JSON, "RestJsonServerPopulatesDefaultsWhenMissingInRequestBody"),
                // TODO(https://github.com/smithy-lang/smithy-rs/issues/4184): Issue in both Client and Server with httpPrefixHeaders
                FailingTest.ResponseTest(REST_JSON, "RestJsonHttpEmptyPrefixHeadersResponseServer"),
            )

        private val BrokenTests:
@@ -444,8 +456,7 @@ class ServerProtocolTestGenerator(
                    // We also escape to avoid interactions with templating in the case where the body contains `#`.
                    val sanitizedBody = escape(body.replace("\u000c", "\\u{000c}")).dq()

                    val encodedBody =
                        """
                    val encodedBody = """
                        #{Bytes}::copy_from_slice(
                            &#{decode_body_data}($sanitizedBody.as_bytes(), #{MediaType}::from(${(bodyMediaType ?: "unknown").dq()}))
                        )
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ smithy.rs.runtime.crate.unstable.version=0.60.6
kotlin.code.style=official
# codegen
smithyGradlePluginVersion=0.9.0
smithyVersion=1.52.0
smithyVersion=1.59.0
allowLocalDeps=false
# kotlin
kotlinVersion=1.9.20