summaryrefslogtreecommitdiffstats
path: root/imap/testsuite
blob: 2762ddd78dc28d7a334b638dcecbd84266ed0779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
#!/bin/sh

# Maintainer's sanity check

OPTIONS=""
export OPTIONS
TZ=EST5EDT
export TZ

echo '****************************' >&2
echo '* Sanity check in progress *' >&2
echo '****************************' >&2
#test ! -d confmdtest || find confmdtest -exec chmod u+rwx {} \;
#test ! -d confmdtest2 || find confmdtest2 -exec chmod u+rwx {} \;
test ! -d confmdtest || chmod -R u+rwx confmdtest
test ! -d confmdtest2 || chmod -R u+rwx confmdtest2
rm -rf confmdtest
../maildir/maildirmake confmdtest || exit 1

if test "$IMAPINVOKE" = ""
then
    IMAPINVOKE="./imapd"
fi

cat >confmdtest/cur/msg1:2,S <<EOF || exit 1
From: John <john@example.com>
To: Steve <steve@example.com>, Tom <tom@example.com>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="b1"
Subject: This is the message

foobar
--b1
Content-Type: text/plain

This is section 1

--b1
Content-Type: text/plain

This is section 2

--b1
Content-Type: message/rfc822

Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="b2"
Subject: This is message part 3

foobar
--b2
Content-Type: text/plain

This is section 3.1

--b2
Content-Type: text/plain

This is section 3.2

--b2--
--b1
Content-Type: multipart/mixed; boundary="b3"

foobar
--b3
Content-Type: text/plain

This is section 4.1

--b3
Content-Type: message/rfc822

Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="b4"
Subject: This is message part 4.2

foobar
--b4
Content-Type: text/plain

This is section 4.2.1

--b4
Content-Type: multipart/alternative; boundary="b5"

foobar
--b5
Content-Type: text/plain

This is section 4.2.2.1

--b5
Content-Type: text/plain

This is section 4.2.2.2

--b5--

--b4--

--b3--

--b1--
EOF

inituid() {

initdir="$1"

if test "$initdir" = ""
then
    initdir="confmdtest"
fi

initinbox="$2"
if test "$initinbox" = ""
then
    initinbox="inbox"
else
    initinbox="inbox.$initinbox"
fi

env IMAP_BROKENUIDV=1 MAILDIR=$initdir $IMAPINVOKE >confmdtest.stdout <<EOF
a001 select $initinbox
a logout
EOF

}

inituid

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
a001 select inbox
a002 fetch 1 (bodystructure)
a003 fetch 1 (body[])
a004 fetch 1 (body[]<500.100>)
a005 fetch 1 (body[1])
a006 fetch 1 (body[1.text])
a007 fetch 1 (body[2])
a008 fetch 1 (body[2.text])
a009 fetch 1 (body[3.header])
a010 fetch 1 (body[3.mime])
a011 fetch 1 (body[3.mime]<10,50>)
a012 fetch 1 (body[3.1])
a013 fetch 1 (body[3.2])
a014 fetch 1 (body[4.1])
a015 fetch 1 (body[4.2.header])
a016 fetch 1 (body[4.2.1])
a017 fetch 1 (body[4.2.2.1])
a018 fetch 1 (body[4.2.2.2])
a019 fetch 1 (envelope)
a020 fetch 1 (body)
a021 fetch 1 (envelope body)
a022 fetch 1 (bodystructure)
a023 fetch 1 (rfc822.size)
a024 fetch 1 (all)
a025 fetch 1 (fast)
a026 fetch 1 (full)
a027 fetch 1 (rfc822.text)
a028 fetch 1 (body[header.fields(content-type)])
adone logout
EOF

rm -f confmdtest/cur/msg1:2,S

cat >confmdtest/new/msg2 <<EOF || exit 1
From: John <john@example.com>
To: Steve <steve@example.com>,
    Tom <tom@example.com>
Mime-Version: 1.0
Date: Wed, 22 Sep 1999 15:41:09 -0200
Content-Type: multipart/mixed; boundary="b1"
Subject: This is the message

foobar
--b1
Content-Type: text/plain

This is section 1

--b1
Content-Type: message/rfc822

Subject: This is message part 4.2
From: dave@example.org
To: tom@example.org
Cc: steve@example.org
Mime-Version: 1.0
content-type: text/plain
content-transfer-encoding: quoted-printable


M=41ry had a little lamb, it's fleece was white as snow.  And everywhere
Mary went, the lamb was sure to go.

