]> git.notmuchmail.org Git - notmuch/blob - test/T220-reply.sh
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / test / T220-reply.sh
1 #!/usr/bin/env bash
2 test_description="\"notmuch reply\" in several variations"
3 . $(dirname "$0")/test-lib.sh || exit 1
4
5 test_begin_subtest "Basic reply"
6 add_message '[from]="Sender <sender@example.com>"' \
7              [to]=test_suite@notmuchmail.org \
8              [subject]=notmuch-reply-test \
9             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
10             '[body]="basic reply test"'
11
12 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
13 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
14 Subject: Re: notmuch-reply-test
15 To: Sender <sender@example.com>
16 In-Reply-To: <${gen_msg_id}>
17 References: <${gen_msg_id}>
18
19 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
20 > basic reply test
21 OK"
22
23 test_begin_subtest "Multiple recipients"
24 add_message '[from]="Sender <sender@example.com>"' \
25             '[to]="test_suite@notmuchmail.org, Someone Else <someone@example.com>"' \
26              [subject]=notmuch-reply-test \
27             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
28             '[body]="Multiple recipients"'
29
30 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
31 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
32 Subject: Re: notmuch-reply-test
33 To: Sender <sender@example.com>, Someone Else <someone@example.com>
34 In-Reply-To: <${gen_msg_id}>
35 References: <${gen_msg_id}>
36
37 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
38 > Multiple recipients
39 OK"
40
41 test_begin_subtest "Reply with CC"
42 add_message '[from]="Sender <sender@example.com>"' \
43              [to]=test_suite@notmuchmail.org \
44             '[cc]="Other Parties <cc@example.com>"' \
45              [subject]=notmuch-reply-test \
46             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
47             '[body]="reply with CC"'
48
49 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
50 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
51 Subject: Re: notmuch-reply-test
52 To: Sender <sender@example.com>
53 Cc: Other Parties <cc@example.com>
54 In-Reply-To: <${gen_msg_id}>
55 References: <${gen_msg_id}>
56
57 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
58 > reply with CC
59 OK"
60
61 test_begin_subtest "Reply from alternate address"
62 add_message '[from]="Sender <sender@example.com>"' \
63              [to]=test_suite_other@notmuchmail.org \
64              [subject]=notmuch-reply-test \
65             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
66             '[body]="reply from alternate address"'
67
68 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
69 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
70 Subject: Re: notmuch-reply-test
71 To: Sender <sender@example.com>
72 In-Reply-To: <${gen_msg_id}>
73 References: <${gen_msg_id}>
74
75 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
76 > reply from alternate address
77 OK"
78
79 test_begin_subtest "Reply from address in named group list"
80 add_message '[from]="Sender <sender@example.com>"' \
81             '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \
82              [cc]=test_suite_other@notmuchmail.org \
83              [subject]=notmuch-reply-test \
84             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
85             '[body]="Reply from address in named group list"'
86
87 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
88 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
89 Subject: Re: notmuch-reply-test
90 To: Sender <sender@example.com>, someone@example.com
91 In-Reply-To: <${gen_msg_id}>
92 References: <${gen_msg_id}>
93
94 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
95 > Reply from address in named group list
96 OK"
97
98 test_begin_subtest "Support for Reply-To"
99 add_message '[from]="Sender <sender@example.com>"' \
100              [to]=test_suite@notmuchmail.org \
101              [subject]=notmuch-reply-test \
102             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
103             '[body]="support for reply-to"' \
104             '[reply-to]="Sender <elsewhere@example.com>"'
105
106 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
107 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
108 Subject: Re: notmuch-reply-test
109 To: Sender <elsewhere@example.com>
110 In-Reply-To: <${gen_msg_id}>
111 References: <${gen_msg_id}>
112
113 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
114 > support for reply-to
115 OK"
116
117 test_begin_subtest "Un-munging Reply-To"
118 add_message '[from]="Sender <sender@example.com>"' \
119             '[to]="Some List <list@example.com>"' \
120              [subject]=notmuch-reply-test \
121             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
122             '[body]="Un-munging Reply-To"' \
123             '[reply-to]="Evil Munging List <list@example.com>"'
124
125 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
126 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
127 Subject: Re: notmuch-reply-test
128 To: Sender <sender@example.com>, Some List <list@example.com>
129 In-Reply-To: <${gen_msg_id}>
130 References: <${gen_msg_id}>
131
132 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
133 > Un-munging Reply-To
134 OK"
135
136 test_begin_subtest "Un-munging Reply-To With Exact Match"
137 add_message '[from]="Sender <sender@example.com>"' \
138             '[to]="Some List <list@example.com>"' \
139              [subject]=notmuch-reply-test \
140             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
141             '[body]="Un-munging Reply-To"' \
142             '[reply-to]="Some List <list@example.com>"'
143
144 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
145 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
146 Subject: Re: notmuch-reply-test
147 To: Sender <sender@example.com>, Some List <list@example.com>
148 In-Reply-To: <${gen_msg_id}>
149 References: <${gen_msg_id}>
150
151 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
152 > Un-munging Reply-To
153 OK"
154
155 test_begin_subtest "Un-munging Reply-To With Raw addr-spec"
156 add_message '[from]="Sender <sender@example.com>"' \
157             '[to]="Some List <list@example.com>"' \
158              [subject]=notmuch-reply-test \
159             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
160             '[body]="Un-munging Reply-To"' \
161             '[reply-to]="list@example.com"'
162
163 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
164 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
165 Subject: Re: notmuch-reply-test
166 To: Sender <sender@example.com>, Some List <list@example.com>
167 In-Reply-To: <${gen_msg_id}>
168 References: <${gen_msg_id}>
169
170 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
171 > Un-munging Reply-To
172 OK"
173
174 test_begin_subtest "Message with header of exactly 200 bytes"
175 add_message '[subject]="This subject is exactly 200 bytes in length. Other than its length there is not much of note here. Note that the length of 200 bytes includes the Subject: and Re: prefixes with two spaces"' \
176             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
177             '[body]="200-byte header"'
178 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
179 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
180 Subject: Re: This subject is exactly 200 bytes in length. Other than its
181  length there is not much of note here. Note that the length of 200 bytes
182  includes the Subject: and Re: prefixes with two spaces
183 To: test_suite@notmuchmail.org
184 In-Reply-To: <${gen_msg_id}>
185 References: <${gen_msg_id}>
186
187 On Tue, 05 Jan 2010 15:43:56 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
188 > 200-byte header
189 OK"
190
191 test_begin_subtest "From guessing: Envelope-To"
192 add_message '[from]="Sender <sender@example.com>"' \
193             '[to]="Recipient <recipient@example.com>"' \
194             '[subject]="From guessing"' \
195             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
196             '[body]="From guessing"' \
197             '[header]="Envelope-To: test_suite_other@notmuchmail.org"'
198
199 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
200 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
201 Subject: Re: From guessing
202 To: Sender <sender@example.com>, Recipient <recipient@example.com>
203 In-Reply-To: <${gen_msg_id}>
204 References: <${gen_msg_id}>
205
206 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
207 > From guessing
208 OK"
209
210 test_begin_subtest "From guessing: X-Original-To"
211 add_message '[from]="Sender <sender@example.com>"' \
212             '[to]="Recipient <recipient@example.com>"' \
213             '[subject]="From guessing"' \
214             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
215             '[body]="From guessing"' \
216             '[header]="X-Original-To: test_suite@otherdomain.org"'
217
218 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
219 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@otherdomain.org>
220 Subject: Re: From guessing
221 To: Sender <sender@example.com>, Recipient <recipient@example.com>
222 In-Reply-To: <${gen_msg_id}>
223 References: <${gen_msg_id}>
224
225 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
226 > From guessing
227 OK"
228
229 test_begin_subtest "From guessing: Delivered-To"
230 add_message '[from]="Sender <sender@example.com>"' \
231             '[to]="Recipient <recipient@example.com>"' \
232             '[subject]="From guessing"' \
233             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
234             '[body]="From guessing"' \
235             '[header]="Delivered-To: test_suite_other@notmuchmail.org"'
236
237 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
238 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
239 Subject: Re: From guessing
240 To: Sender <sender@example.com>, Recipient <recipient@example.com>
241 In-Reply-To: <${gen_msg_id}>
242 References: <${gen_msg_id}>
243
244 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
245 > From guessing
246 OK"
247
248 test_begin_subtest "Reply with RFC 2047-encoded headers"
249 add_message '[subject]="=?iso-8859-1?q?=e0=df=e7?="' \
250             '[from]="=?utf-8?q?=e2=98=83?= <snowman@example.com>"' \
251             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
252             '[body]="Encoding"'
253
254 # GMime happens to change from Q- to B-encoding.  We canonicalize the
255 # case of the encoding and charset because different versions of GMime
256 # capitalize the encoding differently.
257 output=$( (notmuch reply id:${gen_msg_id} 2>&1 && echo OK) | perl -pe 's/=\?[^?]+\?[bB]\?/lc($&)/ge')
258 test_expect_equal "$output" "\
259 From: Notmuch Test Suite <test_suite@notmuchmail.org>
260 Subject: Re: =?iso-8859-1?b?4N/n?=
261 To: =?utf-8?b?4piD?= <snowman@example.com>
262 In-Reply-To: <${gen_msg_id}>
263 References: <${gen_msg_id}>
264
265 On Tue, 05 Jan 2010 15:43:56 -0000, ☃ <snowman@example.com> wrote:
266 > Encoding
267 OK"
268
269 test_begin_subtest "Reply with RFC 2047-encoded headers (JSON)"
270 output=$(echo '{"answer":' && notmuch reply --format=json id:${gen_msg_id} 2>&1 && echo ', "success": "OK"}')
271 test_expect_equal_json "$output" '
272 {  "answer": {
273     "original": {
274         "body": [
275             {
276                 "content": "Encoding\n",
277                 "content-type": "text/plain",
278                 "id": 1
279             }
280         ],
281         "date_relative": "2010-01-05",
282         "excluded": false,
283         "filename": ["'${MAIL_DIR}'/msg-014"],
284         "headers": {
285             "Date": "Tue, 05 Jan 2010 15:43:56 +0000",
286             "From": "\u2603 <snowman@example.com>",
287             "Subject": "\u00e0\u00df\u00e7",
288             "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
289         },
290         "id": "'${gen_msg_id}'",
291         "match": false,
292         "tags": [
293             "inbox",
294             "unread"
295         ],
296         "timestamp": 1262706236
297     },
298     "reply-headers": {
299         "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
300         "In-reply-to": "<'${gen_msg_id}'>",
301         "References": "<'${gen_msg_id}'>",
302         "Subject": "Re: \u00e0\u00df\u00e7",
303         "To": "\u2603 <snowman@example.com>"
304     }
305   },
306   "success": "OK"
307 }'
308
309 test_begin_subtest "Reply to a message with multiple Cc headers"
310 add_email_corpus broken
311 output=$(notmuch reply id:multiple-cc@example.org 2>&1 && echo OK)
312 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
313 Subject: Re: wowsers!
314 To: Alice <alice@example.org>, Daniel <daniel@example.org>
315 Cc: Bob <bob@example.org>, Charles <charles@example.org>
316 In-Reply-To: <multiple-cc@example.org>
317 References: <multiple-cc@example.org>
318
319 On Thu, 16 Jun 2016 22:14:41 -0400, Alice <alice@example.org> wrote:
320 > Note the Cc: and cc: headers.
321 OK"
322
323 test_done