]> git.cworth.org Git - notmuch/blob - test/T220-reply.sh
NEWS: set date
[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 In-Reply-To: <${gen_msg_id}>
184 References: <${gen_msg_id}>
185
186 On Tue, 05 Jan 2010 15:43:56 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
187 > 200-byte header
188 OK"
189
190 test_begin_subtest "From guessing: Envelope-To"
191 add_message '[from]="Sender <sender@example.com>"' \
192             '[to]="Recipient <recipient@example.com>"' \
193             '[subject]="From guessing"' \
194             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
195             '[body]="From guessing"' \
196             '[header]="Envelope-To: test_suite_other@notmuchmail.org"'
197
198 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
199 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
200 Subject: Re: From guessing
201 To: Sender <sender@example.com>, Recipient <recipient@example.com>
202 In-Reply-To: <${gen_msg_id}>
203 References: <${gen_msg_id}>
204
205 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
206 > From guessing
207 OK"
208
209 test_begin_subtest "From guessing: X-Original-To"
210 add_message '[from]="Sender <sender@example.com>"' \
211             '[to]="Recipient <recipient@example.com>"' \
212             '[subject]="From guessing"' \
213             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
214             '[body]="From guessing"' \
215             '[header]="X-Original-To: test_suite@otherdomain.org"'
216
217 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
218 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@otherdomain.org>
219 Subject: Re: From guessing
220 To: Sender <sender@example.com>, Recipient <recipient@example.com>
221 In-Reply-To: <${gen_msg_id}>
222 References: <${gen_msg_id}>
223
224 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
225 > From guessing
226 OK"
227
228 test_begin_subtest "From guessing: Delivered-To"
229 add_message '[from]="Sender <sender@example.com>"' \
230             '[to]="Recipient <recipient@example.com>"' \
231             '[subject]="From guessing"' \
232             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
233             '[body]="From guessing"' \
234             '[header]="Delivered-To: test_suite_other@notmuchmail.org"'
235
236 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
237 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
238 Subject: Re: From guessing
239 To: Sender <sender@example.com>, Recipient <recipient@example.com>
240 In-Reply-To: <${gen_msg_id}>
241 References: <${gen_msg_id}>
242
243 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
244 > From guessing
245 OK"
246
247 test_begin_subtest "Reply with RFC 2047-encoded headers"
248 add_message '[subject]="=?iso-8859-1?q?=e0=df=e7?="' \
249             '[from]="=?utf-8?q?=e2=98=83?= <snowman@example.com>"' \
250             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
251             '[body]="Encoding"'
252
253 # GMime happens to change from Q- to B-encoding.  We canonicalize the
254 # case of the encoding and charset because different versions of GMime
255 # capitalize the encoding differently.
256 output=$( (notmuch reply id:${gen_msg_id} 2>&1 && echo OK) | perl -pe 's/=\?[^?]+\?[bB]\?/lc($&)/ge')
257 test_expect_equal "$output" "\
258 From: Notmuch Test Suite <test_suite@notmuchmail.org>
259 Subject: Re: =?iso-8859-1?b?4N/n?=
260 To: =?utf-8?b?4piD?= <snowman@example.com>
261 In-Reply-To: <${gen_msg_id}>
262 References: <${gen_msg_id}>
263
264 On Tue, 05 Jan 2010 15:43:56 -0000, ☃ <snowman@example.com> wrote:
265 > Encoding
266 OK"
267
268 test_begin_subtest "Reply with RFC 2047-encoded headers (JSON)"
269 output=$(echo '{"answer":' && notmuch reply --format=json id:${gen_msg_id} 2>&1 && echo ', "success": "OK"}')
270 test_expect_equal_json "$output" '
271 {  "answer": {
272     "original": {
273         "body": [
274             {
275                 "content": "Encoding\n",
276                 "content-type": "text/plain",
277                 "id": 1
278             }
279         ],
280         "date_relative": "2010-01-05",
281         "excluded": false,
282         "filename": ["'${MAIL_DIR}'/msg-014"],
283         "headers": {
284             "Date": "Tue, 05 Jan 2010 15:43:56 +0000",
285             "From": "\u2603 <snowman@example.com>",
286             "Subject": "\u00e0\u00df\u00e7",
287             "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
288         },
289         "id": "'${gen_msg_id}'",
290         "match": false,
291         "tags": [
292             "inbox",
293             "unread"
294         ],
295         "timestamp": 1262706236
296     },
297     "reply-headers": {
298         "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
299         "In-reply-to": "<'${gen_msg_id}'>",
300         "References": "<'${gen_msg_id}'>",
301         "Subject": "Re: \u00e0\u00df\u00e7",
302         "To": "\u2603 <snowman@example.com>"
303     }
304   },
305   "success": "OK"
306 }'
307
308 test_begin_subtest "Reply to a message with multiple Cc headers"
309 add_email_corpus broken
310 output=$(notmuch reply id:multiple-cc@example.org 2>&1 && echo OK)
311 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
312 Subject: Re: wowsers!
313 To: Alice <alice@example.org>, Daniel <daniel@example.org>
314 Cc: Bob <bob@example.org>, Charles <charles@example.org>
315 In-Reply-To: <multiple-cc@example.org>
316 References: <multiple-cc@example.org>
317
318 On Thu, 16 Jun 2016 22:14:41 -0400, Alice <alice@example.org> wrote:
319 > Note the Cc: and cc: headers.
320 OK"
321
322 test_done