Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions tool/tsh/tsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,10 @@ func Run(ctx context.Context, args []string, opts ...cliOption) error {
}
}

// Remove HTTPS:// in proxy parameter as https is automatically added
cf.Proxy = strings.TrimPrefix(cf.Proxy, "https://")
cf.Proxy = strings.TrimPrefix(cf.Proxy, "HTTPS://")

// prevent Kingpin from calling os.Exit(), we want to handle errors ourselves.
// shouldTerminate will be checked after app.Parse() call.
var shouldTerminate *int
Expand Down
39 changes: 39 additions & 0 deletions tool/tsh/tsh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4794,3 +4794,42 @@ func TestMakeProfileInfo_NoInternalLogins(t *testing.T) {
})
}
}

// Test when https:// is included in --proxy address
func TestIgnoreHTTPSPrefix(t *testing.T) {
t.Parallel()

tmpHomePath := t.TempDir()

connector := mockConnector(t)

alice, err := types.NewUser("alice@example.com")
require.NoError(t, err)
alice.SetRoles([]string{"access"})

authProcess, proxyProcess := makeTestServers(t,
withBootstrap(connector, alice),
)

authServer := authProcess.GetAuthServer()
require.NotNil(t, authServer)

proxyAddr, err := proxyProcess.ProxyWebAddr()
require.NoError(t, err)

var buf bytes.Buffer

proxyAddress := "https://" + proxyAddr.String()
err = Run(context.Background(), []string{
"login",
"--insecure",
"--debug",
"--auth", connector.GetName(),
"--proxy", proxyAddress,
}, setHomePath(tmpHomePath), func(cf *CLIConf) error {
cf.mockSSOLogin = mockSSOLogin(t, authServer, alice)
cf.overrideStderr = &buf
return nil
})
require.NoError(t, err)
}