X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Fcrypto;h=446a58b7eef28a36169aca597611020e0ed86e6d;hp=ead05829dcdf4f8b00bb1dfbb654d853e9a86a2e;hb=2f50524e27db2ca58f6543a2c73a5719d8d7f491;hpb=627d752501b42326b9016271de33a6cb0fa2dc8c diff --git a/test/crypto b/test/crypto index ead05829..446a58b7 100755 --- a/test/crypto +++ b/test/crypto @@ -12,7 +12,7 @@ add_gnupg_home () local output [ -d ${GNUPGHOME} ] && return mkdir -m 0700 "$GNUPGHOME" - gpg --no-tty --import <../gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1 + gpg --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1 test_debug "cat $GNUPGHOME/import.log" if (gpg --quick-random --version >/dev/null 2>&1) ; then echo quick-random >> "$GNUPGHOME"/gpg.conf @@ -46,7 +46,7 @@ expected='[[[{"id": "XXXXX", "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", - "tags": ["inbox"], + "tags": ["inbox","signed"], "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", @@ -57,8 +57,12 @@ expected='[[[{"id": "XXXXX", "sigstatus": [{"status": "good", "fingerprint": "'$FINGERPRINT'", "created": 946728000}], + "content-type": "multipart/signed", + "content": [{"id": 2, "content-type": "text/plain", - "content": "This is a test signed message.\n"}]}, + "content": "This is a test signed message.\n"}, + {"id": 3, + "content-type": "application/pgp-signature"}]}]}, []]]]' test_expect_equal \ "$output" \ @@ -76,7 +80,7 @@ expected='[[[{"id": "XXXXX", "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", - "tags": ["inbox"], + "tags": ["inbox","signed"], "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", @@ -88,14 +92,20 @@ expected='[[[{"id": "XXXXX", "fingerprint": "'$FINGERPRINT'", "created": 946728000, "userid": " Notmuch Test Suite (INSECURE!)"}], + "content-type": "multipart/signed", + "content": [{"id": 2, "content-type": "text/plain", - "content": "This is a test signed message.\n"}]}, + "content": "This is a test signed message.\n"}, + {"id": 3, + "content-type": "application/pgp-signature"}]}]}, []]]]' test_expect_equal \ "$output" \ "$expected" test_begin_subtest "signature verification with signer key unavailable" +# this is broken with current versions of gmime-2.6 +(ldd $(which notmuch) | grep -Fq gmime-2.6) && test_subtest_known_broken # move the gnupghome temporarily out of the way mv "${GNUPGHOME}"{,.bak} output=$(notmuch show --format=json --verify subject:"test signed message 001" \ @@ -106,7 +116,7 @@ expected='[[[{"id": "XXXXX", "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", - "tags": ["inbox"], + "tags": ["inbox","signed"], "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", @@ -117,8 +127,12 @@ expected='[[[{"id": "XXXXX", "sigstatus": [{"status": "error", "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'", "errors": 2}], + "content-type": "multipart/signed", + "content": [{"id": 2, "content-type": "text/plain", - "content": "This is a test signed message.\n"}]}, + "content": "This is a test signed message.\n"}, + {"id": 3, + "content-type": "application/pgp-signature"}]}]}, []]]]' test_expect_equal \ "$output" \ @@ -141,22 +155,26 @@ output=$(notmuch show --format=text --decrypt subject:"test encrypted message 00 | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected=' message{ id:XXXXX depth:0 match:1 filename:XXXXX header{ -Notmuch Test Suite (2000-01-01) (inbox) +Notmuch Test Suite (2000-01-01) (encrypted inbox) Subject: test encrypted message 001 From: Notmuch Test Suite To: test_suite@notmuchmail.org Date: 01 Jan 2000 12:00:00 -0000 header} body{ - part{ ID: 1, Content-type: multipart/mixed - part{ ID: 2, Content-type: text/plain + part{ ID: 1, Content-type: multipart/encrypted + part{ ID: 2, Content-type: application/pgp-encrypted +Non-text part: application/pgp-encrypted + part} + part{ ID: 3, Content-type: multipart/mixed + part{ ID: 4, Content-type: text/plain This is a test encrypted message. part} - attachment{ ID: 3, Content-type: application/octet-stream -Attachment: TESTATTACHMENT (application/octet-stream) + attachment{ ID: 5, Filename: TESTATTACHMENT, Content-type: application/octet-stream Non-text part: application/octet-stream attachment} part} + part} body} message}' test_expect_equal \ @@ -172,7 +190,7 @@ expected='[[[{"id": "XXXXX", "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", - "tags": ["inbox"], + "tags": ["encrypted","inbox"], "headers": {"Subject": "test encrypted message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", @@ -182,33 +200,37 @@ expected='[[[{"id": "XXXXX", "body": [{"id": 1, "encstatus": [{"status": "good"}], "sigstatus": [], - "content-type": "multipart/mixed", + "content-type": "multipart/encrypted", "content": [{"id": 2, + "content-type": "application/pgp-encrypted"}, + {"id": 3, + "content-type": "multipart/mixed", + "content": [{"id": 4, "content-type": "text/plain", "content": "This is a test encrypted message.\n"}, - {"id": 3, + {"id": 5, "content-type": "application/octet-stream", - "filename": "TESTATTACHMENT"}]}]}, + "filename": "TESTATTACHMENT"}]}]}]}, []]]]' test_expect_equal \ "$output" \ "$expected" -test_begin_subtest "decryption, --format=json, --part=2" -output=$(notmuch show --format=json --part=2 --decrypt subject:"test encrypted message 001" \ +test_begin_subtest "decryption, --format=json, --part=4" +output=$(notmuch show --format=json --part=4 --decrypt subject:"test encrypted message 001" \ | notmuch_json_show_sanitize \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') -expected='{"id": 2, +expected='{"id": 4, "content-type": "text/plain", "content": "This is a test encrypted message.\n"}' test_expect_equal \ "$output" \ "$expected" -test_begin_subtest "decrypt attachment (--part=3 --format=raw)" +test_begin_subtest "decrypt attachment (--part=5 --format=raw)" notmuch show \ --format=raw \ - --part=3 \ + --part=5 \ --decrypt \ subject:"test encrypted message 001" >OUTPUT test_expect_equal_file OUTPUT TESTATTACHMENT @@ -223,7 +245,7 @@ expected='[[[{"id": "XXXXX", "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", - "tags": ["inbox"], + "tags": ["encrypted","inbox"], "headers": {"Subject": "test encrypted message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", @@ -258,7 +280,7 @@ expected='[[[{"id": "XXXXX", "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", - "tags": ["inbox"], + "tags": ["encrypted","inbox"], "headers": {"Subject": "test encrypted message 002", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", @@ -271,8 +293,12 @@ expected='[[[{"id": "XXXXX", "fingerprint": "'$FINGERPRINT'", "created": 946728000, "userid": " Notmuch Test Suite (INSECURE!)"}], + "content-type": "multipart/encrypted", + "content": [{"id": 2, + "content-type": "application/pgp-encrypted"}, + {"id": 3, "content-type": "text/plain", - "content": "This is another test encrypted message.\n"}]}, + "content": "This is another test encrypted message.\n"}]}]}, []]]]' test_expect_equal \ "$output" \ @@ -291,7 +317,7 @@ test_expect_equal \ "$expected" test_begin_subtest "signature verification with revoked key" -# generate revokation certificate and load it to revoke key +# generate revocation certificate and load it to revoke key echo "y 1 Notmuch Test Suite key revocation (automated) $(date '+%F_%T%z') @@ -309,7 +335,7 @@ expected='[[[{"id": "XXXXX", "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", - "tags": ["inbox"], + "tags": ["inbox","signed"], "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", @@ -320,8 +346,12 @@ expected='[[[{"id": "XXXXX", "sigstatus": [{"status": "error", "keyid": "6D92612D94E46381", "errors": 8}], + "content-type": "multipart/signed", + "content": [{"id": 2, "content-type": "text/plain", - "content": "This is a test signed message.\n"}]}, + "content": "This is a test signed message.\n"}, + {"id": 3, + "content-type": "application/pgp-signature"}]}]}, []]]]' test_expect_equal \ "$output" \