1# This file is part of GNU Mailutils. -*- Autotest -*-
2# Copyright (C) 2011-2021 Free Software Foundation, Inc.
3#
4# GNU Mailutils is free software; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License as
6# published by the Free Software Foundation; either version 3, or (at
7# your option) any later version.
8#
9# GNU Mailutils is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12# General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
16
17m4_pushdef([IMAP4D_HOMEDIR],[spool])
18
19dnl LIST_CHECK([NAME],[KW],[ARG],[OUTPUT],[EXTRA-CODE],[filter,][expand]
20m4_define([LIST_CHECK],[
21AT_SETUP([m4_if([$1],,[list $3],[$1])])
22AT_KEYWORDS([list $2])
23
24IMAP4D_CHECK([
25mkdir IMAP4D_HOMEDIR
26for name in bigto relational search sieve teaparty
27do
28  cp $abs_top_srcdir/testsuite/spool/$name.mbox IMAP4D_HOMEDIR/$name
29done
30$5
31],
32[1 LIST $3
33X LOGOUT
34],
35[$4],
36[],
37[sorted_list_output[]m4_if([$6],,,|[$6])],[$7])
38AT_CLEANUP
39])
40
41dnl ----------------------------------------------------------------------
42LIST_CHECK([],[list01],
43["" ""],
44[* LIST (\NoSelect) "/" ""
45])
46
47LIST_CHECK([],[list02],
48["" "*"],
49[dnl
50* LIST (\NoInferiors) "/" bigto
51* LIST (\NoInferiors) "/" relational
52* LIST (\NoInferiors) "/" search
53* LIST (\NoInferiors) "/" sieve
54* LIST (\NoInferiors) "/" teaparty
55* LIST (\NoInferiors) NIL INBOX
56])
57
58LIST_CHECK([],[list02],
59["" "%"],
60[dnl
61* LIST (\NoInferiors) "/" bigto
62* LIST (\NoInferiors) "/" relational
63* LIST (\NoInferiors) "/" search
64* LIST (\NoInferiors) "/" sieve
65* LIST (\NoInferiors) "/" teaparty
66* LIST (\NoInferiors) NIL INBOX
67])
68
69LIST_CHECK([duplicate INBOX],[list02],
70["" "%"],
71[dnl
72* LIST (\NoInferiors) "/" bigto
73* LIST (\NoInferiors) "/" relational
74* LIST (\NoInferiors) "/" search
75* LIST (\NoInferiors) "/" sieve
76* LIST (\NoInferiors) "/" teaparty
77* LIST (\NoInferiors) NIL INBOX
78],
79[cp $abs_top_srcdir/testsuite/spool/mbox IMAP4D_HOMEDIR/INBOX
80])
81
82LIST_CHECK([],[list07],
83["" INBOX],
84[dnl
85* LIST (\NoInferiors) NIL INBOX
86])
87
88LIST_CHECK([],[list08],
89["" "search"],
90[dnl
91* LIST (\NoInferiors) "/" search
92])
93
94LIST_CHECK([],[],
95["" "#archive:*"],
96[* LIST (\NoInferiors) "." #archive:mbox
97* LIST (\NoInferiors) "." #archive:old.mbox1
98* LIST (\NoInferiors) "." #archive:old.very.saved
99* LIST (\NoSelect) "." #archive:old
100* LIST (\NoSelect) "." #archive:old.very
101],
102[mkdir archive archive/old archive/old/very
103cp $abs_top_srcdir/testsuite/spool/mbox archive
104cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old
105cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old/very/saved
106])
107
108LIST_CHECK([],[],
109["#archive:" "*"],
110[* LIST (\NoInferiors) "." #archive:mbox
111* LIST (\NoInferiors) "." #archive:old.mbox1
112* LIST (\NoInferiors) "." #archive:old.very.saved
113* LIST (\NoSelect) "." #archive:old
114* LIST (\NoSelect) "." #archive:old.very
115],
116[mkdir archive archive/old archive/old/very
117cp $abs_top_srcdir/testsuite/spool/mbox archive
118cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old
119cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old/very/saved
120])
121
122LIST_CHECK([],[],
123["" "#archive:%"],
124[* LIST (\NoInferiors) "." #archive:mbox
125* LIST (\NoSelect) "." #archive:old
126],
127[mkdir archive archive/old archive/old/very
128cp $abs_top_srcdir/testsuite/spool/mbox archive
129cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old
130cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old/very/saved
131])
132
133LIST_CHECK([],[],
134["#archive:" "%"],
135[* LIST (\NoInferiors) "." #archive:mbox
136* LIST (\NoSelect) "." #archive:old
137],
138[mkdir archive archive/old archive/old/very
139cp $abs_top_srcdir/testsuite/spool/mbox archive
140cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old
141cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old/very/saved
142])
143
144LIST_CHECK([],[],
145["#archive:" "a.b"],
146[* LIST (\NoSelect) "." #archive:a.b
147],
148[mkdir archive archive/a archive/a/b
149])
150
151LIST_CHECK([],[],
152["#archive:" "a.b.c"],
153[* LIST (\NoInferiors) "." #archive:a.b.c
154],
155[mkdir archive archive/a archive/a/b
156cp $abs_top_srcdir/testsuite/spool/mbox archive/a/b/c
157])
158
159LIST_CHECK([],[],
160["" "archive.*"],
161[* LIST (\NoInferiors) "." archive.mbox
162* LIST (\NoInferiors) "." archive.old.mbox1
163* LIST (\NoInferiors) "." archive.old.very.saved
164* LIST (\NoSelect) "." archive.old
165* LIST (\NoSelect) "." archive.old.very
166],
167[mkdir archive archive/old archive/old/very
168cp $abs_top_srcdir/testsuite/spool/mbox archive
169cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old
170cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old/very/saved
171])
172
173LIST_CHECK([],[],
174["archive." "*"],
175[* LIST (\NoInferiors) "." archive.mbox
176* LIST (\NoInferiors) "." archive.old.mbox1
177* LIST (\NoInferiors) "." archive.old.very.saved
178* LIST (\NoSelect) "." archive.old
179* LIST (\NoSelect) "." archive.old.very
180],
181[mkdir archive archive/old archive/old/very
182cp $abs_top_srcdir/testsuite/spool/mbox archive
183cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old
184# NOTE: Mailbox name with a directory delimiter will be ignored
185cp $abs_top_srcdir/testsuite/spool/mbox archive/mbox.1
186cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old/very/saved
187])
188
189LIST_CHECK([],[],
190["archive" "*"],
191[],
192[mkdir archive archive/old archive/old/very
193cp $abs_top_srcdir/testsuite/spool/mbox archive
194cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old
195cp $abs_top_srcdir/testsuite/spool/mbox1 archive/old/very/saved
196])
197
198LIST_CHECK([],[],
199["~/" "*"],
200[1 NO LIST The requested item could not be found
201])
202
203LIST_CHECK([],[],
204["~foo/" "%"],
205[* LIST (\NoInferiors) "/" ~foo/mbox
206* LIST (\NoSelect) "/" ~foo/dir
207],
208[mkdir home home/foo home/foo/dir home/bar
209cp $abs_top_srcdir/testsuite/spool/mbox home/foo
210cp $abs_top_srcdir/testsuite/spool/mbox1 home/foo/dir/saved
211cp $abs_top_srcdir/testsuite/spool/mbox1 home/bar
212])
213
214LIST_CHECK([],[],
215["~foo/" "*"],
216[* LIST (\NoInferiors) "/" ~foo/dir/saved
217* LIST (\NoInferiors) "/" ~foo/mbox
218* LIST (\NoSelect) "/" ~foo/dir
219],
220[mkdir home home/foo home/foo/dir home/bar
221cp $abs_top_srcdir/testsuite/spool/mbox home/foo
222cp $abs_top_srcdir/testsuite/spool/mbox1 home/foo/dir/saved
223cp $abs_top_srcdir/testsuite/spool/mbox1 home/bar
224])
225
226LIST_CHECK([],[],
227["" "~foo/*"],
228[* LIST (\NoInferiors) "/" ~foo/dir/saved
229* LIST (\NoInferiors) "/" ~foo/mbox
230* LIST (\NoSelect) "/" ~foo/dir
231],
232[mkdir home home/foo home/foo/dir home/bar
233cp $abs_top_srcdir/testsuite/spool/mbox home/foo
234cp $abs_top_srcdir/testsuite/spool/mbox1 home/foo/dir/saved
235cp $abs_top_srcdir/testsuite/spool/mbox1 home/bar
236])
237
238LIST_CHECK([],[],
239["~foo/" "%/*"],
240[* LIST (\NoInferiors) "/" ~foo/dir/saved
241],
242[mkdir home home/foo home/foo/dir home/bar
243cp $abs_top_srcdir/testsuite/spool/mbox home/foo
244cp $abs_top_srcdir/testsuite/spool/mbox1 home/foo/dir/saved
245cp $abs_top_srcdir/testsuite/spool/mbox1 home/bar
246])
247
248# ###
249
250LIST_CHECK([],[],
251["other/" "*"],
252[1 NO LIST The requested item could not be found
253])
254
255LIST_CHECK([],[],
256["other/foo" "%"],
257[* LIST (\NoInferiors) "/" other/foo/mbox
258* LIST (\NoSelect) "/" other/foo/dir
259],
260[mkdir home home/foo home/foo/dir home/bar
261cp $abs_top_srcdir/testsuite/spool/mbox home/foo
262cp $abs_top_srcdir/testsuite/spool/mbox1 home/foo/dir/saved
263cp $abs_top_srcdir/testsuite/spool/mbox1 home/bar
264])
265
266LIST_CHECK([],[],
267["other/foo" "*"],
268[* LIST (\NoInferiors) "/" other/foo/dir/saved
269* LIST (\NoInferiors) "/" other/foo/mbox
270* LIST (\NoSelect) "/" other/foo/dir
271],
272[mkdir home home/foo home/foo/dir home/bar
273cp $abs_top_srcdir/testsuite/spool/mbox home/foo
274cp $abs_top_srcdir/testsuite/spool/mbox1 home/foo/dir/saved
275cp $abs_top_srcdir/testsuite/spool/mbox1 home/bar
276])
277
278LIST_CHECK([],[],
279["" "other/foo/*"],
280[* LIST (\NoInferiors) "/" other/foo/dir/saved
281* LIST (\NoInferiors) "/" other/foo/mbox
282* LIST (\NoSelect) "/" other/foo/dir
283],
284[mkdir home home/foo home/foo/dir home/bar
285cp $abs_top_srcdir/testsuite/spool/mbox home/foo
286cp $abs_top_srcdir/testsuite/spool/mbox1 home/foo/dir/saved
287cp $abs_top_srcdir/testsuite/spool/mbox1 home/bar
288])
289
290LIST_CHECK([],[],
291["other/foo/" "%/*"],
292[* LIST (\NoInferiors) "/" other/foo/dir/saved
293],
294[mkdir home home/foo home/foo/dir home/bar
295cp $abs_top_srcdir/testsuite/spool/mbox home/foo
296cp $abs_top_srcdir/testsuite/spool/mbox1 home/foo/dir/saved
297cp $abs_top_srcdir/testsuite/spool/mbox1 home/bar
298])
299
300# FIXME: I'm not sure whether it should include / in the reply.
301LIST_CHECK([root ref + asterisk],[list03],
302["/" "*"],
303[dnl
304* LIST (\NoInferiors) "/" /bigto
305* LIST (\NoInferiors) "/" /relational
306* LIST (\NoInferiors) "/" /search
307* LIST (\NoInferiors) "/" /sieve
308* LIST (\NoInferiors) "/" /teaparty
309])
310
311LIST_CHECK([absolute reference + asterisk],[list04],
312["/foo/bar/baz/" "*"],
313[],
314[mkdir IMAP4D_HOMEDIR/folder
315 MUT_MBCOPY($abs_top_srcdir/testsuite/folder/one,IMAP4D_HOMEDIR/folder)
316 MUT_MBCOPY($abs_top_srcdir/testsuite/folder/two,IMAP4D_HOMEDIR/folder)])
317
318LIST_CHECK([absolute reference + percent],[list05],
319["/foo/bar/baz/" "%"],
320[],
321[mkdir IMAP4D_HOMEDIR/folder
322 MUT_MBCOPY($abs_top_srcdir/testsuite/folder/one,IMAP4D_HOMEDIR/folder)
323 MUT_MBCOPY($abs_top_srcdir/testsuite/folder/two,IMAP4D_HOMEDIR/folder)])
324
325LIST_CHECK([absolute reference + mailbox],[list06],
326["/foo/bar/baz/" "mbox"],
327[],
328[mkdir IMAP4D_HOMEDIR/folder
329 MUT_MBCOPY($abs_top_srcdir/testsuite/folder/one,IMAP4D_HOMEDIR/folder)
330 MUT_MBCOPY($abs_top_srcdir/testsuite/folder/two,IMAP4D_HOMEDIR/folder)])
331
332dnl ----------------------------------------------------------------------
333
334m4_popdef([IMAP4D_HOMEDIR])
335
336
337
338