From cee7dce86e5012dfc075d1a4a88a62a0fe3e967d Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 16 Sep 2023 02:25:12 +0000 Subject: [PATCH 1/3] feat(cli): display pasted session token --- cli/login.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cli/login.go b/cli/login.go index 73a18a1c40009..2727743e1b487 100644 --- a/cli/login.go +++ b/cli/login.go @@ -278,8 +278,7 @@ func (r *RootCmd) login() *clibase.Cmd { } sessionToken, err = cliui.Prompt(inv, cliui.PromptOptions{ - Text: "Paste your token here:", - Secret: true, + Text: "Paste your token here:", Validate: func(token string) error { client.SetSessionToken(token) _, err := client.User(ctx, codersdk.Me) From 0c78651ba4ed684002bab373369884a4f5622c51 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 20 Sep 2023 14:34:38 +0100 Subject: [PATCH 2/3] fix(cli): expect session token in unit tests --- cli/login_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/login_test.go b/cli/login_test.go index 89d4cd87b37d9..603117435f7ac 100644 --- a/cli/login_test.go +++ b/cli/login_test.go @@ -170,6 +170,7 @@ func TestLogin(t *testing.T) { pty.ExpectMatch("Paste your token here:") pty.WriteLine(client.SessionToken()) + pty.ExpectMatch(client.SessionToken()) pty.ExpectMatch("Welcome to Coder") <-doneChan }) @@ -193,6 +194,7 @@ func TestLogin(t *testing.T) { pty.ExpectMatch("Paste your token here:") pty.WriteLine("an-invalid-token") + pty.ExpectMatch("an-invalid-token") pty.ExpectMatch("That's not a valid token!") cancelFunc() <-doneChan From 0d054d639ba923d359c033b72fc7c36b56156d74 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 20 Sep 2023 16:27:07 +0100 Subject: [PATCH 3/3] skip expecting token match on windows because it is a silly place --- cli/login_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cli/login_test.go b/cli/login_test.go index 603117435f7ac..3bda6bcd1d22f 100644 --- a/cli/login_test.go +++ b/cli/login_test.go @@ -3,6 +3,7 @@ package cli_test import ( "context" "fmt" + "runtime" "testing" "github.com/stretchr/testify/assert" @@ -170,7 +171,10 @@ func TestLogin(t *testing.T) { pty.ExpectMatch("Paste your token here:") pty.WriteLine(client.SessionToken()) - pty.ExpectMatch(client.SessionToken()) + if runtime.GOOS != "windows" { + // For some reason, the match does not show up on Windows. + pty.ExpectMatch(client.SessionToken()) + } pty.ExpectMatch("Welcome to Coder") <-doneChan }) @@ -194,7 +198,10 @@ func TestLogin(t *testing.T) { pty.ExpectMatch("Paste your token here:") pty.WriteLine("an-invalid-token") - pty.ExpectMatch("an-invalid-token") + if runtime.GOOS != "windows" { + // For some reason, the match does not show up on Windows. + pty.ExpectMatch("an-invalid-token") + } pty.ExpectMatch("That's not a valid token!") cancelFunc() <-doneChan