Fixed bug where default vaultaddr is never used. (#791)

* Fixed bug where default vaultaddr is never used.

* Fixing vault tests on Windows.

Co-authored-by: Phil Kedy <phil.kedy@gmail.com>
This commit is contained in:
Donovan Brown 2021-04-28 14:23:17 -05:00 committed by GitHub
parent b404517388
commit 4a1cfea325
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -87,7 +87,7 @@ func (v *vaultSecretStore) Init(metadata secretstores.Metadata) error {
// Get Vault address
address := props[componentVaultAddress]
if address == "" {
v.vaultAddress = defaultVaultAddress
address = defaultVaultAddress
}
v.vaultAddress = address

View File

@ -84,6 +84,31 @@ func TestVaultTLSConfig(t *testing.T) {
})
}
func TestDefaultVaultAddress(t *testing.T) {
t.Run("with blank vaultAddr", func(t *testing.T) {
properties := map[string]string{
"vaultTokenMountPath": "./vault.txt",
}
m := secretstores.Metadata{
Properties: properties,
}
target := &vaultSecretStore{
client: nil,
logger: nil,
}
// This call will throw an error on Windows systems because of the of
// the call x509.SystemCertPool() because system root pool is not
// available on Windows so ignore the error for when the tests are run
// on the Windows platform during CI
_ = target.Init(m)
assert.Equal(t, defaultVaultAddress, target.vaultAddress, "default was not set")
})
}
func getCertificate() []byte {
certificateBytes, _ := base64.StdEncoding.DecodeString(certificate)