From b27b8ba4acb877ea25cf5e8cf42b2d3dbf9b358b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 28 Nov 2014 00:34:56 +0100 Subject: [PATCH] Add test-case for key management --- test/run.sh | 4 ++-- test/test-key-add-remove.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 test/test-key-add-remove.sh diff --git a/test/run.sh b/test/run.sh index 5fb4431f5..12e03eb57 100755 --- a/test/run.sh +++ b/test/run.sh @@ -82,10 +82,10 @@ else testfiles=(${dir}/test-*.sh) fi -echo "testfiles: $testfiles" +echo "testfiles: ${testfiles[@]}" failed="" -for testfile in "$testfiles"; do +for testfile in "${testfiles[@]}"; do current=$(basename "${testfile}" .sh) if bash "${testfile}"; then diff --git a/test/test-key-add-remove.sh b/test/test-key-add-remove.sh new file mode 100755 index 000000000..1bc63334f --- /dev/null +++ b/test/test-key-add-remove.sh @@ -0,0 +1,35 @@ +set -e + +dump_repo() { + if [ "$FAILED" == "1" ]; then + tar cvz "$KHEPRI_REPOSITORY" | base64 >&2 + fi +} + +FAILED=1 + +trap dump_repo 0 + +prepare +unset KHEPRI_PASSWORD +KHEPRI_PASSWORD=foo run khepri init +KHEPRI_PASSWORD=foo run khepri key list +OLD_PWD=foo +for i in {1..3}; do + NEW_PWD=bar$i + KHEPRI_PASSWORD=$OLD_PWD KHEPRI_NEWPASSWORD=$NEW_PWD run khepri key add + KHEPRI_PASSWORD=$OLD_PWD run khepri key list + KHEPRI_PASSWORD=$NEW_PWD run khepri key list + + export KHEPRI_PASSWORD=$OLD_PWD + ID=$(khepri key list | grep '^\*'|cut -d ' ' -f 1| sed 's/^.//') + unset KHEPRI_PASSWORD + KHEPRI_PASSWORD=$NEW_PWD run khepri key rm $ID + KHEPRI_PASSWORD=$NEW_PWD run khepri key list + + OLD_PWD=bar$i +done + +cleanup + +FAILED=0