From bedf4e5a3928f394762fd2c6fb9ed614db2818e3 Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Tue, 22 Mar 2022 14:23:50 -0700 Subject: [PATCH] Try to avoid getting a second username prompt in a test in e2e_test.go --- test/integration/e2e_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/integration/e2e_test.go b/test/integration/e2e_test.go index ac4f4930..b2cfd68d 100644 --- a/test/integration/e2e_test.go +++ b/test/integration/e2e_test.go @@ -659,8 +659,13 @@ func TestE2EFullIntegration_Browser(t *testing.T) { // nolint:gocyclo "--oidc-session-cache", sessionCachePath, }) - // Run "kubectl get namespaces" which should trigger a browser-less CLI prompt login via the plugin. - kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath) + // Run "kubectl get --raw /healthz" which should trigger a browser-less CLI prompt login via the plugin. + // Avoid using something like "kubectl get namespaces" for this test because we expect the auth to fail, + // and kubectl might call the credential exec plugin a second time to try to auth again if it needs to do API + // discovery, in which case this test would hang until the kubectl subprocess is killed because the process + // would be stuck waiting for input on the second username prompt. "kubectl get --raw /healthz" doesn't need + // to do API discovery, so we know it will only call the credential exec plugin once. + kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "--raw", "/healthz", "--kubeconfig", kubeconfigPath) kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...) ptyFile, err := pty.Start(kubectlCmd) require.NoError(t, err)