forked from TrueCloudLab/certificates
Update template tests.
This commit is contained in:
parent
0528971693
commit
5d35586402
4 changed files with 19 additions and 4 deletions
|
@ -407,7 +407,7 @@ func TestAuthority_GetSSHConfig(t *testing.T) {
|
|||
}
|
||||
userOutputWithUserData := []templates.Output{
|
||||
{Name: "include.tpl", Type: templates.File, Comment: "#", Path: "ssh/include", Content: []byte("Host *\n\tInclude /home/user/.step/ssh/config")},
|
||||
{Name: "config.tpl", Type: templates.File, Comment: "#", Path: "ssh/config", Content: []byte("Match exec \"step ssh check-host %h\"\n\tForwardAgent yes\n\tUserKnownHostsFile /home/user/.step/ssh/known_hosts")},
|
||||
{Name: "config.tpl", Type: templates.File, Comment: "#", Path: "ssh/config", Content: []byte("Match exec \"step ssh check-host %h\"\n\tForwardAgent yes\n\tUserKnownHostsFile /home/user/.step/ssh/known_hosts\n\tProxyCommand step ssh proxycommand %r %h %p\n")},
|
||||
}
|
||||
hostOutputWithUserData := []templates.Output{
|
||||
{Name: "sshd_config.tpl", Type: templates.File, Comment: "#", Path: "/etc/ssh/sshd_config", Content: []byte("TrustedUserCAKeys /etc/ssh/ca.pub\nHostCertificate /etc/ssh/ssh_host_ecdsa_key-cert.pub\nHostKey /etc/ssh/ssh_host_ecdsa_key")},
|
||||
|
|
9
authority/testdata/templates/config.tpl
vendored
9
authority/testdata/templates/config.tpl
vendored
|
@ -1,3 +1,12 @@
|
|||
Match exec "step ssh check-host %h"
|
||||
ForwardAgent yes
|
||||
{{- if .User.User }}
|
||||
User {{.User.User}}
|
||||
{{- end }}
|
||||
{{- if or .User.GOOS "none" | eq "windows" }}
|
||||
UserKnownHostsFile {{.User.StepPath}}\ssh\known_hosts
|
||||
ProxyCommand C:\Windows\System32\cmd.exe /c step ssh proxycommand %r %h %p
|
||||
{{- else }}
|
||||
UserKnownHostsFile {{.User.StepPath}}/ssh/known_hosts
|
||||
ProxyCommand step ssh proxycommand %r %h %p
|
||||
{{- end }}
|
||||
|
|
4
authority/testdata/templates/include.tpl
vendored
4
authority/testdata/templates/include.tpl
vendored
|
@ -1,2 +1,6 @@
|
|||
Host *
|
||||
{{- if or .User.GOOS "linux" | eq "windows" }}
|
||||
Include {{ .User.StepPath | replace "\\" "/" | trimPrefix "C:" }}/ssh/config
|
||||
{{- else }}
|
||||
Include {{.User.StepPath}}/ssh/config
|
||||
{{- end }}
|
|
@ -230,6 +230,8 @@ func TestTemplate_Render(t *testing.T) {
|
|||
},
|
||||
"User": map[string]string{
|
||||
"StepPath": "/tmp/.step",
|
||||
"User": "john",
|
||||
"GOOS": "linux",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -271,7 +273,7 @@ func TestTemplate_Render(t *testing.T) {
|
|||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("Template.Render() = %v, want %v", got, tt.want)
|
||||
t.Errorf("Template.Render() = %v, want %v", string(got), string(tt.want))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue