Skip to content

Commit

Permalink
Added tests for legacy aws patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
sksamuel committed May 27, 2023
1 parent 6d8a490 commit 8493468
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.testcontainers.utility.DockerImageName
import java.util.Properties

@OptIn(ExperimentalHoplite::class)
class AwsSecretsManagerResolverTest : FunSpec() {
class AwsSecretsManagerContextResolverTest : FunSpec() {

private val localstack = LocalStackContainer(DockerImageName.parse("localstack/localstack:1.3.1"))
.withServices(LocalStackContainer.Service.SECRETSMANAGER)
Expand Down Expand Up @@ -61,6 +61,39 @@ class AwsSecretsManagerResolverTest : FunSpec() {
.a.shouldBe("secret!")
}

test("legacy1 prefix pattern should be detected and used") {
val props = Properties()
props["a"] = "awssm://foo"
ConfigLoaderBuilder.newBuilder()
.addResolver(AwsSecretsManagerContextResolvers { client })
.addPropertySource(PropsPropertySource(props))
.build()
.loadConfigOrThrow<ConfigHolder>()
.a.shouldBe("secret!")
}

test("legacy2 prefix pattern should be detected and used") {
val props = Properties()
props["a"] = "awssecret://foo"
ConfigLoaderBuilder.newBuilder()
.addResolver(AwsSecretsManagerContextResolvers { client })
.addPropertySource(PropsPropertySource(props))
.build()
.loadConfigOrThrow<ConfigHolder>()
.a.shouldBe("secret!")
}

test("legacy3 prefix pattern should be detected and used") {
val props = Properties()
props["a"] = "secretsmanager://foo"
ConfigLoaderBuilder.newBuilder()
.addResolver(AwsSecretsManagerContextResolvers { client })
.addPropertySource(PropsPropertySource(props))
.build()
.loadConfigOrThrow<ConfigHolder>()
.a.shouldBe("secret!")
}

test("unknown secret should return error and include key") {
val props = Properties()
props["a"] = "\${{ aws-secrets-manager:qwerty }}"
Expand Down

0 comments on commit 8493468

Please sign in to comment.