]> git.notmuchmail.org Git - notmuch/blob - test/T220-reply.sh
c29a900fa5a4415fa58146376d447e6cea80c2fe
[notmuch] / test / T220-reply.sh
1 #!/usr/bin/env bash
2 test_description="\"notmuch reply\" in several variations"
3 . ./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 "Message with header of exactly 200 bytes"
137 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"' \
138             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
139             '[body]="200-byte header"'
140 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
141 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
142 Subject: Re: This subject is exactly 200 bytes in length. Other than its
143  length there is not much of note here. Note that the length of 200 bytes
144  includes the Subject: and Re: prefixes with two spaces
145 In-Reply-To: <${gen_msg_id}>
146 References: <${gen_msg_id}>
147
148 On Tue, 05 Jan 2010 15:43:56 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
149 > 200-byte header
150 OK"
151
152 test_begin_subtest "From guessing: Envelope-To"
153 add_message '[from]="Sender <sender@example.com>"' \
154             '[to]="Recipient <recipient@example.com>"' \
155             '[subject]="From guessing"' \
156             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
157             '[body]="From guessing"' \
158             '[header]="Envelope-To: test_suite_other@notmuchmail.org"'
159
160 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
161 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
162 Subject: Re: From guessing
163 To: Sender <sender@example.com>, Recipient <recipient@example.com>
164 In-Reply-To: <${gen_msg_id}>
165 References: <${gen_msg_id}>
166
167 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
168 > From guessing
169 OK"
170
171 test_begin_subtest "From guessing: X-Original-To"
172 add_message '[from]="Sender <sender@example.com>"' \
173             '[to]="Recipient <recipient@example.com>"' \
174             '[subject]="From guessing"' \
175             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
176             '[body]="From guessing"' \
177             '[header]="X-Original-To: test_suite@otherdomain.org"'
178
179 output=$(notmuch reply id:${gen_msg_id} 2>&1 && echo OK)
180 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@otherdomain.org>
181 Subject: Re: From guessing
182 To: Sender <sender@example.com>, Recipient <recipient@example.com>
183 In-Reply-To: <${gen_msg_id}>
184 References: <${gen_msg_id}>
185
186 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
187 > From guessing
188 OK"
189
190 test_begin_subtest "From guessing: Delivered-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]="Delivered-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 "Reply with RFC 2047-encoded headers"
210 add_message '[subject]="=?iso-8859-1?q?=e0=df=e7?="' \
211             '[from]="=?utf-8?q?=e2=98=83?= <snowman@example.com>"' \
212             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
213             '[body]="Encoding"'
214
215 # GMime happens to change from Q- to B-encoding.  We canonicalize the
216 # case of the encoding and charset because different versions of GMime
217 # capitalize the encoding differently.
218 output=$( (notmuch reply id:${gen_msg_id} 2>&1 && echo OK) | perl -pe 's/=\?[^?]+\?[bB]\?/lc($&)/ge')
219 test_expect_equal "$output" "\
220 From: Notmuch Test Suite <test_suite@notmuchmail.org>
221 Subject: Re: =?iso-8859-1?b?4N/n?=
222 To: =?utf-8?b?4piD?= <snowman@example.com>
223 In-Reply-To: <${gen_msg_id}>
224 References: <${gen_msg_id}>
225
226 On Tue, 05 Jan 2010 15:43:56 -0000, ☃ <snowman@example.com> wrote:
227 > Encoding
228 OK"
229
230 test_begin_subtest "Reply with RFC 2047-encoded headers (JSON)"
231 output=$(echo '{"answer":' && notmuch reply --format=json id:${gen_msg_id} 2>&1 && echo ', "success": "OK"}')
232 test_expect_equal_json "$output" '
233 {  "answer": {
234     "original": {
235         "body": [
236             {
237                 "content": "Encoding\n",
238                 "content-type": "text/plain",
239                 "id": 1
240             }
241         ],
242         "date_relative": "2010-01-05",
243         "excluded": false,
244         "filename": ["'${MAIL_DIR}'/msg-012"],
245         "headers": {
246             "Date": "Tue, 05 Jan 2010 15:43:56 +0000",
247             "From": "\u2603 <snowman@example.com>",
248             "Subject": "\u00e0\u00df\u00e7",
249             "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
250         },
251         "id": "'${gen_msg_id}'",
252         "match": false,
253         "tags": [
254             "inbox",
255             "unread"
256         ],
257         "timestamp": 1262706236
258     },
259     "reply-headers": {
260         "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
261         "In-reply-to": "<'${gen_msg_id}'>",
262         "References": "<'${gen_msg_id}'>",
263         "Subject": "Re: \u00e0\u00df\u00e7",
264         "To": "\u2603 <snowman@example.com>"
265     }
266   },
267   "success": "OK"
268 }'
269
270 test_begin_subtest "Reply to a message with multiple Cc headers"
271 add_email_corpus broken
272 output=$(notmuch reply id:multiple-cc@example.org 2>&1 && echo OK)
273 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
274 Subject: Re: wowsers!
275 To: Alice <alice@example.org>, Daniel <daniel@example.org>
276 Cc: Bob <bob@example.org>, Charles <charles@example.org>
277 In-Reply-To: <multiple-cc@example.org>
278 References: <multiple-cc@example.org>
279
280 On Thu, 16 Jun 2016 22:14:41 -0400, Alice <alice@example.org> wrote:
281 > Note the Cc: and cc: headers.
282 OK"
283
284 test_done