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:
		
							parent
							
								
									b404517388
								
							
						
					
					
						commit
						4a1cfea325
					
				|  | @ -87,7 +87,7 @@ func (v *vaultSecretStore) Init(metadata secretstores.Metadata) error { | ||||||
| 	// Get Vault address
 | 	// Get Vault address
 | ||||||
| 	address := props[componentVaultAddress] | 	address := props[componentVaultAddress] | ||||||
| 	if address == "" { | 	if address == "" { | ||||||
| 		v.vaultAddress = defaultVaultAddress | 		address = defaultVaultAddress | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	v.vaultAddress = address | 	v.vaultAddress = address | ||||||
|  |  | ||||||
|  | @ -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 { | func getCertificate() []byte { | ||||||
| 	certificateBytes, _ := base64.StdEncoding.DecodeString(certificate) | 	certificateBytes, _ := base64.StdEncoding.DecodeString(certificate) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue