From 680028229d926cfb7ea6c68af408fa63a49bbb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 8 Jul 2024 15:10:41 +0200 Subject: [PATCH] pam/integration-tests: Add qrcode quick regeneration test This was failing in previous versions because of the races fixed in this branch, so ensure we won't fail anymore --- pam/integration-tests/cli_test.go | 1 + ...user_with_qr_code_after_many_regenerations | 430 ++++++++++++++++++ .../tapes/cli/qr_code_quick_regenerate.tape | 63 +++ 3 files changed, 494 insertions(+) create mode 100644 pam/integration-tests/testdata/TestCLIAuthenticate/golden/authenticate_user_with_qr_code_after_many_regenerations create mode 100644 pam/integration-tests/testdata/tapes/cli/qr_code_quick_regenerate.tape diff --git a/pam/integration-tests/cli_test.go b/pam/integration-tests/cli_test.go index c95efc409..51262e3c7 100644 --- a/pam/integration-tests/cli_test.go +++ b/pam/integration-tests/cli_test.go @@ -47,6 +47,7 @@ func TestCLIAuthenticate(t *testing.T) { "Authenticate user with qr code in a TTY": {tape: "qr_code", pamUser: "user-integration-qr-code-tty", termEnv: "linux"}, "Authenticate user with qr code in a TTY session": {tape: "qr_code", pamUser: "user-integration-qr-code-tty-session", termEnv: "xterm-256color", sessionEnv: "tty"}, "Authenticate user with qr code in screen": {tape: "qr_code", pamUser: "user-integration-qr-code-screen", termEnv: "screen"}, + "Authenticate user with qr code after many regenerations": {tape: "qr_code_quick_regenerate"}, "Authenticate user and reset password while enforcing policy": {tape: "mandatory_password_reset"}, "Authenticate user and offer password reset": {tape: "optional_password_reset_skip"}, "Authenticate user switching auth mode": {tape: "switch_auth_mode"}, diff --git a/pam/integration-tests/testdata/TestCLIAuthenticate/golden/authenticate_user_with_qr_code_after_many_regenerations b/pam/integration-tests/testdata/TestCLIAuthenticate/golden/authenticate_user_with_qr_code_after_many_regenerations new file mode 100644 index 000000000..f44595fdb --- /dev/null +++ b/pam/integration-tests/testdata/TestCLIAuthenticate/golden/authenticate_user_with_qr_code_after_many_regenerations @@ -0,0 +1,430 @@ +> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} +Username: user name + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +──────────────────────────────────────────────────────────────────────────────── +> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} +Username: user-integration-qrcode-regenerate + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +──────────────────────────────────────────────────────────────────────────────── +> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} + Select your provider + +> 1. local + 2. ExampleBroker + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +──────────────────────────────────────────────────────────────────────────────── +> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} +Gimme your password +> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +──────────────────────────────────────────────────────────────────────────────── +> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} + Select your authentication method + +> 1. Password authentication + 2. Send URL to user-integration-qrcode-regenerate@gmail.com + 3. Use your fido device foo + 4. Use your phone +33… + 5. Use your phone +1… + 6. Use a QR code + 7. Authentication code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +──────────────────────────────────────────────────────────────────────────────── +> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} +Scan the qrcode or enter the code in the login page + +█████████████████████████████████ +█████████████████████████████████ +████ ▄▄▄▄▄ █ ▀▀█▄██ █ ▄▄▄▄▄ ████ +████ █ █ █▀▄██ ▄▄▄██ █ █ ████ +████ █▄▄▄█ ██▄ █ ▄ ▄▄█ █▄▄▄█ ████ +████▄▄▄▄▄▄▄█ ▀▄▀▄▀ ▀▄█▄▄▄▄▄▄▄████ +████▄█ ▄█ ▄ ▀█▄▀▀▄▄█ █▄▀█▄█ ▄████ +█████▀█▀▄ ▄ ▄▀█▀▀▀ ▀█▄▀▄▄▀▀██████ +████▄ █▀█▄▄▄██ █▀█▀█▄ █▄▄ ████ +████▀▄ ▀▄▄█ ▄▄█ ▀▄▀▀ ▀▀ █▄▄▀████ +███████▄▄█▄█ ▀▄▀▀█▀ ▄▄▄ ▄ ▄ ████ +████ ▄▄▄▄▄ █ █▄ ██▀ █▄█ █▄ ████ +████ █ █ █▀▄ ▄ ▀▀▄ ▄ ▀▀▀████ +████ █▄▄▄█ █▄█▄▄▄▄█ █ █ █ ▄█████ +████▄▄▄▄▄▄▄█▄█▄█▄█▄████▄▄▄▄▄▄████ +█████████████████████████████████ +▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ + https://ubuntu.com + 1337 + + [ Regenerate code ] + + + + + + + + + + + + + + + + + + +──────────────────────────────────────────────────────────────────────────────── +> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} +Scan the qrcode or enter the code in the login page + +█████████████████████████████████ +█████████████████████████████████ +████ ▄▄▄▄▄ █ ▀▀█▄██ █ ▄▄▄▄▄ ████ +████ █ █ █▀▄██ ▄▄▄██ █ █ ████ +████ █▄▄▄█ ██▄ █ ▄ ▄▄█ █▄▄▄█ ████ +████▄▄▄▄▄▄▄█ ▀▄▀▄▀ ▀▄█▄▄▄▄▄▄▄████ +████▄█ ▄█ ▄ ▀█▄▀▀▄▄█ █▄▀█▄█ ▄████ +█████▀█▀▄ ▄ ▄▀█▀▀▀ ▀█▄▀▄▄▀▀██████ +████▄ █▀█▄▄▄██ █▀█▀█▄ █▄▄ ████ +████▀▄ ▀▄▄█ ▄▄█ ▀▄▀▀ ▀▀ █▄▄▀████ +███████▄▄█▄█ ▀▄▀▀█▀ ▄▄▄ ▄ ▄ ████ +████ ▄▄▄▄▄ █ █▄ ██▀ █▄█ █▄ ████ +████ █ █ █▀▄ ▄ ▀▀▄ ▄ ▀▀▀████ +████ █▄▄▄█ █▄█▄▄▄▄█ █ █ █ ▄█████ +████▄▄▄▄▄▄▄█▄█▄█▄█▄████▄▄▄▄▄▄████ +█████████████████████████████████ +▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ + https://ubuntu.com + 1337 + + [ Regenerate code ] + + + + + + + + + + + + + + + + + + +──────────────────────────────────────────────────────────────────────────────── +> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} +Scan the qrcode or enter the code in the login page + +█████████████████████████████████ +█████████████████████████████████ +████ ▄▄▄▄▄ █ ▀▀█▄██ █ ▄▄▄▄▄ ████ +████ █ █ █▀▄██ ▄▄▄██ █ █ ████ +████ █▄▄▄█ ██▄ █ ▄ ▄▄█ █▄▄▄█ ████ +████▄▄▄▄▄▄▄█ ▀▄▀▄▀ ▀▄█▄▄▄▄▄▄▄████ +████▄█ ▄█ ▄ ▀█▄▀▀▄▄█ █▄▀█▄█ ▄████ +█████▀█▀▄ ▄ ▄▀█▀▀▀ ▀█▄▀▄▄▀▀██████ +████▄ █▀█▄▄▄██ █▀█▀█▄ █▄▄ ████ +████▀▄ ▀▄▄█ ▄▄█ ▀▄▀▀ ▀▀ █▄▄▀████ +███████▄▄█▄█ ▀▄▀▀█▀ ▄▄▄ ▄ ▄ ████ +████ ▄▄▄▄▄ █ █▄ ██▀ █▄█ █▄ ████ +████ █ █ █▀▄ ▄ ▀▀▄ ▄ ▀▀▀████ +████ █▄▄▄█ █▄█▄▄▄▄█ █ █ █ ▄█████ +████▄▄▄▄▄▄▄█▄█▄█▄█▄████▄▄▄▄▄▄████ +█████████████████████████████████ +▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ + https://ubuntu.com + 1337 + +PAM Authenticate() for user "user-integration-qrcode-regenerate" exited with success +PAM AcctMgmt() exited with success +> + + + + + + + + + + + + + + + + +──────────────────────────────────────────────────────────────────────────────── +> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} +Scan the qrcode or enter the code in the login page + +█████████████████████████████████ +█████████████████████████████████ +████ ▄▄▄▄▄ █ ▀▀█▄██ █ ▄▄▄▄▄ ████ +████ █ █ █▀▄██ ▄▄▄██ █ █ ████ +████ █▄▄▄█ ██▄ █ ▄ ▄▄█ █▄▄▄█ ████ +████▄▄▄▄▄▄▄█ ▀▄▀▄▀ ▀▄█▄▄▄▄▄▄▄████ +████▄█ ▄█ ▄ ▀█▄▀▀▄▄█ █▄▀█▄█ ▄████ +█████▀█▀▄ ▄ ▄▀█▀▀▀ ▀█▄▀▄▄▀▀██████ +████▄ █▀█▄▄▄██ █▀█▀█▄ █▄▄ ████ +████▀▄ ▀▄▄█ ▄▄█ ▀▄▀▀ ▀▀ █▄▄▀████ +███████▄▄█▄█ ▀▄▀▀█▀ ▄▄▄ ▄ ▄ ████ +████ ▄▄▄▄▄ █ █▄ ██▀ █▄█ █▄ ████ +████ █ █ █▀▄ ▄ ▀▀▄ ▄ ▀▀▀████ +████ █▄▄▄█ █▄█▄▄▄▄█ █ █ █ ▄█████ +████▄▄▄▄▄▄▄█▄█▄█▄█▄████▄▄▄▄▄▄████ +█████████████████████████████████ +▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ + https://ubuntu.com + 1337 + +PAM Authenticate() for user "user-integration-qrcode-regenerate" exited with success +PAM AcctMgmt() exited with success +> + + + + + + + + + + + + + + + + +──────────────────────────────────────────────────────────────────────────────── +> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} +Scan the qrcode or enter the code in the login page + +█████████████████████████████████ +█████████████████████████████████ +████ ▄▄▄▄▄ █ ▀▀█▄██ █ ▄▄▄▄▄ ████ +████ █ █ █▀▄██ ▄▄▄██ █ █ ████ +████ █▄▄▄█ ██▄ █ ▄ ▄▄█ █▄▄▄█ ████ +████▄▄▄▄▄▄▄█ ▀▄▀▄▀ ▀▄█▄▄▄▄▄▄▄████ +████▄█ ▄█ ▄ ▀█▄▀▀▄▄█ █▄▀█▄█ ▄████ +█████▀█▀▄ ▄ ▄▀█▀▀▀ ▀█▄▀▄▄▀▀██████ +████▄ █▀█▄▄▄██ █▀█▀█▄ █▄▄ ████ +████▀▄ ▀▄▄█ ▄▄█ ▀▄▀▀ ▀▀ █▄▄▀████ +███████▄▄█▄█ ▀▄▀▀█▀ ▄▄▄ ▄ ▄ ████ +████ ▄▄▄▄▄ █ █▄ ██▀ █▄█ █▄ ████ +████ █ █ █▀▄ ▄ ▀▀▄ ▄ ▀▀▀████ +████ █▄▄▄█ █▄█▄▄▄▄█ █ █ █ ▄█████ +████▄▄▄▄▄▄▄█▄█▄█▄█▄████▄▄▄▄▄▄████ +█████████████████████████████████ +▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ + https://ubuntu.com + 1337 + +PAM Authenticate() for user "user-integration-qrcode-regenerate" exited with success +PAM AcctMgmt() exited with success +> + + + + + + + + + + + + + + + + +──────────────────────────────────────────────────────────────────────────────── diff --git a/pam/integration-tests/testdata/tapes/cli/qr_code_quick_regenerate.tape b/pam/integration-tests/testdata/tapes/cli/qr_code_quick_regenerate.tape new file mode 100644 index 000000000..ca71ebd2f --- /dev/null +++ b/pam/integration-tests/testdata/tapes/cli/qr_code_quick_regenerate.tape @@ -0,0 +1,63 @@ +Output qr_code_quick_regenerate.txt +Output qr_code_quick_regenerate.gif # If we don't specify a .gif output, it will create a default out.gif file. + +# Configuration header to standardize the output. +# Does not work with the "Source" command. +Set Width 800 +Set Height 650 +# TODO: Ideally, we should use Ubuntu Mono. However, the github runner is still on Jammy, which does not have it. +# We should update this to use Ubuntu Mono once the runner is updated. +Set FontFamily "Monospace" +Set FontSize 13 +Set Padding 0 +Set Margin 0 +Set Shell bash + +Hide +Type "./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK}" +Enter +Sleep 300ms +Show + +Hide +Escape +Backspace +Type "user-integration-qrcode-regenerate" +Sleep 300ms +Show + +Hide +Enter +Sleep 300ms +Show + +Hide +Type "2" +Sleep 300ms +Show + +Hide +Escape +Sleep 300ms +Show + +Hide +Type "6" +Sleep 300ms +Show + +Hide +Tab +Sleep 300ms +Show + +Hide +Enter@1ms 50 +Sleep 3s +Show + +Hide +Sleep 5s +Show + +Sleep 300ms