Skip to content

Commit

Permalink
pam/integration-tests: Re-implement Wait pattern to improve debugging
Browse files Browse the repository at this point in the history
In case `Wait` fails we don't have relevant debugging output, so let's
just simulate it by using Wait+Screen regex.

See: charmbracelet/vhs#533
  • Loading branch information
3v1n0 committed Dec 11, 2024
1 parent e7ff461 commit 534ac79
Show file tree
Hide file tree
Showing 52 changed files with 69 additions and 65 deletions.
2 changes: 1 addition & 1 deletion pam/integration-tests/native_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func TestNativeAuthenticate(t *testing.T) {
tape: "switch_local_broker",
tapeSettings: []tapeSetting{{vhsHeight, 700}},
clientOptions: clientOptions{PamUser: "user-integration-switch-broker"},
tapeVariables: map[string]string{"AUTHD_TAPE_FINAL_WAIT_PATTERN": ""},
tapeVariables: map[string]string{"AUTHD_TAPE_FINAL_WAIT_PATTERN": `/>[\n]*/`},
},
"Authenticate user and add it to local group": {
tape: "local_group",
Expand Down
2 changes: 1 addition & 1 deletion pam/integration-tests/testdata/tapes/cli/bad_password.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
2 changes: 1 addition & 1 deletion pam/integration-tests/testdata/tapes/cli/local_broker.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
2 changes: 1 addition & 1 deletion pam/integration-tests/testdata/tapes/cli/local_group.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
2 changes: 1 addition & 1 deletion pam/integration-tests/testdata/tapes/cli/local_user.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
2 changes: 1 addition & 1 deletion pam/integration-tests/testdata/tapes/cli/max_attempts.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
2 changes: 1 addition & 1 deletion pam/integration-tests/testdata/tapes/cli/mfa_auth.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
2 changes: 1 addition & 1 deletion pam/integration-tests/testdata/tapes/cli/passwd_mfa.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
4 changes: 2 additions & 2 deletions pam/integration-tests/testdata/tapes/cli/passwd_rejected.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down Expand Up @@ -66,7 +66,7 @@ ClearTerminal
Hide
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
4 changes: 2 additions & 2 deletions pam/integration-tests/testdata/tapes/cli/passwd_simple.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down Expand Up @@ -49,7 +49,7 @@ ClearTerminal
Hide
Type "${AUTHD_TEST_TAPE_LOGIN_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down Expand Up @@ -40,7 +40,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
2 changes: 1 addition & 1 deletion pam/integration-tests/testdata/tapes/cli/sigint.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
2 changes: 1 addition & 1 deletion pam/integration-tests/testdata/tapes/cli/simple_auth.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand All @@ -11,12 +11,12 @@ Show

Hide
Backspace 26
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Hide
Type "${AUTHD_TEST_TAPE_COMMAND} invalid_flag=foo bar"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
8 changes: 4 additions & 4 deletions pam/integration-tests/testdata/tapes/cli/switch_username.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand All @@ -17,11 +17,11 @@ Show

Hide
Escape
Wait /Username: user-integration-switch-username$/
Wait /Username: user-integration-switch-username\n/
Backspace 15
Wait /Username: user-integration-$/
Wait /Username: user-integration-\n/
Type "username-switched"
Wait /Username: user-integration-username-switched$/
Wait /Username: user-integration-username-switched\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username:$/
Wait /Username:\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Hide
Wait />$/
Wait /^>\n/
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait+Prompt /Choose your provider/
Expand Down
2 changes: 1 addition & 1 deletion pam/integration-tests/testdata/tapes/native/local_ssh.tape
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Hide
Wait />$/
Wait /^>\n/
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
${AUTHD_TEST_TAPE_COMMAND_AUTH_FINAL_WAIT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username:$/
Wait /Username:\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Hide
Wait />$/
Wait /^>\n/
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
${AUTHD_TEST_TAPE_COMMAND_AUTH_FINAL_WAIT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username:$/
Wait /Username:\n/
Show

Hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username:$/
Wait /Username:\n/
Show

Hide
Expand Down
Loading

0 comments on commit 534ac79

Please sign in to comment.