-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: support default checksums #1475
base: main
Are you sure you want to change the base?
Changes from 68 commits
4729584
7b73088
dbfb973
b15358b
dacc345
bbafc3f
a79aa1e
e61efbb
285c08b
fbb3dd5
136c9db
cb4ab12
41ad1b4
1a2d989
11c733f
4d24a24
c514cba
2796317
6d53243
40cfb17
410c085
472fae9
e9bf8e5
5133a60
4ce5da7
da31deb
6037580
2f6e10b
d085dec
0bafdcc
fc84b61
0f6fa65
c76aefe
3476242
b21ec41
dd2792f
779cd3a
6674dc7
a3a2e09
c80b55c
5e2855c
0405b20
eb338f4
a2fb7fb
093ed72
d498e30
b534927
2761bf9
5328641
ad30f70
4a162de
d665873
1aefe66
55bdcb8
44894e6
ad8d1ad
d398801
3c259ef
0029768
427daf3
41ad742
5c6c0bf
4d915c6
609226c
80ba070
94dfc93
77f6ea5
4b61347
756f66d
3ed4d91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package aws.sdk.kotlin.runtime.config.checksums | ||
|
||
import aws.sdk.kotlin.runtime.ConfigurationException | ||
import aws.sdk.kotlin.runtime.InternalSdkApi | ||
import aws.sdk.kotlin.runtime.config.AwsSdkSetting | ||
import aws.sdk.kotlin.runtime.config.profile.AwsProfile | ||
import aws.sdk.kotlin.runtime.config.profile.requestChecksumCalculation | ||
import aws.sdk.kotlin.runtime.config.profile.responseChecksumValidation | ||
import aws.smithy.kotlin.runtime.client.config.HttpChecksumConfigOption | ||
import aws.smithy.kotlin.runtime.config.resolve | ||
import aws.smithy.kotlin.runtime.util.LazyAsyncValue | ||
import aws.smithy.kotlin.runtime.util.PlatformProvider | ||
|
||
/** | ||
* Attempts to resolve requestChecksumCalculation from the specified sources. | ||
* @return requestChecksumCalculation setting if found, the default value if not. | ||
*/ | ||
@InternalSdkApi | ||
public suspend fun resolveRequestChecksumCalculation(platform: PlatformProvider = PlatformProvider.System, profile: LazyAsyncValue<AwsProfile>): HttpChecksumConfigOption { | ||
val unparsedString = AwsSdkSetting.AwsRequestChecksumCalculation.resolve(platform) ?: profile.get().requestChecksumCalculation | ||
return parseHttpChecksumConfigOption(unparsedString, "requestChecksumCalculation") | ||
} | ||
|
||
/** | ||
* Attempts to resolve responseChecksumValidation from the specified sources. | ||
* @return responseChecksumValidation setting if found, the default value if not. | ||
*/ | ||
@InternalSdkApi | ||
public suspend fun resolveResponseChecksumValidation(platform: PlatformProvider = PlatformProvider.System, profile: LazyAsyncValue<AwsProfile>): HttpChecksumConfigOption { | ||
val unparsedString = AwsSdkSetting.AwsResponseChecksumValidation.resolve(platform) ?: profile.get().responseChecksumValidation | ||
return parseHttpChecksumConfigOption(unparsedString, "responseChecksumValidation") | ||
} | ||
|
||
private fun parseHttpChecksumConfigOption(unparsedString: String?, configOption: String): HttpChecksumConfigOption = | ||
when (unparsedString?.uppercase()) { | ||
null -> HttpChecksumConfigOption.WHEN_SUPPORTED | ||
"WHEN_SUPPORTED" -> HttpChecksumConfigOption.WHEN_SUPPORTED | ||
"WHEN_REQUIRED" -> HttpChecksumConfigOption.WHEN_REQUIRED | ||
else -> throw ConfigurationException( | ||
"'$unparsedString' is not a valid value for $configOption. Valid values are: ${HttpChecksumConfigOption.entries}", | ||
) | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correctness: This file should go in |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package aws.sdk.kotlin.runtime.http.interceptors | ||
|
||
import aws.smithy.kotlin.runtime.client.config.HttpChecksumConfigOption | ||
import aws.smithy.kotlin.runtime.http.interceptors.FlexibleChecksumsResponseInterceptor | ||
|
||
/** | ||
* S3 variant of the flexible checksum interceptor where composite checksums are not validated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit/docs: |
||
*/ | ||
public class S3FlexibleChecksumResponseInterceptor( | ||
responseValidationRequired: Boolean, | ||
responseChecksumValidation: HttpChecksumConfigOption?, | ||
) : FlexibleChecksumsResponseInterceptor( | ||
responseValidationRequired, | ||
responseChecksumValidation, | ||
) { | ||
override fun ignoreChecksum(checksum: String): Boolean = | ||
checksum.isCompositeChecksum() | ||
} | ||
|
||
/** | ||
* Verifies if a checksum is composite. | ||
*/ | ||
private fun String.isCompositeChecksum(): Boolean { | ||
// Ends with "-#" where "#" is a number | ||
val regex = Regex("-(\\d)+$") | ||
return regex.containsMatchIn(this) | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to exist? buildSrc is treated as an included build which means every subproject will have these config options applied. It seems odd to need this just for codegen tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the best way I could find to share a data class between subprojects, do you know of alternatives that would work better? I might've missed them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can make a new project that both of those subprojects depend on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still a work in progress, I don't want to block the review because of this. I think worst case scenario we can come back and refactor this without it being a breaking change |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
alias(libs.plugins.kotlin.jvm) | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package aws.sdk.kotlin.shared | ||
|
||
/** | ||
* An AWS SDK for Kotlin codegen test | ||
*/ | ||
data class CodegenTest( | ||
val name: String, | ||
val model: Model, | ||
val serviceShapeId: String, | ||
val protocolName: String? = null, | ||
) | ||
|
||
/** | ||
* A smithy model file | ||
*/ | ||
data class Model( | ||
val fileName: String, | ||
val path: String = "src/commonTest/resources/", | ||
) |
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.
Comment: Good catch!
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.
What are these test reports used for?
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.
Not 100% sure why but sometimes the logs from failed CI tests are not very useful. In those cases you can just get a test report from the build and see which test cases failed and exception messages. Other CI checks have this as well