@@ -76,6 +76,28 @@ func TestRevoked(t *testing.T) {
7676 }
7777}
7878
79+ func TestHostAuthority (t * testing.T ) {
80+ for _ , m := range []struct {
81+ authorityFor string
82+ address string
83+
84+ good bool
85+ }{
86+ {authorityFor : "localhost" , address : "localhost:22" , good : true },
87+ {authorityFor : "localhost" , address : "localhost" , good : false },
88+ {authorityFor : "localhost" , address : "localhost:1234" , good : false },
89+ {authorityFor : "[localhost]:1234" , address : "localhost:1234" , good : true },
90+ {authorityFor : "[localhost]:1234" , address : "localhost:22" , good : false },
91+ {authorityFor : "[localhost]:1234" , address : "localhost" , good : false },
92+ } {
93+ db := testDB (t , `@cert-authority ` + m .authorityFor + ` ` + edKeyStr )
94+ if ok := db .IsHostAuthority (db .lines [0 ].knownKey .Key , m .address ); ok != m .good {
95+ t .Errorf ("IsHostAuthority: authority %s, address %s, wanted good = %v, got good = %v" ,
96+ m .authorityFor , m .address , m .good , ok )
97+ }
98+ }
99+ }
100+
79101func TestBracket (t * testing.T ) {
80102 db := testDB (t , `[git.eclipse.org]:29418,[198.41.30.196]:29418 ` + edKeyStr )
81103
0 commit comments