Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 89 / b41255b5528e36d4f49acb68e2a946877518df
1 Return-Path: <bremner@tethera.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id AA2736DE1A78\r
6  for <notmuch@notmuchmail.org>; Fri, 11 Dec 2015 05:55:16 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.318\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.318 tagged_above=-999 required=5 tests=[AWL=0.233,\r
12   RP_MATCHES_RCVD=-0.55, SPF_PASS=-0.001] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id yuMiU0p-S0Mq for <notmuch@notmuchmail.org>;\r
16  Fri, 11 Dec 2015 05:55:15 -0800 (PST)\r
17 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
18  by arlo.cworth.org (Postfix) with ESMTPS id 9A5836DE1804\r
19  for <notmuch@notmuchmail.org>; Fri, 11 Dec 2015 05:54:59 -0800 (PST)\r
20 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
21  (envelope-from <bremner@tethera.net>)\r
22  id 1a7O9v-0000S3-ER; Fri, 11 Dec 2015 08:54:55 -0500\r
23 Received: (nullmailer pid 11212 invoked by uid 1000);\r
24  Fri, 11 Dec 2015 13:54:52 -0000\r
25 From: David Bremner <david@tethera.net>\r
26 To: notmuch@notmuchmail.org\r
27 Subject: [Patch v2 5/8] test: add broken S/MIME signature verification test\r
28  for notmuch CLI\r
29 Date: Fri, 11 Dec 2015 09:54:44 -0400\r
30 Message-Id: <1449842087-10972-6-git-send-email-david@tethera.net>\r
31 X-Mailer: git-send-email 2.6.2\r
32 In-Reply-To: <1449842087-10972-1-git-send-email-david@tethera.net>\r
33 References: <1449842087-10972-1-git-send-email-david@tethera.net>\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.20\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38  <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
40  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Fri, 11 Dec 2015 13:55:16 -0000\r
47 \r
48 The test is pretty much cut and paste from the PGP/MIME version, with\r
49 obvious updates taken from notmuch output.  This also requires setting\r
50 up gpgsm infrastucture.\r
51 ---\r
52  test/T355-smime.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
53  test/test-lib.sh   |  1 +\r
54  2 files changed, 51 insertions(+)\r
55 \r
56 diff --git a/test/T355-smime.sh b/test/T355-smime.sh\r
57 index 5f3ff12..b3cc76e 100755\r
58 --- a/test/T355-smime.sh\r
59 +++ b/test/T355-smime.sh\r
60 @@ -3,7 +3,17 @@\r
61  test_description='S/MIME signature verification and decryption'\r
62  . ./test-lib.sh\r
63  \r
64 +add_gpgsm_home ()\r
65 +{\r
66 +    local output\r
67 +    [ -d ${GNUPGHOME} ] && return\r
68 +    mkdir -m 0700 "$GNUPGHOME"\r
69 +    gpgsm --no-tty --import < test_suite.pem >"$GNUPGHOME"/import.log 2>&1\r
70 +    test_debug "cat $GNUPGHOME/import.log"\r
71 +}\r
72 +\r
73  test_require_external_prereq openssl\r
74 +test_require_external_prereq gpgsm\r
75  \r
76  test_begin_subtest "Generate CA Cert"\r
77  openssl genpkey -algorithm RSA -out ca.key -pass pass:test -des3 1024\r
78 @@ -21,6 +31,10 @@ openssl x509 -req -in smime.csr -passin pass:test -CA ca.crt -CAkey ca.key -set_\r
79  cat test_suite.crt smime.key > test_suite.pem\r
80  test_expect_equal "$(openssl verify -purpose smimesign -CAfile ca.crt test_suite.pem)" "test_suite.pem: OK"\r
81  \r
82 +add_gpgsm_home\r
83 +\r
84 +FINGERPRINT=$(openssl x509 -fingerprint -in test_suite.crt -noout | sed -e 's/^.*=//' -e s/://g)\r
85 +\r
86  test_expect_success 'emacs delivery of S/MIME signed message' \\r
87       'emacs_fcc_message \\r
88       "test signed message 001" \\r
89 @@ -41,6 +55,42 @@ Verification successful\r
90  EOF\r
91  test_expect_equal_file OUTPUT EXPECTED\r
92  \r
93 +test_begin_subtest "signature verification (notmuch CLI)"\r
94 +test_subtest_known_broken\r
95 +output=$(notmuch show --format=json --verify subject:"test signed message 001" \\r
96 +    | notmuch_json_show_sanitize \\r
97 +    | sed -e 's|"created": [1234567890]*|"created": 946728000|' \\r
98 +         -e 's|"expires": [1234567890]*|"expires": 424242424|' )\r
99 +expected='[[[{"id": "XXXXX",\r
100 + "match": true,\r
101 + "excluded": false,\r
102 + "filename": "YYYYY",\r
103 + "timestamp": 946728000,\r
104 + "date_relative": "2000-01-01",\r
105 + "tags": ["inbox","signed"],\r
106 + "headers": {"Subject": "test signed message 001",\r
107 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
108 + "To": "test_suite@notmuchmail.org",\r
109 + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
110 + "body": [{"id": 1,\r
111 + "sigstatus": [{"status": "good",\r
112 + "fingerprint": "'$FINGERPRINT'",\r
113 + "expires": 424242424,\r
114 + "created": 946728000}],\r
115 + "content-type": "multipart/signed",\r
116 + "content": [{"id": 2,\r
117 + "content-type": "text/plain",\r
118 + "content": "This is a test signed message.\n"},\r
119 + {"id": 3,\r
120 +  "content-length": 1930,\r
121 +  "content-transfer-encoding": "base64",\r
122 +  "content-type": "application/x-pkcs7-signature",\r
123 +  "filename": "smime.p7s"}]}]},\r
124 + []]]]'\r
125 +test_expect_equal_json \\r
126 +    "$output" \\r
127 +    "$expected"\r
128 +\r
129  test_begin_subtest "Decryption and signature verification (openssl)"\r
130  notmuch show --format=raw subject:"test encrypted message 001" |\\r
131      openssl smime -decrypt -recip test_suite.pem |\\r
132 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
133 index 2e9a499..0790698 100644\r
134 --- a/test/test-lib.sh\r
135 +++ b/test/test-lib.sh\r
136 @@ -1326,4 +1326,5 @@ test_declare_external_prereq ${TEST_EMACSCLIENT}\r
137  test_declare_external_prereq gdb\r
138  test_declare_external_prereq gpg\r
139  test_declare_external_prereq openssl\r
140 +test_declare_external_prereq gpgsm\r
141  test_declare_external_prereq ${NOTMUCH_PYTHON}\r
142 -- \r
143 2.6.2\r
144 \r