Debian Codegraph @

cassandane/Cassandane/Cyrus/Bug3470.pm

raw
1 #!/usr/bin/perl
2 #
3 # Copyright (c) 2011-2017 FastMail Pty Ltd. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 #
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 #
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in
14 # the documentation and/or other materials provided with the
15 # distribution.
16 #
17 # 3. The name "Fastmail Pty Ltd" must not be used to
18 # endorse or promote products derived from this software without
19 # prior written permission. For permission or any legal
20 # details, please contact
21 # FastMail Pty Ltd
22 # PO Box 234
23 # Collins St West 8007
24 # Victoria
25 # Australia
26 #
27 # 4. Redistributions of any form whatsoever must retain the following
28 # acknowledgment:
29 # "This product includes software developed by Fastmail Pty. Ltd."
30 #
31 # FASTMAIL PTY LTD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
32 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
33 # EVENT SHALL OPERA SOFTWARE AUSTRALIA BE LIABLE FOR ANY SPECIAL, INDIRECT
34 # OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
35 # USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
36 # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
37 # OF THIS SOFTWARE.
38 #
39
40 package Cassandane::Cyrus::Bug3470;
41 use strict;
42 use warnings;
43 use DateTime;
44 use Data::Dumper;
45
46 use lib '.';
47 use base qw(Cassandane::Cyrus::TestCase);
48
49 sub new
50 {
51 my $class = shift;
52
53 my $config = Cassandane::Config->default()->clone();
54 $config->set(virtdomains => 'userid');
55 $config->set(unixhierarchysep => 'on');
56 $config->set(altnamespace => 'yes');
57
58 return $class->SUPER::new({ config => $config }, @_);
59 }
60
61 sub set_up
62 {
63 my ($self) = @_;
64 $self->SUPER::set_up();
65
66 my $imaptalk = $self->{store}->get_client();
67
68 # Bug #3470 folders
69 # sub folders only
70 $imaptalk->create("Drafts") || die;
71 $imaptalk->create("2001/05/wk18") || die;
72 $imaptalk->create("2001/05/wk19") || die;
73 $imaptalk->create("2001/05/wk20") || die;
74 $imaptalk->subscribe("2001/05/wk20") || die;
75 }
76
77 sub tear_down
78 {
79 my ($self) = @_;
80 $self->SUPER::tear_down();
81 }
82
83 #
84 # Test LSUB behaviour
85 #
86 sub test_list_percent
87 {
88 my ($self) = @_;
89
90 my $imaptalk = $self->{store}->get_client();
91
92 my @inbox_flags = qw( \\HasNoChildren );
93 my @inter_flags = qw( \\HasChildren );
94 my ($maj, $min) = Cassandane::Instance->get_version();
95 if ($maj < 3) {
96 unshift @inbox_flags, qw( \\Noinferiors );
97 unshift @inter_flags, qw( \\Noselect );
98 }
99 elsif ($maj == 3 && $min < 5) {
100 unshift @inter_flags, qw( \\Noselect );
101 }
102
103 my $alldata = $imaptalk->list("", "%");
104 $self->assert_deep_equals($alldata, [
105 [
106 \@inbox_flags,
107 '/',
108 'INBOX'
109 ],
110 [
111 \@inter_flags,
112 '/',
113 '2001'
114 ],
115 [
116 [
117 '\\HasNoChildren'
118 ],
119 '/',
120 'Drafts'
121 ]
122 ], "LIST data mismatch: " . Dumper($alldata, \@inbox_flags));
123 }
124
125 #
126 # Test LSUB behaviour
127 #
128 sub test_list_2011
129 {
130 my ($self) = @_;
131
132 my $imaptalk = $self->{store}->get_client();
133
134 my @inter_flags = qw( \\HasChildren );
135 my ($maj, $min) = Cassandane::Instance->get_version();
136 if ($maj < 3 || ($maj == 3 && $min < 5)) {
137 unshift @inter_flags, qw( \\Noselect );
138 }
139
140 my $alldata = $imaptalk->list("", "2001");
141 $self->assert_deep_equals($alldata, [
142 [
143 \@inter_flags,
144 '/',
145 '2001'
146 ]
147 ], "LIST data mismatch: " . Dumper($alldata));
148 }
149
150 sub test_lsub
151 {
152 my ($self) = @_;
153
154 my $imaptalk = $self->{store}->get_client();
155
156 my $alldata = $imaptalk->lsub("", "2001");
157 $self->assert_deep_equals($alldata, [
158 [
159 [
160 '\\Noselect',
161 '\\HasChildren'
162 ],
163 '/',
164 '2001'
165 ]
166 ], "LSUB data mismatch: " . Dumper($alldata));
167 }
168
169 1;