From 93abdb120597bd36b19139851f3d62ef355e0138 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Larsen Date: Thu, 17 Jan 2019 21:53:32 +0100 Subject: [PATCH 1/2] Fix websocket e2e tests for https endpoints When running e2e conformance tests against a public https protected APIserver the websocket tests would fail because it fell back to using `ws://` instead of `wss://` for the websocket connection. This happened because the code detect if HTTPS is used only looks for HTTPS related configuration in the kubeconfig, like a custom CA or certificates. The fix is to always use HTTPS when the apiserver URL has the scheme `https://`. Signed-off-by: Mikkel Oscar Lyderik Larsen --- test/e2e/framework/util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 7256ab61eb..fa97b132aa 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -4226,7 +4226,7 @@ func OpenWebSocketForURL(url *url.URL, config *restclient.Config, protocols []st if err != nil { return nil, fmt.Errorf("Failed to create tls config: %v", err) } - if tlsConfig != nil { + if tlsConfig != nil || url.Scheme == "https" { url.Scheme = "wss" if !strings.Contains(url.Host, ":") { url.Host += ":443" From 9f34d8bc79cecbffba72879e4ffff3d31c5fff47 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Larsen Date: Mon, 18 Feb 2019 09:45:31 +0100 Subject: [PATCH 2/2] Remove 'tlsConfig != nil' check Signed-off-by: Mikkel Oscar Lyderik Larsen --- test/e2e/framework/util.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index fa97b132aa..b1337ed11e 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -4226,16 +4226,10 @@ func OpenWebSocketForURL(url *url.URL, config *restclient.Config, protocols []st if err != nil { return nil, fmt.Errorf("Failed to create tls config: %v", err) } - if tlsConfig != nil || url.Scheme == "https" { + if url.Scheme == "https" { url.Scheme = "wss" - if !strings.Contains(url.Host, ":") { - url.Host += ":443" - } } else { url.Scheme = "ws" - if !strings.Contains(url.Host, ":") { - url.Host += ":80" - } } headers, err := headersForConfig(config, url) if err != nil {