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 In-Reply-To: <${gen_msg_id}>
184 References: <${gen_msg_id}>
186 On Tue, 05 Jan 2010 15:43:56 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
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"'
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}>
205 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
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"'
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}>
224 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
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"'
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}>
243 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
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"' \
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}>
264 On Tue, 05 Jan 2010 15:43:56 -0000, ☃ <snowman@example.com> wrote:
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" '
275 "content": "Encoding\n",
276 "content-type": "text/plain",
280 "date_relative": "2010-01-05",
282 "filename": ["'${MAIL_DIR}'/msg-014"],
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>"
289 "id": "'${gen_msg_id}'",
295 "timestamp": 1262706236
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>"
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>
318 On Thu, 16 Jun 2016 22:14:41 -0400, Alice <alice@example.org> wrote:
319 > Note the Cc: and cc: headers.