-
Notifications
You must be signed in to change notification settings - Fork 0
/
cipher_suites_test.go
91 lines (87 loc) · 2.16 KB
/
cipher_suites_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
87
88
89
90
91
package ciphersuites_test
import (
"testing"
"github.com/StatusCakeDev/ciphersuites"
)
func TestClassification(t *testing.T) {
var tests = []struct {
name string
classification ciphersuites.Classification
expected string
}{
{
name: "returns recommended",
classification: ciphersuites.Recommended,
expected: "recommended",
},
{
name: "returns secure",
classification: ciphersuites.Secure,
expected: "secure",
},
{
name: "returns weak",
classification: ciphersuites.Weak,
expected: "weak",
},
{
name: "returns insecure",
classification: ciphersuites.Insecure,
expected: "insecure",
},
{
name: "returns unknown",
classification: ciphersuites.Unknown,
expected: "unknown",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
classification := tt.classification.String()
if classification != tt.expected {
t.Errorf("expected %s, got %s", tt.expected, classification)
}
})
}
}
func TestGetClassification(t *testing.T) {
var tests = []struct {
name string
cipherSuite string
classification ciphersuites.Classification
}{
{
name: "returns recommended",
cipherSuite: "TLS_AES_128_CCM_8_SHA256",
classification: ciphersuites.Recommended,
},
{
name: "returns secure",
cipherSuite: "TLS_DHE_RSA_WITH_AES_128_CCM",
classification: ciphersuites.Secure,
},
{
name: "returns weak",
cipherSuite: "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA",
classification: ciphersuites.Weak,
},
{
name: "returns insecure",
cipherSuite: "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
classification: ciphersuites.Insecure,
},
{
name: "returns unknown",
cipherSuite: "fake cipher suite",
classification: ciphersuites.Unknown,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
classification := ciphersuites.GetClassification(tt.cipherSuite)
if classification != tt.classification {
t.Errorf("expected %s, got %s", tt.classification, classification)
}
})
}
}