Przeglądaj źródła

Add test for newTLSOptionCtx

Mariano Cano 8 lat temu
rodzic
commit
9adc65febf
1 zmienionych plików z 30 dodań i 0 usunięć
  1. 30 0
      ca/tls_options_test.go

+ 30 - 0
ca/tls_options_test.go

@@ -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 {