diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index fc4c4c2578b5c5f185517bd30b00e87999da307c..b4f5b3b8b6c9abf8c87eead5c93d03e4b93133b6 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -9,4 +9,10 @@ # message = "Fix typos in module documentation for generated crates" # references = ["smithy-rs#920"] # meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"} -# author = "rcoh" \ No newline at end of file +# author = "rcoh" + +[[aws-sdk-rust]] +message = "Fix aws-sdk-rust#930 (PutSnapshotBlock)" +references = ["smithy-rs#3126", "aws-sdk-rust#930"] +meta = { "breaking" = false, "tada" = false, "bug" = true } +author = "rcoh" diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4AuthDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4AuthDecorator.kt index 46f070e18e26cadf438855ed57e15946973e80d6..b56fa513bb4d90db4f64bc75ef063371133f0f1f 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4AuthDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4AuthDecorator.kt @@ -226,7 +226,7 @@ private class AuthOperationCustomization(private val codegenContext: ClientCodeg if (authSchemes.containsKey(SigV4Trait.ID)) { val unsignedPayload = section.operationShape.hasTrait() val doubleUriEncode = unsignedPayload || !disableDoubleEncode(codegenContext.serviceShape) - val contentSha256Header = needsAmzSha256(codegenContext.serviceShape) + val contentSha256Header = needsAmzSha256(codegenContext.serviceShape) || unsignedPayload val normalizeUrlPath = !disableUriPathNormalization(codegenContext.serviceShape) rustTemplate( """ diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/SigV4AuthDecoratorTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/SigV4AuthDecoratorTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..64f35d197fadaee984f3176ae8290b366bbcbb38 --- /dev/null +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/SigV4AuthDecoratorTest.kt @@ -0,0 +1,64 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +package software.amazon.smithy.rustsdk + +import org.junit.jupiter.api.Test +import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel + +class SigV4AuthDecoratorTest { + private val modelWithSigV4AuthScheme = """ + namespace test + + use aws.auth#sigv4 + use aws.api#service + use aws.protocols#restJson1 + use smithy.rules#endpointRuleSet + use aws.auth#unsignedPayload + use smithy.test#httpRequestTests + + @auth([sigv4]) + @sigv4(name: "dontcare") + @restJson1 + @endpointRuleSet({ + "version": "1.0", + "rules": [{ "type": "endpoint", "conditions": [], "endpoint": { "url": "https://example.com" } }], + "parameters": { + "endpoint": { "required": true, "type": "string", "builtIn": "SDK::Endpoint" }, + } + }) + @service(sdkId: "dontcare") + service TestService { version: "2023-01-01", operations: [SomeOperation] } + structure SomeOutput { something: String } + + structure SomeInput { + @httpPayload + something: Bytestream + } + + @streaming + blob Bytestream + + @httpRequestTests([{ + id: "unsignedPayload", + protocol: restJson1, + method: "POST", + uri: "/", + params: { + something: "hello" + }, + headers: { + "x-amz-content-sha256": "UNSIGNED-PAYLOAD", + }, + }]) + @unsignedPayload + @http(uri: "/", method: "POST") + operation SomeOperation { input: SomeInput, output: SomeOutput } + """.asSmithyModel() + + @Test + fun unsignedPayloadSetsCorrectHeader() { + awsSdkIntegrationTest(modelWithSigV4AuthScheme) { _, _ -> } + } +}