Prefer slices package and slices.Concat where possible

This commit is contained in:
Joshua Casey
2024-05-21 09:31:16 -05:00
parent bdd79a9984
commit fe911a7b7a
26 changed files with 97 additions and 85 deletions
+3 -2
View File
@@ -14,6 +14,7 @@ import (
"os/exec"
"path/filepath"
"regexp"
"slices"
"strings"
"testing"
"time"
@@ -142,7 +143,7 @@ func assertWhoami(ctx context.Context, t *testing.T, useProxy bool, pinnipedExe,
apiGroupSuffix,
)
if useProxy {
cmd.Env = append(os.Environ(), testlib.IntegrationEnv(t).ProxyEnv()...)
cmd.Env = slices.Concat(os.Environ(), testlib.IntegrationEnv(t).ProxyEnv())
}
cmd.Stdout = &stdout
cmd.Stderr = &stderr
@@ -427,6 +428,6 @@ func oidcLoginCommand(ctx context.Context, t *testing.T, pinnipedExe string, ses
}
// If there is a custom proxy, set it using standard environment variables.
cmd.Env = append(os.Environ(), env.ProxyEnv()...)
cmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
return cmd
}
@@ -22,6 +22,7 @@ import (
"os"
"os/exec"
"path/filepath"
"slices"
"sort"
"strings"
"sync"
@@ -594,7 +595,7 @@ func TestImpersonationProxy(t *testing.T) { //nolint:gocyclo // yeah, it's compl
require.NoError(t, err)
expectedGroups := make([]string, 0, len(env.TestUser.ExpectedGroups)+1) // make sure we do not mutate env.TestUser.ExpectedGroups
expectedGroups = append(expectedGroups, env.TestUser.ExpectedGroups...)
expectedGroups = slices.Concat(expectedGroups, env.TestUser.ExpectedGroups)
expectedGroups = append(expectedGroups, "system:authenticated")
expectedOriginalUserInfo := authenticationv1.UserInfo{
Username: env.TestUser.ExpectedUsername,
@@ -880,7 +881,7 @@ func TestImpersonationProxy(t *testing.T) { //nolint:gocyclo // yeah, it's compl
Create(ctx, &identityv1alpha1.WhoAmIRequest{}, metav1.CreateOptions{})
require.NoError(t, err, testlib.Sdump(err))
expectedGroups := make([]string, 0, len(env.TestUser.ExpectedGroups)+1) // make sure we do not mutate env.TestUser.ExpectedGroups
expectedGroups = append(expectedGroups, env.TestUser.ExpectedGroups...)
expectedGroups = slices.Concat(expectedGroups, env.TestUser.ExpectedGroups)
expectedGroups = append(expectedGroups, "system:authenticated")
require.Equal(t,
expectedWhoAmIRequestResponse(
@@ -2116,7 +2117,7 @@ func performImpersonatorDiscovery(ctx context.Context, t *testing.T, env *testli
require.NoError(t, err)
expectedGroups := make([]string, 0, len(env.TestUser.ExpectedGroups)+1) // make sure we do not mutate env.TestUser.ExpectedGroups
expectedGroups = append(expectedGroups, env.TestUser.ExpectedGroups...)
expectedGroups = slices.Concat(expectedGroups, env.TestUser.ExpectedGroups)
expectedGroups = append(expectedGroups, "system:authenticated")
// probe each pod directly for readiness since the concierge status is a lie - it just means a single pod is ready
@@ -2339,7 +2340,7 @@ func getImpersonationKubeconfig(t *testing.T, env *testlib.TestEnv, impersonatio
var envVarsWithProxy []string
if !env.HasCapability(testlib.HasExternalLoadBalancerProvider) {
// Only if you don't have a load balancer, use the squid proxy when it's available.
envVarsWithProxy = append(os.Environ(), env.ProxyEnv()...)
envVarsWithProxy = slices.Concat(os.Environ(), env.ProxyEnv())
}
// Get the kubeconfig.
@@ -2380,7 +2381,7 @@ func getImpersonationKubeconfig(t *testing.T, env *testlib.TestEnv, impersonatio
func kubectlCommand(timeout context.Context, t *testing.T, kubeconfigPath string, envVarsWithProxy []string, args ...string) (*exec.Cmd, *syncBuffer, *syncBuffer) {
t.Helper()
allArgs := append([]string{"--kubeconfig", kubeconfigPath}, args...)
allArgs := slices.Concat([]string{"--kubeconfig", kubeconfigPath}, args)
kubectlCmd := exec.CommandContext(timeout, "kubectl", allArgs...)
var stdout, stderr syncBuffer
kubectlCmd.Stdout = &stdout
+28 -28
View File
@@ -184,7 +184,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a browser login via the plugin.
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath, "-v", "6")
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
// Run the kubectl command, wait for the Pinniped CLI to print the authorization URL, and open it in the browser.
kubectlOutputChan := startKubectlAndOpenAuthorizationURLInBrowser(testCtx, t, kubectlCmd, browser)
@@ -270,7 +270,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a browser login via the plugin.
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath, "-v", "6")
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
// Run the kubectl command, wait for the Pinniped CLI to print the authorization URL, and open it in the browser.
kubectlOutputChan := startKubectlAndOpenAuthorizationURLInBrowser(testCtx, t, kubectlCmd, browser)
@@ -360,7 +360,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a browser login via the plugin.
start := time.Now()
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
ptyFile, err := pty.Start(kubectlCmd)
require.NoError(t, err)
@@ -484,7 +484,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a browser login via the plugin.
start := time.Now()
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
var kubectlStdoutPipe io.ReadCloser
if runtime.GOOS != "darwin" {
// For some unknown reason this breaks the pty library on some MacOS machines.
@@ -616,7 +616,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a browser-less CLI prompt login via the plugin.
start := time.Now()
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
ptyFile, err := pty.Start(kubectlCmd)
require.NoError(t, err)
@@ -699,7 +699,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// 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()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
ptyFile, err := pty.Start(kubectlCmd)
require.NoError(t, err)
@@ -749,7 +749,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger an LDAP-style login CLI prompt via the plugin.
start := time.Now()
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
ptyFile, err := pty.Start(kubectlCmd)
require.NoError(t, err)
@@ -808,7 +808,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger an LDAP-style login CLI prompt via the plugin.
start := time.Now()
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
ptyFile, err := pty.Start(kubectlCmd)
require.NoError(t, err)
@@ -889,7 +889,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should run an LDAP-style login without interactive prompts for username and password.
start := time.Now()
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
ptyFile, err := pty.Start(kubectlCmd)
require.NoError(t, err)
@@ -942,7 +942,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger an LDAP-style login CLI prompt via the plugin.
start := time.Now()
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
ptyFile, err := pty.Start(kubectlCmd)
require.NoError(t, err)
@@ -1019,7 +1019,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should run an LDAP-style login without interactive prompts for username and password.
start := time.Now()
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
ptyFile, err := pty.Start(kubectlCmd)
require.NoError(t, err)
@@ -1076,7 +1076,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a browser login via the plugin.
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath, "-v", "6")
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
// Run the kubectl command, wait for the Pinniped CLI to print the authorization URL, and open it in the browser.
kubectlOutputChan := startKubectlAndOpenAuthorizationURLInBrowser(testCtx, t, kubectlCmd, browser)
@@ -1131,7 +1131,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a browser login via the plugin.
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath, "-v", "6")
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
// Run the kubectl command, wait for the Pinniped CLI to print the authorization URL, and open it in the browser.
kubectlOutputChan := startKubectlAndOpenAuthorizationURLInBrowser(testCtx, t, kubectlCmd, browser)
@@ -1192,7 +1192,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a browser login via the plugin.
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath, "-v", "6")
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
// Run the kubectl command, wait for the Pinniped CLI to print the authorization URL, and open it in the browser.
kubectlOutputChan := startKubectlAndOpenAuthorizationURLInBrowser(testCtx, t, kubectlCmd, browser)
@@ -1404,7 +1404,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
t.Log("starting LDAP auth via kubectl")
start := time.Now()
kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", ldapKubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
ptyFile, err := pty.Start(kubectlCmd)
require.NoError(t, err)
@@ -1431,7 +1431,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a browser login via the plugin for the OIDC IDP.
t.Log("starting OIDC auth via kubectl")
kubectlCmd = exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", oidcKubeconfigPath, "-v", "6")
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
// Run the kubectl command, wait for the Pinniped CLI to print the authorization URL, and open it in the browser.
kubectlOutputChan := startKubectlAndOpenAuthorizationURLInBrowser(testCtx, t, kubectlCmd, browser)
@@ -1517,7 +1517,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger an LDAP-style login CLI prompt via the plugin for the LDAP IDP.
t.Log("starting second LDAP auth via kubectl")
kubectlCmd = exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", ldapKubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
ptyFile, err = pty.Start(kubectlCmd)
require.NoError(t, err)
@@ -1561,8 +1561,8 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
createdLDAPProvider := setupClusterForEndToEndLDAPTest(t, expectedDownstreamLDAPUsername, env)
// Having one IDP should put the FederationDomain into a ready state.
testlib.WaitForFederationDomainStatusPhase(testCtx, t, federationDomain.Name, configv1alpha1.FederationDomainPhaseReady)
testlib.WaitForJWTAuthenticatorStatusPhase(testCtx, t, authenticator.Name, authv1alpha.JWTAuthenticatorPhaseReady)
testlib.WaitForFederationDomainStatusPhase(testCtx, t, federationDomain.Name, supervisorconfigv1alpha1.FederationDomainPhaseReady)
testlib.WaitForJWTAuthenticatorStatusPhase(testCtx, t, authenticator.Name, authenticationv1alpha1.JWTAuthenticatorPhaseReady)
// Create a ClusterRoleBinding to give our test user from the upstream read-only access to the cluster.
testlib.CreateTestClusterRoleBinding(t,
@@ -1596,8 +1596,8 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
}, idpv1alpha1.PhaseReady)
// Having a second IDP should put the FederationDomain back into an error state until we tell it which one to use.
testlib.WaitForFederationDomainStatusPhase(testCtx, t, federationDomain.Name, configv1alpha1.FederationDomainPhaseError)
testlib.WaitForJWTAuthenticatorStatusPhase(testCtx, t, authenticator.Name, authv1alpha.JWTAuthenticatorPhaseReady)
testlib.WaitForFederationDomainStatusPhase(testCtx, t, federationDomain.Name, supervisorconfigv1alpha1.FederationDomainPhaseError)
testlib.WaitForJWTAuthenticatorStatusPhase(testCtx, t, authenticator.Name, authenticationv1alpha1.JWTAuthenticatorPhaseReady)
// Update the FederationDomain to use the two IDPs.
federationDomainsClient := testlib.NewSupervisorClientset(t).ConfigV1alpha1().FederationDomains(env.SupervisorNamespace)
@@ -1611,7 +1611,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
ldapIDPDisplayName := "My LDAP IDP 💾"
oidcIDPDisplayName := "My OIDC IDP 🚀"
gotFederationDomain.Spec.IdentityProviders = []configv1alpha1.FederationDomainIdentityProvider{
gotFederationDomain.Spec.IdentityProviders = []supervisorconfigv1alpha1.FederationDomainIdentityProvider{
{
DisplayName: ldapIDPDisplayName,
ObjectRef: corev1.TypedLocalObjectReference{
@@ -1633,8 +1633,8 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
require.NoError(t, err)
// The FederationDomain should be valid after the above update.
testlib.WaitForFederationDomainStatusPhase(testCtx, t, federationDomain.Name, configv1alpha1.FederationDomainPhaseReady)
testlib.WaitForJWTAuthenticatorStatusPhase(testCtx, t, authenticator.Name, authv1alpha.JWTAuthenticatorPhaseReady)
testlib.WaitForFederationDomainStatusPhase(testCtx, t, federationDomain.Name, supervisorconfigv1alpha1.FederationDomainPhaseReady)
testlib.WaitForJWTAuthenticatorStatusPhase(testCtx, t, authenticator.Name, authenticationv1alpha1.JWTAuthenticatorPhaseReady)
// Use a specific session cache for this test.
sessionCachePath := tempDir + "/test-sessions.yaml"
@@ -1979,7 +1979,7 @@ func requireUserCanUseKubectlWithoutAuthenticatingAgain(
) {
// Run kubectl, which should work without any prompting for authentication.
kubectlCmd := exec.CommandContext(ctx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
startTime := time.Now()
kubectlOutput2, err := kubectlCmd.CombinedOutput()
require.NoError(t, err)
@@ -2017,7 +2017,7 @@ func requireUserCanUseKubectlWithoutAuthenticatingAgain(
require.ElementsMatch(t, expectedGroupsAsEmptyInterfaces, idTokenClaims["groups"])
}
expectedGroupsPlusAuthenticated := append([]string{}, expectedGroups...)
expectedGroupsPlusAuthenticated := expectedGroups
expectedGroupsPlusAuthenticated = append(expectedGroupsPlusAuthenticated, "system:authenticated")
// Confirm we are the right user according to Kube by calling the WhoAmIRequest API.
@@ -2029,7 +2029,7 @@ func requireUserCanUseKubectlWithoutAuthenticatingAgain(
// While it is true that the user cannot list CRDs, that fact seems unrelated to making a create call to the
// aggregated API endpoint, so this is a strange error, but it can be easily reproduced.
kubectlCmd3 := exec.CommandContext(ctx, "kubectl", "create", "-f", "-", "-o", "yaml", "--kubeconfig", kubeconfigPath, "--validate=false")
kubectlCmd3.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd3.Env = slices.Concat(os.Environ(), env.ProxyEnv())
kubectlCmd3.Stdin = strings.NewReader(here.Docf(`
apiVersion: identity.concierge.%s/v1alpha1
kind: WhoAmIRequest
@@ -2091,7 +2091,7 @@ func requireGCAnnotationsOnSessionStorage(ctx context.Context, t *testing.T, sup
func runPinnipedGetKubeconfig(t *testing.T, env *testlib.TestEnv, pinnipedExe string, tempDir string, pinnipedCLICommand []string) string {
// Run "pinniped get kubeconfig" to get a kubeconfig YAML.
envVarsWithProxy := append(os.Environ(), env.ProxyEnv()...)
envVarsWithProxy := slices.Concat(os.Environ(), env.ProxyEnv())
kubeconfigYAML, stderr := runPinnipedCLI(t, envVarsWithProxy, pinnipedExe, pinnipedCLICommand...)
t.Logf("stderr output from 'pinniped get kubeconfig':\n%s\n\n", stderr)
t.Logf("test kubeconfig:\n%s\n\n", kubeconfigYAML)
+2 -2
View File
@@ -1,4 +1,4 @@
// Copyright 2023 the Pinniped contributors. All Rights Reserved.
// Copyright 2023-2024 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package integration
@@ -7,6 +7,7 @@ import (
"bytes"
"context"
"io"
"slices"
"strings"
"testing"
"time"
@@ -14,7 +15,6 @@ import (
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/strings/slices"
"go.pinniped.dev/test/testlib"
)
@@ -13,6 +13,7 @@ import (
"net"
"net/http"
"net/url"
"slices"
"strings"
"testing"
"time"
@@ -23,7 +24,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/util/retry"
"k8s.io/utils/strings/slices"
supervisorconfigv1alpha1 "go.pinniped.dev/generated/latest/apis/supervisor/config/v1alpha1"
idpv1alpha1 "go.pinniped.dev/generated/latest/apis/supervisor/idp/v1alpha1"
+2 -2
View File
@@ -16,6 +16,7 @@ import (
"net/http/httptest"
"net/url"
"regexp"
"slices"
"strings"
"testing"
"time"
@@ -27,7 +28,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
"k8s.io/utils/strings/slices"
supervisorconfigv1alpha1 "go.pinniped.dev/generated/latest/apis/supervisor/config/v1alpha1"
idpv1alpha1 "go.pinniped.dev/generated/latest/apis/supervisor/idp/v1alpha1"
@@ -802,7 +802,7 @@ func TestSupervisorLogin_Browser(t *testing.T) {
requestAuthorizationUsingCLIPasswordFlow(t,
downstreamAuthorizeURL,
env.SupervisorUpstreamLDAP.TestUserMailAttributeValue, // username to present to server during login
"incorrect", // password to present to server during login
"incorrect", // password to present to server during login
httpClient,
true,
)
@@ -10,6 +10,7 @@ import (
"encoding/json"
"fmt"
"os/exec"
"slices"
"testing"
"time"
@@ -1020,10 +1021,7 @@ func retainOnlyMostRecentSecret(list []string) []string {
}
func prependSecret(list []string, newItem string) []string {
newList := make([]string, 0, len(list)+1)
newList = append(newList, newItem)
newList = append(newList, list...)
return newList
return slices.Concat([]string{newItem}, list)
}
func TestOIDCClientSecretRequestUnauthenticated_Parallel(t *testing.T) {
+7 -6
View File
@@ -13,6 +13,7 @@ import (
"path/filepath"
"regexp"
"runtime"
"slices"
"sort"
"strings"
"testing"
@@ -129,7 +130,7 @@ func TestSupervisorWarnings_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a cli-based login.
start := time.Now()
kubectlCmd := exec.CommandContext(ctx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
var kubectlStdoutPipe io.ReadCloser
if runtime.GOOS != "darwin" {
// For some unknown reason this breaks the pty library on some MacOS machines.
@@ -219,7 +220,7 @@ func TestSupervisorWarnings_Browser(t *testing.T) {
// Run kubectl, which should work without any prompting for authentication.
kubectlCmd2 := exec.CommandContext(ctx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd2.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd2.Env = slices.Concat(os.Environ(), env.ProxyEnv())
startTime2 := time.Now()
var kubectlStdoutPipe2 io.ReadCloser
if runtime.GOOS != "darwin" {
@@ -277,7 +278,7 @@ func TestSupervisorWarnings_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a cli-based login.
start := time.Now()
kubectlCmd := exec.CommandContext(ctx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
var kubectlStdoutPipe io.ReadCloser
if runtime.GOOS != "darwin" {
// For some unknown reason this breaks the pty library on some MacOS machines.
@@ -348,7 +349,7 @@ func TestSupervisorWarnings_Browser(t *testing.T) {
// Run kubectl, which should work without any prompting for authentication.
kubectlCmd2 := exec.CommandContext(ctx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd2.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd2.Env = slices.Concat(os.Environ(), env.ProxyEnv())
startTime2 := time.Now()
var kubectlStdoutPipe2 io.ReadCloser
if runtime.GOOS != "darwin" {
@@ -442,7 +443,7 @@ func TestSupervisorWarnings_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a cli-based login.
start := time.Now()
kubectlCmd := exec.CommandContext(ctx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd.Env = slices.Concat(os.Environ(), env.ProxyEnv())
var kubectlStdoutPipe io.ReadCloser
if runtime.GOOS != "darwin" {
// For some unknown reason this breaks the pty library on some MacOS machines.
@@ -555,7 +556,7 @@ func TestSupervisorWarnings_Browser(t *testing.T) {
// Run kubectl, which should work without any prompting for authentication.
kubectlCmd2 := exec.CommandContext(ctx, "kubectl", "get", "namespace", "--kubeconfig", kubeconfigPath)
kubectlCmd2.Env = append(os.Environ(), env.ProxyEnv()...)
kubectlCmd2.Env = slices.Concat(os.Environ(), env.ProxyEnv())
startTime2 := time.Now()
var kubectlStdoutPipe2 io.ReadCloser
if runtime.GOOS != "darwin" {