From 1c391b80fd2f8f9af037b251fdf87d25a9514cb7 Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Thu, 9 Jan 2025 17:18:43 -0500 Subject: [PATCH] Refactor based on upstream changes, simplify parameter addition, change `add` to `put` --- .../kotlin/services/dsql/DsqlAuthTokenGenerator.kt | 14 +++----------- .../kotlin/services/rds/RdsAuthTokenGenerator.kt | 2 +- .../rds/common/test/RdsAuthTokenGeneratorTest.kt | 1 - 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/services/dsql/common/src/aws/sdk/kotlin/services/dsql/DsqlAuthTokenGenerator.kt b/services/dsql/common/src/aws/sdk/kotlin/services/dsql/DsqlAuthTokenGenerator.kt index 9b8e10faee1..2bfef0e72c9 100644 --- a/services/dsql/common/src/aws/sdk/kotlin/services/dsql/DsqlAuthTokenGenerator.kt +++ b/services/dsql/common/src/aws/sdk/kotlin/services/dsql/DsqlAuthTokenGenerator.kt @@ -28,7 +28,7 @@ public class DsqlAuthTokenGenerator( public val signer: AwsSigner = DefaultAwsSigner, public val clock: Clock = Clock.System, ) { - private val generator = AuthTokenGenerator("dsql", credentialsProvider, credentialsRefreshBuffer, signer, clock) + private val generator = AuthTokenGenerator("dsql", credentialsProvider, signer, clock) /** * Generates an auth token for the DbConnect action. @@ -38,11 +38,7 @@ public class DsqlAuthTokenGenerator( */ public suspend fun generateDbConnectAuthToken(endpoint: Url, region: String, expiration: Duration = 900.seconds): String { val dbConnectEndpoint = endpoint.toBuilder().apply { - parameters.apply { - decodedParameters { - add("Action", "DbConnect") - } - } + parameters.decodedParameters.put("Action", "DbConnect") }.build() return generator.generateAuthToken(dbConnectEndpoint, region, expiration) @@ -56,11 +52,7 @@ public class DsqlAuthTokenGenerator( */ public suspend fun generateDbConnectAdminAuthToken(endpoint: Url, region: String, expiration: Duration = 900.seconds): String { val dbConnectAdminEndpoint = endpoint.toBuilder().apply { - parameters.apply { - decodedParameters { - add("Action", "DbConnectAdmin") - } - } + parameters.decodedParameters.put("Action", "DbConnectAdmin") }.build() return generator.generateAuthToken(dbConnectAdminEndpoint, region, expiration) diff --git a/services/rds/common/src/aws/sdk/kotlin/services/rds/RdsAuthTokenGenerator.kt b/services/rds/common/src/aws/sdk/kotlin/services/rds/RdsAuthTokenGenerator.kt index aae531f4578..3d19af00d9b 100644 --- a/services/rds/common/src/aws/sdk/kotlin/services/rds/RdsAuthTokenGenerator.kt +++ b/services/rds/common/src/aws/sdk/kotlin/services/rds/RdsAuthTokenGenerator.kt @@ -29,7 +29,7 @@ public class RdsAuthTokenGenerator( public val signer: AwsSigner = DefaultAwsSigner, public val clock: Clock = Clock.System, ) { - private val generator = AuthTokenGenerator("rds-db", credentialsProvider, credentialsRefreshBuffer, signer, clock) + private val generator = AuthTokenGenerator("rds-db", credentialsProvider, signer, clock) /** * Generates an auth token for the `connect` action. diff --git a/services/rds/common/test/RdsAuthTokenGeneratorTest.kt b/services/rds/common/test/RdsAuthTokenGeneratorTest.kt index 917eb504c93..5a1f76ad37c 100644 --- a/services/rds/common/test/RdsAuthTokenGeneratorTest.kt +++ b/services/rds/common/test/RdsAuthTokenGeneratorTest.kt @@ -20,7 +20,6 @@ class RdsAuthTokenGeneratorTest { @Test fun testGenerateAuthToken() = runTest { val clock = ManualClock(Instant.fromEpochSeconds(1724716800)) - println(clock.now()) val credentials = Credentials("akid", "secret") val credentialsProvider = StaticCredentialsProvider(credentials)