forked from openstack-exporter/openstack-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
56 lines (50 loc) · 1.25 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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfigAuthVerify(t *testing.T) {
const testVerifiedConnectionConfig = `
clouds:
test.cloud:
region_name: RegionOne
identity_api_version: 3
identity_interface: internal
auth:
username: 'admin'
password: 'admin'
project_name: 'admin'
project_domain_name: 'Default'
user_domain_name: 'Default'
auth_url: 'http://test.cloud:35357/v3'
`
const testUnverifiedConnectionConfig = `
clouds:
test.cloud:
region_name: RegionOne
identity_api_version: 3
identity_interface: internal
auth:
username: 'admin'
password: 'admin'
project_name: 'admin'
project_domain_name: 'Default'
user_domain_name: 'Default'
auth_url: 'http://test.cloud:35357/v3'
verify: false
`
cfg, err := NewCloudConfigFromByteArray([]byte(testVerifiedConnectionConfig))
if assert.NoError(t, err) {
cloud, err := cfg.GetByName("test.cloud")
if assert.NoError(t, err) {
assert.True(t, cloud.Auth.Verify)
}
}
cfg, err = NewCloudConfigFromByteArray([]byte(testUnverifiedConnectionConfig))
if assert.NoError(t, err) {
cloud, err := cfg.GetByName("test.cloud")
if assert.NoError(t, err) {
assert.False(t, cloud.Auth.Verify)
}
}
}