-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sebel_test.go
86 lines (67 loc) · 1.26 KB
/
sebel_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package sebel
import (
"testing"
"net/http"
)
var sebel *Sebel
func init() {
sebel = New()
}
func TestNew(t *testing.T) {
t.Parallel()
t.Run("empty", func(t *testing.T) {
if sebel == nil {
t.Fail()
}
})
t.Run("set", func(t *testing.T) {
sebelWithOptions := New(Options{DisableSSLBlacklist: true})
if !sebelWithOptions.options.DisableSSLBlacklist {
t.Fail()
}
})
}
func TestRoundTripper(t *testing.T) {
t.Parallel()
tr := http.DefaultTransport
if tr == sebel.RoundTripper(tr) {
t.Fail()
}
}
func TestCheckTLS(t *testing.T) {
resp, err := http.Get("https://httpbin.org/get")
if err != nil {
t.SkipNow()
}
if resp.TLS == nil {
t.SkipNow()
}
t.Parallel()
t.Run("default", func(t *testing.T) {
_, err := sebel.CheckTLS(resp.TLS)
if err != nil {
t.Fail()
}
})
t.Run("WithDisableSSLBlacklist", func(t *testing.T) {
sebelWithOptions := New(Options{DisableSSLBlacklist: true})
_, err := sebelWithOptions.CheckTLS(resp.TLS)
if err != nil {
t.Fail()
}
})
}
func BenchmarkCheckTLS(b *testing.B) {
resp, err := http.Get("https://httpbin.org/get")
if err != nil {
b.SkipNow()
}
if resp.TLS == nil {
b.SkipNow()
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = sebel.CheckTLS(resp.TLS)
}
}