]> git.notmuchmail.org Git - notmuch/blob - test/T280-from-guessing.sh
Update documentation
[notmuch] / test / T280-from-guessing.sh
1 #!/usr/bin/env bash
2 test_description="From line heuristics (with multiple configured addresses)"
3 . ./test-lib.sh
4
5 test_begin_subtest "Magic from guessing (nothing to go on)"
6 add_message '[from]="Sender <sender@example.com>"' \
7              [to]=mailinglist@notmuchmail.org \
8              [subject]=notmuch-reply-test \
9             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
10             '[body]="from guessing test"'
11
12 output=$(notmuch reply id:${gen_msg_id})
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>, mailinglist@notmuchmail.org
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 > from guessing test"
21
22 test_begin_subtest "Magic from guessing (Envelope-to:)"
23 add_message '[from]="Sender <sender@example.com>"' \
24              [to]=mailinglist@notmuchmail.org \
25              [subject]=notmuch-reply-test \
26             '[header]="Envelope-To: test_suite_other@notmuchmail.org"' \
27             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
28             '[body]="from guessing test"'
29
30 output=$(notmuch reply id:${gen_msg_id})
31 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
32 Subject: Re: notmuch-reply-test
33 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
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 > from guessing test"
39
40 test_begin_subtest "Magic from guessing (X-Original-To:)"
41 add_message '[from]="Sender <sender@example.com>"' \
42              [to]=mailinglist@notmuchmail.org \
43              [subject]=notmuch-reply-test \
44             '[header]="X-Original-To: test_suite_other@notmuchmail.org"' \
45             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
46             '[body]="from guessing test"'
47
48 output=$(notmuch reply id:${gen_msg_id})
49 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
50 Subject: Re: notmuch-reply-test
51 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
52 In-Reply-To: <${gen_msg_id}>
53 References: <${gen_msg_id}>
54
55 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
56 > from guessing test"
57
58 test_begin_subtest "Magic from guessing (Received: .. for ..)"
59 add_message '[from]="Sender <sender@example.com>"' \
60              [to]=mailinglist@notmuchmail.org \
61              [subject]=notmuch-reply-test \
62             "[header]=\"Received: from mail.example.com (mail.example.com [1.1.1.1])
63         by mail.notmuchmail.org (some MTA) with ESMTP id 12345678
64         for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)\"" \
65             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
66             '[body]="from guessing test"'
67
68 output=$(notmuch reply id:${gen_msg_id})
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>, mailinglist@notmuchmail.org
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 > from guessing test"
77
78 test_begin_subtest "Magic from guessing (Received: domain)"
79 add_message '[from]="Sender <sender@example.com>"' \
80              [to]=mailinglist@notmuchmail.org \
81              [subject]=notmuch-reply-test \
82             "[header]=\"Received: from mail.example.com (mail.example.com [1.1.1.1])
83         by mail.otherdomain.org (some MTA) with ESMTP id 12345678
84         Sat, 10 Apr 2010 07:54:51 -0400 (EDT)\"" \
85             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
86             '[body]="from guessing test"'
87
88 output=$(notmuch reply id:${gen_msg_id})
89 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@otherdomain.org>
90 Subject: Re: notmuch-reply-test
91 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
92 In-Reply-To: <${gen_msg_id}>
93 References: <${gen_msg_id}>
94
95 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
96 > from guessing test"
97
98 test_begin_subtest "Magic from guessing (multiple Received: headers)"
99 add_message '[from]="Sender <sender@example.com>"' \
100              [to]=mailinglist@notmuchmail.org \
101              [subject]=notmuch-reply-test \
102             "[header]=\"Received: from extraneous.example.com (extraneous.example.com [1.1.1.1])
103 Received: from mail.example.com (mail.example.com [1.1.1.1])
104         by mail.otherdomain.org (some MTA) with ESMTP id 12345678
105         for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)
106 Received: from extraneous.example.com (extraneous.example.com [1.1.1.1])\"" \
107             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
108             '[body]="from guessing test"'
109
110 output="$(notmuch reply id:${gen_msg_id})"
111 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
112 Subject: Re: notmuch-reply-test
113 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
114 In-Reply-To: <${gen_msg_id}>
115 References: <${gen_msg_id}>
116
117 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
118 > from guessing test"
119
120 test_begin_subtest "Testing From line heuristics (with single configured address)"
121 sed -i -e "s/^other_email.*//" "${NOTMUCH_CONFIG}"
122 test_expect_equal '' ''
123
124 test_begin_subtest "Magic from guessing (nothing to go on)"
125 add_message '[from]="Sender <sender@example.com>"' \
126              [to]=mailinglist@notmuchmail.org \
127              [subject]=notmuch-reply-test \
128             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
129             '[body]="from guessing test"'
130
131 output=$(notmuch reply id:${gen_msg_id})
132 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
133 Subject: Re: notmuch-reply-test
134 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
135 In-Reply-To: <${gen_msg_id}>
136 References: <${gen_msg_id}>
137
138 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
139 > from guessing test"
140
141 test_begin_subtest "Magic from guessing (Envelope-to:)"
142 add_message '[from]="Sender <sender@example.com>"' \
143              [to]=mailinglist@notmuchmail.org \
144              [subject]=notmuch-reply-test \
145             '[header]="Envelope-To: test_suite_other@notmuchmail.org"' \
146             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
147             '[body]="from guessing test"'
148
149 output=$(notmuch reply id:${gen_msg_id})
150 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
151 Subject: Re: notmuch-reply-test
152 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
153 In-Reply-To: <${gen_msg_id}>
154 References: <${gen_msg_id}>
155
156 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
157 > from guessing test"
158
159 test_begin_subtest "Magic from guessing (X-Original-To:)"
160 add_message '[from]="Sender <sender@example.com>"' \
161              [to]=mailinglist@notmuchmail.org \
162              [subject]=notmuch-reply-test \
163             '[header]="X-Original-To: test_suite_other@notmuchmail.org"' \
164             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
165             '[body]="from guessing test"'
166
167 output=$(notmuch reply id:${gen_msg_id})
168 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
169 Subject: Re: notmuch-reply-test
170 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
171 In-Reply-To: <${gen_msg_id}>
172 References: <${gen_msg_id}>
173
174 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
175 > from guessing test"
176
177 test_begin_subtest "Magic from guessing (Received: .. for ..)"
178 add_message '[from]="Sender <sender@example.com>"' \
179              [to]=mailinglist@notmuchmail.org \
180              [subject]=notmuch-reply-test \
181             "[header]=\"Received: from mail.example.com (mail.example.com [1.1.1.1])
182         by mail.notmuchmail.org (some MTA) with ESMTP id 12345678
183         for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)\"" \
184             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
185             '[body]="from guessing test"'
186
187 output=$(notmuch reply id:${gen_msg_id})
188 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
189 Subject: Re: notmuch-reply-test
190 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
191 In-Reply-To: <${gen_msg_id}>
192 References: <${gen_msg_id}>
193
194 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
195 > from guessing test"
196
197 test_begin_subtest "Magic from guessing (Received: domain)"
198 add_message '[from]="Sender <sender@example.com>"' \
199              [to]=mailinglist@notmuchmail.org \
200              [subject]=notmuch-reply-test \
201             "[header]=\"Received: from mail.example.com (mail.example.com [1.1.1.1])
202         by mail.otherdomain.org (some MTA) with ESMTP id 12345678
203         Sat, 10 Apr 2010 07:54:51 -0400 (EDT)\"" \
204             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
205             '[body]="from guessing test"'
206
207 output=$(notmuch reply id:${gen_msg_id})
208 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
209 Subject: Re: notmuch-reply-test
210 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
211 In-Reply-To: <${gen_msg_id}>
212 References: <${gen_msg_id}>
213
214 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
215 > from guessing test"
216
217 test_done