--b1--
EOF

inituid

cat >confmdtest/new/msg3 <<EOF || exit 1
From: todd@example.org
To: kevin@example.org
Subject: today's meeting

Today's meeting has been cancelled
EOF
cat >confmdtest/new/msg4 <<EOF || exit 1
Subject: New MIME headers test
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="c1"
Content-Language: en


--c1
Content-Type: text/plain
Content-ID: <foo@bar>
Content-Description:  MIME test message
Content-MD5: aaaabbbb

test

--c1--
EOF
touch -t 199901010000 confmdtest/new/msg3

inituid

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
b000 status inbox ( MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)
b001 select inbox
b001a status inbox ( MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)
b002 fetch 1:2 (flags uid)
b003 search header "content-type" "multipart"
b004 search 2 header "content-type" "multipart"
b005 search to tom@example
b006 search subject "message part 4.2"
b007 search before "1-Feb-1999"
b008 search on "1-Jan-1999"
b009 search senton "22-Sep-1999"
b010 search recent
b011 fetch 1 (rfc822.header)
b012 fetch 1:2 (flags)
b013 search seen
b014 search body "mary had a little lamb"
b015 uid search body "mary had a little lamb"
b016 store 1:2 +flags(\flagged)
b017 store 1 flags(\seen \deleted)
b018 expunge
b019 fetch 1 (flags uid)
b020 create inbox.bozo
b021 uid copy 3 inbox.bozo
b022 select inbox.bozo
b023 status inbox.bozo (uidnext)
b024 fetch 1 (flags)
b025 append inbox.bozo \Seen {11}
test

test

b026 append inbox.bozo (\Seen \Flagged) {11}
test

test

b027 noop
b028 fetch 1 flags
b029 fetch 1 flags
b030 select inbox
b031 fetch 2 (bodystructure)
adone logout
EOF

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
foo select inbox.bozo
foo store 1 +flags \Deleted
foo expunge
foo logout
EOF
rm -rf confmdtest
mkdir confmdtest || exit 1
mkdir confmdtest/tmp || exit 1
mkdir confmdtest/cur || exit 1
mkdir confmdtest/new || exit 1
echo "10000S,2C" >confmdtest/maildirsize
env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
c001 select inbox
c002 append inbox {5}
test

c003 append inbox {5}
test

c004 append inbox {5}
test

c005 noop
c006 store 1 +flags \Deleted
c007 append inbox {5}
test

c008 noop
c009 append inbox {5}
test

c010 store 1 -flags \Deleted
cdone logout
EOF
cat confmdtest/maildirsize
rm -rf confmdtest
mkdir confmdtest || exit 1
mkdir confmdtest/tmp || exit 1
mkdir confmdtest/cur || exit 1
mkdir confmdtest/new || exit 1
echo "10000S,5C" >confmdtest/maildirsize
env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
d001 select inbox
d002 append inbox {5}
test

d003 noop
d004 copy 1 inbox
d005 noop
ddone logout
EOF
cat confmdtest/maildirsize
env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
e001 select inbox
e002 copy 1:2 inbox
e003 noop
edone logout
EOF
cat confmdtest/maildirsize
../maildir/maildirmake -f Trash confmdtest || exit 1

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
f001 select inbox
f002 copy 1:2 inbox
f002 copy 1:2 inbox.Trash
f003 noop
f004 select inbox.Trash
f005 copy 1:2 inbox
f006 copy 1:2 inbox.Trash
f007 noop
f008 copy 1 inbox
f009 select inbox
fdone logout
EOF
cat confmdtest/maildirsize
echo "Counts:" `ls confmdtest/cur | wc -l` `ls confmdtest/.Trash/cur | wc -l`
env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
g001 select inbox
g002 select Trash
g003 select INBOX.Trash
g004 delete INBOX.Trash
g005 close
g006 delete INBOX.Trash
g007 create INBOX.a
g008 delete INBOX.a/
g009 delete INBOX.a
g010 create inbox.a/
gdone logout
EOF

rm -rf confmdtest2
../maildir/maildirmake confmdtest2
../maildir/maildirmake -f a confmdtest2
../maildir/maildirmake -f b confmdtest2
chmod u-rwx confmdtest2/.b/tmp
chmod u-rwx confmdtest2/.b/new
chmod u-rwx confmdtest2/.b/cur

