From 32c88c4af59b88b331a223d93178ab33d52dbb32 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 23 Apr 2014 17:21:23 +0200 Subject: tests: make more gritty, less setup --- tests/t0300-reencryption.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'tests/t0300-reencryption.sh') diff --git a/tests/t0300-reencryption.sh b/tests/t0300-reencryption.sh index 87f445e..f7968a4 100755 --- a/tests/t0300-reencryption.sh +++ b/tests/t0300-reencryption.sh @@ -5,11 +5,23 @@ test_description='Reencryption consistency' INITIAL_PASSWORD="will this password live? a big question indeed..." -test_expect_success 'Init with key1' ' - pass_init -' +canonicalize_gpg_keys() { + $GPG --list-keys --keyid-format long "$@" | sed -n 's/sub *.*\/\([A-F0-9]\{16\}\) .*/\1/p' | sort -u +} +gpg_keys_from_encrypted_file() { + $GPG -v --list-only --keyid-format long "$1" 2>&1 | cut -d ' ' -f 5 | sort -u +} +gpg_keys_from_group() { + local output="$($GPG --list-config --with-colons | sed -n "s/^cfg:group:$1:\\(.*\\)/\\1/p" | head -n 1)" + local saved_ifs="$IFS" + IFS=";" + local keys=( $output ) + IFS="$saved_ifs" + canonicalize_gpg_keys "${keys[@]}" +} test_expect_success 'Root key encryption' ' + $PASS init $KEY1 && $PASS insert -e folder/cred1 <<<"$INITIAL_PASSWORD" && [[ $(canonicalize_gpg_keys "$KEY1") == "$(gpg_keys_from_encrypted_file "$PASSWORD_STORE_DIR/folder/cred1.gpg")" ]] ' -- cgit v1.2.3