-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathconfig_test.go
85 lines (81 loc) · 1.82 KB
/
config_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
package lwconfig
import "testing"
func TestProfile_Verify(t *testing.T) {
tests := []struct {
profile Profile
desc string
error bool
}{
{
Profile{
Account: "test.test.corp",
ApiKey: "0000000000000000000000000000000000000000000000000000000",
ApiSecret: "000000000000000000000000000000",
},
"fields present and valid",
false,
},
{
Profile{
Account: "test.test.corp.lacework.net",
ApiKey: "0000000000000000000000000000000000000000000000000000000",
ApiSecret: "000000000000000000000000000000",
},
"fields present and valid full URL",
false,
},
{
Profile{
Account: "",
ApiKey: "0000000000000000000000000000000000000000000000000000000",
ApiSecret: "000000000000000000000000000000",
},
"account empty",
true,
},
{
Profile{
Account: "test.test.corp.lacework.net",
ApiKey: "",
ApiSecret: "000000000000000000000000000000",
},
"apikey empty",
true,
},
{
Profile{
Account: "test.test.corp.lacework.net",
ApiKey: "0000000000000000000000000000000000000000000000000000000",
ApiSecret: "",
},
"apisecret empty",
true,
},
{
Profile{
Account: "test.test.corp.lacework.net",
ApiKey: "000000000000000000000000000000000000000000000000000000",
ApiSecret: "000000000000000000000000000000",
},
"apikey length less than 55 characters",
true,
},
{
Profile{
Account: "test.test.corp.lacework.net",
ApiKey: "0000000000000000000000000000000000000000000000000000000",
ApiSecret: "00000000000000000000000000000",
},
"api secret length less than 30 characters",
true,
},
}
for _, tc := range tests {
t.Run(tc.desc, func(t *testing.T) {
err := tc.profile.Verify()
if (err != nil) != tc.error {
t.Error("Incorrect result")
}
})
}
}