-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
46 lines (39 loc) · 1.23 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
package infa_auth
import (
"path/filepath"
"testing"
"github.com/shadow0wolf/infa_auth/internal/metadata"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"
)
type Aaa struct {
id component.ID
expected component.Config
}
func TestLoadConfig(t *testing.T) {
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
require.NoError(t, err)
factory := NewFactory()
defaultCfg := factory.CreateDefaultConfig()
var tt = Aaa{
id: component.NewID(metadata.Type),
expected: &Config{
TimeOut: 1,
ClientSideSsl: true,
ValidationURL: "https://pod.ics.dev:444/session-service/api/v1/session/Agent",
Headerkey: "IDS-AGENT-SESSION-ID",
ClientJksPath: "/mnt/a/c1Client.crt",
ClientJksPassword: "changeit1",
CAJksPath: "/mnt/a/ca_cert_path.crt",
CAJksPassword: "changeit2",
InsecureSkipVerify: false,
},
}
sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, defaultCfg))
assert.NoError(t, component.ValidateConfig(defaultCfg))
assert.Equal(t, tt.expected, defaultCfg)
}