--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 62B356DE025F\r
+ for <notmuch@notmuchmail.org>; Sun, 24 Jan 2016 08:21:31 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.309\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.309 tagged_above=-999 required=5 tests=[AWL=0.242,\r
+ RP_MATCHES_RCVD=-0.55, SPF_PASS=-0.001] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Qeg4Q8ow3x4h for <notmuch@notmuchmail.org>;\r
+ Sun, 24 Jan 2016 08:21:29 -0800 (PST)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 49C966DE02DA\r
+ for <notmuch@notmuchmail.org>; Sun, 24 Jan 2016 08:21:28 -0800 (PST)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1aNNPF-0002N6-28; Sun, 24 Jan 2016 11:20:49 -0500\r
+Received: (nullmailer pid 16068 invoked by uid 1000);\r
+ Sun, 24 Jan 2016 16:21:25 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v4 2/5] test: add broken S/MIME signature verification test\r
+ for notmuch CLI\r
+Date: Sun, 24 Jan 2016 12:21:16 -0400\r
+Message-Id: <1453652479-15968-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.6.4\r
+In-Reply-To: <1453652479-15968-1-git-send-email-david@tethera.net>\r
+References: <1453652479-15968-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 24 Jan 2016 16:21:31 -0000\r
+\r
+The test is pretty much cut and paste from the PGP/MIME version, with\r
+obvious updates taken from notmuch output. This also requires setting\r
+up gpgsm infrastucture.\r
+---\r
+ test/T355-smime.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++\r
+ test/test-lib.sh | 1 +\r
+ 2 files changed, 50 insertions(+)\r
+\r
+diff --git a/test/T355-smime.sh b/test/T355-smime.sh\r
+index a1b7c09..a059fac 100755\r
+--- a/test/T355-smime.sh\r
++++ b/test/T355-smime.sh\r
+@@ -3,6 +3,17 @@\r
+ test_description='S/MIME signature verification and decryption'\r
+ . ./test-lib.sh || exit 1\r
+ \r
++add_gpgsm_home ()\r
++{\r
++ local fpr\r
++ [ -d ${GNUPGHOME} ] && return\r
++ mkdir -m 0700 "$GNUPGHOME"\r
++ gpgsm --no-tty --no-common-certs-import --disable-dirmngr --import < $TEST_DIRECTORY/smime/test.crt >"$GNUPGHOME"/import.log 2>&1\r
++ fpr=$(gpgsm --list-key test_suite@notmuchmail.org | sed -n 's/.*fingerprint: //p')\r
++ echo "$fpr S relax" >> $GNUPGHOME/trustlist.txt\r
++ test_debug "cat $GNUPGHOME/import.log"\r
++}\r
++\r
+ test_require_external_prereq openssl\r
+ test_require_external_prereq gpgsm\r
+ \r
+@@ -10,6 +21,8 @@ cp $TEST_DIRECTORY/smime/key+cert.pem test_suite.pem\r
+ \r
+ FINGERPRINT=$(openssl x509 -fingerprint -in test_suite.pem -noout | sed -e 's/^.*=//' -e s/://g)\r
+ \r
++add_gpgsm_home\r
++\r
+ test_expect_success 'emacs delivery of S/MIME signed message' \\r
+ 'emacs_fcc_message \\r
+ "test signed message 001" \\r
+@@ -30,6 +43,42 @@ Verification successful\r
+ EOF\r
+ test_expect_equal_file EXPECTED OUTPUT\r
+ \r
++test_begin_subtest "signature verification (notmuch CLI)"\r
++test_subtest_known_broken\r
++output=$(notmuch show --format=json --verify subject:"test signed message 001" \\r
++ | notmuch_json_show_sanitize \\r
++ | sed -e 's|"created": [-1234567890]*|"created": 946728000|' \\r
++ -e 's|"expires": [-1234567890]*|"expires": 424242424|' )\r
++expected='[[[{"id": "XXXXX",\r
++ "match": true,\r
++ "excluded": false,\r
++ "filename": "YYYYY",\r
++ "timestamp": 946728000,\r
++ "date_relative": "2000-01-01",\r
++ "tags": ["inbox","signed"],\r
++ "headers": {"Subject": "test signed message 001",\r
++ "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
++ "To": "test_suite@notmuchmail.org",\r
++ "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
++ "body": [{"id": 1,\r
++ "sigstatus": [{"status": "good",\r
++ "fingerprint": "'$FINGERPRINT'",\r
++ "expires": 424242424,\r
++ "created": 946728000}],\r
++ "content-type": "multipart/signed",\r
++ "content": [{"id": 2,\r
++ "content-type": "text/plain",\r
++ "content": "This is a test signed message.\n"},\r
++ {"id": 3,\r
++ "content-length": 1922,\r
++ "content-transfer-encoding": "base64",\r
++ "content-type": "application/x-pkcs7-signature",\r
++ "filename": "smime.p7s"}]}]},\r
++ []]]]'\r
++test_expect_equal_json \\r
++ "$output" \\r
++ "$expected"\r
++\r
+ test_begin_subtest "Decryption and signature verification (openssl)"\r
+ notmuch show --format=raw subject:"test encrypted message 001" |\\r
+ openssl smime -decrypt -recip test_suite.pem |\\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 41710e7..6b7854a 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -1329,4 +1329,5 @@ test_declare_external_prereq ${TEST_EMACSCLIENT}\r
+ test_declare_external_prereq gdb\r
+ test_declare_external_prereq gpg\r
+ test_declare_external_prereq openssl\r
++test_declare_external_prereq gpgsm\r
+ test_declare_external_prereq ${NOTMUCH_PYTHON}\r
+-- \r
+2.6.4\r
+\r