mirror of https://github.com/smithy-lang/smithy-rs
Upgrade Smithy to 1.35 (#2892)
_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: david-perez <d@vidp.dev>
This commit is contained in:
parent
d2690e7ab1
commit
682dc7fb40
|
@ -614,6 +614,20 @@ class DefaultProtocolTestGenerator(
|
||||||
|
|
||||||
// These tests are not even attempted to be generated, either because they will not compile
|
// These tests are not even attempted to be generated, either because they will not compile
|
||||||
// or because they are flaky
|
// or because they are flaky
|
||||||
private val DisableTests = setOf<String>()
|
private val DisableTests = setOf<String>(
|
||||||
|
// 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",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.Expression
|
||||||
import software.amazon.smithy.rulesengine.language.syntax.expr.Literal
|
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.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.Context
|
||||||
import software.amazon.smithy.rust.codegen.client.smithy.endpoint.generators.FunctionRegistry
|
import software.amazon.smithy.rust.codegen.client.smithy.endpoint.generators.FunctionRegistry
|
||||||
import software.amazon.smithy.rust.codegen.core.rustlang.rust
|
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
|
import software.amazon.smithy.rust.codegen.core.testutil.unitTest
|
||||||
|
|
||||||
internal class ExprGeneratorTest {
|
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)
|
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
|
@Test
|
||||||
fun generateExprs() {
|
fun generateExprs() {
|
||||||
val boolEq = Expression.of(true).equal(true).shoop()
|
val boolEq = Expression.of(true).equal(true)
|
||||||
val strEq = Expression.of("helloworld").equal("goodbyeworld").not().shoop()
|
val strEq = Expression.of("helloworld").equal("goodbyeworld").not()
|
||||||
val combined = BooleanEquals.ofExpressions(boolEq, strEq).shoop()
|
val combined = BooleanEquals.ofExpressions(boolEq, strEq)
|
||||||
TestWorkspace.testProject().unitTest {
|
TestWorkspace.testProject().unitTest {
|
||||||
val generator = ExpressionGenerator(Ownership.Borrowed, testContext)
|
val generator = ExpressionGenerator(Ownership.Borrowed, testContext)
|
||||||
rust("assert_eq!(true, #W);", generator.generate(boolEq))
|
rust("assert_eq!(true, #W);", generator.generate(boolEq))
|
||||||
|
|
|
@ -230,26 +230,6 @@ class ServerProtocolTestGenerator(
|
||||||
// not been written with a server-side perspective in mind.
|
// not been written with a server-side perspective in mind.
|
||||||
private fun List<TestCase>.fixBroken(): List<TestCase> = this.map {
|
private fun List<TestCase>.fixBroken(): List<TestCase> = this.map {
|
||||||
when (it) {
|
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 -> {
|
is TestCase.MalformedRequestTest -> {
|
||||||
val howToFixIt = BrokenMalformedRequestTests[Pair(codegenContext.serviceShape.id.toString(), it.id)]
|
val howToFixIt = BrokenMalformedRequestTests[Pair(codegenContext.serviceShape.id.toString(), it.id)]
|
||||||
if (howToFixIt == null) {
|
if (howToFixIt == null) {
|
||||||
|
@ -259,6 +239,7 @@ class ServerProtocolTestGenerator(
|
||||||
TestCase.MalformedRequestTest(fixed)
|
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
|
// These tests are not even attempted to be generated, either because they will not compile
|
||||||
// or because they are flaky
|
// or because they are flaky
|
||||||
private val DisableTests = setOf<String>()
|
private val DisableTests = setOf<String>(
|
||||||
|
// 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(
|
private fun fixRestJsonAllQueryStringTypes(
|
||||||
testCase: HttpRequestTestCase,
|
testCase: HttpRequestTestCase,
|
||||||
|
@ -903,24 +902,6 @@ class ServerProtocolTestGenerator(
|
||||||
).asObjectNode().get(),
|
).asObjectNode().get(),
|
||||||
).build()
|
).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)
|
// TODO(https://github.com/awslabs/smithy/issues/1506)
|
||||||
private fun fixRestJsonMalformedPatternReDOSString(testCase: HttpMalformedRequestTestCase): HttpMalformedRequestTestCase {
|
private fun fixRestJsonMalformedPatternReDOSString(testCase: HttpMalformedRequestTestCase): HttpMalformedRequestTestCase {
|
||||||
val brokenResponse = testCase.response
|
val brokenResponse = testCase.response
|
||||||
|
@ -942,19 +923,11 @@ class ServerProtocolTestGenerator(
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are tests whose definitions in the `awslabs/smithy` repository are wrong.
|
// TODO(https://github.com/awslabs/smithy-rs/issues/1288): Move the fixed versions into
|
||||||
// This is because they have not been written from a server perspective, and as such the expected `params` field is incomplete.
|
// `rest-json-extras.smithy` and put the unfixed ones in `ExpectFail`: this has the
|
||||||
// TODO(https://github.com/awslabs/smithy-rs/issues/1288): Contribute a PR to fix them upstream.
|
// advantage that once our upstream PRs get merged and we upgrade to the next Smithy release, our build will
|
||||||
private val BrokenRequestTests = mapOf(
|
// fail and we will take notice to remove the fixes from `rest-json-extras.smithy`. This is exactly what the
|
||||||
// TODO(https://github.com/awslabs/smithy/pull/1564)
|
// client does.
|
||||||
// Pair(RestJson, "RestJsonAllQueryStringTypes") to ::fixRestJsonAllQueryStringTypes,
|
|
||||||
// TODO(https://github.com/awslabs/smithy/pull/1562)
|
|
||||||
Pair(RestJson, "RestJsonQueryStringEscaping") to ::fixRestJsonQueryStringEscaping,
|
|
||||||
)
|
|
||||||
|
|
||||||
private val BrokenResponseTests: Map<Pair<String, String>, KFunction1<HttpResponseTestCase, HttpResponseTestCase>> =
|
|
||||||
mapOf()
|
|
||||||
|
|
||||||
private val BrokenMalformedRequestTests: Map<Pair<String, String>, KFunction1<HttpMalformedRequestTestCase, HttpMalformedRequestTestCase>> =
|
private val BrokenMalformedRequestTests: Map<Pair<String, String>, KFunction1<HttpMalformedRequestTestCase, HttpMalformedRequestTestCase>> =
|
||||||
// TODO(https://github.com/awslabs/smithy/issues/1506)
|
// TODO(https://github.com/awslabs/smithy/issues/1506)
|
||||||
mapOf(
|
mapOf(
|
||||||
|
|
|
@ -17,8 +17,8 @@ smithy.rs.runtime.crate.version=0.0.0-smithy-rs-head
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
|
||||||
# codegen
|
# codegen
|
||||||
smithyGradlePluginVersion=0.6.0
|
smithyGradlePluginVersion=0.7.0
|
||||||
smithyVersion=1.29.0
|
smithyVersion=1.35.0
|
||||||
|
|
||||||
# kotlin
|
# kotlin
|
||||||
kotlinVersion=1.7.21
|
kotlinVersion=1.7.21
|
||||||
|
|
Loading…
Reference in New Issue