Update template tests.

pull/166/head^2
Mariano Cano 5 years ago committed by max furman
parent b179ad3662
commit 557a45abfa

@ -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")},

@ -1,3 +1,12 @@
Match exec "step ssh check-host %h"
ForwardAgent yes
UserKnownHostsFile {{.User.StepPath}}/ssh/known_hosts
{{- 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 }}

@ -1,2 +1,6 @@
Host *
Include {{.User.StepPath}}/ssh/config
{{- 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…
Cancel
Save