mirror of
https://github.com/smallstep/certificates.git
synced 2024-11-15 18:12:59 +00:00
Merge pull request #287 from smallstep/nil-templates
Avoid nil pointer panic on step ssh config with no templates. Fixes #289
This commit is contained in:
commit
72bb6e159f
@ -125,6 +125,10 @@ func (a *Authority) GetSSHConfig(ctx context.Context, typ string, data map[strin
|
|||||||
return nil, errs.NotFound("getSSHConfig: ssh is not configured")
|
return nil, errs.NotFound("getSSHConfig: ssh is not configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if a.config.Templates == nil {
|
||||||
|
return nil, errs.NotFound("getSSHConfig: ssh templates are not configured")
|
||||||
|
}
|
||||||
|
|
||||||
var ts []templates.Template
|
var ts []templates.Template
|
||||||
switch typ {
|
switch typ {
|
||||||
case provisioner.SSHUserCert:
|
case provisioner.SSHUserCert:
|
||||||
|
@ -455,6 +455,7 @@ func TestAuthority_GetSSHConfig(t *testing.T) {
|
|||||||
{"badType", fields{tmplConfig, userSigner, hostSigner}, args{"bad", nil}, nil, true},
|
{"badType", fields{tmplConfig, userSigner, hostSigner}, args{"bad", nil}, nil, true},
|
||||||
{"userError", fields{tmplConfigErr, userSigner, hostSigner}, args{"user", nil}, nil, true},
|
{"userError", fields{tmplConfigErr, userSigner, hostSigner}, args{"user", nil}, nil, true},
|
||||||
{"hostError", fields{tmplConfigErr, userSigner, hostSigner}, args{"host", map[string]string{"Function": "foo"}}, nil, true},
|
{"hostError", fields{tmplConfigErr, userSigner, hostSigner}, args{"host", map[string]string{"Function": "foo"}}, nil, true},
|
||||||
|
{"noTemplates", fields{nil, userSigner, hostSigner}, args{"user", nil}, nil, true},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user