2011-05-26 03:01:16 +02:00
#!/usr/bin/env bash
# TODO:
# - decryption/verification with signer key not available
# - verification of signatures from expired/revoked keys
test_description = 'PGP/MIME signature verification and decryption'
2017-09-25 22:38:19 +02:00
. $( dirname " $0 " ) /test-lib.sh || exit 1
2021-05-15 22:47:44 +02:00
. $( dirname " $0 " ) /test-lib-emacs.sh || exit 1
2011-05-26 03:01:16 +02:00
##################################################
2021-05-01 13:54:16 +02:00
test_require_emacs
2011-05-26 03:01:16 +02:00
add_gnupg_home
2017-02-26 14:43:00 +01:00
test_begin_subtest "emacs delivery of signed message"
test_expect_success \
2013-12-14 15:39:54 +01:00
' emacs_fcc_message \
2011-05-26 03:01:16 +02:00
"test signed message 001" \
"This is a test signed message." \
"(mml-secure-message-sign)" '
2017-09-16 16:59:03 +02:00
test_begin_subtest "signed part content-type indexing"
output = $( notmuch search mimetype:multipart/signed and mimetype:application/pgp-signature | notmuch_search_sanitize)
test_expect_equal " $output " "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test signed message 001 (inbox signed)"
2011-05-26 03:01:16 +02:00
test_begin_subtest "signature verification"
output = $( notmuch show --format= json --verify subject:"test signed message 001" \
| notmuch_json_show_sanitize \
2019-05-25 20:04:06 +02:00
| sed -e 's|"created": [1234567890]*|"created": 946728000|g' )
2011-05-26 03:01:16 +02:00
expected = ' [ [ [ { "id" : "XXXXX" ,
"match" : true,
2012-03-01 23:30:41 +01:00
"excluded" : false,
2017-02-25 14:31:31 +01:00
"filename" : [ "YYYYY" ] ,
2011-05-26 03:01:16 +02:00
"timestamp" : 946728000,
"date_relative" : "2000-01-01" ,
2011-05-26 03:01:20 +02:00
"tags" : [ "inbox" ,"signed" ] ,
2019-05-25 20:04:06 +02:00
"crypto" : { "signed" : { "status" : [ { "status" : "good" , "created" : 946728000, "fingerprint" : " ' $FINGERPRINT ' " , "userid" : "'" $SELF_USERID "'" } ] } } ,
2011-05-26 03:01:16 +02:00
"headers" : { "Subject" : "test signed message 001" ,
"From" : "Notmuch Test Suite <test_suite@notmuchmail.org>" ,
"To" : "test_suite@notmuchmail.org" ,
2012-08-03 03:14:47 +02:00
"Date" : "Sat, 01 Jan 2000 12:00:00 +0000" } ,
2011-05-26 03:01:16 +02:00
"body" : [ { "id" : 1,
"sigstatus" : [ { "status" : "good" ,
"fingerprint" : " ' $FINGERPRINT ' " ,
2019-05-04 23:33:28 +02:00
"created" : 946728000,
"userid" : "'" $SELF_USERID "'" } ] ,
2011-05-27 12:27:36 +02:00
"content-type" : "multipart/signed" ,
"content" : [ { "id" : 2,
2011-05-26 03:01:16 +02:00
"content-type" : "text/plain" ,
2011-05-27 12:27:36 +02:00
"content" : "This is a test signed message.\n" } ,
{ "id" : 3,
2012-12-15 04:06:45 +01:00
"content-type" : "application/pgp-signature" ,
2016-11-23 18:57:22 +01:00
"content-length" : "NONZERO" } ] } ] } ,
2011-05-26 03:01:16 +02:00
[ ] ] ] ] '
2012-08-03 03:14:47 +02:00
test_expect_equal_json \
2011-05-26 03:01:16 +02:00
" $output " \
" $expected "
2017-06-03 19:47:39 +02:00
test_begin_subtest "detection of modified signed contents"
emacs_fcc_message \
"bad signed message 001" \
"Incriminating stuff. This is a test signed message." \
"(mml-secure-message-sign)"
file = $( notmuch search --output= files subject:"bad signed message 001" )
sed -i 's/Incriminating stuff. //' ${ file }
output = $( notmuch show --format= json --verify subject:"bad signed message 001" \
| notmuch_json_show_sanitize \
| sed -e 's|"created": [1234567890]*|"created": 946728000|' )
expected = ' [ [ [ { "id" : "XXXXX" ,
"match" : true,
"excluded" : false,
"filename" : [ "YYYYY" ] ,
"timestamp" : 946728000,
"date_relative" : "2000-01-01" ,
"tags" : [ "inbox" ,"signed" ] ,
2019-05-25 20:04:06 +02:00
"crypto" : { "signed" : { "status" : [ { "status" : "bad" , "keyid" : " ' $( echo $FINGERPRINT | cut -c 25-) ' " } ] } } ,
2017-06-03 19:47:39 +02:00
"headers" : { "Subject" : "bad signed message 001" ,
"From" : "Notmuch Test Suite <test_suite@notmuchmail.org>" ,
"To" : "test_suite@notmuchmail.org" ,
"Date" : "Sat, 01 Jan 2000 12:00:00 +0000" } ,
"body" : [ { "id" : 1,
"sigstatus" : [ { "status" : "bad" ,
"keyid" : " ' $( echo $FINGERPRINT | cut -c 25-) ' " } ] ,
"content-type" : "multipart/signed" ,
"content" : [ { "id" : 2,
"content-type" : "text/plain" ,
"content" : "This is a test signed message.\n" } ,
{ "id" : 3,
"content-type" : "application/pgp-signature" ,
"content-length" : "NONZERO" } ] } ] } ,
[ ] ] ] ] '
test_expect_equal_json \
" $output " \
" $expected "
2017-06-03 19:47:40 +02:00
test_begin_subtest "corrupted pgp/mime signature"
emacs_fcc_message \
"bad signed message 002" \
"Incriminating stuff. This is a test signed message." \
"(mml-secure-message-sign)"
file = $( notmuch search --output= files subject:"bad signed message 002" )
awk ' /-----BEGIN PGP SIGNATURE-----/{ flag = 1; print; next} \
/-----END PGP SIGNATURE-----/{ flag = 0; print; next} \
flag{ gsub( /[ A-Za-z] /,"0" ) ; print} !flag{ print} ' $file > $file .new
rm $file
mv $file .new $file
output = $( notmuch show --format= json --verify subject:"bad signed message 002" \
| notmuch_json_show_sanitize \
| sed -e 's|"created": [1234567890]*|"created": 946728000|' )
expected = ' [ [ [ { "id" : "XXXXX" ,
2019-05-25 20:04:06 +02:00
"crypto" : { } ,
2017-06-03 19:47:40 +02:00
"match" : true,
"excluded" : false,
"filename" : [ "YYYYY" ] ,
"timestamp" : 946728000,
"date_relative" : "2000-01-01" ,
"tags" : [ "inbox" ,"signed" ] ,
"headers" : { "Subject" : "bad signed message 002" ,
"From" : "Notmuch Test Suite <test_suite@notmuchmail.org>" ,
"To" : "test_suite@notmuchmail.org" ,
"Date" : "Sat, 01 Jan 2000 12:00:00 +0000" } ,
"body" : [ { "id" : 1,
"sigstatus" : [ ] ,
"content-type" : "multipart/signed" ,
"content" : [ { "id" : 2,
"content-type" : "text/plain" ,
"content" : "Incriminating stuff. This is a test signed message.\n" } ,
{ "id" : 3,
"content-type" : "application/pgp-signature" ,
"content-length" : "NONZERO" } ] } ] } ,
[ ] ] ] ] '
test_expect_equal_json \
" $output " \
" $expected "
2019-05-04 23:33:28 +02:00
test_begin_subtest "signature verification without full user ID validity"
# give the key no owner trust, removes validity on all user IDs of the
# certificate in the absence of other trusted certifiers:
gpg --quiet --batch --no-tty --export-ownertrust > " $GNUPGHOME /ownertrust.bak "
echo " ${ FINGERPRINT } :3: " | gpg --quiet --batch --no-tty --import-ownertrust
2011-05-26 03:01:16 +02:00
output = $( notmuch show --format= json --verify subject:"test signed message 001" \
| notmuch_json_show_sanitize \
2019-05-25 20:04:06 +02:00
| sed -e 's|"created": [1234567890]*|"created": 946728000|g' )
2011-05-26 03:01:16 +02:00
expected = ' [ [ [ { "id" : "XXXXX" ,
"match" : true,
2012-03-01 23:30:41 +01:00
"excluded" : false,
2017-02-25 14:31:31 +01:00
"filename" : [ "YYYYY" ] ,
2011-05-26 03:01:16 +02:00
"timestamp" : 946728000,
"date_relative" : "2000-01-01" ,
2011-05-26 03:01:20 +02:00
"tags" : [ "inbox" ,"signed" ] ,
2019-05-25 20:04:06 +02:00
"crypto" : { "signed" : { "status" : [ { "status" : "good" , "created" : 946728000, "fingerprint" : " ' $FINGERPRINT ' " } ] } } ,
2011-05-26 03:01:16 +02:00
"headers" : { "Subject" : "test signed message 001" ,
"From" : "Notmuch Test Suite <test_suite@notmuchmail.org>" ,
"To" : "test_suite@notmuchmail.org" ,
2012-08-03 03:14:47 +02:00
"Date" : "Sat, 01 Jan 2000 12:00:00 +0000" } ,
2011-05-26 03:01:16 +02:00
"body" : [ { "id" : 1,
"sigstatus" : [ { "status" : "good" ,
"fingerprint" : " ' $FINGERPRINT ' " ,
2019-05-04 23:33:28 +02:00
"created" : 946728000} ] ,
2011-05-27 12:27:36 +02:00
"content-type" : "multipart/signed" ,
"content" : [ { "id" : 2,
2011-05-26 03:01:16 +02:00
"content-type" : "text/plain" ,
2011-05-27 12:27:36 +02:00
"content" : "This is a test signed message.\n" } ,
{ "id" : 3,
2012-12-15 04:06:45 +01:00
"content-type" : "application/pgp-signature" ,
2016-11-23 18:57:22 +01:00
"content-length" : "NONZERO" } ] } ] } ,
2011-05-26 03:01:16 +02:00
[ ] ] ] ] '
2012-08-03 03:14:47 +02:00
test_expect_equal_json \
2011-05-26 03:01:16 +02:00
" $output " \
" $expected "
2019-05-04 23:33:28 +02:00
gpg --quiet --batch --no-tty --import-ownertrust < " $GNUPGHOME /ownertrust.bak "
2011-05-26 03:01:16 +02:00
test_begin_subtest "signature verification with signer key unavailable"
# move the gnupghome temporarily out of the way
mv " ${ GNUPGHOME } " { ,.bak}
output = $( notmuch show --format= json --verify subject:"test signed message 001" \
| notmuch_json_show_sanitize \
2019-05-25 20:04:06 +02:00
| sed -e 's|"created": [1234567890]*|"created": 946728000|g' )
2011-05-26 03:01:16 +02:00
expected = ' [ [ [ { "id" : "XXXXX" ,
"match" : true,
2012-03-01 23:30:41 +01:00
"excluded" : false,
2017-02-25 14:31:31 +01:00
"filename" : [ "YYYYY" ] ,
2011-05-26 03:01:16 +02:00
"timestamp" : 946728000,
"date_relative" : "2000-01-01" ,
2011-05-26 03:01:20 +02:00
"tags" : [ "inbox" ,"signed" ] ,
2019-05-25 20:04:06 +02:00
"crypto" : { "signed" : { "status" : [ { "errors" : { "key-missing" : true} , "keyid" : " ' $( echo $FINGERPRINT | cut -c 25-) ' " , "status" : "error" } ] } } ,
2011-05-26 03:01:16 +02:00
"headers" : { "Subject" : "test signed message 001" ,
"From" : "Notmuch Test Suite <test_suite@notmuchmail.org>" ,
"To" : "test_suite@notmuchmail.org" ,
2012-08-03 03:14:47 +02:00
"Date" : "Sat, 01 Jan 2000 12:00:00 +0000" } ,
2011-05-26 03:01:16 +02:00
"body" : [ { "id" : 1,
"sigstatus" : [ { "status" : "error" ,
"keyid" : " ' $( echo $FINGERPRINT | cut -c 25-) ' " ,
2017-06-03 19:47:34 +02:00
"errors" : { "key-missing" : true} } ] ,
2011-05-27 12:27:36 +02:00
"content-type" : "multipart/signed" ,
"content" : [ { "id" : 2,
2011-05-26 03:01:16 +02:00
"content-type" : "text/plain" ,
2011-05-27 12:27:36 +02:00
"content" : "This is a test signed message.\n" } ,
{ "id" : 3,
2012-12-15 04:06:45 +01:00
"content-type" : "application/pgp-signature" ,
2016-11-23 18:57:22 +01:00
"content-length" : "NONZERO" } ] } ] } ,
2011-05-26 03:01:16 +02:00
[ ] ] ] ] '
2012-08-03 03:14:47 +02:00
test_expect_equal_json \
2011-05-26 03:01:16 +02:00
" $output " \
" $expected "
mv " ${ GNUPGHOME } " { .bak,}
2017-02-26 14:43:00 +01:00
test_begin_subtest "emacs delivery of encrypted message with attachment"
2011-05-26 03:01:16 +02:00
# create a test encrypted message with attachment
cat <<EOF >TE STATTACHMENT
This is a test file.
EOF
2017-02-26 14:43:00 +01:00
test_expect_success \
2013-12-14 15:39:54 +01:00
' emacs_fcc_message \
2011-05-26 03:01:16 +02:00
"test encrypted message 001" \
"This is a test encrypted message.\n" \
"(mml-attach-file \"TESTATTACHMENT\") (mml-secure-message-encrypt)" '
2017-09-16 16:59:03 +02:00
test_begin_subtest "encrypted part content-type indexing"
output = $( notmuch search mimetype:multipart/encrypted and mimetype:application/pgp-encrypted and mimetype:application/octet-stream | notmuch_search_sanitize)
test_expect_equal " $output " "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test encrypted message 001 (encrypted inbox)"
2011-05-26 03:01:16 +02:00
test_begin_subtest "decryption, --format=text"
2017-12-19 17:40:54 +01:00
output = $( notmuch show --format= text --decrypt= true subject:"test encrypted message 001" \
2011-05-26 03:01:16 +02:00
| notmuch_show_sanitize_all \
| sed -e 's|"created": [1234567890]*|"created": 946728000|' )
2012-03-01 23:30:41 +01:00
expected = ' message{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX
2011-05-26 03:01:16 +02:00
header{
2011-05-26 03:01:20 +02:00
Notmuch Test Suite <test_suite@notmuchmail.org> ( 2000-01-01) ( encrypted inbox)
2011-05-26 03:01:16 +02:00
Subject: test encrypted message 001
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: test_suite@notmuchmail.org
2012-02-04 22:24:26 +01:00
Date: Sat, 01 Jan 2000 12:00:00 +0000
2011-05-26 03:01:16 +02:00
header}
body{
2011-05-27 12:27:37 +02:00
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
2011-05-26 03:01:16 +02:00
This is a test encrypted message.
part}
2011-05-29 00:03:48 +02:00
attachment{ ID: 5, Filename: TESTATTACHMENT, Content-type: application/octet-stream
2011-05-26 03:01:16 +02:00
Non-text part: application/octet-stream
attachment}
part}
2011-05-27 12:27:37 +02:00
part}
2011-05-26 03:01:16 +02:00
body}
message} '
test_expect_equal \
" $output " \
" $expected "
test_begin_subtest "decryption, --format=json"
2017-12-19 17:40:54 +01:00
output = $( notmuch show --format= json --decrypt= true subject:"test encrypted message 001" \
2011-05-26 03:01:16 +02:00
| notmuch_json_show_sanitize \
| sed -e 's|"created": [1234567890]*|"created": 946728000|' )
expected = ' [ [ [ { "id" : "XXXXX" ,
"match" : true,
2012-03-01 23:30:41 +01:00
"excluded" : false,
2017-02-25 14:31:31 +01:00
"filename" : [ "YYYYY" ] ,
2011-05-26 03:01:16 +02:00
"timestamp" : 946728000,
"date_relative" : "2000-01-01" ,
2011-05-26 03:01:20 +02:00
"tags" : [ "encrypted" ,"inbox" ] ,
2019-05-25 20:04:06 +02:00
"crypto" : { "decrypted" : { "status" : "full" } } ,
2011-05-26 03:01:16 +02:00
"headers" : { "Subject" : "test encrypted message 001" ,
"From" : "Notmuch Test Suite <test_suite@notmuchmail.org>" ,
"To" : "test_suite@notmuchmail.org" ,
2012-08-03 03:14:47 +02:00
"Date" : "Sat, 01 Jan 2000 12:00:00 +0000" } ,
2011-05-26 03:01:16 +02:00
"body" : [ { "id" : 1,
"encstatus" : [ { "status" : "good" } ] ,
2011-05-27 12:27:37 +02:00
"content-type" : "multipart/encrypted" ,
2011-05-26 03:01:16 +02:00
"content" : [ { "id" : 2,
2012-12-15 04:06:45 +01:00
"content-type" : "application/pgp-encrypted" ,
2016-11-23 18:57:22 +01:00
"content-length" : "NONZERO" } ,
2011-05-27 12:27:37 +02:00
{ "id" : 3,
"content-type" : "multipart/mixed" ,
"content" : [ { "id" : 4,
2011-05-26 03:01:16 +02:00
"content-type" : "text/plain" ,
"content" : "This is a test encrypted message.\n" } ,
2011-05-27 12:27:37 +02:00
{ "id" : 5,
2011-05-26 03:01:16 +02:00
"content-type" : "application/octet-stream" ,
2017-02-26 19:33:48 +01:00
"content-disposition" : "attachment" ,
2016-11-23 18:57:22 +01:00
"content-length" : "NONZERO" ,
2012-12-15 04:06:45 +01:00
"content-transfer-encoding" : "base64" ,
2011-05-27 12:27:37 +02:00
"filename" : "TESTATTACHMENT" } ] } ] } ] } ,
2011-05-26 03:01:16 +02:00
[ ] ] ] ] '
2012-08-03 03:14:47 +02:00
test_expect_equal_json \
2011-05-26 03:01:16 +02:00
" $output " \
" $expected "
2011-05-27 12:27:37 +02:00
test_begin_subtest "decryption, --format=json, --part=4"
2017-12-19 17:40:54 +01:00
output = $( notmuch show --format= json --part= 4 --decrypt= true subject:"test encrypted message 001" \
2011-05-26 03:01:16 +02:00
| notmuch_json_show_sanitize \
| sed -e 's|"created": [1234567890]*|"created": 946728000|' )
2011-05-27 12:27:37 +02:00
expected = ' { "id" : 4,
2011-05-26 03:01:16 +02:00
"content-type" : "text/plain" ,
"content" : "This is a test encrypted message.\n" } '
2012-08-03 03:14:47 +02:00
test_expect_equal_json \
2011-05-26 03:01:16 +02:00
" $output " \
" $expected "
2011-05-27 12:27:37 +02:00
test_begin_subtest "decrypt attachment (--part=5 --format=raw)"
2011-05-26 03:01:16 +02:00
notmuch show \
--format= raw \
2011-05-27 12:27:37 +02:00
--part= 5 \
2017-12-19 17:40:54 +01:00
--decrypt= true \
2011-05-26 03:01:16 +02:00
subject:"test encrypted message 001" >OUTPUT
2017-04-05 02:36:29 +02:00
test_expect_equal_file TESTATTACHMENT OUTPUT
2011-05-26 03:01:16 +02:00
test_begin_subtest "decryption failure with missing key"
mv " ${ GNUPGHOME } " { ,.bak}
2017-12-19 17:40:54 +01:00
output = $( notmuch show --format= json --decrypt= true subject:"test encrypted message 001" \
2011-05-26 03:01:16 +02:00
| notmuch_json_show_sanitize \
2016-11-23 18:57:22 +01:00
| sed -e 's|"created": [1234567890]*|"created": 946728000|' )
2011-05-26 03:01:16 +02:00
expected = ' [ [ [ { "id" : "XXXXX" ,
2019-05-25 20:04:06 +02:00
"crypto" : { } ,
2011-05-26 03:01:16 +02:00
"match" : true,
2012-03-01 23:30:41 +01:00
"excluded" : false,
2017-02-25 14:31:31 +01:00
"filename" : [ "YYYYY" ] ,
2011-05-26 03:01:16 +02:00
"timestamp" : 946728000,
"date_relative" : "2000-01-01" ,
2011-05-26 03:01:20 +02:00
"tags" : [ "encrypted" ,"inbox" ] ,
2011-05-26 03:01:16 +02:00
"headers" : { "Subject" : "test encrypted message 001" ,
"From" : "Notmuch Test Suite <test_suite@notmuchmail.org>" ,
"To" : "test_suite@notmuchmail.org" ,
2012-08-03 03:14:47 +02:00
"Date" : "Sat, 01 Jan 2000 12:00:00 +0000" } ,
2011-05-26 03:01:16 +02:00
"body" : [ { "id" : 1,
"encstatus" : [ { "status" : "bad" } ] ,
"content-type" : "multipart/encrypted" ,
"content" : [ { "id" : 2,
2012-12-15 04:06:45 +01:00
"content-type" : "application/pgp-encrypted" ,
2016-11-23 18:57:22 +01:00
"content-length" : "NONZERO" } ,
2011-05-26 03:01:16 +02:00
{ "id" : 3,
2012-12-15 04:06:45 +01:00
"content-type" : "application/octet-stream" ,
2016-11-23 18:57:22 +01:00
"content-length" : "NONZERO" } ] } ] } ,
2011-05-26 03:01:16 +02:00
[ ] ] ] ] '
2012-08-03 03:14:47 +02:00
test_expect_equal_json \
2011-05-26 03:01:16 +02:00
" $output " \
" $expected "
mv " ${ GNUPGHOME } " { .bak,}
2017-02-26 14:43:00 +01:00
test_begin_subtest "emacs delivery of encrypted + signed message"
test_expect_success \
2013-12-14 15:39:54 +01:00
' emacs_fcc_message \
2011-05-26 03:01:16 +02:00
"test encrypted message 002" \
"This is another test encrypted message.\n" \
"(mml-secure-message-sign-encrypt)" '
test_begin_subtest "decryption + signature verification"
2017-12-19 17:40:54 +01:00
output = $( notmuch show --format= json --decrypt= true subject:"test encrypted message 002" \
2011-05-26 03:01:16 +02:00
| notmuch_json_show_sanitize \
2019-05-25 20:04:06 +02:00
| sed -e 's|"created": [1234567890]*|"created": 946728000|g' )
2011-05-26 03:01:16 +02:00
expected = ' [ [ [ { "id" : "XXXXX" ,
"match" : true,
2012-03-01 23:30:41 +01:00
"excluded" : false,
2017-02-25 14:31:31 +01:00
"filename" : [ "YYYYY" ] ,
2011-05-26 03:01:16 +02:00
"timestamp" : 946728000,
"date_relative" : "2000-01-01" ,
2011-05-26 03:01:20 +02:00
"tags" : [ "encrypted" ,"inbox" ] ,
2019-05-25 20:04:06 +02:00
"crypto" : { "signed" : { "status" : [ { "status" : "good" , "created" : 946728000, "fingerprint" : " ' $FINGERPRINT ' " , "userid" : "'" $SELF_USERID "'" } ] ,
"encrypted" : true } ,
"decrypted" : { "status" : "full" } } ,
2011-05-26 03:01:16 +02:00
"headers" : { "Subject" : "test encrypted message 002" ,
"From" : "Notmuch Test Suite <test_suite@notmuchmail.org>" ,
"To" : "test_suite@notmuchmail.org" ,
2012-08-03 03:14:47 +02:00
"Date" : "Sat, 01 Jan 2000 12:00:00 +0000" } ,
2011-05-26 03:01:16 +02:00
"body" : [ { "id" : 1,
"encstatus" : [ { "status" : "good" } ] ,
"sigstatus" : [ { "status" : "good" ,
"fingerprint" : " ' $FINGERPRINT ' " ,
"created" : 946728000,
2019-05-04 23:33:27 +02:00
"userid" : "'" $SELF_USERID "'" } ] ,
2011-05-27 12:27:37 +02:00
"content-type" : "multipart/encrypted" ,
"content" : [ { "id" : 2,
2012-12-15 04:06:45 +01:00
"content-type" : "application/pgp-encrypted" ,
2016-11-23 18:57:22 +01:00
"content-length" : "NONZERO" } ,
2011-05-27 12:27:37 +02:00
{ "id" : 3,
2011-05-26 03:01:16 +02:00
"content-type" : "text/plain" ,
2011-05-27 12:27:37 +02:00
"content" : "This is another test encrypted message.\n" } ] } ] } ,
2011-05-26 03:01:16 +02:00
[ ] ] ] ] '
2012-08-03 03:14:47 +02:00
test_expect_equal_json \
2011-05-26 03:01:16 +02:00
" $output " \
" $expected "
test_begin_subtest "reply to encrypted message"
2017-12-19 17:40:55 +01:00
output = $( notmuch reply --decrypt= true subject:"test encrypted message 002" \
2017-09-02 01:59:47 +02:00
| notmuch_drop_mail_headers In-Reply-To References)
2011-05-26 03:01:16 +02:00
expected = ' From: Notmuch Test Suite <test_suite@notmuchmail.org>
Subject: Re: test encrypted message 002
2018-10-01 18:50:47 +02:00
To: test_suite@notmuchmail.org
2011-05-26 03:01:16 +02:00
On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
> This is another test encrypted message.'
test_expect_equal \
" $output " \
" $expected "
2016-09-13 03:45:57 +02:00
test_begin_subtest "Reply within emacs to an encrypted message"
test_emacs " (let ((message-hidden-headers '())
( notmuch-crypto-process-mime ' t) )
( notmuch-show \" subject:test.encrypted.message.002\" )
( notmuch-show-reply)
( test-output) ) "
2018-10-01 18:50:47 +02:00
grep -v -e '^In-Reply-To:' -e '^References:' -e '^Fcc:' < OUTPUT > OUTPUT.clean
2016-09-13 03:45:57 +02:00
cat <<EOF >E XPECTED
From: Notmuch Test Suite <test_suite@notmuchmail.org>
2018-10-01 18:50:47 +02:00
To: test_suite@notmuchmail.org
2016-09-13 03:45:57 +02:00
Subject: Re: test encrypted message 002
--text follows this line--
<#secure method=pgpmime mode=signencrypt>
Notmuch Test Suite <test_suite@notmuchmail.org> writes:
> This is another test encrypted message.
EOF
test_expect_equal_file EXPECTED OUTPUT.clean
2011-05-26 03:01:16 +02:00
test_begin_subtest "signature verification with revoked key"
2011-06-20 22:14:21 +02:00
# generate revocation certificate and load it to revoke key
2011-05-26 03:01:16 +02:00
echo " y
1
Notmuch Test Suite key revocation ( automated) $( date '+%F_%T%z' )
y
" \
| gpg --no-tty --quiet --command-fd 0 --armor --gen-revoke " 0x ${ FINGERPRINT } ! " 2>/dev/null \
| gpg --no-tty --quiet --import
output = $( notmuch show --format= json --verify subject:"test signed message 001" \
| notmuch_json_show_sanitize \
| sed -e 's|"created": [1234567890]*|"created": 946728000|' )
expected = ' [ [ [ { "id" : "XXXXX" ,
"match" : true,
2012-03-01 23:30:41 +01:00
"excluded" : false,
2017-02-25 14:31:31 +01:00
"filename" : [ "YYYYY" ] ,
2011-05-26 03:01:16 +02:00
"timestamp" : 946728000,
"date_relative" : "2000-01-01" ,
2011-05-26 03:01:20 +02:00
"tags" : [ "inbox" ,"signed" ] ,
2019-05-25 20:04:06 +02:00
"crypto" : { "signed" : { "status" : [ { "errors" : { "key-revoked" : true} , "keyid" : " ' $( echo $FINGERPRINT | cut -c 25-) ' " , "status" : "error" } ] } } ,
2011-05-26 03:01:16 +02:00
"headers" : { "Subject" : "test signed message 001" ,
"From" : "Notmuch Test Suite <test_suite@notmuchmail.org>" ,
"To" : "test_suite@notmuchmail.org" ,
2012-08-03 03:14:47 +02:00
"Date" : "Sat, 01 Jan 2000 12:00:00 +0000" } ,
2011-05-26 03:01:16 +02:00
"body" : [ { "id" : 1,
"sigstatus" : [ { "status" : "error" ,
"keyid" : "6D92612D94E46381" ,
2017-06-03 19:47:34 +02:00
"errors" : { "key-revoked" : true} } ] ,
2011-05-27 12:27:36 +02:00
"content-type" : "multipart/signed" ,
"content" : [ { "id" : 2,
2011-05-26 03:01:16 +02:00
"content-type" : "text/plain" ,
2011-05-27 12:27:36 +02:00
"content" : "This is a test signed message.\n" } ,
{ "id" : 3,
2012-12-15 04:06:45 +01:00
"content-type" : "application/pgp-signature" ,
2016-11-23 18:57:22 +01:00
"content-length" : "NONZERO" } ] } ] } ,
2011-05-26 03:01:16 +02:00
[ ] ] ] ] '
2012-08-03 03:14:47 +02:00
test_expect_equal_json \
2011-05-26 03:01:16 +02:00
" $output " \
" $expected "
test_done