forked from open-horizon/anax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_sync_service_test.go
148 lines (127 loc) · 6.72 KB
/
file_sync_service_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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package config
import (
"path"
"testing"
)
func Test_default_FSS(t *testing.T) {
testCfg := &HorizonConfig{
Edge: Config{
FileSyncService: FSSConfig{},
},
}
if !testCfg.FSSIsUnixProtocol() {
t.Errorf("config API should indicate unix FSS protocol in use")
} else if testCfg.GetFileSyncServiceProtocol() != "secure-unix" {
t.Errorf("config API should indicate unix FSS protocol value, is %v", testCfg.GetFileSyncServiceProtocol())
} else if testCfg.GetFileSyncServiceAPIPort() != 0 {
t.Errorf("config API should indicate port 0, is %v", testCfg.GetFileSyncServiceAPIPort())
} else if testCfg.GetFileSyncServiceAPIListen() != path.Join(HZN_FSS_DOMAIN_SOCKET_PATH, HZN_FSS_DOMAIN_SOCKET) {
t.Errorf("config API should be the default unix socket, is %v", testCfg.GetFileSyncServiceAPIListen())
} else if testCfg.GetFileSyncServiceAPIUnixDomainSocketPath() != HZN_FSS_DOMAIN_SOCKET_PATH {
t.Errorf("config API should be the default unix socket path, is %v", testCfg.GetFileSyncServiceAPIUnixDomainSocketPath())
} else if testCfg.GetFileSyncServiceStoragePath() != path.Join(getDefaultBase(), HZN_FSS_STORAGE_PATH) {
t.Errorf("config API should be the default persistence path, is %v", testCfg.GetFileSyncServiceStoragePath())
} else if testCfg.GetFileSyncServiceAuthPath() != path.Join(getDefaultBase(), HZN_FSS_AUTH_PATH) {
t.Errorf("config API should be the default authentication path, is %v", testCfg.GetFileSyncServiceAuthPath())
} else if testCfg.GetCSSURL() != "" {
t.Errorf("config API should have an empty CSS URL, is %v", testCfg.GetCSSURL())
}
}
func Test_unix_config_FSS(t *testing.T) {
testCfg := &HorizonConfig{
Edge: Config{
FileSyncService: FSSConfig{
APIListen: "/var/run/something/my.sock",
},
},
}
if !testCfg.FSSIsUnixProtocol() {
t.Errorf("config API should indicate unix FSS protocol in use")
} else if testCfg.GetFileSyncServiceProtocol() != "secure-unix" {
t.Errorf("config API should indicate unix FSS protocol value, is %v", testCfg.GetFileSyncServiceProtocol())
} else if testCfg.GetFileSyncServiceAPIPort() != 0 {
t.Errorf("config API should indicate port 0, is %v", testCfg.GetFileSyncServiceAPIPort())
} else if testCfg.GetFileSyncServiceAPIListen() != "/var/run/something/my.sock" {
t.Errorf("config API should be the default unix socket, is %v", testCfg.GetFileSyncServiceAPIListen())
} else if testCfg.GetFileSyncServiceAPIUnixDomainSocketPath() != "/var/run/something" {
t.Errorf("config API should be the default unix socket path, is %v", testCfg.GetFileSyncServiceAPIUnixDomainSocketPath())
}
}
func Test_unix_config_error_FSS(t *testing.T) {
testCfg := &HorizonConfig{
Edge: Config{
FileSyncService: FSSConfig{
APIListen: "1.1.1.1",
APIPort: 5555,
},
},
}
if !testCfg.FSSIsUnixProtocol() {
t.Errorf("config API should indicate unix FSS protocol in use")
} else if testCfg.GetFileSyncServiceProtocol() != "secure-unix" {
t.Errorf("config API should indicate unix FSS protocol value, is %v", testCfg.GetFileSyncServiceProtocol())
} else if testCfg.GetFileSyncServiceAPIPort() != 0 {
t.Errorf("config API should indicate port 0, is %v", testCfg.GetFileSyncServiceAPIPort())
} else if testCfg.GetFileSyncServiceAPIListen() != path.Join(HZN_FSS_DOMAIN_SOCKET_PATH, HZN_FSS_DOMAIN_SOCKET) {
t.Errorf("config API should be the default unix socket, is %v", testCfg.GetFileSyncServiceAPIListen())
} else if testCfg.GetFileSyncServiceAPIUnixDomainSocketPath() != HZN_FSS_DOMAIN_SOCKET_PATH {
t.Errorf("config API should be the default unix socket path, is %v", testCfg.GetFileSyncServiceAPIUnixDomainSocketPath())
}
}
func Test_TCP_default_FSS(t *testing.T) {
testCfg := &HorizonConfig{
Edge: Config{
FileSyncService: FSSConfig{
APIProtocol: "https",
},
},
}
if testCfg.FSSIsUnixProtocol() {
t.Errorf("config API should not indicate unix FSS protocol in use")
} else if testCfg.GetFileSyncServiceProtocol() != "https" {
t.Errorf("config API should indicate https FSS protocol value, is %v", testCfg.GetFileSyncServiceProtocol())
} else if testCfg.GetFileSyncServiceAPIPort() != HZN_FSS_API_LISTEN_PORT_DEFAULT {
t.Errorf("config API should indicate port %v, is %v", HZN_FSS_API_LISTEN_PORT_DEFAULT, testCfg.GetFileSyncServiceAPIPort())
} else if testCfg.GetFileSyncServiceAPIListen() != HZN_FSS_API_LISTEN_DEFAULT {
t.Errorf("config API should be the default listen address, is %v", testCfg.GetFileSyncServiceAPIListen())
} else if testCfg.GetFileSyncServiceAPIUnixDomainSocketPath() != "" {
t.Errorf("config API should not return a unix socket path, is %v", testCfg.GetFileSyncServiceAPIUnixDomainSocketPath())
} else if testCfg.GetFileSyncServiceStoragePath() != path.Join(getDefaultBase(), HZN_FSS_STORAGE_PATH) {
t.Errorf("config API should be the default persistence path, is %v", testCfg.GetFileSyncServiceStoragePath())
} else if testCfg.GetFileSyncServiceAuthPath() != path.Join(getDefaultBase(), HZN_FSS_AUTH_PATH) {
t.Errorf("config API should be the default authentication path, is %v", testCfg.GetFileSyncServiceAuthPath())
} else if testCfg.GetCSSURL() != "" {
t.Errorf("config API should have an empty CSS URL, is %v", testCfg.GetCSSURL())
}
}
func Test_TCP_config_FSS(t *testing.T) {
testCfg := &HorizonConfig{
Edge: Config{
FileSyncService: FSSConfig{
APIProtocol: "https",
APIPort: 8888,
APIListen: "1.1.1.1",
PersistencePath: "/tmp/",
AuthenticationPath: "/tmp/auth/",
CSSURL: "cloud.css.com",
},
},
}
if testCfg.FSSIsUnixProtocol() {
t.Errorf("config API should not indicate unix FSS protocol in use")
} else if testCfg.GetFileSyncServiceProtocol() != "https" {
t.Errorf("config API should indicate https FSS protocol value, is %v", testCfg.GetFileSyncServiceProtocol())
} else if testCfg.GetFileSyncServiceAPIPort() != 8888 {
t.Errorf("config API should indicate port %v, is %v", 8888, testCfg.GetFileSyncServiceAPIPort())
} else if testCfg.GetFileSyncServiceAPIListen() != "1.1.1.1" {
t.Errorf("config API should be the default listen address, is %v", testCfg.GetFileSyncServiceAPIListen())
} else if testCfg.GetFileSyncServiceAPIUnixDomainSocketPath() != "" {
t.Errorf("config API should not return a unix socket path, is %v", testCfg.GetFileSyncServiceAPIUnixDomainSocketPath())
} else if testCfg.GetFileSyncServiceStoragePath() != "/tmp/" {
t.Errorf("config API should be the default persistence path, is %v", testCfg.GetFileSyncServiceStoragePath())
} else if testCfg.GetFileSyncServiceAuthPath() != "/tmp/auth/" {
t.Errorf("config API should be the default authentication path, is %v", testCfg.GetFileSyncServiceAuthPath())
} else if testCfg.GetCSSURL() != "cloud.css.com" {
t.Errorf("config API should have an empty CSS URL, is %v", testCfg.GetCSSURL())
}
}