Fix ansible-vault integration test for missing vault ids (#83777)

* Fix broken, circumvented test for missing vault ids

* verify the command returns a non-zero exit code

Co-authored-by: Matt Clay <matt@mystile.com>
pull/83786/head
Sloane Hertel 1 year ago committed by GitHub
parent 9a54ba5a39
commit fe7e68bfcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -552,21 +552,22 @@ sudo chmod 000 "${MYTMPDIR}/unreadable"
ansible-vault encrypt_string content
ansible-vault encrypt_string content --encrypt-vault-id id3
set +e
# Try to use a missing vault password file
ansible-vault encrypt_string content --encrypt-vault-id id1 2>&1 | tee out.txt
test $? -ne 0
grep out.txt -e '[WARNING]: Error getting vault password file (id1)'
grep out.txt -e "ERROR! Did not find a match for --encrypt-vault-id=id2 in the known vault-ids ['id3']"
if ansible-vault encrypt_string content --encrypt-vault-id id1 > out.txt 2>&1; then
echo "command did not fail"
exit 1
fi
grep out.txt -e '\[WARNING\]: Error getting vault password file (id1)'
grep out.txt -e "ERROR! Did not find a match for --encrypt-vault-id=id1 in the known vault-ids \['id3'\]"
# Try to use an inaccessible vault password file
ansible-vault encrypt_string content --encrypt-vault-id id2 2>&1 | tee out.txt
test $? -ne 0
grep out.txt -e "[WARNING]: Error in vault password file loading (id2)"
grep out.txt -e "ERROR! Did not find a match for --encrypt-vault-id=id2 in the known vault-ids ['id3']"
if ansible-vault encrypt_string content --encrypt-vault-id id2 > out.txt 2>&1; then
echo "command did not fail"
exit 1
fi
grep out.txt -e "\[WARNING\]: Error in vault password file loading (id2)"
grep out.txt -e "ERROR! Did not find a match for --encrypt-vault-id=id2 in the known vault-ids \['id3'\]"
set -e
unset ANSIBLE_VAULT_IDENTITY_LIST
# 'real script'

Loading…
Cancel
Save