Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions tool/tsh/common/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ func TestTSHProxyTemplate(t *testing.T) {
require.NoError(t, err)

s := newTestSuite(t)
tshHome := mustLoginSetEnv(t, s)
tshHome, _ := mustLoginSetEnv(t, s)

// Create proxy template configuration.
tshConfigFile := filepath.Join(tshHome, tshConfigPath)
Expand Down Expand Up @@ -974,9 +974,9 @@ func setMockSSOLogin(t *testing.T, s *suite) CliOption {
}
}

func mustLogin(t *testing.T, s *suite, args ...string) (string, string) {
tshHome := t.TempDir()
kubeConfig := filepath.Join(t.TempDir(), teleport.KubeConfigFile)
func mustLogin(t *testing.T, s *suite, args ...string) (tshHome, kubeConfig string) {
tshHome = t.TempDir()
kubeConfig = filepath.Join(t.TempDir(), teleport.KubeConfigFile)
args = append([]string{
"login",
"--insecure",
Expand All @@ -989,24 +989,15 @@ func mustLogin(t *testing.T, s *suite, args ...string) (string, string) {
setKubeConfigPath(kubeConfig),
)
require.NoError(t, err)
return tshHome, kubeConfig
return
}

// login with new temp tshHome and set it in Env. This is useful
// when running "ssh" commands with a tsh "ProxyCommand".
func mustLoginSetEnv(t *testing.T, s *suite, args ...string) string {
tshHome := t.TempDir()
func mustLoginSetEnv(t *testing.T, s *suite, args ...string) (tshHome, kubeConfig string) {
tshHome, kubeConfig = mustLogin(t, s, args...)
t.Setenv(types.HomeEnvVar, tshHome)

args = append([]string{
"login",
"--insecure",
"--debug",
"--proxy", s.root.Config.Proxy.WebAddr.String(),
}, args...)
err := Run(context.Background(), args, setMockSSOLogin(t, s), setHomePath(tshHome))
require.NoError(t, err)
return tshHome
return
}

func mustLoginIdentity(t *testing.T, s *suite, opts ...CliOption) string {
Expand Down