Skip to content

Commit

Permalink
added test to ensure that config_templates are handled correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Apr 20, 2018
1 parent 7a407e2 commit e5141bf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,21 @@ func TestConfiguration_ReadConfig_DuplicateActiveTemplates(t *testing.T) {
//assert
require.Error(t, err, "should return an error if there is an duplicate active template")
}

func TestConfiguration_ReadConfig_OverrideDefaultConfigTemplate(t *testing.T) {
t.Parallel()

//setup
testConfig, _ := config.Create()

//test
err := testConfig.ReadConfig(path.Join("testdata", "valid_config_template.yaml"))
require.NoError(t, err, "should allow overriding default config template.")

configTmpl, err := testConfig.GetActiveConfigTemplate()

//assert
require.NoError(t, err, "should allow overriding default config template.")
require.Equal(t,"{{.environment}}-{{.username}}", configTmpl.FilePath)

}
19 changes: 19 additions & 0 deletions pkg/config/testdata/valid_config_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
options:
pem_dir: '~/.ssh/drawbridge/pem'
config_templates:
default:
filepath: '{{.environment}}-{{.username}}'
content: |
ForwardAgent yes
ForwardX11 no
HashKnownHosts yes
IdentitiesOnly yes
StrictHostKeyChecking no
Host bastion
Hostname bastion.example.com
User {{.username}}
IdentityFile {{.pem_dir}}/{{.pem_filename}}
LocalForward localhost:{{uniquePort .}} localhost:8080
UserKnownHostsFile=/dev/null
StrictHostKeyChecking=no
Empty file.

0 comments on commit e5141bf

Please sign in to comment.