Add a .ProxyEnv() helper on the test environment.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2020-12-15 11:45:40 -06:00
parent b6edc3dc08
commit 4088793cc5
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D
2 changed files with 9 additions and 7 deletions

View File

@ -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 there is a custom proxy, set it using standard environment variables.
if env.Proxy != "" { cmd.Env = append(os.Environ(), env.ProxyEnv()...)
cmd.Env = append(os.Environ(),
"http_proxy="+env.Proxy,
"https_proxy="+env.Proxy,
"no_proxy=127.0.0.1",
)
}
return cmd return cmd
} }

View File

@ -59,6 +59,14 @@ type TestOIDCUpstream struct {
Password string `json:"password"` 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 // IntegrationEnv gets the integration test environment from OS environment variables. This
// method also implies SkipUnlessIntegration(). // method also implies SkipUnlessIntegration().
func IntegrationEnv(t *testing.T) *TestEnv { func IntegrationEnv(t *testing.T) *TestEnv {