Skip to content

Commit

Permalink
feat: Add default trait support (#1696)
Browse files Browse the repository at this point in the history
* Don't add x-amz-content-sha256 header before request is handed off to CRT signer.

* Enable protocol tests that use defaults tag again.

* swiftlint

---------

Co-authored-by: Sichan Yoo <[email protected]>
  • Loading branch information
sichanyoo and Sichan Yoo committed Sep 6, 2024
1 parent 4ce6d05 commit aacff71
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@ public struct Sha256TreeHashMiddleware<OperationStackInput, OperationStackOutput
context: Context
) async throws {
switch request.body {
case .data(let data):
guard let data = data else {
return
}
if !request.headers.exists(name: X_AMZ_CONTENT_SHA256_HEADER_NAME) {
let sha256 = try data.computeSHA256().encodeToHexString()
builder.withHeader(name: X_AMZ_CONTENT_SHA256_HEADER_NAME, value: sha256)
}
case .data:
break
case .stream(let stream):
let streamBytes: Data?
let currentPosition = stream.position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public extension Context {
get { attributes.get(key: businessMetricsKey) ?? [:] }
set(newPair) {
var combined = businessMetrics
combined.merge(newPair) { (current, new) in new }
combined.merge(newPair) { (_, new) in new }
attributes.set(key: businessMetricsKey, value: combined)
}
}
Expand Down Expand Up @@ -82,7 +82,7 @@ public let businessMetricsKey = AttributeKey<Dictionary<String, String>>(name: "
"SIGV4A_SIGNING" : "S" : Y
"RESOLVED_ACCOUNT_ID" : "T" :
*/
fileprivate func setFlagsIntoContext(
private func setFlagsIntoContext(
config: UserAgentValuesFromConfig,
context: Context
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class AWSJSON1_0ProtocolGenerator : AWSHTTPBindingProtocolGenerator(AWSJSONCusto
"SDKAppliedContentEncoding_awsJson1_0",
"SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_0",
)
override val tagsToIgnore = setOf("defaults")
override fun getProtocolHttpBindingResolver(ctx: ProtocolGenerator.GenerationContext, defaultContentType: String):
HttpBindingResolver = AWSJSONHttpBindingResolver(ctx, defaultContentType)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class AWSJSON1_1ProtocolGenerator : AWSHTTPBindingProtocolGenerator(AWSJSONCusto
"SDKAppliedContentEncoding_awsJson1_1",
"SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_1",
)
override val tagsToIgnore = setOf("defaults")
override fun getProtocolHttpBindingResolver(ctx: ProtocolGenerator.GenerationContext, defaultContentType: String):
HttpBindingResolver = AWSJSONHttpBindingResolver(ctx, defaultContentType)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ open class AWSQueryProtocolGenerator : AWSHTTPBindingProtocolGenerator(AWSQueryC
"SDKAppliedContentEncoding_awsQuery",
"SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsQuery",
)
override val tagsToIgnore = setOf("defaults")

override fun addProtocolSpecificMiddleware(ctx: ProtocolGenerator.GenerationContext, operation: OperationShape) {
super.addProtocolSpecificMiddleware(ctx, operation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class EC2QueryProtocolGenerator : AWSHTTPBindingProtocolGenerator(EC2QueryCustom
"SDKAppliedContentEncoding_ec2Query",
"SDKAppendsGzipAndIgnoresHttpProvidedEncoding_ec2Query"
)
override val tagsToIgnore = setOf("defaults")

override fun addProtocolSpecificMiddleware(ctx: ProtocolGenerator.GenerationContext, operation: OperationShape) {
super.addProtocolSpecificMiddleware(ctx, operation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class AWSRestJson1ProtocolGenerator : AWSHTTPBindingProtocolGenerator(RestJSONCu
override val testsToIgnore = setOf(
"SDKAppliedContentEncoding_restJson1",
"SDKAppendedGzipAfterProvidedEncoding_restJson1",
// This test is disabled until Smithy v1.51.0 with the fix for the test gets released.
"RestJsonClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse"
)
override val tagsToIgnore = setOf("defaults")
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class RestXMLProtocolGenerator : AWSHTTPBindingProtocolGenerator(RestXMLCustomiz
"S3PreservesEmbeddedDotSegmentInUriLabel", // moved to s3-tests.smithy
"S3PreservesLeadingDotSegmentInUriLabel", // moved to s3-tests.smithy
)
override val tagsToIgnore = setOf("defaults")

override fun generateDeserializers(ctx: ProtocolGenerator.GenerationContext) {
super.generateDeserializers(ctx)
Expand Down

0 comments on commit aacff71

Please sign in to comment.