Addapt test to api change.

This commit is contained in:
Mariano Cano 2019-12-11 18:21:20 -08:00
parent bde29b1bbd
commit 96b6989658

View file

@ -1,6 +1,7 @@
package authority package authority
import ( import (
"context"
"crypto/ecdsa" "crypto/ecdsa"
"crypto/elliptic" "crypto/elliptic"
"crypto/rand" "crypto/rand"
@ -476,7 +477,9 @@ func TestAuthority_CheckSSHHost(t *testing.T) {
err error err error
} }
type args struct { type args struct {
ctx context.Context
principal string principal string
token string
} }
tests := []struct { tests := []struct {
name string name string
@ -485,12 +488,12 @@ func TestAuthority_CheckSSHHost(t *testing.T) {
want bool want bool
wantErr bool wantErr bool
}{ }{
{"true", fields{true, nil}, args{"foo.internal.com"}, true, false}, {"true", fields{true, nil}, args{context.TODO(), "foo.internal.com", ""}, true, false},
{"false", fields{false, nil}, args{"foo.internal.com"}, false, false}, {"false", fields{false, nil}, args{context.TODO(), "foo.internal.com", ""}, false, false},
{"notImplemented", fields{false, db.ErrNotImplemented}, args{"foo.internal.com"}, false, true}, {"notImplemented", fields{false, db.ErrNotImplemented}, args{context.TODO(), "foo.internal.com", ""}, false, true},
{"notImplemented", fields{true, db.ErrNotImplemented}, args{"foo.internal.com"}, false, true}, {"notImplemented", fields{true, db.ErrNotImplemented}, args{context.TODO(), "foo.internal.com", ""}, false, true},
{"internal", fields{false, fmt.Errorf("an error")}, args{"foo.internal.com"}, false, true}, {"internal", fields{false, fmt.Errorf("an error")}, args{context.TODO(), "foo.internal.com", ""}, false, true},
{"internal", fields{true, fmt.Errorf("an error")}, args{"foo.internal.com"}, false, true}, {"internal", fields{true, fmt.Errorf("an error")}, args{context.TODO(), "foo.internal.com", ""}, false, 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) {
@ -500,7 +503,7 @@ func TestAuthority_CheckSSHHost(t *testing.T) {
return tt.fields.exists, tt.fields.err return tt.fields.exists, tt.fields.err
}, },
} }
got, err := a.CheckSSHHost(tt.args.principal) got, err := a.CheckSSHHost(tt.args.ctx, tt.args.principal, tt.args.token)
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("Authority.CheckSSHHost() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("Authority.CheckSSHHost() error = %v, wantErr %v", err, tt.wantErr)
return return