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 Nov 29, 2024
1 parent 1488d47 commit 56ca164
Show file tree
Hide file tree
Showing 53 changed files with 104 additions and 98 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
4 changes: 2 additions & 2 deletions pam/integration-tests/testdata/tapes/cli/bad_password.tape
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ Hide
Wait
Type "${AUTHD_TEST_TAPE_COMMAND}"
Enter
Wait /Username: user name$/
Wait /Username: user name\n/
Show

Hide
Type "user-needs-reset"
Wait /Username: user-needs-reset$/
Wait /Username: user-needs-reset\n/
Show

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

Hide
Type "user-integration-form-w-button"
Wait /Username: user-integration-form-w-button$/
Wait /Username: user-integration-form-w-button\n/
Show

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

Hide
Type "user-local-broker"
Wait /Username: user-local-broker$/
Wait /Username: user-local-broker\n/
Show

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

Hide
Type "user-local-groups"
Wait /Username: user-local-groups$/
Wait /Username: user-local-groups\n/
Show

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

Hide
Type "root"
Wait /Username: root$/
Wait /Username: root\n/
Show

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

Hide
Type "user-needs-reset-integration-mandatory"
Wait /Username: user-needs-reset-integration-mandatory$/
Wait /Username: user-needs-reset-integration-mandatory\n/
Show

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

Hide
Type "user-integration-max-attempts"
Wait /Username: user-integration-max-attempts$/
Wait /Username: user-integration-max-attempts\n/
Show

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

Hide
Type "user-mfa"
Wait /Username: user-mfa$/
Wait /Username: user-mfa\n/
Show

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

Hide
Type "user-mfa-with-reset"
Wait /Username: user-mfa-with-reset$/
Wait /Username: user-mfa-with-reset\n/
Show

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

Hide
Type "user-can-reset"
Wait /Username: user-can-reset$/
Wait /Username: user-can-reset\n/
Show

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

Hide
Type "user-integration-max-attempts"
Wait /Username: user-integration-max-attempts$/
Wait /Username: user-integration-max-attempts\n/
Show

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

Hide
Type "user-integration-bad-password"
Wait /Username: user-integration-bad-password$/
Wait /Username: user-integration-bad-password\n/
Show

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

Hide
Type "user-local-broker"
Wait /Username: user-local-broker$/
Wait /Username: user-local-broker\n/
Show

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

Hide
Type "user-mfa"
Wait /Username: user-mfa$/
Wait /Username: user-mfa\n/
Show

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

Hide
Type "user-integration-same-new-password"
Wait /Username: user-integration-same-new-password$/
Wait /Username: user-integration-same-new-password\n/
Show

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

Hide
Type "user-integration-wrong-confirmation"
Wait /Username: user-integration-wrong-confirmation$/
Wait /Username: user-integration-wrong-confirmation\n/
Show

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

Hide
Type "user-integration-invalid-new-password"
Wait /Username: user-integration-invalid-new-password$/
Wait /Username: user-integration-invalid-new-password\n/
Show

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

Hide
Type "user-integration-invalid-new-password"
Wait /Username: user-integration-invalid-new-password$/
Wait /Username: user-integration-invalid-new-password\n/
Show

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

Hide
Type "user-integration-sigint"
Wait /Username: user-integration-sigint$/
Wait /Username: user-integration-sigint\n/
Show

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

Hide
Type "user1"
Wait /Username: user1$/
Wait /Username: user1\n/
Show

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

Hide
Type "user1"
Wait+Screen /Username: user1\n/
Wait /Username: user1\n/
Show

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

Hide
Type "user-unexistent"
Wait /Username: user-unexistent$/
Wait /Username: user-unexistent\n/
Show

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

Hide
Type "user-integration-qrcode-static-regenerate"
Wait /Username: user-integration-qrcode-static-regenerate$/
Wait /Username: user-integration-qrcode-static-regenerate\n/
Show

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

Hide
Type "user-integration-remember-mode"
Wait /Username: user-integration-remember-mode$/
Wait /Username: user-integration-remember-mode\n/
Show

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

Hide
Type "user-integration-remember-mode"
Wait /Username: user-integration-remember-mode$/
Wait /Username: user-integration-remember-mode\n/
Show

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

Hide
Type "user-integration-sigint"
Wait /Username: user-integration-sigint$/
Wait /Username: user-integration-sigint\n/
Show

Hide
Expand Down
Loading

0 comments on commit 56ca164

Please sign in to comment.