Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 80 / f9d496b3e707f12d473cfac09c60832b6535fc
1 Return-Path: <jrollins@servo.finestructure.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 olra.theworths.org (Postfix) with ESMTP id B87EA431FB6\r
6         for <notmuch@notmuchmail.org>; Wed, 25 May 2011 18:01:41 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.921\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.921 tagged_above=-999 required=5\r
12         tests=[NO_DNS_FOR_FROM=0.379, RCVD_IN_DNSWL_MED=-2.3]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id IINXHzid94ai for <notmuch@notmuchmail.org>;\r
17         Wed, 25 May 2011 18:01:37 -0700 (PDT)\r
18 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
19         [131.215.239.19])\r
20         by olra.theworths.org (Postfix) with ESMTP id 79A69429E3A\r
21         for <notmuch@notmuchmail.org>; Wed, 25 May 2011 18:01:34 -0700 (PDT)\r
22 Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
23         by fire-doxen-postvirus (Postfix) with ESMTP id 787CB2E50E75;\r
24         Wed, 25 May 2011 17:55:19 -0700 (PDT)\r
25 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
26 Received: from servo.finestructure.net (gwave-104.ligo.caltech.edu\r
27         [131.215.114.104]) (Authenticated sender: jrollins)\r
28         by fire-doxen-submit (Postfix) with ESMTP id 0AAA43282CD;\r
29         Wed, 25 May 2011 17:55:14 -0700 (PDT)\r
30 Received: by servo.finestructure.net (Postfix, from userid 1000)\r
31         id 7DD747C8; Wed, 25 May 2011 18:01:26 -0700 (PDT)\r
32 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
33 To: notmuch@notmuchmail.org\r
34 Subject: [PATCH 07/11] test: add crypto tests for signature verification and\r
35         decryption\r
36 Date: Wed, 25 May 2011 18:01:16 -0700\r
37 Message-Id: <1306371680-19441-8-git-send-email-jrollins@finestructure.net>\r
38 X-Mailer: git-send-email 1.7.4.4\r
39 In-Reply-To: <1306371680-19441-1-git-send-email-jrollins@finestructure.net>\r
40 References: <1306371680-19441-1-git-send-email-jrollins@finestructure.net>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Thu, 26 May 2011 01:01:42 -0000\r
54 \r
55 This adds a new "crypto" test script to the test suite to test\r
56 PGP/MIME signature verification and message decryption.  Included here\r
57 is a test GNUPGHOME with a test secret key (passwordless), and test\r
58 for:\r
59 \r
60   * signing/verification\r
61   * signing/verification with full owner trust\r
62   * verification with signer key unavailable\r
63   * encryption/decryption\r
64   * decryption failure with missing key\r
65   * encryption/decryption + signing/verfifying\r
66   * reply to encrypted message\r
67   * verification of signature from revoked key\r
68 \r
69 These tests are not expected to pass now, but will as crypto\r
70 functionality is included.\r
71 ---\r
72  test/basic                 |    5 +-\r
73  test/crypto                |  330 ++++++++++++++++++++++++++++++++++++++++++++\r
74  test/gnupg-secret-key.NOTE |    9 ++\r
75  test/gnupg-secret-key.asc  |   34 +++++\r
76  test/notmuch-test          |    1 +\r
77  test/test-lib.sh           |   29 ++++\r
78  6 files changed, 407 insertions(+), 1 deletions(-)\r
79  create mode 100755 test/crypto\r
80  create mode 100644 test/gnupg-secret-key.NOTE\r
81  create mode 100644 test/gnupg-secret-key.asc\r
82 \r
83 diff --git a/test/basic b/test/basic\r
84 index 3b43ad9..d6c0d00 100755\r
85 --- a/test/basic\r
86 +++ b/test/basic\r
87 @@ -57,7 +57,10 @@ available=$(ls -1 ../ | \\r
88      sed -r -e "/^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test)/d" \\r
89            -e "/^(README|test-lib.sh|test-results|tmp.*|valgrind|corpus*)/d" \\r
90            -e "/^(emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose)/d" \\r
91 -          -e "/^(test.expected-output|.*~)/d" | sort)\r
92 +          -e "/^(test.expected-output|.*~)/d" \\r
93 +          -e "/^(gnupg-secret-key.asc)/d" \\r
94 +          -e "/^(gnupg-secret-key.NOTE)/d" \\r
95 +          | sort)\r
96  test_expect_equal "$tests_in_suite" "$available"\r
97  \r
98  EXPECTED=../test.expected-output\r
99 diff --git a/test/crypto b/test/crypto\r
100 new file mode 100755\r
101 index 0000000..3b0f381\r
102 --- /dev/null\r
103 +++ b/test/crypto\r
104 @@ -0,0 +1,330 @@\r
105 +#!/bin/bash\r
106 +\r
107 +# TODO:\r
108 +# - decryption/verification with signer key not available\r
109 +# - verification of signatures from expired/revoked keys\r
110 +\r
111 +test_description='PGP/MIME signature verification and decryption'\r
112 +. ./test-lib.sh\r
113 +\r
114 +add_gnupg_home ()\r
115 +{\r
116 +    local output\r
117 +    [ -d ${GNUPGHOME} ] && return\r
118 +    mkdir -m 0700 "$GNUPGHOME"\r
119 +    gpg --no-tty --import <../gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1\r
120 +    test_debug "cat $GNUPGHOME/import.log"\r
121 +    if (gpg --quick-random --version >/dev/null 2>&1) ; then\r
122 +       echo quick-random >> "$GNUPGHOME"/gpg.conf\r
123 +    elif (gpg --debug-quick-random --version >/dev/null 2>&1) ; then\r
124 +       echo debug-quick-random >> "$GNUPGHOME"/gpg.conf\r
125 +    fi\r
126 +}\r
127 +\r
128 +##################################################\r
129 +\r
130 +add_gnupg_home\r
131 +# get key fingerprint\r
132 +FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10)\r
133 +\r
134 +# for some reason this is needed for emacs_deliver_message to work,\r
135 +# although I can't figure out why\r
136 +add_email_corpus\r
137 +\r
138 +test_expect_success 'emacs delivery of signed message' \\r
139 +'emacs_deliver_message \\r
140 +    "test signed message 001" \\r
141 +    "This is a test signed message." \\r
142 +    "(mml-secure-message-sign)"'\r
143 +\r
144 +test_begin_subtest "signature verification"\r
145 +output=$(notmuch show --format=json --verify subject:"test signed message 001" \\r
146 +    | notmuch_json_show_sanitize \\r
147 +    | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
148 +expected='[[[{"id": "XXXXX",\r
149 + "match": true,\r
150 + "filename": "YYYYY",\r
151 + "timestamp": 946728000,\r
152 + "date_relative": "2000-01-01",\r
153 + "tags": ["inbox"],\r
154 + "headers": {"Subject": "test signed message 001",\r
155 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
156 + "To": "test_suite@notmuchmail.org",\r
157 + "Cc": "",\r
158 + "Bcc": "",\r
159 + "Date": "01 Jan 2000 12:00:00 -0000"},\r
160 + "body": [{"id": 1,\r
161 + "sigstatus": [{"status": "good",\r
162 + "fingerprint": "'$FINGERPRINT'",\r
163 + "created": 946728000}],\r
164 + "content-type": "text/plain",\r
165 + "content": "This is a test signed message.\n"}]},\r
166 + []]]]'\r
167 +test_expect_equal \\r
168 +    "$output" \\r
169 +    "$expected"\r
170 +\r
171 +test_begin_subtest "signature verification with full owner trust"\r
172 +# give the key full owner trust\r
173 +echo "${FINGERPRINT}:6:" | gpg --no-tty --import-ownertrust >>"$GNUPGHOME"/trust.log 2>&1\r
174 +gpg --no-tty --check-trustdb >>"$GNUPGHOME"/trust.log 2>&1\r
175 +output=$(notmuch show --format=json --verify subject:"test signed message 001" \\r
176 +    | notmuch_json_show_sanitize \\r
177 +    | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
178 +expected='[[[{"id": "XXXXX",\r
179 + "match": true,\r
180 + "filename": "YYYYY",\r
181 + "timestamp": 946728000,\r
182 + "date_relative": "2000-01-01",\r
183 + "tags": ["inbox"],\r
184 + "headers": {"Subject": "test signed message 001",\r
185 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
186 + "To": "test_suite@notmuchmail.org",\r
187 + "Cc": "",\r
188 + "Bcc": "",\r
189 + "Date": "01 Jan 2000 12:00:00 -0000"},\r
190 + "body": [{"id": 1,\r
191 + "sigstatus": [{"status": "good",\r
192 + "fingerprint": "'$FINGERPRINT'",\r
193 + "created": 946728000,\r
194 + "userid": " Notmuch Test Suite <test_suite@notmuchmail.org> (INSECURE!)"}],\r
195 + "content-type": "text/plain",\r
196 + "content": "This is a test signed message.\n"}]},\r
197 + []]]]'\r
198 +test_expect_equal \\r
199 +    "$output" \\r
200 +    "$expected"\r
201 +\r
202 +test_begin_subtest "signature verification with signer key unavailable"\r
203 +# move the gnupghome temporarily out of the way\r
204 +mv "${GNUPGHOME}"{,.bak}\r
205 +output=$(notmuch show --format=json --verify subject:"test signed message 001" \\r
206 +    | notmuch_json_show_sanitize \\r
207 +    | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
208 +expected='[[[{"id": "XXXXX",\r
209 + "match": true,\r
210 + "filename": "YYYYY",\r
211 + "timestamp": 946728000,\r
212 + "date_relative": "2000-01-01",\r
213 + "tags": ["inbox"],\r
214 + "headers": {"Subject": "test signed message 001",\r
215 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
216 + "To": "test_suite@notmuchmail.org",\r
217 + "Cc": "",\r
218 + "Bcc": "",\r
219 + "Date": "01 Jan 2000 12:00:00 -0000"},\r
220 + "body": [{"id": 1,\r
221 + "sigstatus": [{"status": "error",\r
222 + "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'",\r
223 + "errors": 2}],\r
224 + "content-type": "text/plain",\r
225 + "content": "This is a test signed message.\n"}]},\r
226 + []]]]'\r
227 +test_expect_equal \\r
228 +    "$output" \\r
229 +    "$expected"\r
230 +mv "${GNUPGHOME}"{.bak,}\r
231 +\r
232 +# create a test encrypted message with attachment\r
233 +cat <<EOF >TESTATTACHMENT\r
234 +This is a test file.\r
235 +EOF\r
236 +test_expect_success 'emacs delivery of encrypted message with attachment' \\r
237 +'emacs_deliver_message \\r
238 +    "test encrypted message 001" \\r
239 +    "This is a test encrypted message.\n" \\r
240 +    "(mml-attach-file \"TESTATTACHMENT\") (mml-secure-message-encrypt)"'\r
241 +\r
242 +test_begin_subtest "decryption, --format=text"\r
243 +output=$(notmuch show --format=text --decrypt subject:"test encrypted message 001" \\r
244 +    | notmuch_show_sanitize_all \\r
245 +    | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
246 +expected='\f\r
247 message{ id:XXXXX depth:0 match:1 filename:XXXXX\r
248 +\f\r
249 header{\r
250 +Notmuch Test Suite <test_suite@notmuchmail.org> (2000-01-01) (inbox)\r
251 +Subject: test encrypted message 001\r
252 +From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
253 +To: test_suite@notmuchmail.org\r
254 +Date: 01 Jan 2000 12:00:00 -0000\r
255 +\f\r
256 header}\r
257 +\f\r
258 body{\r
259 +\f\r
260 part{ ID: 1, Content-type: multipart/mixed\r
261 +\f\r
262 part{ ID: 2, Content-type: text/plain\r
263 +This is a test encrypted message.\r
264 +\f\r
265 part}\r
266 +\f\r
267 attachment{ ID: 3, Content-type: application/octet-stream\r
268 +Attachment: TESTATTACHMENT (application/octet-stream)\r
269 +Non-text part: application/octet-stream\r
270 +\f\r
271 attachment}\r
272 +\f\r
273 part}\r
274 +\f\r
275 body}\r
276 +\f\r
277 message}'\r
278 +test_expect_equal \\r
279 +    "$output" \\r
280 +    "$expected"\r
281 +\r
282 +test_begin_subtest "decryption, --format=json"\r
283 +output=$(notmuch show --format=json --decrypt subject:"test encrypted message 001" \\r
284 +    | notmuch_json_show_sanitize \\r
285 +    | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
286 +expected='[[[{"id": "XXXXX",\r
287 + "match": true,\r
288 + "filename": "YYYYY",\r
289 + "timestamp": 946728000,\r
290 + "date_relative": "2000-01-01",\r
291 + "tags": ["inbox"],\r
292 + "headers": {"Subject": "test encrypted message 001",\r
293 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
294 + "To": "test_suite@notmuchmail.org",\r
295 + "Cc": "",\r
296 + "Bcc": "",\r
297 + "Date": "01 Jan 2000 12:00:00 -0000"},\r
298 + "body": [{"id": 1,\r
299 + "encstatus": [{"status": "good"}],\r
300 + "sigstatus": [],\r
301 + "content-type": "multipart/mixed",\r
302 + "content": [{"id": 2,\r
303 + "content-type": "text/plain",\r
304 + "content": "This is a test encrypted message.\n"},\r
305 + {"id": 3,\r
306 + "content-type": "application/octet-stream",\r
307 + "filename": "TESTATTACHMENT"}]}]},\r
308 + []]]]'\r
309 +test_expect_equal \\r
310 +    "$output" \\r
311 +    "$expected"\r
312 +\r
313 +test_begin_subtest "decryption, --format=json, --part=2"\r
314 +output=$(notmuch show --format=json --part=2 --decrypt subject:"test encrypted message 001" \\r
315 +    | notmuch_json_show_sanitize \\r
316 +    | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
317 +expected='{"id": 2,\r
318 + "content-type": "text/plain",\r
319 + "content": "This is a test encrypted message.\n"}'\r
320 +test_expect_equal \\r
321 +    "$output" \\r
322 +    "$expected"\r
323 +\r
324 +test_begin_subtest "decrypt attachment (--part=3 --format=raw)"\r
325 +notmuch show \\r
326 +    --format=raw \\r
327 +    --part=3 \\r
328 +    --decrypt \\r
329 +    subject:"test encrypted message 001" >OUTPUT\r
330 +test_expect_equal_file OUTPUT TESTATTACHMENT\r
331 +\r
332 +test_begin_subtest "decryption failure with missing key"\r
333 +mv "${GNUPGHOME}"{,.bak}\r
334 +output=$(notmuch show --format=json --decrypt subject:"test encrypted message 001" \\r
335 +    | notmuch_json_show_sanitize \\r
336 +    | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
337 +expected='[[[{"id": "XXXXX",\r
338 + "match": true,\r
339 + "filename": "YYYYY",\r
340 + "timestamp": 946728000,\r
341 + "date_relative": "2000-01-01",\r
342 + "tags": ["inbox"],\r
343 + "headers": {"Subject": "test encrypted message 001",\r
344 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
345 + "To": "test_suite@notmuchmail.org",\r
346 + "Cc": "",\r
347 + "Bcc": "",\r
348 + "Date": "01 Jan 2000 12:00:00 -0000"},\r
349 + "body": [{"id": 1,\r
350 + "encstatus": [{"status": "bad"}],\r
351 + "content-type": "multipart/encrypted",\r
352 + "content": [{"id": 2,\r
353 + "content-type": "application/pgp-encrypted"},\r
354 + {"id": 3,\r
355 + "content-type": "application/octet-stream"}]}]},\r
356 + []]]]'\r
357 +test_expect_equal \\r
358 +    "$output" \\r
359 +    "$expected"\r
360 +mv "${GNUPGHOME}"{.bak,}\r
361 +\r
362 +test_expect_success 'emacs delivery of encrypted + signed message' \\r
363 +'emacs_deliver_message \\r
364 +    "test encrypted message 002" \\r
365 +    "This is another test encrypted message.\n" \\r
366 +    "(mml-secure-message-sign-encrypt)"'\r
367 +\r
368 +test_begin_subtest "decryption + signature verification"\r
369 +output=$(notmuch show --format=json --decrypt subject:"test encrypted message 002" \\r
370 +    | notmuch_json_show_sanitize \\r
371 +    | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
372 +expected='[[[{"id": "XXXXX",\r
373 + "match": true,\r
374 + "filename": "YYYYY",\r
375 + "timestamp": 946728000,\r
376 + "date_relative": "2000-01-01",\r
377 + "tags": ["inbox"],\r
378 + "headers": {"Subject": "test encrypted message 002",\r
379 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
380 + "To": "test_suite@notmuchmail.org",\r
381 + "Cc": "",\r
382 + "Bcc": "",\r
383 + "Date": "01 Jan 2000 12:00:00 -0000"},\r
384 + "body": [{"id": 1,\r
385 + "encstatus": [{"status": "good"}],\r
386 + "sigstatus": [{"status": "good",\r
387 + "fingerprint": "'$FINGERPRINT'",\r
388 + "created": 946728000,\r
389 + "userid": " Notmuch Test Suite <test_suite@notmuchmail.org> (INSECURE!)"}],\r
390 + "content-type": "text/plain",\r
391 + "content": "This is another test encrypted message.\n"}]},\r
392 + []]]]'\r
393 +test_expect_equal \\r
394 +    "$output" \\r
395 +    "$expected"\r
396 +\r
397 +test_begin_subtest "reply to encrypted message"\r
398 +output=$(notmuch reply --decrypt subject:"test encrypted message 002" \\r
399 +    | grep -v -e '^In-Reply-To:' -e '^References:')\r
400 +expected='From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
401 +Subject: Re: test encrypted message 002\r
402 +\r
403 +On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:\r
404 +> This is another test encrypted message.'\r
405 +test_expect_equal \\r
406 +    "$output" \\r
407 +    "$expected"\r
408 +\r
409 +test_begin_subtest "signature verification with revoked key"\r
410 +# generate revokation certificate and load it to revoke key\r
411 +echo "y\r
412 +1\r
413 +Notmuch Test Suite key revocation (automated) $(date '+%F_%T%z')\r
414 +\r
415 +y\r
416 +\r
417 +" \\r
418 +    | gpg --no-tty --quiet --command-fd 0 --armor --gen-revoke "0x${FINGERPRINT}!" 2>/dev/null \\r
419 +    | gpg --no-tty --quiet --import\r
420 +output=$(notmuch show --format=json --verify subject:"test signed message 001" \\r
421 +    | notmuch_json_show_sanitize \\r
422 +    | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
423 +expected='[[[{"id": "XXXXX",\r
424 + "match": true,\r
425 + "filename": "YYYYY",\r
426 + "timestamp": 946728000,\r
427 + "date_relative": "2000-01-01",\r
428 + "tags": ["inbox"],\r
429 + "headers": {"Subject": "test signed message 001",\r
430 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
431 + "To": "test_suite@notmuchmail.org",\r
432 + "Cc": "",\r
433 + "Bcc": "",\r
434 + "Date": "01 Jan 2000 12:00:00 -0000"},\r
435 + "body": [{"id": 1,\r
436 + "sigstatus": [{"status": "error",\r
437 + "keyid": "6D92612D94E46381",\r
438 + "errors": 8}],\r
439 + "content-type": "text/plain",\r
440 + "content": "This is a test signed message.\n"}]},\r
441 + []]]]'\r
442 +test_expect_equal \\r
443 +    "$output" \\r
444 +    "$expected"\r
445 +\r
446 +test_done\r
447 diff --git a/test/gnupg-secret-key.NOTE b/test/gnupg-secret-key.NOTE\r
448 new file mode 100644\r
449 index 0000000..604496c\r
450 --- /dev/null\r
451 +++ b/test/gnupg-secret-key.NOTE\r
452 @@ -0,0 +1,9 @@\r
453 +How the crypto test gnupg secret was generated:\r
454 +\r
455 +GNUPGHOME=gnupghome gpg --quick-random --gen-key\r
456 +kind: 1 (RSA/RSA)\r
457 +size: 1024\r
458 +expire: 0\r
459 +name: Notmuch Test Suite\r
460 +email: test_suite@notmuchmail.org\r
461 +(no passphrase)\r
462 diff --git a/test/gnupg-secret-key.asc b/test/gnupg-secret-key.asc\r
463 new file mode 100644\r
464 index 0000000..6431b56\r
465 --- /dev/null\r
466 +++ b/test/gnupg-secret-key.asc\r
467 @@ -0,0 +1,34 @@\r
468 +-----BEGIN PGP PRIVATE KEY BLOCK-----\r
469 +Version: GnuPG v1.4.10 (GNU/Linux)\r
470 +\r
471 +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\r
499 +SWXT1JrwPoKh9xe++90=\r
500 +=rvTR\r
501 +-----END PGP PRIVATE KEY BLOCK-----\r
502 diff --git a/test/notmuch-test b/test/notmuch-test\r
503 index 0ea4f4f..37db920 100755\r
504 --- a/test/notmuch-test\r
505 +++ b/test/notmuch-test\r
506 @@ -39,6 +39,7 @@ TESTS="\r
507    emacs\r
508    emacs-large-search-buffer\r
509    maildir-sync\r
510 +  crypto\r
511  "\r
512  TESTS=${NOTMUCH_TESTS:=$TESTS}\r
513  \r
514 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
515 index ae25635..428ac7b 100755\r
516 --- a/test/test-lib.sh\r
517 +++ b/test/test-lib.sh\r
518 @@ -379,6 +379,26 @@ add_message ()\r
519      notmuch new > /dev/null\r
520  }\r
521  \r
522 +# Deliver a message with emacs and add it to the database\r
523 +#\r
524 +# Uses emacs to generate and deliver a message to the mail store.\r
525 +# Accepts arbitrary extra emacs/elisp functions to modify the message\r
526 +# before sending, which is useful to doing things like attaching files\r
527 +# to the message and encrypting/signing.\r
528 +emacs_deliver_message ()\r
529 +{\r
530 +    local subject="$1"\r
531 +    local body="$2"\r
532 +    shift 2\r
533 +    # before we can send a message, we have to prepare the FCC maildir\r
534 +    mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp}\r
535 +    ../smtp-dummy sent_message &\r
536 +    smtp_dummy_pid=$!\r
537 +    test_emacs "(setq message-send-mail-function 'message-smtpmail-send-it) (setq smtpmail-smtp-server \"localhost\") (setq smtpmail-smtp-service \"25025\") (notmuch-hello) (notmuch-mua-mail) (message-goto-to) (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\") (message-goto-subject) (insert \"${subject}\") (message-goto-body) (insert \"${body}\") $@ (message-send-and-exit)" >/dev/null 2>&1\r
538 +    wait ${smtp_dummy_pid}\r
539 +    notmuch new >/dev/null\r
540 +}\r
541 +\r
542  # Generate a corpus of email and add it to the database.\r
543  #\r
544  # This corpus is fixed, (it happens to be 50 messages from early in\r
545 @@ -509,6 +529,14 @@ notmuch_show_sanitize_all ()\r
546         -e 's| id:[^ ]* | id:XXXXX |'\r
547  }\r
548  \r
549 +notmuch_json_show_sanitize ()\r
550 +{\r
551 +    sed -e 's|, |,\n |g' | \\r
552 +       sed \\r
553 +       -e 's|"id": "[^"]*",|"id": "XXXXX",|' \\r
554 +       -e 's|"filename": "[^"]*",|"filename": "YYYYY",|'\r
555 +}\r
556 +\r
557  # End of notmuch helper functions\r
558  \r
559  # Use test_set_prereq to tell that a particular prerequisite is available.\r
560 @@ -945,6 +973,7 @@ rm -fr "$test" || {\r
561  }\r
562  \r
563  MAIL_DIR="${TMP_DIRECTORY}/mail"\r
564 +export GNUPGHOME="${TMP_DIRECTORY}/gnupg"\r
565  export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"\r
566  \r
567  mkdir -p "${test}"\r
568 -- \r
569 1.7.4.4\r
570 \r