Improve assertion for disabled echo mode (#10927)
* Improve assertion for disabled echo Signed-off-by: Babak K. Shandiz <babakks@github.com> * Use `expect.RegExpPattern` Signed-off-by: Babak K. Shandiz <babakks@github.com> --------- Signed-off-by: Babak K. Shandiz <babakks@github.com>
This commit is contained in:
parent
e5f7a453df
commit
90532e8377
1 changed files with 22 additions and 3 deletions
|
|
@ -164,7 +164,12 @@ func TestAccessiblePrompter(t *testing.T) {
|
|||
|
||||
// Ensure the dummy password is not printed to the screen,
|
||||
// asserting that echo mode is disabled.
|
||||
_, err = console.ExpectString(" \r\n\r\n")
|
||||
//
|
||||
// Note that since console.ExpectString returns successful if the
|
||||
// expected string matches any part of the stream, we have to use an
|
||||
// anchored regexp (i.e., with ^ and $) to make sure the password/token
|
||||
// is not printed at all.
|
||||
_, err = console.Expect(expect.RegexpPattern("^ \r\n\r\n$"))
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
|
|
@ -230,7 +235,12 @@ func TestAccessiblePrompter(t *testing.T) {
|
|||
|
||||
// Ensure the dummy password is not printed to the screen,
|
||||
// asserting that echo mode is disabled.
|
||||
_, err = console.ExpectString(" \r\n\r\n")
|
||||
//
|
||||
// Note that since console.ExpectString returns successful if the
|
||||
// expected string matches any part of the stream, we have to use an
|
||||
// anchored regexp (i.e., with ^ and $) to make sure the password/token
|
||||
// is not printed at all.
|
||||
_, err = console.Expect(expect.RegexpPattern("^ \r\n\r\n$"))
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
|
|
@ -252,6 +262,10 @@ func TestAccessiblePrompter(t *testing.T) {
|
|||
_, err = console.ExpectString("token is required")
|
||||
require.NoError(t, err)
|
||||
|
||||
// Wait for the retry prompt
|
||||
_, err = console.ExpectString("Paste your authentication token:")
|
||||
require.NoError(t, err)
|
||||
|
||||
// Wait to ensure huh has time to set the echo mode
|
||||
time.Sleep(beforePasswordSendTimeout)
|
||||
|
||||
|
|
@ -266,7 +280,12 @@ func TestAccessiblePrompter(t *testing.T) {
|
|||
|
||||
// Ensure the dummy password is not printed to the screen,
|
||||
// asserting that echo mode is disabled.
|
||||
_, err = console.ExpectString(" \r\n\r\n")
|
||||
//
|
||||
// Note that since console.ExpectString returns successful if the
|
||||
// expected string matches any part of the stream, we have to use an
|
||||
// anchored regexp (i.e., with ^ and $) to make sure the password/token
|
||||
// is not printed at all.
|
||||
_, err = console.Expect(expect.RegexpPattern("^ \r\n\r\n$"))
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue