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

* 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>
(cherry picked from commit fe7e68bfcb)
pull/83882/head
Sloane Hertel 3 months ago committed by GitHub
parent c58b88b1dd
commit 56e39b3e72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -546,21 +546,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