/
tests.go
203 lines (173 loc) · 4.46 KB
/
tests.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
package tests
import (
"fmt"
"testing"
// load the ginko test package
_ "github.com/onsi/ginkgo"
)
// RunSuite executes the complete test suite for a driver.
func RunSuite(t *testing.T, driver string) {
// the driver's tests using a tcp server
Describe(newSuiteRunner(t, driver, "tcp"))
// the driver's tests using a unix socket server
Describe(newSuiteRunner(t, driver, "unix"))
RegisterFailHandler(Fail)
RunSpecs(t, fmt.Sprintf("%s Suite", driver))
}
func (sr *suiteRunner) Describe() {
var t *testRunner
BeforeEach(func() {
t = newTestRunner(sr.driverName)
t.beforeEach()
})
AfterEach(func() {
t.afterEach()
t = nil
})
JustBeforeEach(func() {
t.justBeforeEach()
})
Describe("w server", func() {
BeforeEach(func() {
switch sr.proto {
case "tcp":
t.initTCPSocket()
case "unix":
t.initUNIXSocket()
}
t.initConfigData()
})
JustBeforeEach(func() {
t.initServer()
})
Context("w client", func() {
JustBeforeEach(func() {
t.justBeforeEachClientSpec()
})
It("list root resources", func() {
t.itClientSpecListRootResources()
})
It("list all volumes for all services", func() {
t.itClientSpecListVolumes()
})
Context("w service", func() {
BeforeEach(func() {
t.beforeEachClientServiceSpec()
})
It("list volumes", func() {
t.itClientSvcSpecListVolumes()
})
It("inspect a missing volume", func() {
t.itClientSvcSpecInspectMissingVolume()
})
It("create a new volume", func() {
t.itClientSvcSpecCreateVolume()
})
Context("w volume", func() {
AfterEach(func() {
t.afterEachVolumeSpec()
})
JustBeforeEach(func() {
t.justBeforeEachVolumeSpec()
})
It("inspect the volume", func() {
t.itVolumeSpecInspect()
})
It("delete the volume", func() {
t.itVolumeSpecDelete()
})
It("attach the volume", func() {
t.itVolumeSpecAttach()
})
Context("that is attached", func() {
JustBeforeEach(func() {
t.justBeforeEachAttVolumeSpec()
})
It("inspect w att req", func() {
t.itAttVolumeSpecInspect()
})
It("inspect w att req - avai", func() {
t.itAttVolumeSpecInspectAvai()
})
It("inspect w att req - att or avai", func() {
t.itAttVolumeSpecInspectAttOrAvai()
})
It("deatch", func() {
t.itAttVolumeSpecDetach()
})
}) // Context w att volume
}) // Context w volume
}) // Context w service
}) // Context w client
// withClients is used to validate the following tls connections
withClients := func() {
Context("w client", func() {
JustBeforeEach(func() {
t.justBeforeEachClientSpec()
})
It("list root resources", func() {
t.itClientSpecListRootResources()
})
}) // Context w client
Context("w non-tls client", func() {
JustBeforeEach(func() {
t.justBeforeEachTLSClientNoTLS()
})
It("client should fail", func() {
t.itTLSClientError()
})
}) // Context w non-tls client
}
Describe("w tls", func() {
BeforeEach(func() {
t.beforeEachTLS()
})
withClients()
}) // Describe w tls
Describe("w tls auto config", func() {
BeforeEach(func() {
t.beforeEachTLSAuto()
})
withClients()
}) // Describe w tls auto config
Describe("w tls insecure config", func() {
BeforeEach(func() {
t.beforeEachTLSInsecure()
})
withClients()
}) // Describe w tls insecure config
// withRemovedKnownHostsFile is used to validate the below
// tests that involve configuring TLS using a known hosts file.
withRemovedKnownHostsFile := func() {
Context("w removed known_hosts file", func() {
JustBeforeEach(func() {
t.justBeforeEachTLSRemoveKnownHosts()
})
Specify("client should fail", func() {
t.itTLSClientError()
})
}) // Context w removed known_hosts file
}
Describe("w tls known_hosts", func() {
BeforeEach(func() {
t.beforeEachTLSKnownHosts()
})
withClients()
withRemovedKnownHostsFile()
}) // Describe w tls known_hosts
Describe("w tls auto known_hosts", func() {
BeforeEach(func() {
t.beforeEachTLSKnownHostsAuto()
})
withClients()
withRemovedKnownHostsFile()
}) // Describe w tls auto known_hosts
Describe("w tls auto known_hosts & auto config", func() {
BeforeEach(func() {
t.beforeEachTLSAutoKnownHostsAuto()
})
withClients()
withRemovedKnownHostsFile()
}) // Describe w tls auto known_hosts & auto config
}) // Describe w server
}