diff options
author | Lee Garrett <leegarrett@users.noreply.github.com> | 2025-01-14 16:46:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-14 16:46:31 +0100 |
commit | 73180c0630244519c632c2a43c3ed3d794953010 (patch) | |
tree | 0378b7c05c92ad68b7cef130725359a6e991a05b | |
parent | get_url: add support for BSD-style digest (#84485) (diff) | |
download | ansible-73180c0630244519c632c2a43c3ed3d794953010.tar.xz ansible-73180c0630244519c632c2a43c3ed3d794953010.zip |
ansible-vault integration test fix (fixes: #83837) (#84486)
Correct the test that expects an error when using ansible-vault to write against
a non-writeable dir. Skip the test as root, as root can always write.
Co-authored-by: Lee Garrett <lgarrett@rocketjump.eu>
-rwxr-xr-x | test/integration/targets/ansible-vault/runme.sh | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/test/integration/targets/ansible-vault/runme.sh b/test/integration/targets/ansible-vault/runme.sh index f64728def6..c8c503a4e6 100755 --- a/test/integration/targets/ansible-vault/runme.sh +++ b/test/integration/targets/ansible-vault/runme.sh @@ -48,16 +48,19 @@ echo $? ansible-vault view "$@" --vault-id vault-password encrypted-vault-password # check if ansible-vault fails when destination is not writable -NOT_WRITABLE_DIR="${MYTMPDIR}/not_writable" -TEST_FILE_EDIT4="${NOT_WRITABLE_DIR}/testfile" -mkdir "${NOT_WRITABLE_DIR}" -touch "${TEST_FILE_EDIT4}" -chmod ugo-w "${NOT_WRITABLE_DIR}" -ansible-vault encrypt "$@" --vault-password-file vault-password "${TEST_FILE_EDIT4}" < /dev/null > log 2>&1 && : -grep "not writable" log && : -WRONG_RC=$? -echo "rc was $WRONG_RC (1 is expected)" -[ $WRONG_RC -eq 1 ] +# skip check as root as root can always read/write +if [ ${UID} -ne "0" ]; then + NOT_WRITABLE_DIR="${MYTMPDIR}/not_writable" + TEST_FILE_EDIT4="${NOT_WRITABLE_DIR}/testfile" + mkdir "${NOT_WRITABLE_DIR}" + touch "${TEST_FILE_EDIT4}" + chmod ugo-w "${NOT_WRITABLE_DIR}" + ansible-vault encrypt "$@" --vault-password-file vault-password "${TEST_FILE_EDIT4}" < /dev/null > log 2>&1 && : + grep "not writable" log && : + WRONG_RC=$? + echo "rc was $WRONG_RC (0 is expected)" + [ $WRONG_RC -eq 0 ] +fi # encrypt with a password from a vault encrypted password file and multiple vault-ids # should fail because we dont know which vault id to use to encrypt with |