diff --git a/test/integration/audit_test.go b/test/integration/audit_test.go index 68c6f7652..9e9a0bfe0 100644 --- a/test/integration/audit_test.go +++ b/test/integration/audit_test.go @@ -62,7 +62,7 @@ func TestAuditLogsDuringLogin_Disruptive(t *testing.T) { testStartTime := metav1.Now() ctx, cancelFunc := context.WithTimeout(context.Background(), 10*time.Minute) - defer cancelFunc() + t.Cleanup(cancelFunc) kubeClient := testlib.NewKubernetesClientset(t) kubeClientForK8sResourcesOnly := kubeClientWithoutPinnipedAPISuffix(t) @@ -377,7 +377,7 @@ func TestAuditLogsDuringLogin_Disruptive(t *testing.T) { func TestAuditLogsEmittedForDiscoveryEndpoints_Parallel(t *testing.T) { ctx, cancelFunc := context.WithTimeout(context.Background(), 2*time.Minute) - defer cancelFunc() + t.Cleanup(cancelFunc) env, kubeClientForK8sResourcesOnly, fakeIssuerForDisplayPurposes, ca, dnsOverrides := auditSetup(t, ctx) @@ -427,7 +427,7 @@ func TestAuditLogsEmittedForDiscoveryEndpoints_Parallel(t *testing.T) { // /oauth2/authorize, /callback, /login, and /oauth2/token. func TestAuditLogsEmittedForEndpointsEvenWhenTheCallsAreInvalid_Parallel(t *testing.T) { ctx, cancelFunc := context.WithTimeout(context.Background(), 2*time.Minute) - defer cancelFunc() + t.Cleanup(cancelFunc) env, kubeClientForK8sResourcesOnly, fakeIssuerForDisplayPurposes, ca, dnsOverrides := auditSetup(t, ctx) diff --git a/test/integration/cli_test.go b/test/integration/cli_test.go index 36269e339..45439c30f 100644 --- a/test/integration/cli_test.go +++ b/test/integration/cli_test.go @@ -1,4 +1,4 @@ -// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved. +// Copyright 2020-2025 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package integration @@ -42,7 +42,7 @@ func TestCLIGetKubeconfigStaticToken_Parallel(t *testing.T) { // Create a test webhook configuration to use with the CLI. ctx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Minute) - defer cancelFunc() + t.Cleanup(cancelFunc) authenticator := testlib.CreateTestWebhookAuthenticator(ctx, t, &testlib.IntegrationEnv(t).TestWebhook, authenticationv1alpha1.WebhookAuthenticatorPhaseReady) diff --git a/test/integration/e2e_test.go b/test/integration/e2e_test.go index eed238f08..ca0881992 100644 --- a/test/integration/e2e_test.go +++ b/test/integration/e2e_test.go @@ -64,7 +64,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) { } topSetupCtx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Minute) - defer cancelFunc() + t.Cleanup(cancelFunc) supervisorClient := testlib.NewSupervisorClientset(t) kubeClient := testlib.NewKubernetesClientset(t) temporarilyRemoveAllFederationDomainsAndDefaultTLSCertSecret( diff --git a/test/integration/kube_api_discovery_test.go b/test/integration/kube_api_discovery_test.go index 94bc399a3..ded484662 100644 --- a/test/integration/kube_api_discovery_test.go +++ b/test/integration/kube_api_discovery_test.go @@ -1,4 +1,4 @@ -// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved. +// Copyright 2020-2025 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package integration @@ -519,7 +519,7 @@ func TestCRDAdditionalPrinterColumns_Parallel(t *testing.T) { env := testlib.IntegrationEnv(t) ctx, cancelFunc := context.WithTimeout(context.Background(), time.Minute) - defer cancelFunc() + t.Cleanup(cancelFunc) // AdditionalPrinterColumns are not returned by the Kube discovery endpoints, // so "discover" them in the CRD definitions instead. diff --git a/test/integration/supervisor_warnings_test.go b/test/integration/supervisor_warnings_test.go index 2c91487f9..26e975880 100644 --- a/test/integration/supervisor_warnings_test.go +++ b/test/integration/supervisor_warnings_test.go @@ -1,4 +1,4 @@ -// Copyright 2022-2024 the Pinniped contributors. All Rights Reserved. +// Copyright 2022-2025 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package integration @@ -40,7 +40,7 @@ func TestSupervisorWarnings_Browser(t *testing.T) { env := testlib.IntegrationEnv(t) ctx, cancelFunc := context.WithTimeout(context.Background(), 10*time.Minute) - defer cancelFunc() + t.Cleanup(cancelFunc) // Build pinniped CLI. pinnipedExe := testlib.PinnipedCLIPath(t)