Skip to content

Commit

Permalink
feat(test): Enhance integration tests for multiple secret paths
Browse files Browse the repository at this point in the history
This should cover the removal of afterEvaluate, i wanted to test if we
still can get different secrets with one extension.
  • Loading branch information
Patrick Mirwald committed Aug 9, 2024
1 parent c905bcb commit 94d77a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/integrationMain/kotlin/com/liftric/vault/ContainerBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ abstract class ContainerBase {
"exampleint" to 1337,
) as Map<String, Any>?
)

vault.logical().write(
"secret/example2", hashMapOf(
"examplestring2" to "helloworld2",
"exampleint2" to 1338,
) as Map<String, Any>?
)
}

}
Expand Down
12 changes: 9 additions & 3 deletions src/integrationMain/kotlin/com/liftric/vault/GetSecretTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,22 @@ tasks {
println("getting secret succeeded!")
}
}
val build by existing {
dependsOn(needsSecretsConfigTime, needsSecrets)
val needsSecrets2 by creating(GetVaultSecretTask::class) {
secretPath.set("secret/example2")
doLast {
val secret = secret.get()
if (secret["examplestring2"] != "helloworld2") throw kotlin.IllegalStateException("examplestring2 couldn't be read")
if (secret["exampleint2"]?.toInt() != 1338) throw kotlin.IllegalStateException("exampleint2 couldn't be read")
println("getting secret succeeded!")
}
}
}
"""
)

val result = GradleRunner.create()
.withProjectDir(projectDir)
.withArguments("build")
.withArguments("needsSecrets", "needsSecrets2")
.withPluginClasspath()
.build()

Expand Down

0 comments on commit 94d77a2

Please sign in to comment.