mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(cli): display pasted session token (#9710)
This commit is contained in:
+1
-2
@@ -278,8 +278,7 @@ func (r *RootCmd) login() *clibase.Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sessionToken, err = cliui.Prompt(inv, cliui.PromptOptions{
|
sessionToken, err = cliui.Prompt(inv, cliui.PromptOptions{
|
||||||
Text: "Paste your token here:",
|
Text: "Paste your token here:",
|
||||||
Secret: true,
|
|
||||||
Validate: func(token string) error {
|
Validate: func(token string) error {
|
||||||
client.SetSessionToken(token)
|
client.SetSessionToken(token)
|
||||||
_, err := client.User(ctx, codersdk.Me)
|
_, err := client.User(ctx, codersdk.Me)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package cli_test
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -170,6 +171,10 @@ func TestLogin(t *testing.T) {
|
|||||||
|
|
||||||
pty.ExpectMatch("Paste your token here:")
|
pty.ExpectMatch("Paste your token here:")
|
||||||
pty.WriteLine(client.SessionToken())
|
pty.WriteLine(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")
|
pty.ExpectMatch("Welcome to Coder")
|
||||||
<-doneChan
|
<-doneChan
|
||||||
})
|
})
|
||||||
@@ -193,6 +198,10 @@ func TestLogin(t *testing.T) {
|
|||||||
|
|
||||||
pty.ExpectMatch("Paste your token here:")
|
pty.ExpectMatch("Paste your token here:")
|
||||||
pty.WriteLine("an-invalid-token")
|
pty.WriteLine("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!")
|
pty.ExpectMatch("That's not a valid token!")
|
||||||
cancelFunc()
|
cancelFunc()
|
||||||
<-doneChan
|
<-doneChan
|
||||||
|
|||||||
Reference in New Issue
Block a user