|
|
|
@ -1,10 +1,12 @@
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
# PURPOSE: Test to verify update_sops.sh script
|
|
|
|
# PURPOSE: Test to verify update_sops.sh script
|
|
|
|
set -ueo pipefail
|
|
|
|
set -ueo pipefail
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
|
|
test_dir="$(realpath $(dirname "${BASH_SOURCE[0]}"))"
|
|
|
|
|
|
|
|
cd "${test_dir}"
|
|
|
|
|
|
|
|
|
|
|
|
keys_dir="$(dirname "${BASH_SOURCE[0]}")/.."
|
|
|
|
# opinionated: keys located in current repo, one level up
|
|
|
|
# deliberate just "dot" for current dir
|
|
|
|
keys_dir="$(dirname "${test_dir}")"
|
|
|
|
|
|
|
|
# deliberate: just "dot" for current dir
|
|
|
|
sops_cfg_dir=.
|
|
|
|
sops_cfg_dir=.
|
|
|
|
secrets_file="mock_secrets.yaml"
|
|
|
|
secrets_file="mock_secrets.yaml"
|
|
|
|
|
|
|
|
|
|
|
|
@ -13,8 +15,6 @@ test -e "${secrets_file}" || (yq -n '.demo.credentials.secret = "hunter2"' > "${
|
|
|
|
|
|
|
|
|
|
|
|
set -x
|
|
|
|
set -x
|
|
|
|
# SAMPLE COMMANDS - manually uncomment to try out
|
|
|
|
# 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
|
|
|
|
# TEST: induce error: invalid file
|
|
|
|
# ../bin/update_sops.sh "${secrets_file}" -s non_existing_secrets.yaml
|
|
|
|
# ../bin/update_sops.sh "${secrets_file}" -s non_existing_secrets.yaml
|
|
|
|
set +x
|
|
|
|
set +x
|
|
|
|
@ -71,6 +71,22 @@ else
|
|
|
|
>&2 echo "# INFO: skipping ...."
|
|
|
|
>&2 echo "# INFO: skipping ...."
|
|
|
|
fi
|
|
|
|
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"
|
|
|
|
echo "TESTCASES PASSED"
|
|
|
|
exit 0
|
|
|
|
exit 0
|
|
|
|
|