2 test_description="\"notmuch reply\" in several variations"
3 . $(dirname "$0")/test-lib.sh || exit 1
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"'
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}>
19 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
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"'
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}>
37 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
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"'
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}>
57 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
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"'
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}>
75 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
76 > reply from alternate address
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"'
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}>
94 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
95 > Reply from address in named group list
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>"'
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}>
113 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
114 > support for reply-to
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>"'
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}>
132 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
133 > Un-munging Reply-To
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>"'
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}>
151 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
152 > Un-munging Reply-To
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"'
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}>
170 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
171 > Un-munging Reply-To
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}>
187 On Tue, 05 Jan 2010 15:43:56 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
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"'
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}>
206 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
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"'
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}>
225 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
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"'
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}>
244 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
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"' \
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}>
265 On Tue, 05 Jan 2010 15:43:56 -0000, ☃ <snowman@example.com> wrote:
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" '
276 "content": "Encoding\n",
277 "content-type": "text/plain",
282 "date_relative": "2010-01-05",
284 "filename": ["'${MAIL_DIR}'/msg-014"],
286 "Date": "Tue, 05 Jan 2010 15:43:56 +0000",
287 "From": "\u2603 <snowman@example.com>",
288 "Subject": "\u00e0\u00df\u00e7",
289 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
291 "id": "'${gen_msg_id}'",
297 "timestamp": 1262706236
300 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
301 "In-reply-to": "<'${gen_msg_id}'>",
302 "References": "<'${gen_msg_id}'>",
303 "Subject": "Re: \u00e0\u00df\u00e7",
304 "To": "\u2603 <snowman@example.com>"
310 test_begin_subtest "Reply to a message with multiple Cc headers"
311 add_email_corpus broken
312 output=$(notmuch reply id:multiple-cc@example.org 2>&1 && echo OK)
313 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
314 Subject: Re: wowsers!
315 To: Alice <alice@example.org>, Daniel <daniel@example.org>
316 Cc: Bob <bob@example.org>, Charles <charles@example.org>
317 In-Reply-To: <multiple-cc@example.org>
318 References: <multiple-cc@example.org>
320 On Thu, 16 Jun 2016 22:14:41 -0400, Alice <alice@example.org> wrote:
321 > Note the Cc: and cc: headers.