...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package crane
16
17 import (
18 "errors"
19 "net/http"
20 "testing"
21
22 "github.com/google/go-containerregistry/pkg/v1/remote"
23 )
24
25 func TestInsecureOptionTracking(t *testing.T) {
26 want := true
27 opts := GetOptions(Insecure)
28
29 if got := opts.insecure; got != want {
30 t.Errorf("got %t\nwant: %t", got, want)
31 }
32 }
33
34 func TestTransportSetting(t *testing.T) {
35 opts := GetOptions(WithTransport(remote.DefaultTransport))
36
37 if opts.Transport == nil {
38 t.Error("expected crane transport to be set when user passes WithTransport")
39 }
40 }
41
42 func TestInsecureTransport(t *testing.T) {
43 want := true
44 opts := GetOptions(Insecure)
45 var transport *http.Transport
46 var ok bool
47 if transport, ok = opts.Transport.(*http.Transport); !ok {
48 t.Fatal("Unable to successfully assert default transport")
49 }
50
51 if transport.TLSClientConfig == nil {
52 t.Fatal(errors.New("TLSClientConfig was nil and should be set"))
53 }
54
55 if got := transport.TLSClientConfig.InsecureSkipVerify; got != want {
56 t.Errorf("got: %t\nwant: %t", got, want)
57 }
58 }
59
View as plain text