diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt index 6c08785bf..2f994788f 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt @@ -614,6 +614,20 @@ class DefaultProtocolTestGenerator( // These tests are not even attempted to be generated, either because they will not compile // or because they are flaky - private val DisableTests = setOf() + private val DisableTests = setOf( + // TODO(https://github.com/awslabs/smithy-rs/issues/2891): Implement support for `@requestCompression` + "SDKAppendedGzipAfterProvidedEncoding_restJson1", + "SDKAppendedGzipAfterProvidedEncoding_restXml", + "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_0", + "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_1", + "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsQuery", + "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_ec2Query", + "SDKAppliedContentEncoding_awsJson1_0", + "SDKAppliedContentEncoding_awsJson1_1", + "SDKAppliedContentEncoding_awsQuery", + "SDKAppliedContentEncoding_ec2Query", + "SDKAppliedContentEncoding_restJson1", + "SDKAppliedContentEncoding_restXml", + ) } } diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/ExpressionGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/ExpressionGeneratorTest.kt index 34781b1ea..823d6ace7 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/ExpressionGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/ExpressionGeneratorTest.kt @@ -14,7 +14,6 @@ import software.amazon.smithy.rulesengine.language.syntax.Identifier import software.amazon.smithy.rulesengine.language.syntax.expr.Expression import software.amazon.smithy.rulesengine.language.syntax.expr.Literal import software.amazon.smithy.rulesengine.language.syntax.expr.Template -import software.amazon.smithy.rulesengine.language.syntax.fn.LibraryFunction import software.amazon.smithy.rust.codegen.client.smithy.endpoint.Context import software.amazon.smithy.rust.codegen.client.smithy.endpoint.generators.FunctionRegistry import software.amazon.smithy.rust.codegen.core.rustlang.rust @@ -26,25 +25,13 @@ import software.amazon.smithy.rust.codegen.core.testutil.compileAndTest import software.amazon.smithy.rust.codegen.core.testutil.unitTest internal class ExprGeneratorTest { - /** - * This works around a bug in smithy-endpoint-rules where the constructors on functions like `BooleanEquals` - * hit the wrong branch in the visitor (but when they get parsed, they hit the right branch). - */ - fun Expression.shoop() = Expression.fromNode(this.toNode()) private val testContext = Context(FunctionRegistry(listOf()), TestRuntimeConfig) - @Test - fun `fail when smithy is fixed`() { - check(BooleanEquals.ofExpressions(Expression.of(true), Expression.of(true)) is LibraryFunction) { - "smithy has been fixed, shoop can be removed" - } - } - @Test fun generateExprs() { - val boolEq = Expression.of(true).equal(true).shoop() - val strEq = Expression.of("helloworld").equal("goodbyeworld").not().shoop() - val combined = BooleanEquals.ofExpressions(boolEq, strEq).shoop() + val boolEq = Expression.of(true).equal(true) + val strEq = Expression.of("helloworld").equal("goodbyeworld").not() + val combined = BooleanEquals.ofExpressions(boolEq, strEq) TestWorkspace.testProject().unitTest { val generator = ExpressionGenerator(Ownership.Borrowed, testContext) rust("assert_eq!(true, #W);", generator.generate(boolEq)) 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 74978699c..ee0038e53 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 @@ -230,26 +230,6 @@ class ServerProtocolTestGenerator( // not been written with a server-side perspective in mind. private fun List.fixBroken(): List = this.map { when (it) { - is TestCase.RequestTest -> { - val howToFixIt = BrokenRequestTests[Pair(codegenContext.serviceShape.id.toString(), it.id)] - if (howToFixIt == null) { - it - } else { - val fixed = howToFixIt(it.testCase, it.operationShape) - TestCase.RequestTest(fixed, it.operationShape) - } - } - - is TestCase.ResponseTest -> { - val howToFixIt = BrokenResponseTests[Pair(codegenContext.serviceShape.id.toString(), it.id)] - if (howToFixIt == null) { - it - } else { - val fixed = howToFixIt(it.testCase) - TestCase.ResponseTest(fixed, it.targetShape) - } - } - is TestCase.MalformedRequestTest -> { val howToFixIt = BrokenMalformedRequestTests[Pair(codegenContext.serviceShape.id.toString(), it.id)] if (howToFixIt == null) { @@ -259,6 +239,7 @@ class ServerProtocolTestGenerator( TestCase.MalformedRequestTest(fixed) } } + else -> it } } @@ -847,7 +828,25 @@ class ServerProtocolTestGenerator( // These tests are not even attempted to be generated, either because they will not compile // or because they are flaky - private val DisableTests = setOf() + private val DisableTests = setOf( + // TODO(https://github.com/awslabs/smithy-rs/issues/2891): Implement support for `@requestCompression` + "SDKAppendedGzipAfterProvidedEncoding_restJson1", + "SDKAppendedGzipAfterProvidedEncoding_restXml", + "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_0", + "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_1", + "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsQuery", + "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_ec2Query", + "SDKAppliedContentEncoding_awsJson1_0", + "SDKAppliedContentEncoding_awsJson1_1", + "SDKAppliedContentEncoding_awsQuery", + "SDKAppliedContentEncoding_ec2Query", + "SDKAppliedContentEncoding_restJson1", + "SDKAppliedContentEncoding_restXml", + + // RestXml S3 tests that fail to compile + "S3EscapeObjectKeyInUriLabel", + "S3EscapePathObjectKeyInUriLabel", + ) private fun fixRestJsonAllQueryStringTypes( testCase: HttpRequestTestCase, @@ -903,24 +902,6 @@ class ServerProtocolTestGenerator( ).asObjectNode().get(), ).build() - private fun fixRestJsonQueryStringEscaping( - testCase: HttpRequestTestCase, - @Suppress("UNUSED_PARAMETER") - operationShape: OperationShape, - ): HttpRequestTestCase = - testCase.toBuilder().params( - Node.parse( - """ - { - "queryString": "%:/?#[]@!${'$'}&'()*+,;=😹", - "queryParamsMapOfStringList": { - "String": ["%:/?#[]@!${'$'}&'()*+,;=😹"] - } - } - """.trimMargin(), - ).asObjectNode().get(), - ).build() - // TODO(https://github.com/awslabs/smithy/issues/1506) private fun fixRestJsonMalformedPatternReDOSString(testCase: HttpMalformedRequestTestCase): HttpMalformedRequestTestCase { val brokenResponse = testCase.response @@ -942,19 +923,11 @@ class ServerProtocolTestGenerator( .build() } - // These are tests whose definitions in the `awslabs/smithy` repository are wrong. - // This is because they have not been written from a server perspective, and as such the expected `params` field is incomplete. - // TODO(https://github.com/awslabs/smithy-rs/issues/1288): Contribute a PR to fix them upstream. - private val BrokenRequestTests = mapOf( - // TODO(https://github.com/awslabs/smithy/pull/1564) - // Pair(RestJson, "RestJsonAllQueryStringTypes") to ::fixRestJsonAllQueryStringTypes, - // TODO(https://github.com/awslabs/smithy/pull/1562) - Pair(RestJson, "RestJsonQueryStringEscaping") to ::fixRestJsonQueryStringEscaping, - ) - - private val BrokenResponseTests: Map, KFunction1> = - mapOf() - + // TODO(https://github.com/awslabs/smithy-rs/issues/1288): Move the fixed versions into + // `rest-json-extras.smithy` and put the unfixed ones in `ExpectFail`: this has the + // advantage that once our upstream PRs get merged and we upgrade to the next Smithy release, our build will + // fail and we will take notice to remove the fixes from `rest-json-extras.smithy`. This is exactly what the + // client does. private val BrokenMalformedRequestTests: Map, KFunction1> = // TODO(https://github.com/awslabs/smithy/issues/1506) mapOf( diff --git a/gradle.properties b/gradle.properties index aa791db00..ccadd9016 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,8 +17,8 @@ smithy.rs.runtime.crate.version=0.0.0-smithy-rs-head kotlin.code.style=official # codegen -smithyGradlePluginVersion=0.6.0 -smithyVersion=1.29.0 +smithyGradlePluginVersion=0.7.0 +smithyVersion=1.35.0 # kotlin kotlinVersion=1.7.21