Add test for newTLSOptionCtx

This commit is contained in:
Mariano Cano 2019-01-10 15:31:40 -08:00
parent 1763ede99d
commit 9adc65febf

View file

@ -1,6 +1,7 @@
package ca package ca
import ( import (
"crypto"
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"fmt" "fmt"
@ -9,8 +10,37 @@ import (
"reflect" "reflect"
"sort" "sort"
"testing" "testing"
"github.com/smallstep/certificates/api"
) )
func Test_newTLSOptionCtx(t *testing.T) {
client, sign, pk := sign("test.smallstep.com")
type args struct {
c *Client
sign *api.SignResponse
pk crypto.PrivateKey
config *tls.Config
}
tests := []struct {
name string
args args
wantErr bool
}{
{"ok", args{client, sign, pk, &tls.Config{}}, false},
{"fail", args{client, sign, "foo", &tls.Config{}}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := newTLSOptionCtx(tt.args.c, tt.args.sign, tt.args.pk, tt.args.config)
if (err != nil) != tt.wantErr {
t.Errorf("newTLSOptionCtx() error = %v, wantErr %v", err, tt.wantErr)
return
}
})
}
}
func TestTLSOptionCtx_apply(t *testing.T) { func TestTLSOptionCtx_apply(t *testing.T) {
fail := func() TLSOption { fail := func() TLSOption {
return func(ctx *TLSOptionCtx) error { return func(ctx *TLSOptionCtx) error {