From cfa69c4ee019162a604acdb1ffa2b4116ea22b96 Mon Sep 17 00:00:00 2001 From: dencoded <33698537+dencoded@users.noreply.github.com> Date: Fri, 4 May 2018 16:47:46 -0400 Subject: [PATCH] tests fixed --- cert_test.go | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/cert_test.go b/cert_test.go index b11b868addb..d820a3163e1 100644 --- a/cert_test.go +++ b/cert_test.go @@ -752,32 +752,40 @@ func TestProxyTransport(t *testing.T) { })) defer upstream.Close() - config.Global.ProxySSLInsecureSkipVerify = true + globalConf := config.Global() + globalConf.ProxySSLInsecureSkipVerify = true // force creating new transport on each reque - config.Global.MaxConnTime = -1 + globalConf.MaxConnTime = -1 + config.SetGlobal(globalConf) defer resetTestConfig() ts := newTykTestServer() defer ts.Close() - buildAndLoadAPI(func(spec *APISpec) { - spec.Proxy.ListenPath = "/" - spec.Proxy.TargetURL = upstream.URL - }) - //matching ciphers t.Run("Global: Cipher match", func(t *testing.T) { - config.Global.ProxySSLCipherSuites = []string{"TLS_RSA_WITH_AES_128_CBC_SHA"} + globalConf.ProxySSLCipherSuites = []string{"TLS_RSA_WITH_AES_128_CBC_SHA"} + config.SetGlobal(globalConf) + buildAndLoadAPI(func(spec *APISpec) { + spec.Proxy.ListenPath = "/" + spec.Proxy.TargetURL = upstream.URL + }) ts.Run(t, test.TestCase{Path: "/", Code: 200}) }) t.Run("Global: Cipher not match", func(t *testing.T) { - config.Global.ProxySSLCipherSuites = []string{"TLS_RSA_WITH_RC4_128_SHA"} + globalConf.ProxySSLCipherSuites = []string{"TLS_RSA_WITH_RC4_128_SHA"} + config.SetGlobal(globalConf) + buildAndLoadAPI(func(spec *APISpec) { + spec.Proxy.ListenPath = "/" + spec.Proxy.TargetURL = upstream.URL + }) ts.Run(t, test.TestCase{Path: "/", Code: 500}) }) t.Run("API: Cipher override", func(t *testing.T) { - config.Global.ProxySSLCipherSuites = []string{"TLS_RSA_WITH_RC4_128_SHA"} + globalConf.ProxySSLCipherSuites = []string{"TLS_RSA_WITH_RC4_128_SHA"} + config.SetGlobal(globalConf) buildAndLoadAPI(func(spec *APISpec) { spec.Proxy.ListenPath = "/" spec.Proxy.TargetURL = upstream.URL @@ -788,7 +796,8 @@ func TestProxyTransport(t *testing.T) { }) t.Run("API: MinTLS not match", func(t *testing.T) { - config.Global.ProxySSLMinVersion = 772 + globalConf.ProxySSLMinVersion = 772 + config.SetGlobal(globalConf) buildAndLoadAPI(func(spec *APISpec) { spec.Proxy.ListenPath = "/" spec.Proxy.TargetURL = upstream.URL @@ -799,7 +808,8 @@ func TestProxyTransport(t *testing.T) { }) t.Run("API: Proxy", func(t *testing.T) { - config.Global.ProxySSLMinVersion = 771 + globalConf.ProxySSLMinVersion = 771 + config.SetGlobal(globalConf) buildAndLoadAPI(func(spec *APISpec) { spec.Proxy.ListenPath = "/" spec.Proxy.TargetURL = upstream.URL