From 12f18cbed88f90f8ff6e9ce7afe029d7ea7ab113 Mon Sep 17 00:00:00 2001 From: Joshua Casey Date: Tue, 29 Aug 2023 17:03:11 -0500 Subject: [PATCH] Inline and remove testutil.TempDir --- cmd/pinniped/cmd/flag_types_test.go | 5 ++-- cmd/pinniped/cmd/kubeconfig_test.go | 2 +- cmd/pinniped/cmd/login_oidc_test.go | 5 ++-- cmd/pinniped/cmd/login_static_test.go | 3 +- internal/execcredcache/cachefile_test.go | 8 ++--- internal/execcredcache/execcredcache_test.go | 10 +++---- internal/testutil/tempdir.go | 12 -------- pkg/oidcclient/filesession/cachefile_test.go | 7 ++--- .../filesession/filesession_test.go | 9 +++--- test/integration/cli_test.go | 11 ++++--- .../concierge_impersonation_proxy_test.go | 2 +- test/integration/e2e_test.go | 30 +++++++++---------- test/integration/supervisor_warnings_test.go | 3 +- test/testlib/cli.go | 4 +-- 14 files changed, 43 insertions(+), 68 deletions(-) delete mode 100644 internal/testutil/tempdir.go diff --git a/cmd/pinniped/cmd/flag_types_test.go b/cmd/pinniped/cmd/flag_types_test.go index 1d731494..255ad2a8 100644 --- a/cmd/pinniped/cmd/flag_types_test.go +++ b/cmd/pinniped/cmd/flag_types_test.go @@ -1,4 +1,4 @@ -// Copyright 2021-2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package cmd @@ -15,7 +15,6 @@ import ( configv1alpha1 "go.pinniped.dev/generated/latest/apis/concierge/config/v1alpha1" "go.pinniped.dev/internal/certauthority" - "go.pinniped.dev/internal/testutil" ) func TestConciergeModeFlag(t *testing.T) { @@ -52,7 +51,7 @@ func TestConciergeModeFlag(t *testing.T) { func TestCABundleFlag(t *testing.T) { testCA, err := certauthority.New("Test CA", 1*time.Hour) require.NoError(t, err) - tmpdir := testutil.TempDir(t) + tmpdir := t.TempDir() emptyFilePath := filepath.Join(tmpdir, "empty") require.NoError(t, os.WriteFile(emptyFilePath, []byte{}, 0600)) diff --git a/cmd/pinniped/cmd/kubeconfig_test.go b/cmd/pinniped/cmd/kubeconfig_test.go index ca8b762c..d0d4220b 100644 --- a/cmd/pinniped/cmd/kubeconfig_test.go +++ b/cmd/pinniped/cmd/kubeconfig_test.go @@ -32,7 +32,7 @@ import ( func TestGetKubeconfig(t *testing.T) { testOIDCCA, err := certauthority.New("Test CA", 1*time.Hour) require.NoError(t, err) - tmpdir := testutil.TempDir(t) + tmpdir := t.TempDir() testOIDCCABundlePath := filepath.Join(tmpdir, "testca.pem") require.NoError(t, os.WriteFile(testOIDCCABundlePath, testOIDCCA.Bundle(), 0600)) diff --git a/cmd/pinniped/cmd/login_oidc_test.go b/cmd/pinniped/cmd/login_oidc_test.go index b2b97077..c73565a5 100644 --- a/cmd/pinniped/cmd/login_oidc_test.go +++ b/cmd/pinniped/cmd/login_oidc_test.go @@ -23,7 +23,6 @@ import ( "go.pinniped.dev/internal/certauthority" "go.pinniped.dev/internal/here" "go.pinniped.dev/internal/plog" - "go.pinniped.dev/internal/testutil" "go.pinniped.dev/pkg/conciergeclient" "go.pinniped.dev/pkg/oidcclient" "go.pinniped.dev/pkg/oidcclient/oidctypes" @@ -34,7 +33,7 @@ func TestLoginOIDCCommand(t *testing.T) { testCA, err := certauthority.New("Test CA", 1*time.Hour) require.NoError(t, err) - tmpdir := testutil.TempDir(t) + tmpdir := t.TempDir() testCABundlePath := filepath.Join(tmpdir, "testca.pem") require.NoError(t, os.WriteFile(testCABundlePath, testCA.Bundle(), 0600)) @@ -513,7 +512,7 @@ func TestLoginOIDCCommand(t *testing.T) { "--concierge-endpoint", "https://127.0.0.1:1234/", "--concierge-ca-bundle-data", base64.StdEncoding.EncodeToString(testCA.Bundle()), "--concierge-api-group-suffix", "some.suffix.com", - "--credential-cache", testutil.TempDir(t) + "/credentials.yaml", // must specify --credential-cache or else the cache file on disk causes test pollution + "--credential-cache", t.TempDir() + "/credentials.yaml", // must specify --credential-cache or else the cache file on disk causes test pollution "--upstream-identity-provider-name", "some-upstream-name", "--upstream-identity-provider-type", "ldap", }, diff --git a/cmd/pinniped/cmd/login_static_test.go b/cmd/pinniped/cmd/login_static_test.go index 53456d91..f11a76ba 100644 --- a/cmd/pinniped/cmd/login_static_test.go +++ b/cmd/pinniped/cmd/login_static_test.go @@ -21,7 +21,6 @@ import ( "go.pinniped.dev/internal/certauthority" "go.pinniped.dev/internal/here" "go.pinniped.dev/internal/plog" - "go.pinniped.dev/internal/testutil" "go.pinniped.dev/pkg/conciergeclient" ) @@ -30,7 +29,7 @@ func TestLoginStaticCommand(t *testing.T) { testCA, err := certauthority.New("Test CA", 1*time.Hour) require.NoError(t, err) - tmpdir := testutil.TempDir(t) + tmpdir := t.TempDir() testCABundlePath := filepath.Join(tmpdir, "testca.pem") require.NoError(t, os.WriteFile(testCABundlePath, testCA.Bundle(), 0600)) diff --git a/internal/execcredcache/cachefile_test.go b/internal/execcredcache/cachefile_test.go index e0544448..c4c71948 100644 --- a/internal/execcredcache/cachefile_test.go +++ b/internal/execcredcache/cachefile_test.go @@ -1,4 +1,4 @@ -// Copyright 2021 the Pinniped contributors. All Rights Reserved. +// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package execcredcache @@ -11,8 +11,6 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientauthenticationv1beta1 "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1" - - "go.pinniped.dev/internal/testutil" ) var ( @@ -100,7 +98,7 @@ func TestWriteTo(t *testing.T) { t.Parallel() t.Run("io error", func(t *testing.T) { t.Parallel() - tmp := testutil.TempDir(t) + "/credentials.yaml" + tmp := t.TempDir() + "/credentials.yaml" require.NoError(t, os.Mkdir(tmp, 0700)) err := validCache.writeTo(tmp) require.EqualError(t, err, "open "+tmp+": is a directory") @@ -108,7 +106,7 @@ func TestWriteTo(t *testing.T) { t.Run("success", func(t *testing.T) { t.Parallel() - require.NoError(t, validCache.writeTo(testutil.TempDir(t)+"/credentials.yaml")) + require.NoError(t, validCache.writeTo(t.TempDir()+"/credentials.yaml")) }) } diff --git a/internal/execcredcache/execcredcache_test.go b/internal/execcredcache/execcredcache_test.go index c9b161e5..1b92a5b8 100644 --- a/internal/execcredcache/execcredcache_test.go +++ b/internal/execcredcache/execcredcache_test.go @@ -1,4 +1,4 @@ -// Copyright 2021-2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package execcredcache @@ -14,13 +14,11 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientauthenticationv1beta1 "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1" - - "go.pinniped.dev/internal/testutil" ) func TestNew(t *testing.T) { t.Parallel() - tmp := testutil.TempDir(t) + "/credentials.yaml" + tmp := t.TempDir() + "/credentials.yaml" c := New(tmp) require.NotNil(t, c) require.Equal(t, tmp, c.path) @@ -167,7 +165,7 @@ func TestGet(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() - tmp := testutil.TempDir(t) + "/sessions.yaml" + tmp := t.TempDir() + "/sessions.yaml" if tt.makeTestFile != nil { tt.makeTestFile(t, tmp) } @@ -333,7 +331,7 @@ func TestPutToken(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() - tmp := testutil.TempDir(t) + "/cachedir/credentials.yaml" + tmp := t.TempDir() + "/cachedir/credentials.yaml" if tt.makeTestFile != nil { tt.makeTestFile(t, tmp) } diff --git a/internal/testutil/tempdir.go b/internal/testutil/tempdir.go deleted file mode 100644 index 485de699..00000000 --- a/internal/testutil/tempdir.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -package testutil - -import ( - "testing" -) - -func TempDir(t *testing.T) string { - return t.TempDir() -} diff --git a/pkg/oidcclient/filesession/cachefile_test.go b/pkg/oidcclient/filesession/cachefile_test.go index 39ac87fb..413cd5f0 100644 --- a/pkg/oidcclient/filesession/cachefile_test.go +++ b/pkg/oidcclient/filesession/cachefile_test.go @@ -1,4 +1,4 @@ -// Copyright 2020 the Pinniped contributors. All Rights Reserved. +// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package filesession @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "go.pinniped.dev/internal/testutil" "go.pinniped.dev/pkg/oidcclient" "go.pinniped.dev/pkg/oidcclient/oidctypes" ) @@ -120,7 +119,7 @@ func TestWriteTo(t *testing.T) { t.Parallel() t.Run("io error", func(t *testing.T) { t.Parallel() - tmp := testutil.TempDir(t) + "/sessions.yaml" + tmp := t.TempDir() + "/sessions.yaml" require.NoError(t, os.Mkdir(tmp, 0700)) err := validSession.writeTo(tmp) require.EqualError(t, err, "open "+tmp+": is a directory") @@ -128,7 +127,7 @@ func TestWriteTo(t *testing.T) { t.Run("success", func(t *testing.T) { t.Parallel() - require.NoError(t, validSession.writeTo(testutil.TempDir(t)+"/sessions.yaml")) + require.NoError(t, validSession.writeTo(t.TempDir()+"/sessions.yaml")) }) } diff --git a/pkg/oidcclient/filesession/filesession_test.go b/pkg/oidcclient/filesession/filesession_test.go index ed684825..f2ff116c 100644 --- a/pkg/oidcclient/filesession/filesession_test.go +++ b/pkg/oidcclient/filesession/filesession_test.go @@ -1,4 +1,4 @@ -// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package filesession @@ -14,14 +14,13 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "go.pinniped.dev/internal/testutil" "go.pinniped.dev/pkg/oidcclient" "go.pinniped.dev/pkg/oidcclient/oidctypes" ) func TestNew(t *testing.T) { t.Parallel() - tmp := testutil.TempDir(t) + "/sessions.yaml" + tmp := t.TempDir() + "/sessions.yaml" c := New(tmp) require.NotNil(t, c) require.Equal(t, tmp, c.path) @@ -222,7 +221,7 @@ func TestGetToken(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() - tmp := testutil.TempDir(t) + "/sessions.yaml" + tmp := t.TempDir() + "/sessions.yaml" if tt.makeTestFile != nil { tt.makeTestFile(t, tmp) } @@ -480,7 +479,7 @@ func TestPutToken(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() - tmp := testutil.TempDir(t) + "/sessiondir/sessions.yaml" + tmp := t.TempDir() + "/sessiondir/sessions.yaml" if tt.makeTestFile != nil { tt.makeTestFile(t, tmp) } diff --git a/test/integration/cli_test.go b/test/integration/cli_test.go index 8f0cadc2..910bd362 100644 --- a/test/integration/cli_test.go +++ b/test/integration/cli_test.go @@ -28,7 +28,6 @@ import ( identityv1alpha1 "go.pinniped.dev/generated/latest/apis/concierge/identity/v1alpha1" conciergescheme "go.pinniped.dev/internal/concierge/scheme" - "go.pinniped.dev/internal/testutil" "go.pinniped.dev/pkg/oidcclient" "go.pinniped.dev/pkg/oidcclient/filesession" "go.pinniped.dev/test/testlib" @@ -48,7 +47,7 @@ func TestCLIGetKubeconfigStaticToken_Parallel(t *testing.T) { // Build pinniped CLI. pinnipedExe := testlib.PinnipedCLIPath(t) - credCacheDir := testutil.TempDir(t) + credCacheDir := t.TempDir() stdout, stderr := runPinnipedCLI(t, nil, pinnipedExe, "get", "kubeconfig", "--static-token", env.TestUser.Token, "--concierge-api-group-suffix", env.APIGroupSuffix, @@ -92,7 +91,7 @@ func TestCLIGetKubeconfigStaticToken_Parallel(t *testing.T) { t.Run("whoami", func(t *testing.T) { // Validate that `pinniped whoami` returns the correct identity. - kubeconfigPath := filepath.Join(testutil.TempDir(t), "whoami-kubeconfig") + kubeconfigPath := filepath.Join(t.TempDir(), "whoami-kubeconfig") require.NoError(t, os.WriteFile(kubeconfigPath, []byte(stdout), 0600)) assertWhoami( ctx, @@ -277,7 +276,7 @@ func runPinnipedLoginOIDC( env := testlib.IntegrationEnv(t) // Make a temp directory to hold the session cache for this test. - sessionCachePath := testutil.TempDir(t) + "/sessions.yaml" + sessionCachePath := t.TempDir() + "/sessions.yaml" // Start the browser driver. browser := browsertest.OpenBrowser(t) @@ -417,13 +416,13 @@ func oidcLoginCommand(ctx context.Context, t *testing.T, pinnipedExe string, ses "--scopes", "offline_access,openid,email,profile", "--listen-port", callbackURL.Port(), "--session-cache", sessionCachePath, - "--credential-cache", testutil.TempDir(t)+"/credentials.yaml", + "--credential-cache", t.TempDir()+"/credentials.yaml", "--skip-browser", ) // If there is a custom CA bundle, pass it via --ca-bundle and a temporary file. if env.CLIUpstreamOIDC.CABundle != "" { - path := filepath.Join(testutil.TempDir(t), "test-ca.pem") + path := filepath.Join(t.TempDir(), "test-ca.pem") require.NoError(t, os.WriteFile(path, []byte(env.CLIUpstreamOIDC.CABundle), 0600)) cmd.Args = append(cmd.Args, "--ca-bundle", path) } diff --git a/test/integration/concierge_impersonation_proxy_test.go b/test/integration/concierge_impersonation_proxy_test.go index 8fa6e69c..dd1dadb3 100644 --- a/test/integration/concierge_impersonation_proxy_test.go +++ b/test/integration/concierge_impersonation_proxy_test.go @@ -2325,7 +2325,7 @@ func getImpersonationKubeconfig(t *testing.T, env *testlib.TestEnv, impersonatio t.Helper() pinnipedExe := testlib.PinnipedCLIPath(t) - tempDir := testutil.TempDir(t) + tempDir := t.TempDir() var envVarsWithProxy []string if !env.HasCapability(testlib.HasExternalLoadBalancerProvider) { diff --git a/test/integration/e2e_test.go b/test/integration/e2e_test.go index bb872098..7b43b692 100644 --- a/test/integration/e2e_test.go +++ b/test/integration/e2e_test.go @@ -79,7 +79,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { require.NoError(t, err) // Save that bundle plus the one that signs the upstream issuer, for test purposes. - testCABundlePath := filepath.Join(testutil.TempDir(t), "test-ca.pem") + testCABundlePath := filepath.Join(t.TempDir(), "test-ca.pem") testCABundlePEM := []byte(string(ca.Bundle()) + "\n" + env.SupervisorUpstreamOIDC.CABundle) testCABundleBase64 := base64.StdEncoding.EncodeToString(testCABundlePEM) require.NoError(t, os.WriteFile(testCABundlePath, testCABundlePEM, 0600)) @@ -119,7 +119,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests // Start a fresh browser driver because we don't want to share cookies between the various tests in this file. browser := browsertest.OpenBrowser(t) @@ -200,7 +200,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests // Start a fresh browser driver because we don't want to share cookies between the various tests in this file. browser := browsertest.OpenBrowser(t) @@ -284,7 +284,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests // Start a fresh browser driver because we don't want to share cookies between the various tests in this file. browser := browsertest.OpenBrowser(t) @@ -395,7 +395,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests // Start a fresh browser driver because we don't want to share cookies between the various tests in this file. browser := browsertest.OpenBrowser(t) @@ -531,7 +531,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests expectedUsername := env.SupervisorUpstreamOIDC.Username expectedGroups := env.SupervisorUpstreamOIDC.ExpectedGroups @@ -614,7 +614,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests // Create upstream OIDC provider and wait for it to become ready. oidcIdentityProvider := testlib.CreateTestOIDCIdentityProvider(t, idpv1alpha1.OIDCIdentityProviderSpec{ @@ -700,7 +700,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests expectedUsername := env.SupervisorUpstreamLDAP.TestUserMailAttributeValue expectedGroups := env.SupervisorUpstreamLDAP.TestUserDirectGroupsDNs @@ -754,7 +754,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests expectedUsername := env.SupervisorUpstreamLDAP.TestUserMailAttributeValue expectedGroups := env.SupervisorUpstreamLDAP.TestUserDirectGroupsDNs @@ -813,7 +813,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests expectedUsername := env.SupervisorUpstreamLDAP.TestUserMailAttributeValue expectedGroups := env.SupervisorUpstreamLDAP.TestUserDirectGroupsDNs @@ -879,7 +879,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests expectedUsername := env.SupervisorUpstreamActiveDirectory.TestUserPrincipalNameValue expectedGroups := env.SupervisorUpstreamActiveDirectory.TestUserIndirectGroupsSAMAccountPlusDomainNames @@ -933,7 +933,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests expectedUsername := env.SupervisorUpstreamActiveDirectory.TestUserPrincipalNameValue expectedGroups := env.SupervisorUpstreamActiveDirectory.TestUserIndirectGroupsSAMAccountPlusDomainNames @@ -998,7 +998,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests // Start a fresh browser driver because we don't want to share cookies between the various tests in this file. browser := browsertest.OpenBrowser(t) @@ -1048,7 +1048,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests // Start a fresh browser driver because we don't want to share cookies between the various tests in this file. browser := browsertest.OpenBrowser(t) @@ -1098,7 +1098,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) t.Cleanup(cancel) - tempDir := testutil.TempDir(t) // per-test tmp dir to avoid sharing files between tests + tempDir := t.TempDir() // per-test tmp dir to avoid sharing files between tests // Start a fresh browser driver because we don't want to share cookies between the various tests in this file. browser := browsertest.OpenBrowser(t) diff --git a/test/integration/supervisor_warnings_test.go b/test/integration/supervisor_warnings_test.go index b8acd368..f84b5358 100644 --- a/test/integration/supervisor_warnings_test.go +++ b/test/integration/supervisor_warnings_test.go @@ -31,7 +31,6 @@ import ( "go.pinniped.dev/internal/oidc" "go.pinniped.dev/internal/oidc/oidcclientvalidator" "go.pinniped.dev/internal/psession" - "go.pinniped.dev/internal/testutil" "go.pinniped.dev/pkg/oidcclient" "go.pinniped.dev/pkg/oidcclient/filesession" "go.pinniped.dev/test/testlib" @@ -46,7 +45,7 @@ func TestSupervisorWarnings_Browser(t *testing.T) { // Build pinniped CLI. pinnipedExe := testlib.PinnipedCLIPath(t) - tempDir := testutil.TempDir(t) + tempDir := t.TempDir() // Infer the downstream issuer URL from the callback associated with the upstream test client registration. issuerURL, err := url.Parse(env.SupervisorUpstreamOIDC.CallbackURL) diff --git a/test/testlib/cli.go b/test/testlib/cli.go index 303087d7..63c524ed 100644 --- a/test/testlib/cli.go +++ b/test/testlib/cli.go @@ -12,8 +12,6 @@ import ( "time" "github.com/stretchr/testify/require" - - "go.pinniped.dev/internal/testutil" ) //nolint:gochecknoglobals @@ -34,7 +32,7 @@ func PinnipedCLIPath(t *testing.T) string { pinnipedCLIBinaryCache.mutex.Lock() defer pinnipedCLIBinaryCache.mutex.Unlock() - path := filepath.Join(testutil.TempDir(t), "pinniped") + path := filepath.Join(t.TempDir(), "pinniped") if pinnipedCLIBinaryCache.buf != nil { t.Log("using previously built pinniped CLI binary") //nolint:gosec // this is test code.