From 4088793cc5cd9e3bf109181013159ed72f553abf Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Tue, 15 Dec 2020 11:45:40 -0600 Subject: [PATCH] Add a .ProxyEnv() helper on the test environment. Signed-off-by: Matt Moyer --- test/integration/cli_test.go | 8 +------- test/library/env.go | 8 ++++++++ 2 files changed, 9 insertions(+), 7 deletions(-) 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 {