1
1
package f5
2
2
3
3
import (
4
- "crypto/tls"
5
4
"encoding/json"
6
5
"flag"
7
6
"fmt"
@@ -182,6 +181,10 @@ func newF5Routes(mockF5State mockF5State) *mux.Router {
182
181
return mockF5
183
182
}
184
183
184
+ // newTestRouterWithState creates a new F5 plugin with a mock F5 BIG-IP server
185
+ // initialized from the given mock F5 state and returns pointers to the plugin
186
+ // and mock server. Note that these pointers will be nil if an error is
187
+ // returned.
185
188
func newTestRouterWithState (state mockF5State , partitionPath string ) (* F5Plugin , * mockF5 , error ) {
186
189
routerLogLevel := util .Env ("TEST_ROUTER_LOGLEVEL" , "" )
187
190
if routerLogLevel != "" {
@@ -190,18 +193,7 @@ func newTestRouterWithState(state mockF5State, partitionPath string) (*F5Plugin,
190
193
191
194
execCommand = mockExecCommand
192
195
193
- server := httptest .NewUnstartedServer (newF5Routes (state ))
194
- // Work around performance issues with Golang's ECDHE implementation.
195
- // See <https://github.com/openshift/origin/issues/4407>.
196
- server .Config .TLSConfig = new (tls.Config )
197
- server .Config .TLSConfig .CipherSuites = []uint16 {
198
- tls .TLS_RSA_WITH_RC4_128_SHA ,
199
- tls .TLS_RSA_WITH_AES_128_CBC_SHA ,
200
- tls .TLS_RSA_WITH_AES_256_CBC_SHA ,
201
- tls .TLS_RSA_WITH_3DES_EDE_CBC_SHA ,
202
- }
203
- server .TLS = server .Config .TLSConfig
204
- server .StartTLS ()
196
+ server := httptest .NewTLSServer (newF5Routes (state ))
205
197
206
198
url , err := url .Parse (server .URL )
207
199
if err != nil {
@@ -230,6 +222,9 @@ func newTestRouterWithState(state mockF5State, partitionPath string) (*F5Plugin,
230
222
return router , mockF5 , nil
231
223
}
232
224
225
+ // newTestRouter creates a new F5 plugin with a mock F5 BIG-IP server and
226
+ // returns pointers to the plugin and mock server. Note that these pointers
227
+ // will be nil if an error is returned.
233
228
func newTestRouter (partitionPath string ) (* F5Plugin , * mockF5 , error ) {
234
229
pathKey := strings .Replace (partitionPath , "/" , "~" , - 1 )
235
230
state := mockF5State {
@@ -1264,6 +1259,7 @@ func TestInitializeF5Plugin(t *testing.T) {
1264
1259
if err != nil {
1265
1260
t .Fatalf ("Failed to initialize test router: %v" , err )
1266
1261
}
1262
+ defer mockF5 .close ()
1267
1263
1268
1264
// The policy for secure routes and the policy for insecure routes should
1269
1265
// exist.
@@ -1405,7 +1401,6 @@ func TestF5RouterPartition(t *testing.T) {
1405
1401
1406
1402
for _ , tc := range testCases {
1407
1403
_ , mockF5 , err := newTestRouter (tc .partition )
1408
- mockF5 .close ()
1409
1404
if err != nil {
1410
1405
t .Fatalf ("Test case %q failed to initialize test router: %v" , tc .name , err )
1411
1406
}
@@ -1415,7 +1410,7 @@ func TestF5RouterPartition(t *testing.T) {
1415
1410
if ! ok {
1416
1411
t .Fatalf ("Test case %q missing partition key %s" , tc .name , name )
1417
1412
}
1418
- defer mockF5 .close ()
1413
+ mockF5 .close ()
1419
1414
}
1420
1415
}
1421
1416
0 commit comments