adds another test

ADP-216_sops_automation
LeeW 10 months ago
parent f1de3d9c03
commit 4e8790f8ca

@ -1,10 +1,12 @@
#!/usr/bin/env bash
# PURPOSE: Test to verify update_sops.sh script
set -ueo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
test_dir="$(realpath $(dirname "${BASH_SOURCE[0]}"))"
cd "${test_dir}"
keys_dir="$(dirname "${BASH_SOURCE[0]}")/.."
# deliberate just "dot" for current dir
# opinionated: keys located in current repo, one level up
keys_dir="$(dirname "${test_dir}")"
# deliberate: just "dot" for current dir
sops_cfg_dir=.
secrets_file="mock_secrets.yaml"
@ -13,8 +15,6 @@ test -e "${secrets_file}" || (yq -n '.demo.credentials.secret = "hunter2"' > "${
set -x
# SAMPLE COMMANDS - manually uncomment to try out
# Full Args: specify path to each, also for secrets, mix specified and positional params
# ../bin/update_sops.sh -k "${keys_dir}" -c "${sops_cfg_dir}" -s "${secrets_file}" "${secrets_file}"
# TEST: induce error: invalid file
# ../bin/update_sops.sh "${secrets_file}" -s non_existing_secrets.yaml
set +x
@ -71,6 +71,22 @@ else
>&2 echo "# INFO: skipping ...."
fi
# ---
if [[ 1 -eq 1 ]]; then
>&2 echo -e "# ---\n# TEST: Full Args: specify path to each, also for secrets, mix specified and positional params"
set -x
../bin/update_sops.sh -k "${keys_dir}" -c "${sops_cfg_dir}" -s "${secrets_file}" "${secrets_file}" > /dev/null 2>&1
set +x
echo "TEST RC: $?"
# teardown
# not necessary, all tracked in git
# enmesh: restore, since this particular one is checked in
git checkout "${PWD}/.sops.yaml" > /dev/null 2>&1
else
>&2 echo "# INFO: skipping ...."
fi
# ---
echo "TESTCASES PASSED"
exit 0

Loading…
Cancel
Save