diff --git a/pam/integration-tests/testdata/tapes/cli/bad_password.tape b/pam/integration-tests/testdata/tapes/cli/bad_password.tape index 52a1d9117..aa4abb61d 100644 --- a/pam/integration-tests/testdata/tapes/cli/bad_password.tape +++ b/pam/integration-tests/testdata/tapes/cli/bad_password.tape @@ -35,8 +35,7 @@ Show Hide Enter -Wait /No password supplied/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /No password supplied/ Show Hide @@ -45,8 +44,7 @@ Show Hide Enter -Wait+Screen /New password:\n>\n/ -Wait /The password is shorter than \d+ characters/ +Wait+CLIPrompt /New password/ /The password is shorter than \d+ characters/ Show Hide @@ -55,8 +53,7 @@ Show Hide Enter -Wait /The password fails the dictionary check/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /The password fails the dictionary check[^\n]*/ Show Hide @@ -74,8 +71,7 @@ Show Hide Enter -Wait /Password entries don't match/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /Password entries don't match/ Show Hide diff --git a/pam/integration-tests/testdata/tapes/cli/form_with_button.tape b/pam/integration-tests/testdata/tapes/cli/form_with_button.tape index e82b5bd00..abf9a6f81 100644 --- a/pam/integration-tests/testdata/tapes/cli/form_with_button.tape +++ b/pam/integration-tests/testdata/tapes/cli/form_with_button.tape @@ -28,8 +28,7 @@ Show Hide Type "7" -Wait+Screen /Enter your one time credential:\n>\n/ -Wait /\[ Resend SMS \(1 sent\) \]/ +Wait+CLIPrompt /Enter your one time credential/ /\[ Resend SMS \(1 sent\) \]/ Show Hide @@ -38,8 +37,7 @@ Show Hide Enter -Wait+Screen /Enter your one time credential:\n>\n/ -Wait /\[ Resend SMS \(2 sent\) \]/ +Wait+CLIPrompt /Enter your one time credential/ /\[ Resend SMS \(2 sent\) \]/ Show Hide diff --git a/pam/integration-tests/testdata/tapes/cli/max_attempts.tape b/pam/integration-tests/testdata/tapes/cli/max_attempts.tape index 6bedd6cc8..34b0103e2 100644 --- a/pam/integration-tests/testdata/tapes/cli/max_attempts.tape +++ b/pam/integration-tests/testdata/tapes/cli/max_attempts.tape @@ -26,8 +26,7 @@ Show Hide Enter -Wait /invalid password/ -Wait+Screen /Gimme your password:\n>\n/ +Wait+CLIPrompt /Gimme your password/ /invalid password '.+', should be[^\n]+/ Show Hide @@ -36,8 +35,7 @@ Show Hide Enter -Wait /invalid password/ -Wait+Screen /Gimme your password:\n>\n/ +Wait+CLIPrompt /Gimme your password/ /invalid password '.+', should be[^\n]+/ Show Hide @@ -46,8 +44,7 @@ Show Hide Enter -Wait /invalid password/ -Wait+Screen /Gimme your password:\n>\n/ +Wait+CLIPrompt /Gimme your password/ /invalid password '.+', should be[^\n]+/ Show Hide @@ -56,8 +53,7 @@ Show Hide Enter -Wait /invalid password/ -Wait+Screen /Gimme your password:\n>\n/ +Wait+CLIPrompt /Gimme your password/ /invalid password '.+', should be[^\n]+/ Show Hide @@ -66,6 +62,6 @@ Show Hide Enter -Wait+Screen /invalid password/ +Wait+Screen /invalid password 'wrongpass', should be[^\n]+/ ${AUTHD_TEST_TAPE_COMMAND_AUTH_FINAL_WAIT} Show diff --git a/pam/integration-tests/testdata/tapes/cli/mfa_reset_pwquality_auth.tape b/pam/integration-tests/testdata/tapes/cli/mfa_reset_pwquality_auth.tape index ef250d5db..85ebf9aef 100644 --- a/pam/integration-tests/testdata/tapes/cli/mfa_reset_pwquality_auth.tape +++ b/pam/integration-tests/testdata/tapes/cli/mfa_reset_pwquality_auth.tape @@ -32,7 +32,7 @@ Show # Wait for MFA auth to happen Hide Wait+Screen @${AUTHD_SLEEP_EXAMPLE_BROKER_MFA_WAIT} * 1.2 /Enter your new password \(3 days until mandatory\)\n/ -Wait+Screen @${AUTHD_SLEEP_EXAMPLE_BROKER_MFA_WAIT} * 1.2 /New password:\n>\n/ +Wait+CLIPrompt@${AUTHD_SLEEP_EXAMPLE_BROKER_MFA_WAIT} * 1.2 /New password/ /\[ Skip \]/ Show Hide @@ -41,8 +41,7 @@ Show Hide Enter -Wait /The password is the same as the old one/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /\[ Skip \]/ /The password is the same as the old one/ Show Hide @@ -51,8 +50,7 @@ Show Hide Enter -Wait /The password fails the dictionary check/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /\[ Skip \]\nThe password fails the dictionary check[^\n]+/ Show Hide @@ -61,8 +59,7 @@ Show Hide Enter -Wait /The password is the same as the old one/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /\[ Skip \]\nThe password is the same as the old one/ Show Hide @@ -71,8 +68,7 @@ Show Hide Enter -Wait /The password is shorter than \d+ characters/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /\[ Skip \]\nThe password is shorter than \d+ characters/ Show Hide @@ -81,7 +77,7 @@ Show Hide Enter -Wait+Screen /Confirm password:\n>\n/ +Wait+CLIPrompt /Confirm password/ /\[ Skip \]/ Show Hide diff --git a/pam/integration-tests/testdata/tapes/cli/optional_password_reset_skip.tape b/pam/integration-tests/testdata/tapes/cli/optional_password_reset_skip.tape index 25d6a32a6..593c5d66c 100644 --- a/pam/integration-tests/testdata/tapes/cli/optional_password_reset_skip.tape +++ b/pam/integration-tests/testdata/tapes/cli/optional_password_reset_skip.tape @@ -26,8 +26,7 @@ Show Hide Enter -Wait+Screen /New password:\n>\n/ -Wait /\[ Skip \]/ +Wait+CLIPrompt /New password/ /\[ Skip \]/ Show Hide diff --git a/pam/integration-tests/testdata/tapes/cli/passwd_auth_fail.tape b/pam/integration-tests/testdata/tapes/cli/passwd_auth_fail.tape index 28071a98c..ce2317214 100644 --- a/pam/integration-tests/testdata/tapes/cli/passwd_auth_fail.tape +++ b/pam/integration-tests/testdata/tapes/cli/passwd_auth_fail.tape @@ -26,8 +26,7 @@ Show Hide Enter -Wait /invalid password/ -Wait+Screen /Gimme your password:\n>\n/ +Wait+CLIPrompt /Gimme your password/ /invalid password '.+', should be[^\n]+/ Show Hide @@ -36,8 +35,7 @@ Show Hide Enter -Wait /invalid password/ -Wait+Screen /Gimme your password:\n>\n/ +Wait+CLIPrompt /Gimme your password/ /invalid password '.+', should be[^\n]+/ Show Hide @@ -46,8 +44,7 @@ Show Hide Enter -Wait /invalid password/ -Wait+Screen /Gimme your password:\n>\n/ +Wait+CLIPrompt /Gimme your password/ /invalid password '.+', should be[^\n]+/ Show Hide @@ -56,8 +53,7 @@ Show Hide Enter -Wait /invalid password/ -Wait+Screen /Gimme your password:\n>\n/ +Wait+CLIPrompt /Gimme your password/ /invalid password '.+', should be[^\n]+/ Show Hide @@ -66,6 +62,6 @@ Show Hide Enter -Wait+Screen /invalid password/ +Wait+Screen /invalid password '.+', should be[^\n]+/ ${AUTHD_TEST_TAPE_COMMAND_PASSWD_FINAL_WAIT} Show diff --git a/pam/integration-tests/testdata/tapes/cli/passwd_bad_password.tape b/pam/integration-tests/testdata/tapes/cli/passwd_bad_password.tape index ae46115af..61044f477 100644 --- a/pam/integration-tests/testdata/tapes/cli/passwd_bad_password.tape +++ b/pam/integration-tests/testdata/tapes/cli/passwd_bad_password.tape @@ -26,27 +26,24 @@ Show Hide Enter -Wait+Prompt /New password/ +Wait+CLIPrompt /New password/ Show Hide Enter -Wait /No password supplied/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /No password supplied/ Show Hide TypeCLIPassword "1234" Enter -Wait /The password is shorter than \d+ characters/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /The password is shorter than \d+ characters/ Show Hide TypeCLIPassword "12345678" Enter -Wait /The password fails the dictionary check/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /The password fails the dictionary check[^\n]*/ Show Hide @@ -61,8 +58,7 @@ Show Hide Enter -Wait /Password entries don't match/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /Password entries don't match/ Show Hide diff --git a/pam/integration-tests/testdata/tapes/cli/passwd_not_changed.tape b/pam/integration-tests/testdata/tapes/cli/passwd_not_changed.tape index 1a864b796..098b38901 100644 --- a/pam/integration-tests/testdata/tapes/cli/passwd_not_changed.tape +++ b/pam/integration-tests/testdata/tapes/cli/passwd_not_changed.tape @@ -35,8 +35,7 @@ Show Hide Enter -Wait /The password is the same as the old one/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /The password is the same as the old one/ Show Hide diff --git a/pam/integration-tests/testdata/tapes/cli/passwd_not_confirmed.tape b/pam/integration-tests/testdata/tapes/cli/passwd_not_confirmed.tape index fee92678e..78773ef3d 100644 --- a/pam/integration-tests/testdata/tapes/cli/passwd_not_confirmed.tape +++ b/pam/integration-tests/testdata/tapes/cli/passwd_not_confirmed.tape @@ -41,8 +41,7 @@ Show Hide Enter -Wait /Password entries don't match/ -Wait+Screen /New password:\n>\n/ +Wait+CLIPrompt /New password/ /Password entries don't match/ Show Hide diff --git a/pam/integration-tests/testdata/tapes/cli/passwd_rejected.tape b/pam/integration-tests/testdata/tapes/cli/passwd_rejected.tape index 8af375969..21c29fb5c 100644 --- a/pam/integration-tests/testdata/tapes/cli/passwd_rejected.tape +++ b/pam/integration-tests/testdata/tapes/cli/passwd_rejected.tape @@ -41,8 +41,7 @@ Show Hide Enter -Wait+Screen /New password:\n>\n/ -Wait /new password does not match criteria/ +Wait+CLIPrompt /New password/ /new password does not match criteria: must be [^\n]+/ Show Hide @@ -97,8 +96,7 @@ Show Hide Enter -Wait+Screen /New password:\n>\n/ -Wait /new password does not match criteria/ +Wait+CLIPrompt /New password/ /new password does not match criteria: must be [^\n]+/ Show Hide diff --git a/pam/integration-tests/testdata/tapes/cli/remember_broker_and_mode.tape b/pam/integration-tests/testdata/tapes/cli/remember_broker_and_mode.tape index 8a2b89d66..01a7145ac 100644 --- a/pam/integration-tests/testdata/tapes/cli/remember_broker_and_mode.tape +++ b/pam/integration-tests/testdata/tapes/cli/remember_broker_and_mode.tape @@ -25,7 +25,7 @@ Show Hide Type "7" -Wait+Screen /Enter your one time credential:\n>\n/ +Wait+CLIPrompt /Enter your one time credential/ /\[ Resend SMS \(1 sent\) \]/ Show Hide @@ -49,7 +49,7 @@ Show Hide Enter -Wait+Screen /Enter your one time credential:\n>\n/ +Wait+CLIPrompt /Enter your one time credential/ /\[ Resend SMS \(1 sent\) \]/ Show Hide diff --git a/pam/integration-tests/vhs-helpers_test.go b/pam/integration-tests/vhs-helpers_test.go index b925fc11c..a66ce34ce 100644 --- a/pam/integration-tests/vhs-helpers_test.go +++ b/pam/integration-tests/vhs-helpers_test.go @@ -109,6 +109,9 @@ var ( vhsWaitSuffix = regexp.MustCompile(`\bWait\+Suffix(@\S+)?[\t ]+(/(.*)/|(.*))`) // vhsWaitPromptRegex adds support for Wait+Prompt /Pattern/ command. vhsWaitPromptRegex = regexp.MustCompile(`\bWait\+Prompt(@\S+)?[\t ]+(/(.*)/|(.*))`) + // vhsWaitCLIPromptRegex adds support for Wait+CLIPrompt /Pattern1/ /Pattern2/ command. + vhsWaitCLIPromptRegex = regexp.MustCompile( + `\bWait\+CLIPrompt(@\S+)?[\t ]+/([^/]+)/([\t ]+/([^/]+)/)?([\t ]+/(.+)/)?`) // vhsWaitNth adds support for Wait+Nth(X) /Pattern/ command, where X is the // number of values of the same content we want to match. vhsWaitNth = regexp.MustCompile(`\bWait\+Nth\((\d+)\)(@\S+)?[\t ]+(/(.*)/|(.*))`) @@ -456,6 +459,8 @@ Wait+Screen /\n> %s\n/`, regexp.QuoteMeta(strings.Repeat("*", len(password))))) } + tapeString = vhsWaitCLIPromptRegex.ReplaceAllString(tapeString, + `Wait+Suffix$1 /$2:\n>[\n]+[ ]*$4[\n]*[\n]+$6/`) tapeString = vhsWaitPromptRegex.ReplaceAllString(tapeString, `Wait+Suffix$1 /$3$4:\n>/`) tapeString = vhsWaitSuffix.ReplaceAllString(tapeString,