echo "test `pwd`/confmdtest2" >confmdtest/shared-maildirs

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
h001 list "" "*"
h002 list "" "%"
h003 list "" "%.%"
h004 list "" "%.%.%"
h005 list "shared" "*"
h006 list "shared.test" "*"
h007 list "INBOX" ""
h008 list "shared" ""
h009 list "shared.test" ""
h010 subscribe inbox
h011 list "" "*"
h012 lsub "" "*"
h013 subscribe shared.test.a
h014 list "" "*"
h015 lsub "" "*"
h016 subscribe shared.test.b
h017 list "" "*"
h018 lsub "" "*"
h019 unsubscribe shared.test.a
h020 list "" "*"
h021 lsub "" "*"
h022 subscribe shared.test.a
h023 list "" "*"
h024 lsub "" "*"
hdone logout
EOF

cat >confmdtest2/.a/new/msg1 <<EOF
Subject: message 1

message 1
EOF

inituid confmdtest2 a

cat >confmdtest2/.a/new/msg2 <<EOF
Subject: message 2

message 2
EOF

inituid confmdtest2 a

cat >confmdtest/new/msg1 <<EOF
Subject: message 1
EOF

cat >confmdtest/.Trash/new/msg2 <<EOF
Subject: message 2
EOF

../maildir/maildirmake -f c confmdtest
../maildir/maildirmake -f Trash confmdtest2

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
ii001 list "" "*"
ii002 list "" "*"
iidone logout
EOF

env IMAP_BROKENUIDV=1 IMAP_CHECK_ALL_FOLDERS=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
ii003 list "" "*"
ii004 list "" "*"
iidone logout
EOF

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
i001 select shared.test.b
i002 select shared.test.a
i003 close
i004 select shared.test.a
i005 append shared.test.a {5}
test

i006 noop
i007 fetch 1:* (flags)
i008 select inbox
i009 copy 1:2 shared.test.a
i010 select shared.test.a
i011 fetch 1:* (flags)
i012 append shared.test.b {5}
i013 copy 1 shared.test.b
i014 store 1:2 +flags (\Deleted)
i015 expunge
idone logout
EOF
chmod -R u+rwx confmdtest
chmod -R u+rwx confmdtest2

