From 9a0f75980d8b62a81fa52c9f543727e84c9d7502 Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Thu, 4 Mar 2021 12:35:29 -0600 Subject: [PATCH] Set a special proxy environment just for the "pinniped login oidc" command in the E2E test. Signed-off-by: Matt Moyer --- test/integration/e2e_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/integration/e2e_test.go b/test/integration/e2e_test.go index 35f67e1d..ba77759b 100644 --- a/test/integration/e2e_test.go +++ b/test/integration/e2e_test.go @@ -26,6 +26,7 @@ import ( authorizationv1 "k8s.io/api/authorization/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" + clientcmdapi "k8s.io/client-go/tools/clientcmd/api" authv1alpha "go.pinniped.dev/generated/latest/apis/concierge/authentication/v1alpha1" configv1alpha1 "go.pinniped.dev/generated/latest/apis/supervisor/config/v1alpha1" @@ -162,6 +163,17 @@ func TestE2EFullIntegration(t *testing.T) { restConfig := library.NewRestConfigFromKubeconfig(t, kubeconfigYAML) require.NotNil(t, restConfig.ExecProvider) require.Equal(t, []string{"login", "oidc"}, restConfig.ExecProvider.Args[:2]) + + // If there is a proxy, we always want the "pinniped login oidc" command to use it, even if the + // parent kubectl process is connecting to an external load balancer and not using the proxy. + if env.Proxy != "" { + restConfig.ExecProvider.Env = append(restConfig.ExecProvider.Env, + clientcmdapi.ExecEnvVar{Name: "http_proxy", Value: env.Proxy}, + clientcmdapi.ExecEnvVar{Name: "https_proxy", Value: env.Proxy}, + clientcmdapi.ExecEnvVar{Name: "no_proxy", Value: "127.0.0.1"}, + ) + } + kubeconfigPath := filepath.Join(tempDir, "kubeconfig.yaml") require.NoError(t, ioutil.WriteFile(kubeconfigPath, []byte(kubeconfigYAML), 0600))