diff --git a/test/integration/cli_test.go b/test/integration/cli_test.go index aaf3e2c4..33a0cda1 100644 --- a/test/integration/cli_test.go +++ b/test/integration/cli_test.go @@ -372,12 +372,6 @@ func oidcLoginCommand(ctx context.Context, t *testing.T, pinnipedExe string, ses } // If there is a custom proxy, set it using standard environment variables. - if env.Proxy != "" { - cmd.Env = append(os.Environ(), - "http_proxy="+env.Proxy, - "https_proxy="+env.Proxy, - "no_proxy=127.0.0.1", - ) - } + cmd.Env = append(os.Environ(), env.ProxyEnv()...) return cmd } diff --git a/test/library/env.go b/test/library/env.go index e6f3c1da..41ab3329 100644 --- a/test/library/env.go +++ b/test/library/env.go @@ -59,6 +59,14 @@ type TestOIDCUpstream struct { Password string `json:"password"` } +// ProxyEnv returns a set of environment variable strings (e.g., to combine with os.Environ()) which set up the configured test HTTP proxy. +func (e *TestEnv) ProxyEnv() []string { + if e.Proxy == "" { + return nil + } + return []string{"http_proxy=" + e.Proxy, "https_proxy=" + e.Proxy, "no_proxy=127.0.0.1"} +} + // IntegrationEnv gets the integration test environment from OS environment variables. This // method also implies SkipUnlessIntegration(). func IntegrationEnv(t *testing.T) *TestEnv {