rm -f confmdtest/new/*
rm -f confmdtest/cur/*

cat >confmdtest/new/msg1 <<EOF
From: John <john1@example.com>
To: John <cca4@example.com>, <ccb1@example.com>
Cc: John <toa1@example.com>, <tob4@example.com>
Subject: Re[2]: [foo] message 1
Date: Wed, 22 Sep 1999 15:41:09 -0200

message 1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
EOF

inituid

cat >confmdtest/new/msg2 <<EOF
From: John <john2@example.com>
To: John <cca3@example.com>, <ccb2@example.com>
Cc: John <toa2@example.com>, <tob3@example.com>
Subject: message 2
Date: Wed, 22 Sep 1999 15:41:00 -0200

message 2
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
EOF

inituid

cat >confmdtest/new/msg3 <<EOF
From: John <john3@example.com>
To: John <cca2@example.com>, <ccb3@example.com>
Cc: John <toa3@example.com>, <tob2@example.com>
Subject: message 1
Date: Wed, 22 Sep 1999 15:41:00 -0200

message 3
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
EOF

inituid

cat >confmdtest/new/msg4 <<EOF
From: John <john4@example.com>
To: John <cca1@example.com>, <ccb4@example.com>
Cc: John <toa4@example.com>, <tob1@example.com>
Subject: [fwd:message 1] (fwd)
Date: Wed, 15 Sep 1999 15:41:00 -0200

message 3
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
EOF

inituid

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
T001 select INBOX
T002 fetch 1:* (uid body[header.fields(date)])
T003 THREAD ORDEREDSUBJECT US-ASCII ALL
T004 THREAD ORDEREDSUBJECT US-ASCII SENTSINCE 19-SEP-1999
S001 SORT (SUBJECT DATE) US-ASCII ALL
S002 SORT (SUBJECT REVERSE DATE) US-ASCII ALL
S003 SORT (REVERSE SUBJECT DATE) US-ASCII ALL
S004 SORT (FROM) US-ASCII ALL
S005 SORT (REVERSE FROM) US-ASCII ALL
S006 SORT (FROM) US-ASCII SENTSINCE 19-SEP-1999
S007 SORT (REVERSE FROM) US-ASCII SENTSINCE 19-SEP-1999
S008 SORT (TO) US-ASCII ALL
S009 SORT (CC) US-ASCII ALL
S010 SORT (REVERSE SIZE) US-ASCII ALL
TDONE logout
EOF

rm -rf confmdtest
../maildir/maildirmake confmdtest || exit 1
../maildir/maildirmake -f Trash confmdtest || exit 1
env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
J001 list "" "*"
J002 lsub "" "*"
J003 SUBSCRIBE INBOX
J004 SUBSCRIBE INBOX.Trash
J005 list "" "*"
J006 lsub "" "*"
J007 UNSUBSCRIBE INBOX
J008 LIST "" "*"
J009 LSUB "" "*"
JDONE logout
EOF

rm -rf confmdtest
../maildir/maildirmake confmdtest || exit 1

cat >confmdtest/new/msg1 <<EOF
From: postmaster
Subject: thread 1
Message-ID: <mid1>
Date: Sat, 05 Feb 2000 13:34:02 -0800

message 1
EOF

inituid

cat >confmdtest/new/msg2 <<EOF
From: postmaster
Subject: thread 1.1
Date: Sat, 05 Feb 2000 13:34:02 -0800
Message-ID: <mid2>
References: <mid1>

message 2
EOF

inituid

cat >confmdtest/new/msg3 <<EOF
From: postmaster
Date: Sat, 05 Feb 2000 13:34:02 -0800
Subject: thread 1.2
In-Reply-To: <mid2>

message 3
EOF

inituid

cat >confmdtest/new/msg4 <<EOF
From: postmaster
Date: Sat, 05 Feb 2000 13:34:02 -0800
Subject: thread 1.2
References: <mid1>

message 4
EOF

inituid

cat >confmdtest/new/msg5 <<EOF
From: postmaster
Date: Sat, 05 Feb 2000 13:34:02 -0800
Subject: thread 1.2
Message-ID: <mid11>
References: <mid10>

message 5
EOF

inituid

cat >confmdtest/new/msg6 <<EOF
From: postmaster
Date: Sat, 05 Feb 2000 13:34:01 -0800
Subject: thread 1.2
Message-ID: <mid12>
References: <mid10>

message 6
EOF

inituid

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
K001 select INBOX
K002 THREAD REFERENCES US-ASCII ALL
KDONE logout
EOF

rm -rf confmdtest
../maildir/maildirmake confmdtest || exit 1
../maildir/maildirmake -f Trash confmdtest || exit 1

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
L001 CREATE INBOX.a
L002 CREATE INBOX.a.a
L003 CREATE INBOX.aa
L004 RENAME INBOX.a INBOX.b
L005 LIST "" "*"
L006 RENAME INBOX.b INBOX.a
L007 LIST "" "*"
L008 RENAME INBOX.a. INBOX.b.
L009 LIST "" "*"
L010 RENAME INBOX.b. INBOX.a.
L011 LIST "" "*"
L012 CREATE INBOX.b.a
L013 DELETE INBOX.a
L014 CREATE INBOX.a.a
L015 LIST "" "*"
L016 RENAME INBOX.a INBOX.b
L017 RENAME INBOX.a. INBOX.b.
L018 SELECT INBOX
L019 APPEND INBOX \Seen {5}
test

L020 NOOP
L021 COPY 1 INBOX
L022 COPY 1 INBOX
L023 COPY 1 INBOX
L024 COPY 1 INBOX
L025 COPY 1 INBOX
L026 COPY 1 INBOX
L027 NOOP
L028 STORE 2:3,5:7 +FLAGS \Deleted
L029 FETCH 1:* (UID FLAGS)
L030 UID EXPUNGE 2,3:5
L031 FETCH 1:* (UID FLAGS)
LDONE logout
EOF

rm -rf confmdtest

../maildir/maildirmake confmdtest || exit 1
../maildir/maildirmake -q 10C confmdtest || exit 1

env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
M001 CREATE INBOX.a
M002 APPEND INBOX \Seen {5}
test

M003 SELECT INBOX
M004 COPY 1 INBOX
M005 COPY 1 INBOX
M006 NOOP
M007 COPY 1:3 INBOX.a
M008 RENAME INBOX.a INBOX.b
MDONE logout
EOF
cat confmdtest/maildirsize
env IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
M009 DELETE INBOX.b
MDONE logout
EOF
cat confmdtest/maildirsize

rm -rf confmdtest

../maildir/maildirmake confmdtest || exit 1
env IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
N001 LIST "" "*"
N002 append inbox \Deleted {11}
test

test

N003 LIST "" "*"
N004 SELECT inbox
N005 EXPUNGE
N006 LIST "" "*"
NDONE logout
EOF

rm -rf confmdtest
../maildir/maildirmake confmdtest || exit 1
../maildir/maildirmake -q10C confmdtest
env IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
O001 append inbox NIL {11}
test

test

o002 SELECT inbox
o003 COPY 1 inbox
o004 NOOP
o005 STORE 1 +FLAGS \Deleted
o006 COPY 1:2 inbox
o007 NOOP
o008 logout
EOF
cat confmdtest/maildirsize
rm -f confmdtest/maildirsize

env IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
p001 SELECT INBOX
p002 CREATE INBOX.a
p003 COPY 1 INBOX.a
p004 SELECT INBOX.a
p005 STORE 1 +FLAGS(-Label1 \Deleted)
p006 append INBOX.a (-Label2) {11}
test

test

p007 EXPUNGE
p008 FETCH 1:* FLAGS
p009 COPY 1 INBOX.a
p010 NOOP
P011 FETCH 1:* FLAGS
P012 STORE 1 -FLAGS (-Label2)
P013 STORE 1 +FLAGS (\SEEN)
P013 FETCH 1:* FLAGS
P014 SEARCH SEEN
P015 SEARCH KEYWORD -LABEL2
P016 SEARCH UNKEYWORD -Label2
P017 SEARCH KEYWORD -Label1
P018 COPY 1:* INBOX.a
P019 COPY 1:* INBOX.a
P020 NOOP
P021 COPY 1:* INBOX.a
P022 COPY 1:* INBOX.a
P023 NOOP
P025 STORE 4 +FLAGS -Label1
P024 FETCH 1:* FLAGS
P025 SEARCH KEYWORD -Label2
P026 SEARCH KEYWORD -Label2 KEYWORD -Label1
pDONE LOGOUT
EOF

env IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
Q001 select INBOX
Q002 fetch 1:* FLAGS
Q003 status INBOX.Trash MESSAGES
Q004 expunge
Q005 status INBOX.Trash MESSAGES
Q006 COPY 1 INBOX.a
Q007 STORE 1:* +FLAGS \Deleted
Q008 NOOP
Q009 EXPUNGE
Q005 status INBOX.Trash MESSAGES
qDONE LOGOUT
EOF

rm -rf confmdtest
../maildir/maildirmake confmdtest || exit 1

env IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
R001 CREATE INBOX.a
R002 LIST (ACL MYRIGHTS POSTADDRESS) "" "*"
R003 ACL STORE INBOX owner -t
R004 ACL STORE (INBOX *) owner +d
R005 ACL STORE INBOX.a user=systemuser1 alr
R006 ACL STORE INBOX.a user=systemuser1 +w
R007 ACL STORE INBOX.a user=systemuser1 -w
R008 ACL STORE INBOX.a user=systemuser1 -alr
R009 ACL STORE INBOX.a user=systemuser1 alr
R010 ACL STORE INBOX.a user=systemuser1 ""
R011 ACL STORE INBOX.a user=systemuser1 alr
R012 ACL SET (INBOX *) "owner" "acdilrsw" administrators "acdilrsw" user=systemuser2 alr
R013 ACL DELETE INBOX.a user=systemuser1
R014 ACL DELETE INBOX.a user=systemuser2
R015 ACL STORE INBOX.a owner -a
R016 ACL STORE INBOX.a -owner +wt
R017 ACL STORE INBOX.a -owner -w
R018 ACL DELETE INBOX.a -owner
R019 ACL STORE INBOX.a -owner +a
R020 ACL STORE INBOX.a owner -ci
R021 CREATE INBOX.a.b
R022 ACL STORE INBOX.a owner +c
R023 CREATE INBOX.a.b
R024 LIST (ACL) "" INBOX.a.b
R025 CREATE INBOX.c.d
R026 LIST (ACL) "" "INBOX.c*"
R027 ACL STORE (INBOX.c*) -owner x
R028 DELETE INBOX.c.d
R029 ACL DELETE INBOX.c.d -owner
R030 DELETE INBOX.c.d
R031 DELETE INBOX.c.
R032 LIST (ACL) "" "*"
R033 DELETE INBOX.a
R034 LIST (ACL) "" "*"
R035 RENAME INBOX.a INBOX.f
R036 LIST (ACL) "" "*"
R037 CREATE INBOX.f
R038 LIST (ACL) "" "*"
R039 ACL STORE INBOX owner -i
R040 SELECT INBOX
R041 APPEND INBOX (\Seen \Deleted \Answered Foo) {0}
R042 ACL STORE INBOX owner +i
R043 APPEND INBOX (\Seen \Deleted \Answered Foo) {11}
test

test

R043 NOOP
R044 FETCH 1 (FLAGS)
R045 ACL STORE INBOX owner -tw
R046 APPEND INBOX (\Seen \Deleted \Answered Foo) {11}
test

test

R047 NOOP
R048 FETCH 2 (FLAGS)
R049 ACL STORE INBOX owner +tw
R050 ACL STORE INBOX owner -s
R051 APPEND INBOX (\Seen \Deleted \Answered Foo) {11}
test

test

R052 NOOP
R053 FETCH 3 (FLAGS)
R054 STORE 2:3 +FLAGS (\Deleted)
R055 STORE 1 -FLAGS (\Deleted)
R056 EXPUNGE
R057 STORE 1 +FLAGS (\Deleted)
R058 ACL STORE INBOX owner +s
R059 CREATE INBOX.x
R060 COPY 1 INBOX.x
R061 SELECT INBOX.x
R062 FETCH 1 (FLAGS)
R063 SELECT INBOX
R064 ACL STORE INBOX.x owner -s
R065 COPY 1 INBOX.x
R066 SELECT INBOX.x
R067 FETCH 2 (FLAGS)
R068 SELECT INBOX
R069 ACL STORE INBOX.x owner +s
R070 ACL STORE INBOX.x owner -w
R071 COPY 1 INBOX.x
R072 SELECT INBOX.x
R073 FETCH 3 (FLAGS)
R074 SELECT INBOX
R075 ACL STORE INBOX.x owner +w
R076 ACL STORE INBOX.x owner -t
R077 COPY 1 INBOX.x
R078 SELECT INBOX.x
R079 FETCH 4 (FLAGS)
R080 SELECT INBOX
RDONE LOGOUT
EOF

rm -rf confmdtest
../maildir/maildirmake confmdtest || exit 1
../maildir/maildirmake -f a confmdtest || exit 1
cat >confmdtest/.a/cur/msg1:2,S <<EOF || exit 1
From: John <john@example.com>
To: john <john@example.com>
Subject: test

test
EOF
env IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
S001 SELECT INBOX.a
S002 COPY 1 INBOX.a
S003 NOOP
S004 COPY 1:2 INBOX.a
S005 NOOP
S006 ACL STORE INBOX.a owner -e
S007 STORE 1 +FLAGS(\Deleted)
S008 EXPUNGE
S009 CLOSE
S010 SELECT INBOX.a
S011 ACL STORE INBOX.a owner +e
S012 EXPUNGE
S013 STORE 1 +FLAGS(\Deleted)
S014 CLOSE
S015 SELECT INBOX.a
S016 CLOSE
S017 ACL STORE INBOX.a owner -r
S018 SELECT INBOX.a
S019 EXAMINE INBOX.a
S020 STATUS INBOX.a (UIDVALIDITY)
S021 ACL STORE INBOX.a owner +r
S022 SELECT INBOX.a
S023 APPEND INBOX.a NIL {11}
test

test

S024 NOOP
S025 STORE 1:* FLAGS ()
S027 ACL STORE INBOX.a owner -s
S028 FETCH 1 (BODY[])
S029 ACL STORE INBOX.a owner +s
S030 FETCH 1 (BODY[])
S031 ACL STORE INBOX.a owner -s
S032 STORE 1:2 FLAGS(\Seen \Deleted Foo)
S033 STORE 1:2 -FLAGS(\Seen \Deleted Foo)
S034 STORE 2 +FLAGS(\Seen \Deleted \Answered Foo)
S035 FETCH 1:2 (FLAGS)
S036 ACL STORE INBOX.a owner +s
S037 ACL STORE INBOX.a owner -w
S038 STORE 1:2 FLAGS(\Seen \Deleted Bar)
S039 STORE 1:2 -FLAGS(\Seen \Deleted Bar)
S040 STORE 1:2 +FLAGS(\Seen \Deleted Bar)
S041 ACL STORE INBOX.a owner +w
S042 STORE 2 -FLAGS (\Deleted)
S043 ACL STORE INBOX.a owner -t
S044 STORE 1:2 FLAGS (\Deleted \Seen Bar)
S045 STORE 1:2 -FLAGS (\Deleted \Seen Bar)
S046 STORE 1:2 +FLAGS (\Deleted \Seen Bar)
S047 CLOSE
S048 ACL STORE INBOX user=courierimaptestuser1 alr
S049 ACL STORE INBOX user=courierimaptestuser2 lr
S050 LIST (ACL) "" INBOX
SDONE LOGOUT
EOF

rm -rf confmdtest*
../maildir/maildirmake confmdtest || exit 1
../maildir/maildirmake confmdtest2 || exit 1
../maildir/maildirmake confmdtest3 || exit 1
mkdir confmdtest4 || exit 1
cat >confmdtest4/index <<EOF || exit 1
user0	1	1	`pwd`	confmdtest
a	*	indexa
b	*	indexb
EOF
echo "user1	1	1	`pwd`	confmdtest2" >confmdtest4/indexa || exit 1
echo "aashared	1	1	`pwd`	confmdtest5" >>confmdtest4/indexa || exit 1
echo "user2	1	1	`pwd`	confmdtest3" >confmdtest4/indexb || exit 1

IMAP_SHAREDINDEXFILE=`pwd`/confmdtest4/index
export IMAP_SHAREDINDEXFILE

env AUTHENTICATED=user1 IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest2 $IMAPINVOKE <<EOF
T001 ACL STORE INBOX user=user0 +l
T002 CREATE INBOX.a
T003 ACL STORE INBOX.a anyone +lr
T004 append INBOX.a \Seen {22}
Subject: user1

user1

T005 LOGOUT
EOF

env AUTHENTICATED=user2 IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest3 $IMAPINVOKE <<EOF
T010 ACL STORE INBOX anyone +l
T011 CREATE INBOX.a
T012 append INBOX.a \Seen {22}
Subject: user2

user2

T013 LOGOUT
EOF

env AUTHENTICATED=user0 IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest $IMAPINVOKE <<EOF
T020 list(acl) "" "#shared.*"
T021 ACL STORE INBOX anyone acdilrsw
T022 list(acl) "" "#shared.%"
T023 LOGOUT
EOF

env AUTHENTICATED=user2 IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest3 $IMAPINVOKE <<EOF
T030 LIST "" "#shared.*"
T031 LIST "" "#shared.%"
T032 LIST "" "#shared.a.%"
T033 LIST "" "#shared.c.%"
T034 SELECT "#shared.a.user1"
T035 SELECT "#shared.a.user1.a"
T036 FETCH 1:* (ENVELOPE)
T037 STATUS #shared.a.user1 (UIDVALIDITY)
T038 COPY 1 #shared.user0
T039 SELECT #shared.user0
T040 CREATE #shared.a.user1.b
T041 CREATE #shared.c
T042 CREATE #shared.user0.foo
T043 RENAME #shared.user0.foo #shared.user0.bar
T044 LIST(ACL) "" "#shared.user0*"
T045 ACL STORE #shared.a.user1.a anyone lr
T046 CREATE #shared.user0.foo
T047 ACL STORE #shared.user0.foo anyone alr
T048 ACL STORE #shared.user0.bar anyone -x
T049 RENAME #shared.user0.bar #shared.user0.foo.bar
T050 ACL STORE #shared.user0.bar anyone +x
T051 RENAME #shared.user0.bar #shared.user0.foo.bar
T052 ACL STORE #shared.user0.foo anyone +c
T053 RENAME #shared.user0.bar #shared.user0.foo.bar
T054 LIST "" "#shared.user0*"
TDONE LOGOUT
EOF

cat >confmdtest4/indexb <<EOF
use&2	1	1	`pwd`	confmdtest3
user.2	1	1	`pwd`	confmdtest3
usér/3	1	1	`pwd`	confmdtest3
EOF

env AUTHENTICATED=user1 IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest2 $IMAPINVOKE <<EOF
a ENABLE UTF8=ACCEPT
T055 LIST "" "#shared.b.*"
T056 LIST "" "#shared.b.%"
T057 LIST "" "#shared.b.user 2.*"
T058 LIST "" "#shared.b.use&-2.*"
TDONE LOGOUT
EOF

env IMAP_SHAREDMUNGENAMES=1 AUTHENTICATED=user1 IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest2 $IMAPINVOKE <<EOF
a ENABLE UTF8=ACCEPT
T055 LIST "" "#shared.b.*"
T056 LIST "" "#shared.b.%"
T057 LIST "" "#shared.b.user\\\\:2.*"
T058 LIST "" "#shared.b.use&-2.*"
T059 CREATE INBOX.a.b
T060 SELECT INBOX.a.b
T061 RENAME INBOX.a INBOX.aa
T062 CLOSE
T063 RENAME INBOX.a INBOX.aa
T064 RENAME INBOX INBOX.c
T065 RENAME INBOX.aa #shared.user0.aa
T066 LIST "" #shared.*
T067 LIST "" #shared.%
T068 LIST "" #shared.%
T069 LIST "" #shared.%.%
T070 LIST "" #shared.%.%.%
T071 LIST "" #shared.%.%.%.%
TDONE LOGOUT
EOF

echo "usergroup1	1	1	`pwd`	confmdtest" >confmdtest4/indexgroup1 || exit 1

env IMAP_SHAREDMUNGENAMES=1 AUTHENTICATED=user1 OPTIONS=sharedgroup=group1 IMAP_KEYWORDS=1 IMAP_MOVE_EXPUNGE_TO_TRASH=1 IMAP_BROKENUIDV=1 MAILDIR=confmdtest2 $IMAPINVOKE <<EOF
T072 LIST "" #shared.*
T073 LIST(ACL) "" INBOX
T074 ACL STORE INBOX user=fred lr
T075 ACL STORE INBOX -user=john lr
T076 ACL STORE INBOX -authuser lr
T077 GETACL INBOX
T078 SETACL INBOX -authuser lcr
T079 SETACL INBOX -john lcr
T080 SETACL INBOX fred cr
T081 GETACL INBOX
T082 LIST(ACL) "" INBOX
T083 DELETEACL INBOX -john
T084 DELETEACL INBOX fred
T085 GETACL INBOX
T086 LIST(ACL) "" INBOX
TDONE LOGOUT
EOF

rm -rf confmdtest confmdtest2
../maildir/maildirmake confmdtest
../maildir/maildirmake -f Trash confmdtest
../maildir/maildirmake -f folder:with:colonTD confmdtest
../maildir/maildirmake -S confmdtest2
../maildir/maildirmake -s write -f writable confmdtest2
../maildir/maildirmake --add another=`pwd`/confmdtest2 confmdtest

echo '#! /bin/sh' >confsendmail
echo "cat >`pwd`/confsendmail.out" >>confsendmail
chmod +x confsendmail

echo >confmdtest/.Trash/cur/msg:2
touch -t 202001011200 confmdtest/.Trash/cur/msg:2

echo >confmdtest/.folder:with:colonTD/cur/001:2,T
echo >confmdtest/.folder:with:colonTD/cur/002TD:2,T
echo >confmdtest/.folder:with:colonTD/cur/003:2,ATDB

env IMAP_BROKENUIDV=1 IMAP_TRASHFOLDERNAME=Trash IMAP_EMPTYTRASH=Trash:7 \
    MAILDIR=confmdtest AUTHENTICATED=user1 OUTBOX=.Outbox \
    IMAP_MOVE_EXPUNGE_TO_TRASH=1 \
    SENDMAIL=`pwd`/confsendmail $IMAPINVOKE <<EOF
U001 APPEND INBOX \Seen {5}
test

U002 LIST "" "*"
U003 SELECT INBOX
U004 COPY 1 "shared.another.writable"
U005 STATUS invalid (UIDVALIDITY)
U006 DELETE INBOX
U007 LISTRIGHTS INBOX user=user1
U008 LISTRIGHTS shared.another.writable user=user1
U009 MYRIGHTS INBOX
U010 COPY 1 public.nonexistent
U011 COPY 1 INBOX.nonexistent
U012 CREATE INBOX.Outbox
U013 APPEND INBOX \Seen {5}
test

U014 NOOP
U015 COPY 1,2 INBOX.Outbox
U016 COPY 1 INBOX.Outbox
U017 SELECT INBOX.folder:with:colonTD
U019 EXPUNGE
EOF
echo "===Sent=="
cat confsendmail.out
echo "===Trash="
ls confmdtest/.Trash/cur
echo "==="
rm -f confsendmail confsendmail.out

../maildir/maildirmake -q 2C ./confmdtest
env IMAP_BROKENUIDV=1 IMAP_TRASHFOLDERNAME=Trash IMAP_EMPTYTRASH=Trash:7 \
    MAILDIR=confmdtest AUTHENTICATED=user1 OUTBOX=.Outbox \
    IMAP_KEYWORDS=2\
    IMAP_MOVE_EXPUNGE_TO_TRASH=1 \
    SENDMAIL=`pwd`/confsendmail $IMAPINVOKE <<EOF
U021 SELECT INBOX
U022 STORE 1 +FLAGS(Label1)
U023 COPY 1 INBOX
EOF