File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
runtime/auth/http-auth/common
src/aws/smithy/kotlin/runtime/http/auth
test/aws/smithy/kotlin/runtime/http/auth Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ package aws.smithy.kotlin.runtime.http.auth
77import aws.smithy.kotlin.runtime.businessmetrics.SmithyBusinessMetric
88import aws.smithy.kotlin.runtime.businessmetrics.emitBusinessMetric
99import aws.smithy.kotlin.runtime.collections.Attributes
10- import aws.smithy.kotlin.runtime.collections.toMutableAttributes
10+ import aws.smithy.kotlin.runtime.collections.mutableAttributes
1111import aws.smithy.kotlin.runtime.time.Instant
1212import aws.smithy.kotlin.runtime.util.PlatformProvider
1313
@@ -23,7 +23,7 @@ public class EnvironmentBearerTokenProvider(
2323 ? : error(" $key environment variable is not set" )
2424 return object : BearerToken {
2525 override val token: String = bearerToken
26- override val attributes: Attributes = attributes.toMutableAttributes ().apply {
26+ override val attributes: Attributes = mutableAttributes ().apply {
2727 emitBusinessMetric(SmithyBusinessMetric .BEARER_SERVICE_ENV_VARS )
2828 }
2929 override val expiration: Instant ? = null
Original file line number Diff line number Diff line change @@ -8,11 +8,24 @@ import kotlin.test.assertFailsWith
88
99class EnvironmentBearerTokenProviderTest {
1010 @Test
11- fun testResolveWithValidToken () = runTest {
11+ fun testResolveFromEnvVar () = runTest {
1212 val provider = EnvironmentBearerTokenProvider (
1313 " TEST_TOKEN" ,
1414 TestPlatformProvider (
1515 env = mutableMapOf (" TEST_TOKEN" to " test-env-bearer-token" ),
16+ ),
17+ )
18+
19+ val token = provider.resolve()
20+
21+ assertEquals(" test-env-bearer-token" , token.token)
22+ }
23+
24+ @Test
25+ fun testResolveFromSysProps () = runTest {
26+ val provider = EnvironmentBearerTokenProvider (
27+ " TEST_TOKEN" ,
28+ TestPlatformProvider (
1629 props = mutableMapOf (" TEST_TOKEN" to " test-sys-props-bearer-token" ),
1730 ),
1831 )
You can’t perform that action at this time.
0 commit comments