1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/pkg/config/interpolation/interpolation_test.go
Kevin Stiehl 3eae0c5f68
feat(vault): fetch secrets from vault (#2032)
* cloud-foundry & sonar from vault

* add vault development hint

* don't abort on vault errors

* cloudfoundry make credentialsId only mandatory when vault is not configured

* add vault ref to step ymls

* rename vaultAddress to vaultServerUrl

* rename PIPER_vaultRole* to PIPER_vaultAppRole*

* add resourceRef for detect step

* fix error when no namespace is set

* added debug logs

* added debug logs

* fix vault resolving

* add vaultCustomBasePath

* rename vault_test.go to client_test.go

* refactored vault logging

* refactored config param lookup for vault

* added tüddelchen

* rename vaultCustomBasePath to vaultPath

* fix tests

* change lookup path for group secrets

* fix interpolation tests

* added vault resource ref to versioning

* execute go generate

* rename Approle to AppRole

* change verbose back to false

Co-authored-by: Leander Schulz <leander.schulz01@sap.com>
Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
2020-10-13 14:14:47 +02:00

46 lines
868 B
Go

package interpolation
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestResolveMap(t *testing.T) {
t.Parallel()
t.Run("That lookup works", func(t *testing.T) {
testMap := map[string]interface{}{
"prop1": "val1",
"prop2": "val2",
"prop3": "$(prop1)/$(prop2)",
}
ok := ResolveMap(testMap)
assert.True(t, ok)
assert.Equal(t, "val1/val2", testMap["prop3"])
})
t.Run("That lookups fails when property is not found", func(t *testing.T) {
testMap := map[string]interface{}{
"prop1": "val1",
"prop2": "val2",
"prop3": "$(prop1)/$(prop2)/$(prop5)",
}
ok := ResolveMap(testMap)
assert.False(t, ok)
})
t.Run("That resolve loops are aborted", func(t *testing.T) {
testMap := map[string]interface{}{
"prop1": "$(prop2)",
"prop2": "$(prop1)",
}
ok := ResolveMap(testMap)
assert.False(t, ok)
})
}