Skip to content

Commit

Permalink
agent-inject: add config test
Browse files Browse the repository at this point in the history
  • Loading branch information
calvn committed Jun 28, 2021
1 parent 649a051 commit 10031a9
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions agent-inject/agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,56 @@ func TestConfigVaultAgentCache_persistent(t *testing.T) {

}

func TestConfigVaultAgentTemplateConfig(t *testing.T) {
tests := []struct {
name string
annotations map[string]string
expectedTemplateConfig *TemplateConfig
}{
{
"exit_on_retry_failure true",
map[string]string{
AnnotationTemplateConfigExitOnRetryFailure: "true",
},
&TemplateConfig{ExitOnRetryFailure: true},
},
{
"exit_on_retry_failure false",
map[string]string{
AnnotationTemplateConfigExitOnRetryFailure: "false",
},
&TemplateConfig{ExitOnRetryFailure: false},
},
{
"exit_on_retry_failure absent",
map[string]string{},
&TemplateConfig{ExitOnRetryFailure: true},
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pod := testPod(tt.annotations)
var patches []*jsonpatch.JsonPatchOperation

agentConfig := basicAgentConfig()
err := Init(pod, agentConfig)
require.NoError(t, err)

agent, err := New(pod, patches)
require.NoError(t, err)
cfg, err := agent.newConfig(true)
require.NoError(t, err)

config := &Config{}
err = json.Unmarshal(cfg, config)
require.NoError(t, err)

assert.Equal(t, tt.expectedTemplateConfig, config.TemplateConfig)
})
}
}

func TestInjectTokenSink(t *testing.T) {

tokenHelperSink := &Sink{
Expand Down

0 comments on commit 10031a9

Please sign in to comment.