-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
43 lines (37 loc) · 1.04 KB
/
main_test.go
File metadata and controls
43 lines (37 loc) · 1.04 KB
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
package main
import (
"testing"
"github.com/compliance-framework/agent/runner/proto"
"github.com/hashicorp/go-hclog"
)
func TestConfigureDefaultsCollectIPAllowListToFalse(t *testing.T) {
plugin := &CompliancePlugin{logger: hclog.NewNullLogger()}
_, err := plugin.Configure(&proto.ConfigureRequest{
Config: map[string]string{
"token": "token",
"organization": "acme",
},
})
if err != nil {
t.Fatalf("Configure returned error: %v", err)
}
if plugin.config.CollectIPAllowList {
t.Fatal("CollectIPAllowList should default to false")
}
}
func TestConfigureParsesCollectIPAllowList(t *testing.T) {
plugin := &CompliancePlugin{logger: hclog.NewNullLogger()}
_, err := plugin.Configure(&proto.ConfigureRequest{
Config: map[string]string{
"token": "token",
"organization": "acme",
"collect_ip_allow_list": "true",
},
})
if err != nil {
t.Fatalf("Configure returned error: %v", err)
}
if !plugin.config.CollectIPAllowList {
t.Fatal("CollectIPAllowList should be true when configured")
}
}