mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
Fix Agent and Proxy env var handling (#24790)
* Fix Agent and Proxy env var handling * Changelog * Review suggestions
This commit is contained in:
@@ -2820,6 +2820,36 @@ func TestAgent_LogFile_Config(t *testing.T) {
|
||||
assert.Equal(t, 1048576, cfg.LogRotateBytes)
|
||||
}
|
||||
|
||||
// TestAgent_EnvVar_Overrides tests that environment variables are properly
|
||||
// parsed and override defaults.
|
||||
func TestAgent_EnvVar_Overrides(t *testing.T) {
|
||||
configFile := populateTempFile(t, "agent-config.hcl", BasicHclConfig)
|
||||
|
||||
cfg, err := agentConfig.LoadConfigFile(configFile.Name())
|
||||
if err != nil {
|
||||
t.Fatal("Cannot load config to test update/merge", err)
|
||||
}
|
||||
|
||||
assert.Equal(t, false, cfg.Vault.TLSSkipVerify)
|
||||
|
||||
t.Setenv("VAULT_SKIP_VERIFY", "true")
|
||||
// Parse the cli flags (but we pass in an empty slice)
|
||||
cmd := &AgentCommand{BaseCommand: &BaseCommand{}}
|
||||
f := cmd.Flags()
|
||||
err = f.Parse([]string{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cmd.applyConfigOverrides(f, cfg)
|
||||
assert.Equal(t, true, cfg.Vault.TLSSkipVerify)
|
||||
|
||||
t.Setenv("VAULT_SKIP_VERIFY", "false")
|
||||
|
||||
cmd.applyConfigOverrides(f, cfg)
|
||||
assert.Equal(t, false, cfg.Vault.TLSSkipVerify)
|
||||
}
|
||||
|
||||
func TestAgent_Config_NewLogger_Default(t *testing.T) {
|
||||
cmd := &AgentCommand{BaseCommand: &BaseCommand{}}
|
||||
cmd.config = agentConfig.NewConfig()
|
||||
|
||||
Reference in New Issue
Block a user