summaryrefslogtreecommitdiff
path: root/tests/t0300-reencryption.sh
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2014-04-23 17:21:23 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2014-04-23 17:21:23 +0200
commit32c88c4af59b88b331a223d93178ab33d52dbb32 (patch)
treeb54081a2ac7f1be4dfb9e96b9803b8da339e11ff /tests/t0300-reencryption.sh
parent4e44306e8c10fcea59f6927035ce9b956d4140e9 (diff)
downloadpass-32c88c4af59b88b331a223d93178ab33d52dbb32.tar.gz
pass-32c88c4af59b88b331a223d93178ab33d52dbb32.tar.bz2
pass-32c88c4af59b88b331a223d93178ab33d52dbb32.zip
tests: make more gritty, less setup
Diffstat (limited to '')
-rwxr-xr-xtests/t0300-reencryption.sh18
1 files changed, 15 insertions, 3 deletions
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")" ]]
'