From 35693570943d3f01bda8c78f2886c44f5934b586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lesimple?= Date: Tue, 20 Feb 2024 13:56:40 +0000 Subject: [PATCH] fix: tests for FreeBSD --- tests/functional/launch_tests_on_instance.sh | 2 +- tests/functional/tests.d/325-accountinfo.sh | 2 +- tests/functional/tests.d/395-mfa-scp-sftp.sh | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/functional/launch_tests_on_instance.sh b/tests/functional/launch_tests_on_instance.sh index 59c02cf9b..0bbc35467 100755 --- a/tests/functional/launch_tests_on_instance.sh +++ b/tests/functional/launch_tests_on_instance.sh @@ -672,7 +672,7 @@ runtests() configchg 's=^\\\\x22bastionCommand\\\\x22.+=\\\\x22bastionCommand\\\\x22:\\\\x22ssh\\\\x20USER\\\\x40'"$remote_ip"'\\\\x20-p\\\\x20'"$remote_port"'\\\\x20-t\\\\x20--\\\\x22,=' # account1 skips PAM MFA - success account1_nopam $r0 "usermod -a -G bastion-nopam $account0" + success account1_nopam $r0 "command -v pw \>/dev/null \&\& pw groupmod -n bastion-nopam -m $account0 \|\| usermod -a -G bastion-nopam $account0" # backup the original default configuration on target side now=$(date +%s) diff --git a/tests/functional/tests.d/325-accountinfo.sh b/tests/functional/tests.d/325-accountinfo.sh index 3718c57fe..942671fb8 100644 --- a/tests/functional/tests.d/325-accountinfo.sh +++ b/tests/functional/tests.d/325-accountinfo.sh @@ -47,7 +47,7 @@ testsuite_accountinfo() # a0 should see basic info about a2 success a0_accountinfo_a2_basic $a0 --osh accountInfo --account $account2 - json_document '{"error_message":"OK","command":"accountInfo","error_code":"OK","value":{"account":"'"$account2"'","always_active":1,"is_active":1,"allowed_commands":[],"groups":{}}}' + json_document '{"error_message":"OK","command":"accountInfo","error_code":"OK","value":{"account":"'"$account2"'","always_active":1,"always_active_reason":"account local configuration","is_active":1,"allowed_commands":[],"groups":{}}}' # a1 should see detailed info about a2 success a1_accountinfo_a2_detailed $a1 --osh accountInfo --account $account2 --with-mfa-password-info diff --git a/tests/functional/tests.d/395-mfa-scp-sftp.sh b/tests/functional/tests.d/395-mfa-scp-sftp.sh index 3c3ece8cc..b4be53a68 100644 --- a/tests/functional/tests.d/395-mfa-scp-sftp.sh +++ b/tests/functional/tests.d/395-mfa-scp-sftp.sh @@ -134,7 +134,7 @@ testsuite_mfa_scp_sftp() expect \":\" { sleep 0.2; send \"$a0_password\\n\"; }; expect eof; lassign [wait] pid spawnid value value; - exit \$value' | expect -f -" + exit \$value' | timeout --foreground $default_timeout expect -f -" retvalshouldbe 0 unset a0_password_tmp nocontain 'enter this:' @@ -149,7 +149,7 @@ testsuite_mfa_scp_sftp() expect \":\" { sleep 0.2; send \"$a0_password\\n\"; }; expect eof; lassign [wait] pid spawnid value value; - exit \$value' | expect -f -" + exit \$value' | timeout --foreground $default_timeout expect -f -" nocontain 'MFA_TOKEN=notrequired' if [ "${capabilities[mfa]}" = 1 ] || [ "${capabilities[mfa-password]}" = 1 ]; then retvalshouldbe 0 @@ -166,7 +166,7 @@ testsuite_mfa_scp_sftp() expect \":\" { sleep 0.2; send \"$a0_password\\n\"; }; expect eof; lassign [wait] pid spawnid value value; - exit \$value' | expect -f -" + exit \$value' | timeout --foreground $default_timeout expect -f -" nocontain 'MFA_TOKEN=notrequired' if [ "${capabilities[mfa]}" = 1 ] || [ "${capabilities[mfa-password]}" = 1 ]; then retvalshouldbe 0 @@ -182,12 +182,12 @@ testsuite_mfa_scp_sftp() json .error_code KO_MFA_FAILED_INVALID_FORMAT local invalid_token - invalid_token="v1,$(date +%s -d '1 hour ago'),9f25d680b1bae2ef73abc3c62926ddb9c88f8ea1f4120b1125cc09720c74268b" + invalid_token="v1,$(perl -e 'CORE::say time()-3600'),9f25d680b1bae2ef73abc3c62926ddb9c88f8ea1f4120b1125cc09720c74268b" run scp_upload_bad_token_expired $a0 --osh scp --host 127.0.0.2 --port 22 --user $shellaccount --mfa-token "$invalid_token" retvalshouldbe 125 json .error_code KO_MFA_FAILED_EXPIRED_TOKEN - invalid_token="v1,$(date +%s -d '1 hour'),9f25d680b1bae2ef73abc3c62926ddb9c88f8ea1f4120b1125cc09720c74268b" + invalid_token="v1,$(perl -e 'CORE::say time()-3600'),9f25d680b1bae2ef73abc3c62926ddb9c88f8ea1f4120b1125cc09720c74268b" run scp_upload_bad_token_future $a0 --osh scp --host 127.0.0.2 --port 22 --user $shellaccount --mfa-token "$invalid_token" retvalshouldbe 125 json .error_code KO_MFA_FAILED_FUTURE_TOKEN @@ -200,7 +200,7 @@ testsuite_mfa_scp_sftp() expect \"word:\" { sleep 0.2; send \"$a0_password\\n\"; }; expect eof; lassign [wait] pid spawnid value value; - exit \$value' | expect -f -" + exit \$value' | timeout --foreground $default_timeout expect -f -" retvalshouldbe 0 json .error_code OK .command selfMFAResetPassword else