Skip to content

fix: (Re-)enable TestPasswordTerminalState test #3169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2022
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
18 changes: 8 additions & 10 deletions cli/cliui/prompt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ func newPrompt(ptty *ptytest.PTY, opts cliui.PromptOptions, cmdOpt func(cmd *cob
}

func TestPasswordTerminalState(t *testing.T) {
// TODO: fix this test so that it runs reliably
t.Skip()

if os.Getenv("TEST_SUBPROCESS") == "1" {
passwordHelper()
return
Expand All @@ -192,20 +189,21 @@ func TestPasswordTerminalState(t *testing.T) {
defer process.Kill()

ptty.ExpectMatch("Password: ")
time.Sleep(100 * time.Millisecond) // wait for child process to turn off echo and start reading input

echo, err := ptyWithFlags.EchoEnabled()
require.NoError(t, err)
require.False(t, echo, "echo is on while reading password")
require.Eventually(t, func() bool {
echo, err := ptyWithFlags.EchoEnabled()
return err == nil && !echo
}, 5*time.Second, 50*time.Millisecond, "echo is on while reading password")

err = process.Signal(os.Interrupt)
require.NoError(t, err)
_, err = process.Wait()
require.NoError(t, err)

echo, err = ptyWithFlags.EchoEnabled()
require.NoError(t, err)
require.True(t, echo, "echo is off after reading password")
require.Eventually(t, func() bool {
echo, err := ptyWithFlags.EchoEnabled()
return err == nil && echo
}, 5*time.Second, 50*time.Millisecond, "echo is off after reading password")
}

// nolint:unused
Expand Down