]> git.notmuchmail.org Git - notmuch/blobdiff - test/T357-index-decryption.sh
Merge branch 'release'
[notmuch] / test / T357-index-decryption.sh
index 0a602e50c3b6fb7833e170edc1e26a0a4bfca41a..1ac2836a6e31e9cab1b8c37444038fc6162bce29 100755 (executable)
@@ -8,8 +8,6 @@ test_description='indexing decrypted mail'
 ##################################################
 
 add_gnupg_home
-# get key fingerprint
-FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10)
 
 # create a test encrypted message
 test_begin_subtest 'emacs delivery of encrypted message'
@@ -224,10 +222,12 @@ add_email_corpus crypto
 
 test_begin_subtest "indexing message fails when secret key not available"
 notmuch reindex --decrypt=true id:simple-encrypted@crypto.notmuchmail.org
-output=$(notmuch dump )
-expected='#notmuch-dump batch-tag:3 config,properties,tags
-+encrypted +inbox +unread -- id:simple-encrypted@crypto.notmuchmail.org
-#= simple-encrypted@crypto.notmuchmail.org index.decryption=failure'
+output=$(notmuch dump | LC_ALL=C sort)
+expected='#= simple-encrypted@crypto.notmuchmail.org index.decryption=failure
+#notmuch-dump batch-tag:3 config,properties,tags
++encrypted +inbox +unread -- id:basic-encrypted@crypto.notmuchmail.org
++encrypted +inbox +unread -- id:encrypted-signed@crypto.notmuchmail.org
++encrypted +inbox +unread -- id:simple-encrypted@crypto.notmuchmail.org'
 test_expect_equal \
     "$output" \
     "$expected"
@@ -245,8 +245,8 @@ notmuch restore <<EOF
 #= simple-encrypted@crypto.notmuchmail.org session-key=9%3AFC09987F5F927CC0CC0EE80A96E4C5BBF4A499818FB591207705DFDDD6112CF9
 EOF
 notmuch reindex id:simple-encrypted@crypto.notmuchmail.org
-output=$(notmuch search sekrit)
-expected='thread:0000000000000001   2016-12-22 [1/1] Daniel Kahn Gillmor; encrypted message (encrypted inbox unread)'
+output=$(notmuch search sekrit | notmuch_search_sanitize)
+expected='thread:XXX   2016-12-22 [1/1] Daniel Kahn Gillmor; encrypted message (encrypted inbox unread)'
 test_expect_equal \
     "$output" \
     "$expected"
@@ -289,6 +289,24 @@ test_expect_equal \
     "$output" \
     "$expected"
 
+goodsig='good_sig:[0][0][0]["crypto"]["signed"]["status"][0]["status"]="good"'
+nosig='no_sig:[0][0][0]["crypto"]!"signed"'
+
+test_begin_subtest "verify signature without a session key stashed when --decrypt=true"
+output=$(notmuch show --format=json --decrypt=true id:encrypted-signed@crypto.notmuchmail.org)
+test_json_nodes <<<"$output" "$goodsig"
+
+test_begin_subtest "do not verify sig without a session key stashed if --decrypt=auto"
+output=$(notmuch show --format=json id:encrypted-signed@crypto.notmuchmail.org)
+test_json_nodes <<<"$output" "$nosig"
+
+test_begin_subtest "verify signature when --decrypt=stash"
+output=$(notmuch show --format=json --decrypt=stash id:encrypted-signed@crypto.notmuchmail.org)
+test_json_nodes <<<"$output" "$goodsig"
+
+test_begin_subtest "verify signature with stashed session key"
+output=$(notmuch show --format=json id:encrypted-signed@crypto.notmuchmail.org)
+test_json_nodes <<<"$output" "$goodsig"
 
 # TODO: test removal of a message from the message store between
 # indexing and reindexing.