forked from TrueCloudLab/certificates
Add test for newTLSOptionCtx
This commit is contained in:
parent
1763ede99d
commit
9adc65febf
1 changed files with 30 additions and 0 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue