generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 31
kn/misc: enable various ignored tests #1257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
dd715a1
Re-enable aws-signing-tests
lauzadis 61c9b69
Re-enable `testReadAfterExecutionSuppressedException`
lauzadis f5660b5
ktlint
lauzadis 1281338
Re-enable some tests
lauzadis 986907f
Initialize CRT in CrtAwsSigner
lauzadis 9f8999e
Update FIXME message
lauzadis 3fca267
Ignore SigV4a test on Native
lauzadis ba8f1cb
Re-enable `AwsChunkedByteReadChannelTestBase`
lauzadis 3bbc14a
Re-enable `AwsChunkedTestBase`
lauzadis 00d10a5
Initialize CRT runtime to get correct error code
lauzadis eac0502
Update FIXME message
lauzadis a0d2fc5
ktlint
lauzadis d8878a3
Implement transferRequestBody
lauzadis 1eebd5e
Update FIXME message
lauzadis 27af57e
Make `DefaultAwsSigner` expect/actual, point to CRT signer on Native
lauzadis 8d73a86
ktlint
lauzadis ed5da6b
Unignore passing test
lauzadis 5ad9d5e
Update FIXME message
lauzadis cf45c86
CI
lauzadis 6b1756b
CI
lauzadis eeb8463
CI
lauzadis c5905cd
Use setup-build action in artifact-size-metrics to pull in aws-crt-ko…
lauzadis 11dac4e
Try to fix path
lauzadis 2857ecd
CI glitch: size-check Expected — Waiting for status to be reported
lauzadis 3580da4
Temporarily remove `size-check`
lauzadis d4bb8e4
Revert "Temporarily remove `size-check`"
lauzadis 56d6f71
Add a FIXME comment for `ex` / `ex.cause`
lauzadis 4ea1a06
Address nit / `run { ... }`
lauzadis d17bf67
Remove getter for `DefaultAwsSigner` values
lauzadis 5621fe0
Add an explanation for CRT.initRuntime
lauzadis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
...-signing-default/jvm/src/aws/smithy/kotlin/runtime/auth/awssigning/DefaultAwsSignerJVM.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| /* | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package aws.smithy.kotlin.runtime.auth.awssigning | ||
|
|
||
| import aws.smithy.kotlin.runtime.ExperimentalApi | ||
| import aws.smithy.kotlin.runtime.http.Headers | ||
| import aws.smithy.kotlin.runtime.http.request.HttpRequest | ||
| import aws.smithy.kotlin.runtime.telemetry.TelemetryProvider | ||
| import aws.smithy.kotlin.runtime.telemetry.logging.logger | ||
| import kotlin.coroutines.coroutineContext | ||
|
|
||
| /** The default implementation of [AwsSigner] */ | ||
| public actual val DefaultAwsSigner: AwsSigner = DefaultAwsSignerImpl() | ||
|
|
||
| /** Creates a customized instance of [AwsSigner] */ | ||
| @Suppress("ktlint:standard:function-naming") | ||
| public fun DefaultAwsSigner(block: DefaultAwsSignerBuilder.() -> Unit): AwsSigner = | ||
| DefaultAwsSignerBuilder().apply(block).build() | ||
|
|
||
| /** A builder class for creating instances of [AwsSigner] using the default implementation */ | ||
| public class DefaultAwsSignerBuilder { | ||
| public var telemetryProvider: TelemetryProvider? = null | ||
|
|
||
| public fun build(): AwsSigner = DefaultAwsSignerImpl( | ||
| telemetryProvider = telemetryProvider, | ||
| ) | ||
| } | ||
|
|
||
| private val AwsSigningAlgorithm.signatureCalculator | ||
| get() = when (this) { | ||
| AwsSigningAlgorithm.SIGV4 -> SignatureCalculator.SigV4 | ||
| AwsSigningAlgorithm.SIGV4_ASYMMETRIC -> SignatureCalculator.SigV4a | ||
| } | ||
|
|
||
| @OptIn(ExperimentalApi::class) | ||
| internal class DefaultAwsSignerImpl( | ||
| private val canonicalizer: Canonicalizer = Canonicalizer.Default, | ||
| private val requestMutator: RequestMutator = RequestMutator.Default, | ||
| private val telemetryProvider: TelemetryProvider? = null, | ||
| ) : AwsSigner { | ||
| override suspend fun sign(request: HttpRequest, config: AwsSigningConfig): AwsSigningResult<HttpRequest> { | ||
| val logger = telemetryProvider?.loggerProvider?.getOrCreateLogger("DefaultAwsSigner") | ||
| ?: coroutineContext.logger<DefaultAwsSignerImpl>() | ||
|
|
||
| val canonical = canonicalizer.canonicalRequest(request, config) | ||
| if (config.logRequest) { | ||
| logger.trace { "Canonical request:\n${canonical.requestString}" } | ||
| } | ||
|
|
||
| val signatureCalculator = config.algorithm.signatureCalculator | ||
|
|
||
| val stringToSign = signatureCalculator.stringToSign(canonical.requestString, config) | ||
| logger.trace { "String to sign:\n$stringToSign" } | ||
|
|
||
| val signingKey = signatureCalculator.signingKey(config) | ||
|
|
||
| val signature = signatureCalculator.calculate(signingKey, stringToSign) | ||
| logger.debug { "Calculated signature: $signature" } | ||
|
|
||
| val signedRequest = requestMutator.appendAuth(config, canonical, signature) | ||
|
|
||
| return AwsSigningResult(signedRequest, signature.encodeToByteArray()) | ||
| } | ||
|
|
||
| override suspend fun signChunk( | ||
| chunkBody: ByteArray, | ||
| prevSignature: ByteArray, | ||
| config: AwsSigningConfig, | ||
| ): AwsSigningResult<Unit> { | ||
| val logger = telemetryProvider?.loggerProvider?.getOrCreateLogger("DefaultAwsSigner") | ||
| ?: coroutineContext.logger<DefaultAwsSignerImpl>() | ||
|
|
||
| val signatureCalculator = config.algorithm.signatureCalculator | ||
|
|
||
| val stringToSign = signatureCalculator.chunkStringToSign(chunkBody, prevSignature, config) | ||
| logger.trace { "Chunk string to sign:\n$stringToSign" } | ||
|
|
||
| val signingKey = signatureCalculator.signingKey(config) | ||
|
|
||
| val signature = signatureCalculator.calculate(signingKey, stringToSign) | ||
| logger.debug { "Calculated chunk signature: $signature" } | ||
|
|
||
| return AwsSigningResult(Unit, signature.encodeToByteArray()) | ||
| } | ||
|
|
||
| override suspend fun signChunkTrailer( | ||
| trailingHeaders: Headers, | ||
| prevSignature: ByteArray, | ||
| config: AwsSigningConfig, | ||
| ): AwsSigningResult<Unit> { | ||
| val logger = telemetryProvider?.loggerProvider?.getOrCreateLogger("DefaultAwsSigner") | ||
| ?: coroutineContext.logger<DefaultAwsSignerImpl>() | ||
|
|
||
| val signatureCalculator = config.algorithm.signatureCalculator | ||
|
|
||
| // FIXME - can we share canonicalization code more than we are..., also this reduce is inefficient. | ||
| // canonicalize the headers | ||
| val trailingHeadersBytes = trailingHeaders.entries().sortedBy { e -> e.key.lowercase() } | ||
| .map { e -> | ||
| buildString { | ||
| append(e.key.lowercase()) | ||
| append(":") | ||
| append(e.value.joinToString(",") { v -> v.trim() }) | ||
| append("\n") | ||
| }.encodeToByteArray() | ||
| }.reduce { acc, bytes -> acc + bytes } | ||
|
|
||
| val stringToSign = signatureCalculator.chunkTrailerStringToSign(trailingHeadersBytes, prevSignature, config) | ||
| logger.trace { "Chunk trailer string to sign:\n$stringToSign" } | ||
|
|
||
| val signingKey = signatureCalculator.signingKey(config) | ||
|
|
||
| val signature = signatureCalculator.calculate(signingKey, stringToSign) | ||
| logger.debug { "Calculated chunk signature: $signature" } | ||
|
|
||
| return AwsSigningResult(Unit, signature.encodeToByteArray()) | ||
| } | ||
| } | ||
10 changes: 10 additions & 0 deletions
10
...ng-default/native/src/aws/smithy/kotlin/runtime/auth/awssigning/DefaultAwsSignerNative.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package aws.smithy.kotlin.runtime.auth.awssigning | ||
|
|
||
| import aws.smithy.kotlin.runtime.auth.awssigning.crt.CrtAwsSigner | ||
|
|
||
| /** The default implementation of [AwsSigner] */ | ||
| public actual val DefaultAwsSigner: AwsSigner = CrtAwsSigner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opinion: It now feels weird that this factory function and builder type exist only in JVM when the named value exists in all source sets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed separately and agreed that this API disparity is fine for now and can be reexamined if we ever see problems or get feedback.