@@ -398,7 +398,14 @@ func TestAuthority_GetSSHConfig(t *testing.T) {
398
398
{Name : "config.tpl" , Type : templates .File , TemplatePath : "./testdata/templates/config.tpl" , Path : "ssh/config" , Comment : "#" },
399
399
},
400
400
Host : []templates.Template {
401
- {Name : "sshd_config.tpl" , Type : templates .File , TemplatePath : "./testdata/templates/sshd_config.tpl" , Path : "/etc/ssh/sshd_config" , Comment : "#" },
401
+ {
402
+ Name : "sshd_config.tpl" ,
403
+ Type : templates .File ,
404
+ TemplatePath : "./testdata/templates/sshd_config.tpl" ,
405
+ Path : "/etc/ssh/sshd_config" ,
406
+ Comment : "#" ,
407
+ RequiredData : []string {"Certificate" , "Key" },
408
+ },
402
409
},
403
410
},
404
411
Data : map [string ]interface {}{
@@ -429,6 +436,14 @@ func TestAuthority_GetSSHConfig(t *testing.T) {
429
436
},
430
437
}
431
438
439
+ tmplConfigFail := & templates.Templates {
440
+ SSH : & templates.SSHTemplates {
441
+ User : []templates.Template {
442
+ {Name : "fail.tpl" , Type : templates .File , TemplatePath : "./testdata/templates/fail.tpl" , Path : "ssh/fail" , Comment : "#" },
443
+ },
444
+ },
445
+ }
446
+
432
447
type fields struct {
433
448
templates * templates.Templates
434
449
userSigner ssh.Signer
@@ -456,6 +471,8 @@ func TestAuthority_GetSSHConfig(t *testing.T) {
456
471
{"userError" , fields {tmplConfigErr , userSigner , hostSigner }, args {"user" , nil }, nil , true },
457
472
{"hostError" , fields {tmplConfigErr , userSigner , hostSigner }, args {"host" , map [string ]string {"Function" : "foo" }}, nil , true },
458
473
{"noTemplates" , fields {nil , userSigner , hostSigner }, args {"user" , nil }, nil , true },
474
+ {"missingData" , fields {tmplConfigWithUserData , userSigner , hostSigner }, args {"host" , map [string ]string {"Certificate" : "ssh_host_ecdsa_key-cert.pub" }}, nil , true },
475
+ {"failError" , fields {tmplConfigFail , userSigner , hostSigner }, args {"user" , nil }, nil , true },
459
476
}
460
477
for _ , tt := range tests {
461
478
t .Run (tt .name , func (t * testing.T ) {
0 commit comments