| 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::MurderIMAP; |
| 41 |
use strict; |
| 42 |
use warnings; |
| 43 |
use Data::Dumper; |
| 44 |
|
| 45 |
use lib '.'; |
| 46 |
use base qw(Cassandane::Cyrus::TestCase); |
| 47 |
use Cassandane::Util::Log; |
| 48 |
use Cassandane::Util::Words; |
| 49 |
use Cassandane::Instance; |
| 50 |
|
| 51 |
$Data::Dumper::Sortkeys = 1; |
| 52 |
|
| 53 |
sub new |
| 54 |
{ |
| 55 |
my $class = shift; |
| 56 |
|
| 57 |
my $config = Cassandane::Config->default()->clone(); |
| 58 |
|
| 59 |
$config->set(conversations => 'yes'); |
| 60 |
|
| 61 |
my $self = $class->SUPER::new({ |
| 62 |
imapmurder => 1, adminstore => 1, deliver => 1, |
| 63 |
}, @_); |
| 64 |
|
| 65 |
$self->needs('component', 'murder'); |
| 66 |
return $self; |
| 67 |
} |
| 68 |
|
| 69 |
sub set_up |
| 70 |
{ |
| 71 |
my ($self) = @_; |
| 72 |
$self->SUPER::set_up(); |
| 73 |
} |
| 74 |
|
| 75 |
sub tear_down |
| 76 |
{ |
| 77 |
my ($self) = @_; |
| 78 |
$self->SUPER::tear_down(); |
| 79 |
} |
| 80 |
|
| 81 |
sub test_aaasetup |
| 82 |
{ |
| 83 |
my ($self) = @_; |
| 84 |
|
| 85 |
# does everything set up and tear down cleanly? |
| 86 |
$self->assert(1); |
| 87 |
} |
| 88 |
|
| 89 |
sub test_frontend_commands |
| 90 |
{ |
| 91 |
my ($self) = @_; |
| 92 |
my $result; |
| 93 |
|
| 94 |
my $frontend = $self->{frontend_store}->get_client(); |
| 95 |
|
| 96 |
# should be able to list |
| 97 |
$result = $frontend->list("", "*"); |
| 98 |
$self->assert_not_null($result); |
| 99 |
|
| 100 |
# select a folder that doesn't exist yet |
| 101 |
$result = $frontend->select('INBOX.newfolder'); |
| 102 |
$self->assert_null($result); |
| 103 |
$self->assert_matches(qr/Mailbox does not exist/i, |
| 104 |
$frontend->get_last_error()); |
| 105 |
|
| 106 |
# create should be proxied through |
| 107 |
$result = $frontend->create('INBOX.newfolder'); |
| 108 |
$self->assert_not_null($result); |
| 109 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 110 |
|
| 111 |
# should be able to select it now |
| 112 |
$result = $frontend->select('INBOX.newfolder'); |
| 113 |
$self->assert_not_null($result); |
| 114 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 115 |
|
| 116 |
# should be able to getmetadata |
| 117 |
$result = $frontend->getmetadata('INBOX', |
| 118 |
'/shared/vendor/cmu/cyrus-imapd/size'); |
| 119 |
$self->assert_not_null($result); |
| 120 |
$self->assert(exists $result->{'INBOX'}{'/shared/vendor/cmu/cyrus-imapd/size'}); |
| 121 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 122 |
$result = $frontend->getmetadata('(INBOX INBOX.newfolder)', |
| 123 |
'/shared/vendor/cmu/cyrus-imapd/size'); |
| 124 |
$self->assert_not_null($result); |
| 125 |
$self->assert(exists $result->{'INBOX'}{'/shared/vendor/cmu/cyrus-imapd/size'}); |
| 126 |
$self->assert(exists $result->{'INBOX.newfolder'}{'/shared/vendor/cmu/cyrus-imapd/size'}); |
| 127 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 128 |
|
| 129 |
# check frontend version for which resource type to use |
| 130 |
my $res_mailbox = 'MAILBOX'; |
| 131 |
my ($maj, $min) = Cassandane::Instance->get_version('murder'); |
| 132 |
if ($maj < 3 || ($maj == 3 && $min < 9)) { |
| 133 |
$res_mailbox = 'X-NUM-FOLDERS'; |
| 134 |
} |
| 135 |
|
| 136 |
my $frontend_admin = $self->{frontend_adminstore}->get_client(); |
| 137 |
$result = $frontend_admin->setquota('user.cassandane', |
| 138 |
"(STORAGE 1024 MESSAGE 5000 $res_mailbox 100)"); |
| 139 |
$self->assert_not_null($result); |
| 140 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 141 |
|
| 142 |
# enable should be proxied through |
| 143 |
$result = $frontend->enable('qresync'); |
| 144 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 145 |
|
| 146 |
# should be able to fetch vanished |
| 147 |
$result = $frontend->uid(1); |
| 148 |
$result = $frontend->fetch('1:*', ['FLAGS'], |
| 149 |
['CHANGEDSINCE', '1', 'VANISHED']); |
| 150 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 151 |
|
| 152 |
# XXX test other commands |
| 153 |
} |
| 154 |
|
| 155 |
sub test_list_specialuse |
| 156 |
{ |
| 157 |
my ($self) = @_; |
| 158 |
|
| 159 |
my $frontend = $self->{frontend_store}->get_client(); |
| 160 |
my $backend = $self->{backend1_store}->get_client(); |
| 161 |
|
| 162 |
my %specialuse = map { $_ => 1 } qw( Drafts Junk Sent Trash ); |
| 163 |
my %other = map { $_ => 1 } qw( lists personal timesheets ); |
| 164 |
|
| 165 |
# create some special-use folders |
| 166 |
foreach my $f (keys %specialuse) { |
| 167 |
$frontend->create("INBOX.$f"); |
| 168 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 169 |
|
| 170 |
$frontend->subscribe("INBOX.$f"); |
| 171 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 172 |
|
| 173 |
$frontend->setmetadata("INBOX.$f", |
| 174 |
'/private/specialuse', "\\$f"); |
| 175 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 176 |
} |
| 177 |
|
| 178 |
# create some other non special-use folders (control group) |
| 179 |
foreach my $f (keys %other) { |
| 180 |
$frontend->create("INBOX.$f"); |
| 181 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 182 |
|
| 183 |
$frontend->subscribe("INBOX.$f"); |
| 184 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 185 |
} |
| 186 |
|
| 187 |
# ask the backend about them |
| 188 |
my $bresult = $backend->list([qw(SPECIAL-USE)], "", "*", |
| 189 |
'RETURN', [qw(SUBSCRIBED)]); |
| 190 |
$self->assert_str_equals('ok', $backend->get_last_completion_response()); |
| 191 |
xlog $self, Dumper $bresult; |
| 192 |
|
| 193 |
# check the responses |
| 194 |
my %found; |
| 195 |
foreach my $r (@{$bresult}) { |
| 196 |
my ($flags, $sep, $name) = @{$r}; |
| 197 |
# carve out the interesting part of the name |
| 198 |
$self->assert_matches(qr/^INBOX$sep/, $name); |
| 199 |
$name = substr($name, 6); |
| 200 |
$found{$name} = 1; |
| 201 |
# only want specialuse folders |
| 202 |
$self->assert(exists $specialuse{$name}); |
| 203 |
# must be flagged with appropriate flag |
| 204 |
$self->assert_equals(1, scalar grep { $_ eq "\\$name" } @{$flags}); |
| 205 |
# must be flagged with \subscribed |
| 206 |
$self->assert_equals(1, scalar grep { $_ eq '\\Subscribed' } @{$flags}); |
| 207 |
} |
| 208 |
|
| 209 |
# make sure no expected responses were missing |
| 210 |
$self->assert_deep_equals(\%specialuse, \%found); |
| 211 |
|
| 212 |
# ask the frontend about them |
| 213 |
my $fresult = $frontend->list([qw(SPECIAL-USE)], "", "*", |
| 214 |
'RETURN', [qw(SUBSCRIBED)]); |
| 215 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 216 |
xlog $self, Dumper $fresult; |
| 217 |
|
| 218 |
# expect the same results as on backend |
| 219 |
$self->assert_deep_equals($bresult, $fresult); |
| 220 |
} |
| 221 |
|
| 222 |
sub test_list_subscribed |
| 223 |
{ |
| 224 |
my ($self) = @_; |
| 225 |
|
| 226 |
my $frontend = $self->{frontend_store}->get_client(); |
| 227 |
my $backend = $self->{backend1_store}->get_client(); |
| 228 |
|
| 229 |
my %subscribed = map { $_ => 1 } qw( A1 A2 A3 ); |
| 230 |
my %other = map { $_ => 1 } qw( lists personal timesheets ); |
| 231 |
|
| 232 |
# create some subscribed folders |
| 233 |
foreach my $f (keys %subscribed) { |
| 234 |
$frontend->create("INBOX.$f"); |
| 235 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 236 |
|
| 237 |
$frontend->subscribe("INBOX.$f"); |
| 238 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 239 |
} |
| 240 |
|
| 241 |
# create some other non special-use folders (control group) |
| 242 |
foreach my $f (keys %other) { |
| 243 |
$frontend->create("INBOX.$f"); |
| 244 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 245 |
|
| 246 |
$frontend->subscribe("INBOX.$f"); |
| 247 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 248 |
} |
| 249 |
|
| 250 |
# ask the backend about them |
| 251 |
my $bresult = $backend->list([qw(SUBSCRIBED)], "", "INBOX.A*"); |
| 252 |
$self->assert_str_equals('ok', $backend->get_last_completion_response()); |
| 253 |
xlog $self, Dumper $bresult; |
| 254 |
|
| 255 |
# check the responses |
| 256 |
my %found; |
| 257 |
foreach my $r (@{$bresult}) { |
| 258 |
my ($flags, $sep, $name) = @{$r}; |
| 259 |
# carve out the interesting part of the name |
| 260 |
$self->assert_matches(qr/^INBOX$sep/, $name); |
| 261 |
$name = substr($name, 6); |
| 262 |
$found{$name} = 1; |
| 263 |
# only want subscribed folders |
| 264 |
$self->assert(exists $subscribed{$name}); |
| 265 |
# must be flagged with \subscribed |
| 266 |
$self->assert_equals(1, scalar grep { $_ eq '\\Subscribed' } @{$flags}); |
| 267 |
} |
| 268 |
|
| 269 |
# make sure no expected responses were missing |
| 270 |
$self->assert_deep_equals(\%subscribed, \%found); |
| 271 |
|
| 272 |
# ask the frontend about them |
| 273 |
my $fresult = $frontend->list([qw(SUBSCRIBED)], "", "INBOX.A*"); |
| 274 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 275 |
xlog $self, Dumper $fresult; |
| 276 |
|
| 277 |
# expect the same results as on backend |
| 278 |
$self->assert_deep_equals($bresult, $fresult); |
| 279 |
|
| 280 |
# ask the frontend about them with a non-empty reference argument |
| 281 |
$fresult = $frontend->list([qw(SUBSCRIBED)], "INBOX.A", "*"); |
| 282 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 283 |
xlog $self, Dumper $fresult; |
| 284 |
|
| 285 |
# expect the same results as on backend |
| 286 |
$self->assert_deep_equals($bresult, $fresult); |
| 287 |
} |
| 288 |
|
| 289 |
sub test_xlist |
| 290 |
{ |
| 291 |
my ($self) = @_; |
| 292 |
|
| 293 |
my $frontend = $self->{frontend_store}->get_client(); |
| 294 |
my $backend = $self->{backend1_store}->get_client(); |
| 295 |
|
| 296 |
my %specialuse = map { $_ => 1 } qw( Drafts Junk Sent Trash ); |
| 297 |
my %other = map { $_ => 1 } qw( lists personal timesheets ); |
| 298 |
|
| 299 |
# create some special-use folders |
| 300 |
foreach my $f (keys %specialuse) { |
| 301 |
$frontend->create("INBOX.$f"); |
| 302 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 303 |
|
| 304 |
$frontend->setmetadata("INBOX.$f", |
| 305 |
'/private/specialuse', "\\$f"); |
| 306 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 307 |
} |
| 308 |
|
| 309 |
# create some other non special-use folders (control group) |
| 310 |
foreach my $f (keys %other) { |
| 311 |
$frontend->create("INBOX.$f"); |
| 312 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 313 |
} |
| 314 |
|
| 315 |
# ask the backend about them |
| 316 |
my $bresult = $backend->xlist("", "*"); |
| 317 |
$self->assert_str_equals('ok', $backend->get_last_completion_response()); |
| 318 |
xlog $self, "backend: " . Dumper $bresult; |
| 319 |
|
| 320 |
# check the responses |
| 321 |
my %found; |
| 322 |
foreach my $r (@{$bresult}) { |
| 323 |
my ($flags, $sep, $name) = @{$r}; |
| 324 |
if ($name eq 'INBOX') { |
| 325 |
$found{$name} = 1; |
| 326 |
# must be flagged with \Inbox |
| 327 |
$self->assert_equals(1, scalar grep { $_ eq '\\Inbox' } @{$flags}); |
| 328 |
} |
| 329 |
else { |
| 330 |
# carve out the interesting part of the name |
| 331 |
$self->assert_matches(qr/^INBOX$sep/, $name); |
| 332 |
$name = substr($name, 6); |
| 333 |
$found{$name} = 1; |
| 334 |
$self->assert(exists $specialuse{$name} or exists $other{$name}); |
| 335 |
if (exists $specialuse{$name}) { |
| 336 |
# must be flagged with appropriate flag |
| 337 |
$self->assert_equals(1, scalar grep { $_ eq "\\$name" } @{$flags}); |
| 338 |
} |
| 339 |
else { |
| 340 |
# must not be flagged with name-based flag |
| 341 |
$self->assert_equals(0, scalar grep { $_ eq "\\$name" } @{$flags}); |
| 342 |
} |
| 343 |
} |
| 344 |
} |
| 345 |
|
| 346 |
# make sure no expected responses were missing |
| 347 |
$self->assert_deep_equals({ 'INBOX' => 1, %specialuse, %other }, \%found); |
| 348 |
|
| 349 |
# ask the frontend about them |
| 350 |
my $fresult = $frontend->xlist("", "*"); |
| 351 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 352 |
xlog $self, "frontend: " . Dumper $fresult; |
| 353 |
|
| 354 |
# expect the same results as on backend |
| 355 |
$self->assert_deep_equals($bresult, $fresult); |
| 356 |
} |
| 357 |
|
| 358 |
sub test_move_to_backend_nonexistent |
| 359 |
{ |
| 360 |
my ($self) = @_; |
| 361 |
|
| 362 |
my $dest_folder = 'INBOX.dest'; |
| 363 |
|
| 364 |
# put some messages into the INBOX |
| 365 |
my %exp; |
| 366 |
$exp{A} = $self->make_message("Message A", store => $self->{frontend_store}); |
| 367 |
$exp{B} = $self->make_message("Message B", store => $self->{frontend_store}); |
| 368 |
$exp{C} = $self->make_message("Message C", store => $self->{frontend_store}); |
| 369 |
|
| 370 |
my $frontend = $self->{frontend_store}->get_client(); |
| 371 |
my $backend = $self->{backend1_store}->get_client(); |
| 372 |
my $backend_admin = $self->{backend1_adminstore}->get_client(); |
| 373 |
|
| 374 |
# create a destination folder (on both frontend and backend) |
| 375 |
$frontend->create($dest_folder); |
| 376 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 377 |
|
| 378 |
# nuke the destination folder (on the backend only) |
| 379 |
# n.b. 'INBOX' is part of the mailbox name, it's not just the cassandane |
| 380 |
# user's inbox, hence the weird admin path here. Not sure why I did it |
| 381 |
# that way, might have been just what was in the bug report. |
| 382 |
$backend_admin->localdelete('user.cassandane.INBOX.dest'); |
| 383 |
$self->assert_str_equals('ok', $backend_admin->get_last_completion_response()); |
| 384 |
|
| 385 |
my $f_folders = $frontend->list('', '*'); |
| 386 |
$self->assert_deep_equals( |
| 387 |
[[[ '\\HasChildren' ], '.', 'INBOX' ], |
| 388 |
[[ '\\HasNoChildren' ], '.', 'INBOX.dest' ]], |
| 389 |
$f_folders); |
| 390 |
|
| 391 |
my $b_folders = $backend->list('', '*'); |
| 392 |
$self->assert_deep_equals( |
| 393 |
[[[ '\\HasNoChildren' ], '.', 'INBOX' ]], |
| 394 |
$b_folders); |
| 395 |
|
| 396 |
# try to move a message to dest |
| 397 |
$frontend->move($exp{A}->get_attribute('uid'), $dest_folder); |
| 398 |
|
| 399 |
# it should fail nicely |
| 400 |
$self->assert_str_equals('no', $frontend->get_last_completion_response()); |
| 401 |
$self->assert_matches(qr/Mailbox does not exist/, $frontend->get_last_error()); |
| 402 |
|
| 403 |
# try to copy a message to dest |
| 404 |
$frontend->copy($exp{B}->get_attribute('uid'), $dest_folder); |
| 405 |
|
| 406 |
# it should fail nicely |
| 407 |
$self->assert_str_equals('no', $frontend->get_last_completion_response()); |
| 408 |
$self->assert_matches(qr/Mailbox does not exist/, $frontend->get_last_error()); |
| 409 |
} |
| 410 |
|
| 411 |
sub test_move_to_nonexistent |
| 412 |
{ |
| 413 |
my ($self) = @_; |
| 414 |
|
| 415 |
my $dest_folder = 'INBOX.nonexistent'; |
| 416 |
|
| 417 |
# put some messages into the INBOX |
| 418 |
my %exp; |
| 419 |
$exp{A} = $self->make_message("Message A", store => $self->{frontend_store}); |
| 420 |
$exp{B} = $self->make_message("Message B", store => $self->{frontend_store}); |
| 421 |
$exp{C} = $self->make_message("Message C", store => $self->{frontend_store}); |
| 422 |
|
| 423 |
my $frontend = $self->{frontend_store}->get_client(); |
| 424 |
my $backend = $self->{backend1_store}->get_client(); |
| 425 |
|
| 426 |
# make sure we don't unexpectedly have the nonexistent folder |
| 427 |
my $f_folders = $frontend->list('', '*'); |
| 428 |
$self->assert_deep_equals( |
| 429 |
[[[ '\\HasNoChildren' ], '.', 'INBOX' ]], |
| 430 |
$f_folders); |
| 431 |
|
| 432 |
my $b_folders = $backend->list('', '*'); |
| 433 |
$self->assert_deep_equals( |
| 434 |
[[[ '\\HasNoChildren' ], '.', 'INBOX' ]], |
| 435 |
$b_folders); |
| 436 |
|
| 437 |
# try to move a message to dest |
| 438 |
$frontend->move($exp{A}->get_attribute('uid'), $dest_folder); |
| 439 |
|
| 440 |
# it should fail nicely |
| 441 |
$self->assert_str_equals('no', $frontend->get_last_completion_response()); |
| 442 |
$self->assert_matches(qr/Mailbox does not exist/, $frontend->get_last_error()); |
| 443 |
|
| 444 |
# try to copy a message to dest |
| 445 |
$frontend->copy($exp{B}->get_attribute('uid'), $dest_folder); |
| 446 |
|
| 447 |
# it should fail nicely |
| 448 |
$self->assert_str_equals('no', $frontend->get_last_completion_response()); |
| 449 |
$self->assert_matches(qr/Mailbox does not exist/, $frontend->get_last_error()); |
| 450 |
} |
| 451 |
|
| 452 |
sub test_rename_with_location |
| 453 |
:AllowMoves |
| 454 |
{ |
| 455 |
my ($self) = @_; |
| 456 |
|
| 457 |
my $frontend_adminstore = $self->{frontend_adminstore}->get_client(); |
| 458 |
|
| 459 |
my $backend2_servername = $self->{backend2}->get_servername(); |
| 460 |
|
| 461 |
xlog $self, "backend2 servername: $backend2_servername"; |
| 462 |
|
| 463 |
# not allowed to change mailbox name if location also specified |
| 464 |
$frontend_adminstore->rename('user.cassandane', 'user.foo', "$backend2_servername!"); |
| 465 |
$self->assert_str_equals('no', $frontend_adminstore->get_last_completion_response()); |
| 466 |
|
| 467 |
# but can change location if mailbox name remains the same |
| 468 |
$frontend_adminstore->rename('user.cassandane', 'user.cassandane', "$backend2_servername!"); |
| 469 |
# XXX need to check for "* NO USER cassandane (some error)" untagged response |
| 470 |
$self->assert_str_equals('ok', $frontend_adminstore->get_last_completion_response()); |
| 471 |
|
| 472 |
# verify that it moved |
| 473 |
my $backend1_store = $self->{backend1_store}->get_client(); |
| 474 |
$backend1_store->select('INBOX'); |
| 475 |
$self->assert_str_equals('no', $backend1_store->get_last_completion_response()); |
| 476 |
|
| 477 |
my $backend2_store = $self->{backend2_store}->get_client(); |
| 478 |
$backend2_store->select('INBOX'); |
| 479 |
$self->assert_str_equals('ok', $backend2_store->get_last_completion_response()); |
| 480 |
} |
| 481 |
|
| 482 |
sub test_xfer_nonexistent_unixhs |
| 483 |
:UnixHierarchySep |
| 484 |
{ |
| 485 |
my ($self) = @_; |
| 486 |
|
| 487 |
my $admintalk = $self->{backend1_adminstore}->get_client(); |
| 488 |
my $backend2_servername = $self->{backend2}->get_servername(); |
| 489 |
|
| 490 |
# xfer a user that doesn't exist |
| 491 |
$admintalk->_imap_cmd('xfer', 0, {}, |
| 492 |
'user/nonexistent', $backend2_servername); |
| 493 |
$self->assert_str_equals( |
| 494 |
'no', $admintalk->get_last_completion_response() |
| 495 |
); |
| 496 |
|
| 497 |
# xfer a mailbox that doesn't exist |
| 498 |
$admintalk->_imap_cmd('xfer', 0, {}, |
| 499 |
'user/cassandane/nonexistent', $backend2_servername); |
| 500 |
$self->assert_str_equals( |
| 501 |
'no', $admintalk->get_last_completion_response() |
| 502 |
); |
| 503 |
|
| 504 |
# xfer a pattern that doesn't match anything |
| 505 |
$admintalk->_imap_cmd('xfer', 0, {}, |
| 506 |
'user/cassandane/non%', $backend2_servername); |
| 507 |
$self->assert_str_equals( |
| 508 |
'no', $admintalk->get_last_completion_response() |
| 509 |
); |
| 510 |
|
| 511 |
# xfer a partition that doesn't exist |
| 512 |
$admintalk->_imap_cmd('xfer', 0, {}, |
| 513 |
'nonexistent', $backend2_servername); |
| 514 |
$self->assert_str_equals( |
| 515 |
'no', $admintalk->get_last_completion_response() |
| 516 |
); |
| 517 |
} |
| 518 |
|
| 519 |
sub test_xfer_user_altns_unixhs |
| 520 |
:AllowMoves :AltNamespace :UnixHierarchySep |
| 521 |
:min_version_3_2 |
| 522 |
{ |
| 523 |
my ($self) = @_; |
| 524 |
|
| 525 |
# set up some data for cassandane on backend1 |
| 526 |
my $expected = $self->populate_user($self->{instance}, |
| 527 |
$self->{backend1_store}, |
| 528 |
[qw(INBOX Drafts)]); |
| 529 |
|
| 530 |
my $imaptalk = $self->{backend1_store}->get_client(); |
| 531 |
my $admintalk = $self->{backend1_adminstore}->get_client(); |
| 532 |
my $backend2_servername = $self->{backend2}->get_servername(); |
| 533 |
|
| 534 |
# what's the frontend mailboxes.db say before we move? |
| 535 |
my $mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 536 |
xlog "XXX before move, frontend mailboxes.db:" . Dumper $mailboxes_db; |
| 537 |
|
| 538 |
# what's imap LIST say before we move? |
| 539 |
# original backend: |
| 540 |
my $data = $imaptalk->list("", "*"); |
| 541 |
$self->assert_mailbox_structure($data, '/', { |
| 542 |
'INBOX' => [qw( \\HasNoChildren )], |
| 543 |
'Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 544 |
}); |
| 545 |
|
| 546 |
# frontend doesn't know about annotations |
| 547 |
my $frontendtalk = $self->{frontend_store}->get_client(); |
| 548 |
$data = $frontendtalk->list("", "*"); |
| 549 |
$self->assert_mailbox_structure($data, '/', { |
| 550 |
'INBOX' => [qw( \\HasNoChildren )], |
| 551 |
'Drafts' => [qw( \\HasNoChildren )], |
| 552 |
}); |
| 553 |
|
| 554 |
# ... but if we ask for them it'll proxy the request and find them |
| 555 |
$data = $frontendtalk->list("", "*", 'RETURN', [ 'SPECIAL-USE' ]); |
| 556 |
$self->assert_mailbox_structure($data, '/', { |
| 557 |
'INBOX' => [qw( \\HasNoChildren )], |
| 558 |
'Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 559 |
}); |
| 560 |
|
| 561 |
# now xfer the cassandane user to backend2 |
| 562 |
my $ret = $admintalk->_imap_cmd('xfer', 0, {}, |
| 563 |
'user/cassandane', $backend2_servername); |
| 564 |
xlog "XXX xfer returned: " . Dumper $ret; |
| 565 |
# XXX 3.2+ with 3.0 target fails here: syntax error in parameters |
| 566 |
$self->assert_str_equals('ok', $ret); |
| 567 |
# XXX 3.2+ with 2.5 target fails here: mailbox has an invalid format |
| 568 |
$self->assert_str_equals( |
| 569 |
'ok', $admintalk->get_last_completion_response() |
| 570 |
); |
| 571 |
|
| 572 |
# account contents should be on the other store now |
| 573 |
$self->check_user($self->{backend2}, $self->{backend2_store}, $expected); |
| 574 |
|
| 575 |
# frontend should now say the user is on the other store |
| 576 |
# XXX is there a better way to discover this? |
| 577 |
$mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 578 |
xlog "XXX after move, frontend mailboxes.db: " . Dumper $mailboxes_db; |
| 579 |
# XXX 3.0 with 2.5 frontend fails here: server field is blank |
| 580 |
$self->assert_str_equals( |
| 581 |
$backend2_servername, |
| 582 |
$mailboxes_db->{'user.cassandane'}->{server} |
| 583 |
); |
| 584 |
$self->assert_str_equals( |
| 585 |
$backend2_servername, |
| 586 |
$mailboxes_db->{'user.cassandane.Drafts'}->{server} |
| 587 |
); |
| 588 |
|
| 589 |
# what's imap LIST say after the move? |
| 590 |
undef $imaptalk; |
| 591 |
$self->{store}->disconnect(); |
| 592 |
$imaptalk = $self->{store}->get_client(); |
| 593 |
xlog "checking LIST on old backend"; |
| 594 |
$data = $imaptalk->list("", "*"); |
| 595 |
$self->assert_mailbox_structure($data, '/', {}); |
| 596 |
|
| 597 |
my $backend2talk = $self->{backend2_store}->get_client(); |
| 598 |
xlog "checking LIST on new backend"; |
| 599 |
$data = $backend2talk->list("", "*"); |
| 600 |
$self->assert_mailbox_structure($data, '/', { |
| 601 |
'INBOX' => [qw( \\HasNoChildren )], |
| 602 |
'Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 603 |
}); |
| 604 |
|
| 605 |
# frontend doesn't know about annotations |
| 606 |
$frontendtalk = $self->{frontend_store}->get_client(); |
| 607 |
xlog "checking LIST on frontend"; |
| 608 |
$data = $frontendtalk->list("", "*"); |
| 609 |
$self->assert_mailbox_structure($data, '/', { |
| 610 |
'INBOX' => [qw( \\HasNoChildren )], |
| 611 |
'Drafts' => [qw( \\HasNoChildren )], |
| 612 |
}); |
| 613 |
|
| 614 |
# ... but if we ask for them it'll proxy the request and find them |
| 615 |
$data = $frontendtalk->list("", "*", 'RETURN', [ 'SPECIAL-USE' ]); |
| 616 |
$self->assert_mailbox_structure($data, '/', { |
| 617 |
'INBOX' => [qw( \\HasNoChildren )], |
| 618 |
'Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 619 |
}); |
| 620 |
} |
| 621 |
|
| 622 |
sub test_xfer_user_noaltns_nounixhs |
| 623 |
:AllowMoves :NoAltNamespace |
| 624 |
:min_version_3_2 |
| 625 |
{ |
| 626 |
my ($self) = @_; |
| 627 |
|
| 628 |
# set up some data for cassandane on backend1 |
| 629 |
my $expected = $self->populate_user($self->{instance}, |
| 630 |
$self->{backend1_store}, |
| 631 |
[qw(INBOX INBOX.Drafts)]); |
| 632 |
|
| 633 |
my $imaptalk = $self->{backend1_store}->get_client(); |
| 634 |
my $admintalk = $self->{backend1_adminstore}->get_client(); |
| 635 |
my $backend2_servername = $self->{backend2}->get_servername(); |
| 636 |
|
| 637 |
# what's the frontend mailboxes.db say before we move? |
| 638 |
my $mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 639 |
xlog "XXX before move, frontend mailboxes.db:" . Dumper $mailboxes_db; |
| 640 |
|
| 641 |
# what's imap LIST say before we move? |
| 642 |
# original backend: |
| 643 |
my $data = $imaptalk->list("", "*"); |
| 644 |
$self->assert_mailbox_structure($data, '.', { |
| 645 |
'INBOX' => [qw( \\HasChildren )], |
| 646 |
'INBOX.Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 647 |
}); |
| 648 |
|
| 649 |
# frontend doesn't know about annotations |
| 650 |
my $frontendtalk = $self->{frontend_store}->get_client(); |
| 651 |
$data = $frontendtalk->list("", "*"); |
| 652 |
$self->assert_mailbox_structure($data, '.', { |
| 653 |
'INBOX' => [qw( \\HasChildren )], |
| 654 |
'INBOX.Drafts' => [qw( \\HasNoChildren )], |
| 655 |
}); |
| 656 |
|
| 657 |
# ... but if we ask for them it'll proxy the request and find them |
| 658 |
$data = $frontendtalk->list("", "*", 'RETURN', [ 'SPECIAL-USE' ]); |
| 659 |
$self->assert_mailbox_structure($data, '.', { |
| 660 |
'INBOX' => [qw( \\HasChildren )], |
| 661 |
'INBOX.Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 662 |
}); |
| 663 |
|
| 664 |
# now xfer the cassandane user to backend2 |
| 665 |
my $ret = $admintalk->_imap_cmd('xfer', 0, {}, |
| 666 |
'user.cassandane', $backend2_servername); |
| 667 |
xlog "XXX xfer returned: " . Dumper $ret; |
| 668 |
# XXX 3.2+ with 3.0 target fails here: syntax error in parameters |
| 669 |
$self->assert_str_equals('ok', $ret); |
| 670 |
# XXX 3.2+ with 2.5 target fails here: mailbox has an invalid format |
| 671 |
$self->assert_str_equals( |
| 672 |
'ok', $admintalk->get_last_completion_response() |
| 673 |
); |
| 674 |
|
| 675 |
# account contents should be on the other store now |
| 676 |
$self->check_user($self->{backend2}, $self->{backend2_store}, $expected); |
| 677 |
|
| 678 |
# frontend should now say the user is on the other store |
| 679 |
# XXX is there a better way to discover this? |
| 680 |
$mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 681 |
xlog "XXX after move, frontend mailboxes.db: " . Dumper $mailboxes_db; |
| 682 |
# XXX 3.0 with 2.5 frontend fails here: server field is blank |
| 683 |
$self->assert_str_equals( |
| 684 |
$backend2_servername, |
| 685 |
$mailboxes_db->{'user.cassandane'}->{server} |
| 686 |
); |
| 687 |
$self->assert_str_equals( |
| 688 |
$backend2_servername, |
| 689 |
$mailboxes_db->{'user.cassandane.Drafts'}->{server} |
| 690 |
); |
| 691 |
|
| 692 |
# what's imap LIST say after the move? |
| 693 |
undef $imaptalk; |
| 694 |
$self->{store}->disconnect(); |
| 695 |
$imaptalk = $self->{store}->get_client(); |
| 696 |
xlog "checking LIST on old backend"; |
| 697 |
$data = $imaptalk->list("", "*"); |
| 698 |
$self->assert_mailbox_structure($data, '.', {}); |
| 699 |
|
| 700 |
my $backend2talk = $self->{backend2_store}->get_client(); |
| 701 |
xlog "checking LIST on new backend"; |
| 702 |
$data = $backend2talk->list("", "*"); |
| 703 |
$self->assert_mailbox_structure($data, '.', { |
| 704 |
'INBOX' => [qw( \\HasChildren )], |
| 705 |
'INBOX.Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 706 |
}); |
| 707 |
|
| 708 |
# frontend doesn't know about annotations |
| 709 |
$frontendtalk = $self->{frontend_store}->get_client(); |
| 710 |
xlog "checking LIST on frontend"; |
| 711 |
$data = $frontendtalk->list("", "*"); |
| 712 |
$self->assert_mailbox_structure($data, '.', { |
| 713 |
'INBOX' => [qw( \\HasChildren )], |
| 714 |
'INBOX.Drafts' => [qw( \\HasNoChildren )], |
| 715 |
}); |
| 716 |
|
| 717 |
# ... but if we ask for them it'll proxy the request and find them |
| 718 |
$data = $frontendtalk->list("", "*", 'RETURN', [ 'SPECIAL-USE' ]); |
| 719 |
$self->assert_mailbox_structure($data, '.', { |
| 720 |
'INBOX' => [qw( \\HasChildren )], |
| 721 |
'INBOX.Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 722 |
}); |
| 723 |
} |
| 724 |
|
| 725 |
sub test_xfer_user_verify_cleanup |
| 726 |
:AllowMoves :NoAltNamespace :Conversations |
| 727 |
:min_version_3_9 |
| 728 |
{ |
| 729 |
my ($self) = @_; |
| 730 |
|
| 731 |
# set up some data for cassandane on backend1 |
| 732 |
my $expected = $self->populate_user($self->{instance}, |
| 733 |
$self->{backend1_store}, |
| 734 |
[qw(INBOX INBOX.Drafts)]); |
| 735 |
|
| 736 |
my $imaptalk = $self->{backend1_store}->get_client(); |
| 737 |
my $admintalk = $self->{backend1_adminstore}->get_client(); |
| 738 |
my $backend2_servername = $self->{backend2}->get_servername(); |
| 739 |
|
| 740 |
xlog $self, "Subscribe to INBOX"; |
| 741 |
$imaptalk->subscribe("INBOX"); |
| 742 |
|
| 743 |
xlog $self, "Install a sieve script"; |
| 744 |
$self->{instance}->install_sieve_script(<<EOF |
| 745 |
keep; |
| 746 |
EOF |
| 747 |
); |
| 748 |
|
| 749 |
xlog $self, "Run squatter"; |
| 750 |
$self->{instance}->run_command({cyrus => 1}, 'squatter'); |
| 751 |
|
| 752 |
xlog $self, "Verify user mailbox directories exist"; |
| 753 |
my $inbox_dir = $self->{instance}->folder_to_directory('INBOX'); |
| 754 |
my $drafts_dir = $self->{instance}->folder_to_directory('INBOX.Drafts'); |
| 755 |
$self->assert_file_test($inbox_dir, '-d'); |
| 756 |
$self->assert_file_test($drafts_dir, '-d'); |
| 757 |
|
| 758 |
xlog $self, "Verify user data files/directories exist"; |
| 759 |
my $data = $self->{instance}->run_mbpath('-u', 'cassandane'); |
| 760 |
$self->assert_file_test($data->{user}{'sub'}, '-f'); |
| 761 |
$self->assert_file_test($data->{user}{counters}, '-f'); |
| 762 |
$self->assert_file_test($data->{user}{conversations}, '-f'); |
| 763 |
$self->assert_file_test($data->{user}{xapianactive}, '-f'); |
| 764 |
$self->assert_file_test("$data->{user}{sieve}/defaultbc", '-f'); |
| 765 |
$self->assert_file_test($data->{xapian}{t1}, '-d'); |
| 766 |
|
| 767 |
# now xfer the cassandane user to backend2 |
| 768 |
my $ret = $admintalk->_imap_cmd('xfer', 0, {}, |
| 769 |
'user.cassandane', $backend2_servername); |
| 770 |
|
| 771 |
xlog $self, "Verify user mailbox directories have been deleted"; |
| 772 |
$self->assert_not_file_test($inbox_dir, '-e'); |
| 773 |
$self->assert_not_file_test($drafts_dir, '-e'); |
| 774 |
|
| 775 |
xlog $self, "Verify user data files/directories have been deleted"; |
| 776 |
$self->assert_not_file_test($data->{user}{'sub'}, '-e'); |
| 777 |
$self->assert_not_file_test($data->{user}{counters}, '-e'); |
| 778 |
$self->assert_not_file_test($data->{user}{conversations}, '-e'); |
| 779 |
$self->assert_not_file_test($data->{user}{xapianactive}, '-e'); |
| 780 |
$self->assert_not_file_test($data->{user}{sieve}, '-e'); |
| 781 |
$self->assert_not_file_test($data->{xapian}{t1}, '-e'); |
| 782 |
} |
| 783 |
|
| 784 |
sub test_xfer_user_altns_unixhs_virtdom |
| 785 |
:AllowMoves :AltNamespace :UnixHierarchySep :VirtDomains |
| 786 |
:min_version_3_2 |
| 787 |
{ |
| 788 |
my ($self) = @_; |
| 789 |
|
| 790 |
# set up a user with a domain |
| 791 |
my $admintalk = $self->{backend1_adminstore}->get_client(); |
| 792 |
$admintalk->create('user/[email protected]'); |
| 793 |
$self->assert_str_equals('ok', |
| 794 |
$admintalk->get_last_completion_response()); |
| 795 |
|
| 796 |
my $frontend_store = $self->{frontend}->get_service('imap')->create_store( |
| 797 |
username => '[email protected]'); |
| 798 |
my $backend1_store = $self->{instance}->get_service('imap')->create_store( |
| 799 |
username => '[email protected]'); |
| 800 |
my $backend2_store = $self->{backend2}->get_service('imap')->create_store( |
| 801 |
username => '[email protected]'); |
| 802 |
|
| 803 |
# set up some data for cassandane on backend1 |
| 804 |
my $expected = $self->populate_user($self->{instance}, |
| 805 |
$backend1_store, |
| 806 |
[qw(INBOX Drafts)]); |
| 807 |
|
| 808 |
my $imaptalk = $backend1_store->get_client(); |
| 809 |
my $backend2_servername = $self->{backend2}->get_servername(); |
| 810 |
|
| 811 |
# what's the frontend mailboxes.db say before we move? |
| 812 |
my $mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 813 |
xlog "XXX before move, frontend mailboxes.db:" . Dumper $mailboxes_db; |
| 814 |
|
| 815 |
# what's imap LIST say before we move? |
| 816 |
# original backend: |
| 817 |
my $data = $imaptalk->list("", "*"); |
| 818 |
$self->assert_mailbox_structure($data, '/', { |
| 819 |
'INBOX' => [qw( \\HasNoChildren )], |
| 820 |
'Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 821 |
}); |
| 822 |
|
| 823 |
# frontend doesn't know about annotations |
| 824 |
my $frontendtalk = $frontend_store->get_client(); |
| 825 |
$data = $frontendtalk->list("", "*"); |
| 826 |
$self->assert_mailbox_structure($data, '/', { |
| 827 |
'INBOX' => [qw( \\HasNoChildren )], |
| 828 |
'Drafts' => [qw( \\HasNoChildren )], |
| 829 |
}); |
| 830 |
|
| 831 |
# ... but if we ask for them it'll proxy the request and find them |
| 832 |
$data = $frontendtalk->list("", "*", 'RETURN', [ 'SPECIAL-USE' ]); |
| 833 |
$self->assert_mailbox_structure($data, '/', { |
| 834 |
'INBOX' => [qw( \\HasNoChildren )], |
| 835 |
'Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 836 |
}); |
| 837 |
|
| 838 |
# now xfer the cassandane user to backend2 |
| 839 |
my $ret = $admintalk->_imap_cmd('xfer', 0, {}, |
| 840 |
'user/[email protected]', |
| 841 |
$backend2_servername); |
| 842 |
xlog "XXX xfer returned: " . Dumper $ret; |
| 843 |
# XXX 3.2+ with 3.0 target fails here: syntax error in parameters |
| 844 |
$self->assert_str_equals('ok', $ret); |
| 845 |
# XXX 3.2+ with 2.5 target fails here: mailbox has an invalid format |
| 846 |
$self->assert_str_equals( |
| 847 |
'ok', $admintalk->get_last_completion_response() |
| 848 |
); |
| 849 |
|
| 850 |
# account contents should be on the other store now |
| 851 |
$self->check_user($self->{backend2}, $backend2_store, $expected); |
| 852 |
|
| 853 |
# frontend should now say the user is on the other store |
| 854 |
# XXX is there a better way to discover this? |
| 855 |
$mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 856 |
xlog "XXX after move, frontend mailboxes.db: " . Dumper $mailboxes_db; |
| 857 |
# XXX 3.0 with 2.5 frontend fails here: server field is blank |
| 858 |
$self->assert_str_equals( |
| 859 |
$backend2_servername, |
| 860 |
$mailboxes_db->{'example.com!user.foo'}->{server} |
| 861 |
); |
| 862 |
$self->assert_str_equals( |
| 863 |
$backend2_servername, |
| 864 |
$mailboxes_db->{'example.com!user.foo.Drafts'}->{server} |
| 865 |
); |
| 866 |
|
| 867 |
# what's imap LIST say after the move? |
| 868 |
undef $imaptalk; |
| 869 |
$backend1_store->disconnect(); |
| 870 |
$imaptalk = $backend1_store->get_client(); |
| 871 |
xlog "checking LIST on old backend"; |
| 872 |
$data = $imaptalk->list("", "*"); |
| 873 |
$self->assert_mailbox_structure($data, '/', {}); |
| 874 |
|
| 875 |
my $backend2talk = $backend2_store->get_client(); |
| 876 |
xlog "checking LIST on new backend"; |
| 877 |
$data = $backend2talk->list("", "*"); |
| 878 |
$self->assert_mailbox_structure($data, '/', { |
| 879 |
'INBOX' => [qw( \\HasNoChildren )], |
| 880 |
'Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 881 |
}); |
| 882 |
|
| 883 |
# frontend doesn't know about annotations |
| 884 |
$frontendtalk = $frontend_store->get_client(); |
| 885 |
xlog "checking LIST on frontend"; |
| 886 |
$data = $frontendtalk->list("", "*"); |
| 887 |
$self->assert_mailbox_structure($data, '/', { |
| 888 |
'INBOX' => [qw( \\HasNoChildren )], |
| 889 |
'Drafts' => [qw( \\HasNoChildren )], |
| 890 |
}); |
| 891 |
|
| 892 |
# ... but if we ask for them it'll proxy the request and find them |
| 893 |
$data = $frontendtalk->list("", "*", 'RETURN', [ 'SPECIAL-USE' ]); |
| 894 |
$self->assert_mailbox_structure($data, '/', { |
| 895 |
'INBOX' => [qw( \\HasNoChildren )], |
| 896 |
'Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 897 |
}); |
| 898 |
} |
| 899 |
|
| 900 |
sub test_xfer_user_noaltns_nounixhs_virtdom |
| 901 |
:AllowMoves :NoAltNamespace :VirtDomains |
| 902 |
:min_version_3_2 |
| 903 |
{ |
| 904 |
my ($self) = @_; |
| 905 |
|
| 906 |
# set up a user with a domain |
| 907 |
my $admintalk = $self->{backend1_adminstore}->get_client(); |
| 908 |
$admintalk->create('[email protected]'); |
| 909 |
$self->assert_str_equals('ok', |
| 910 |
$admintalk->get_last_completion_response()); |
| 911 |
|
| 912 |
my $frontend_store = $self->{frontend}->get_service('imap')->create_store( |
| 913 |
username => '[email protected]'); |
| 914 |
my $backend1_store = $self->{instance}->get_service('imap')->create_store( |
| 915 |
username => '[email protected]'); |
| 916 |
my $backend2_store = $self->{backend2}->get_service('imap')->create_store( |
| 917 |
username => '[email protected]'); |
| 918 |
|
| 919 |
# set up some data for cassandane on backend1 |
| 920 |
my $expected = $self->populate_user($self->{instance}, |
| 921 |
$backend1_store, |
| 922 |
[qw(INBOX INBOX.Drafts)]); |
| 923 |
|
| 924 |
my $imaptalk = $backend1_store->get_client(); |
| 925 |
my $backend2_servername = $self->{backend2}->get_servername(); |
| 926 |
|
| 927 |
# what's the frontend mailboxes.db say before we move? |
| 928 |
my $mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 929 |
xlog "XXX before move, frontend mailboxes.db:" . Dumper $mailboxes_db; |
| 930 |
|
| 931 |
# what's imap LIST say before we move? |
| 932 |
# original backend: |
| 933 |
my $data = $imaptalk->list("", "*"); |
| 934 |
$self->assert_mailbox_structure($data, '.', { |
| 935 |
'INBOX' => [qw( \\HasChildren )], |
| 936 |
'INBOX.Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 937 |
}); |
| 938 |
|
| 939 |
# frontend doesn't know about annotations |
| 940 |
my $frontendtalk = $frontend_store->get_client(); |
| 941 |
$data = $frontendtalk->list("", "*"); |
| 942 |
$self->assert_mailbox_structure($data, '.', { |
| 943 |
'INBOX' => [qw( \\HasChildren )], |
| 944 |
'INBOX.Drafts' => [qw( \\HasNoChildren )], |
| 945 |
}); |
| 946 |
|
| 947 |
# ... but if we ask for them it'll proxy the request and find them |
| 948 |
$data = $frontendtalk->list("", "*", 'RETURN', [ 'SPECIAL-USE' ]); |
| 949 |
$self->assert_mailbox_structure($data, '.', { |
| 950 |
'INBOX' => [qw( \\HasChildren )], |
| 951 |
'INBOX.Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 952 |
}); |
| 953 |
|
| 954 |
# now xfer the cassandane user to backend2 |
| 955 |
my $ret = $admintalk->_imap_cmd('xfer', 0, {}, |
| 956 |
'[email protected]', |
| 957 |
$backend2_servername); |
| 958 |
xlog "XXX xfer returned: " . Dumper $ret; |
| 959 |
# XXX 3.2+ with 3.0 target fails here: syntax error in parameters |
| 960 |
$self->assert_str_equals('ok', $ret); |
| 961 |
# XXX 3.2+ with 2.5 target fails here: mailbox has an invalid format |
| 962 |
$self->assert_str_equals( |
| 963 |
'ok', $admintalk->get_last_completion_response() |
| 964 |
); |
| 965 |
|
| 966 |
# account contents should be on the other store now |
| 967 |
$self->check_user($self->{backend2}, $backend2_store, $expected); |
| 968 |
|
| 969 |
# frontend should now say the user is on the other store |
| 970 |
# XXX is there a better way to discover this? |
| 971 |
$mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 972 |
xlog "XXX after move, frontend mailboxes.db: " . Dumper $mailboxes_db; |
| 973 |
# XXX 3.0 with 2.5 frontend fails here: server field is blank |
| 974 |
$self->assert_str_equals( |
| 975 |
$backend2_servername, |
| 976 |
$mailboxes_db->{'example.com!user.foo'}->{server} |
| 977 |
); |
| 978 |
$self->assert_str_equals( |
| 979 |
$backend2_servername, |
| 980 |
$mailboxes_db->{'example.com!user.foo.Drafts'}->{server} |
| 981 |
); |
| 982 |
|
| 983 |
# what's imap LIST say after the move? |
| 984 |
undef $imaptalk; |
| 985 |
$backend1_store->disconnect(); |
| 986 |
$imaptalk = $backend1_store->get_client(); |
| 987 |
xlog "checking LIST on old backend"; |
| 988 |
$data = $imaptalk->list("", "*"); |
| 989 |
$self->assert_mailbox_structure($data, '.', {}); |
| 990 |
|
| 991 |
my $backend2talk = $backend2_store->get_client(); |
| 992 |
xlog "checking LIST on new backend"; |
| 993 |
$data = $backend2talk->list("", "*"); |
| 994 |
$self->assert_mailbox_structure($data, '.', { |
| 995 |
'INBOX' => [qw( \\HasChildren )], |
| 996 |
'INBOX.Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 997 |
}); |
| 998 |
|
| 999 |
# frontend doesn't know about annotations |
| 1000 |
$frontendtalk = $frontend_store->get_client(); |
| 1001 |
xlog "checking LIST on frontend"; |
| 1002 |
$data = $frontendtalk->list("", "*"); |
| 1003 |
$self->assert_mailbox_structure($data, '.', { |
| 1004 |
'INBOX' => [qw( \\HasChildren )], |
| 1005 |
'INBOX.Drafts' => [qw( \\HasNoChildren )], |
| 1006 |
}); |
| 1007 |
|
| 1008 |
# ... but if we ask for them it'll proxy the request and find them |
| 1009 |
$data = $frontendtalk->list("", "*", 'RETURN', [ 'SPECIAL-USE' ]); |
| 1010 |
$self->assert_mailbox_structure($data, '.', { |
| 1011 |
'INBOX' => [qw( \\HasChildren )], |
| 1012 |
'INBOX.Drafts' => [qw( \\HasNoChildren \\Drafts )], |
| 1013 |
}); |
| 1014 |
} |
| 1015 |
|
| 1016 |
sub test_xfer_mailbox_altns_unixhs |
| 1017 |
:AllowMoves :AltNamespace :UnixHierarchySep |
| 1018 |
:min_version_3_2 :max_version_3_4 |
| 1019 |
{ |
| 1020 |
my ($self) = @_; |
| 1021 |
|
| 1022 |
# what we expect from this test will depend on the cyrus version being |
| 1023 |
# run on backend2 |
| 1024 |
my $backend2_permits_single_mailbox = 1; |
| 1025 |
my ($maj, $min) = Cassandane::Instance->get_version('murder'); |
| 1026 |
if ($maj > 3 || ($maj == 3 && $min >= 5)) { |
| 1027 |
$backend2_permits_single_mailbox = 0; |
| 1028 |
} |
| 1029 |
|
| 1030 |
# set up some data for cassandane on backend1 |
| 1031 |
my $expected_stay = $self->populate_user( |
| 1032 |
$self->{instance}, |
| 1033 |
$self->{backend1_store}, |
| 1034 |
[qw(INBOX Big Big/Red Big/Red/Dog)] |
| 1035 |
); |
| 1036 |
|
| 1037 |
# we're planning to only XFER "Big/Red" (but not the others!) |
| 1038 |
my $expected_move->{mailboxes}->{'Big/Red'} |
| 1039 |
= $expected_stay->{mailboxes}->{'Big/Red'}; |
| 1040 |
delete $expected_stay->{mailboxes}->{'Big/Red'}; |
| 1041 |
|
| 1042 |
my $imaptalk = $self->{backend1_store}->get_client(); |
| 1043 |
my $admintalk = $self->{backend1_adminstore}->get_client(); |
| 1044 |
my $backend1_servername = $self->{instance}->get_servername(); |
| 1045 |
my $backend2_servername = $self->{backend2}->get_servername(); |
| 1046 |
|
| 1047 |
# what's the frontend mailboxes.db say before we move? |
| 1048 |
my $mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 1049 |
xlog "XXX before move, frontend mailboxes.db:" . Dumper $mailboxes_db; |
| 1050 |
|
| 1051 |
# what's imap LIST say before we move? |
| 1052 |
# original backend: |
| 1053 |
my $data = $imaptalk->list("", "*"); |
| 1054 |
$self->assert_mailbox_structure($data, '/', { |
| 1055 |
'INBOX' => [qw( \\HasNoChildren )], |
| 1056 |
'Big' => [qw( \\HasChildren )], |
| 1057 |
'Big/Red' => [qw( \\HasChildren )], |
| 1058 |
'Big/Red/Dog' => [qw( \\HasNoChildren )], |
| 1059 |
}); |
| 1060 |
|
| 1061 |
my $frontendtalk = $self->{frontend_store}->get_client(); |
| 1062 |
$data = $frontendtalk->list("", "*"); |
| 1063 |
$self->assert_mailbox_structure($data, '/', { |
| 1064 |
'INBOX' => [qw( \\HasNoChildren )], |
| 1065 |
'Big' => [qw( \\HasChildren )], |
| 1066 |
'Big/Red' => [qw( \\HasChildren )], |
| 1067 |
'Big/Red/Dog' => [qw( \\HasNoChildren )], |
| 1068 |
}); |
| 1069 |
|
| 1070 |
# now xfer the BigRed folder (only) to backend2 |
| 1071 |
my $ret = $admintalk->_imap_cmd('xfer', 0, {}, |
| 1072 |
'user/cassandane/Big/Red', |
| 1073 |
$backend2_servername); |
| 1074 |
|
| 1075 |
# 3.5+ won't permit receiving just one mid-tree mailbox |
| 1076 |
if (not $backend2_permits_single_mailbox) { |
| 1077 |
$self->assert_str_equals( |
| 1078 |
'no', $admintalk->get_last_completion_response() |
| 1079 |
); |
| 1080 |
return; # nothing more to test here! |
| 1081 |
} |
| 1082 |
|
| 1083 |
$self->assert_str_equals('ok', $ret); |
| 1084 |
$self->assert_str_equals( |
| 1085 |
'ok', $admintalk->get_last_completion_response() |
| 1086 |
); |
| 1087 |
|
| 1088 |
# most of the account should have remained on the original backend |
| 1089 |
$self->check_user($self->{instance}, |
| 1090 |
$self->{backend1_store}, |
| 1091 |
$expected_stay); |
| 1092 |
# but Big/Red should have been moved |
| 1093 |
$self->check_user($self->{backend2}, |
| 1094 |
$self->{backend2_store}, |
| 1095 |
$expected_move); |
| 1096 |
|
| 1097 |
# frontend should now say the new mailbox locations |
| 1098 |
# XXX is there a better way to discover this? |
| 1099 |
$mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 1100 |
xlog "XXX after move, frontend mailboxes.db: " . Dumper $mailboxes_db; |
| 1101 |
# XXX 3.0 with 2.5 frontend fails here: server field is blank |
| 1102 |
$self->assert_str_equals( |
| 1103 |
$backend1_servername, |
| 1104 |
$mailboxes_db->{'user.cassandane'}->{server} |
| 1105 |
); |
| 1106 |
$self->assert_str_equals( |
| 1107 |
$backend1_servername, |
| 1108 |
$mailboxes_db->{'user.cassandane.Big'}->{server} |
| 1109 |
); |
| 1110 |
$self->assert_str_equals( |
| 1111 |
$backend2_servername, |
| 1112 |
$mailboxes_db->{'user.cassandane.Big.Red'}->{server} |
| 1113 |
); |
| 1114 |
$self->assert_str_equals( |
| 1115 |
$backend1_servername, |
| 1116 |
$mailboxes_db->{'user.cassandane.Big.Red.Dog'}->{server} |
| 1117 |
); |
| 1118 |
|
| 1119 |
# what's imap LIST say after the move? |
| 1120 |
undef $imaptalk; |
| 1121 |
$self->{store}->disconnect(); |
| 1122 |
$imaptalk = $self->{store}->get_client(); |
| 1123 |
xlog "checking LIST on old backend"; |
| 1124 |
$data = $imaptalk->list("", "*"); |
| 1125 |
$self->assert_mailbox_structure($data, '/', { |
| 1126 |
'INBOX' => [qw( \\HasNoChildren )], |
| 1127 |
'Big' => [qw( \\HasChildren )], |
| 1128 |
'Big/Red/Dog' => [qw( \\HasNoChildren )], |
| 1129 |
}); |
| 1130 |
|
| 1131 |
my $backend2talk = $self->{backend2_store}->get_client(); |
| 1132 |
xlog "checking LIST on new backend"; |
| 1133 |
$data = $backend2talk->list("", "*"); |
| 1134 |
$self->assert_mailbox_structure($data, '/', { |
| 1135 |
'Big/Red' => [qw( \\HasNoChildren )], |
| 1136 |
}); |
| 1137 |
|
| 1138 |
$frontendtalk = $self->{frontend_store}->get_client(); |
| 1139 |
xlog "checking LIST on frontend"; |
| 1140 |
$data = $frontendtalk->list("", "*"); |
| 1141 |
$self->assert_mailbox_structure($data, '/', { |
| 1142 |
'INBOX' => [qw( \\HasNoChildren )], |
| 1143 |
'Big' => [qw( \\HasChildren )], |
| 1144 |
'Big/Red' => [qw( \\HasChildren )], |
| 1145 |
'Big/Red/Dog' => [qw( \\HasNoChildren )], |
| 1146 |
}); |
| 1147 |
} |
| 1148 |
|
| 1149 |
sub test_xfer_no_user_intermediates |
| 1150 |
:AllowMoves :AltNamespace :UnixHierarchySep |
| 1151 |
:min_version_3_5 |
| 1152 |
{ |
| 1153 |
my ($self) = @_; |
| 1154 |
|
| 1155 |
# set up some data for cassandane on backend1 |
| 1156 |
my $expected = $self->populate_user( |
| 1157 |
$self->{instance}, |
| 1158 |
$self->{backend1_store}, |
| 1159 |
[qw(INBOX Big Big/Red Big/Red/Dog)] |
| 1160 |
); |
| 1161 |
|
| 1162 |
my $admintalk = $self->{backend1_adminstore}->get_client(); |
| 1163 |
my $backend2_servername = $self->{backend2}->get_servername(); |
| 1164 |
|
| 1165 |
# what's the frontend mailboxes.db say before we move? |
| 1166 |
my $mailboxes_db = $self->{frontend}->read_mailboxes_db(); |
| 1167 |
xlog "XXX before move, frontend mailboxes.db:" . Dumper $mailboxes_db; |
| 1168 |
|
| 1169 |
# try to xfer individual non-INBOX mailboxes, all should be refused |
| 1170 |
foreach my $folder (qw(Big Big/Red Big/Red/Dog)) { |
| 1171 |
$admintalk->_imap_cmd('xfer', 0, {}, |
| 1172 |
"user/cassandane/$folder", |
| 1173 |
$backend2_servername); |
| 1174 |
$self->assert_str_equals( |
| 1175 |
'no', $admintalk->get_last_completion_response() |
| 1176 |
); |
| 1177 |
$self->assert_matches( |
| 1178 |
qr{Operation is not supported on mailbox}, |
| 1179 |
$admintalk->get_last_error() |
| 1180 |
); |
| 1181 |
} |
| 1182 |
|
| 1183 |
# everything should still be on the original backend |
| 1184 |
$self->check_user($self->{instance}, $self->{backend1_store}, $expected); |
| 1185 |
} |
| 1186 |
|
| 1187 |
# XXX test_xfer_partition |
| 1188 |
# XXX test_xfer_mboxpattern |
| 1189 |
# XXX shared mailboxes! |
| 1190 |
|
| 1191 |
sub test_copy_across_backends |
| 1192 |
:NoAltNamespace |
| 1193 |
{ |
| 1194 |
my ($self) = @_; |
| 1195 |
|
| 1196 |
my $shared = 'shared'; |
| 1197 |
|
| 1198 |
my $admintalk = $self->{backend2_adminstore}->get_client(); |
| 1199 |
|
| 1200 |
# create a shared folder (on backend2) |
| 1201 |
$admintalk->create($shared); |
| 1202 |
$self->assert_str_equals('ok', $admintalk->get_last_completion_response()); |
| 1203 |
$admintalk->setacl($shared, 'anyone', 'lrswi'); |
| 1204 |
$self->assert_str_equals('ok', $admintalk->get_last_completion_response()); |
| 1205 |
|
| 1206 |
# put some messages into the INBOX |
| 1207 |
my %exp; |
| 1208 |
$self->make_message("Message A", store => $self->{frontend_store}); |
| 1209 |
$exp{B} = $self->make_message("Message B", store => $self->{frontend_store}); |
| 1210 |
$self->make_message("Message C", store => $self->{frontend_store}); |
| 1211 |
$exp{D} = $self->make_message("Message D", store => $self->{frontend_store}); |
| 1212 |
|
| 1213 |
my $frontend = $self->{frontend_store}->get_client(); |
| 1214 |
|
| 1215 |
my $res = $frontend->select('INBOX'); |
| 1216 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 1217 |
|
| 1218 |
# expunge the some messages so that seqno != uid |
| 1219 |
$frontend->store('1,3', '+flags', '(\\Deleted)'); |
| 1220 |
$frontend->expunge(); |
| 1221 |
|
| 1222 |
$res = $frontend->copy('1:*', $shared); |
| 1223 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 1224 |
|
| 1225 |
$exp{B}->set_attribute('uid', 1); |
| 1226 |
$exp{D}->set_attribute('uid', 2); |
| 1227 |
$self->{frontend_store}->set_folder($shared); |
| 1228 |
$self->check_messages(\%exp, store => $self->{frontend_store}); |
| 1229 |
} |
| 1230 |
|
| 1231 |
sub test_replace_same_backend |
| 1232 |
:NoAltNamespace :min_version_3_9 |
| 1233 |
{ |
| 1234 |
# :min_version_3_9 checks backend1 version. The test below checks frontend |
| 1235 |
my ($maj, $min) = Cassandane::Instance->get_version('murder'); |
| 1236 |
if ($maj < 3 || ($maj == 3 && $min < 9)) { |
| 1237 |
return; |
| 1238 |
} |
| 1239 |
|
| 1240 |
my ($self) = @_; |
| 1241 |
|
| 1242 |
my $talk = $self->{frontend_store}->get_client(); |
| 1243 |
|
| 1244 |
my %exp; |
| 1245 |
$exp{A} = $self->make_message("Message A", store => $self->{store}); |
| 1246 |
$self->check_messages(\%exp); |
| 1247 |
|
| 1248 |
$talk->select('INBOX'); |
| 1249 |
|
| 1250 |
%exp = (); |
| 1251 |
$exp{B} = $self->{gen}->generate(subject => "Message B"); |
| 1252 |
|
| 1253 |
$talk->_imap_cmd('REPLACE', 0, '', "1", "INBOX", |
| 1254 |
{ Literal => $exp{B}->as_string() }); |
| 1255 |
$self->check_messages(\%exp); |
| 1256 |
} |
| 1257 |
|
| 1258 |
sub test_replace_across_backends |
| 1259 |
:NoAltNamespace :min_version_3_9 |
| 1260 |
{ |
| 1261 |
# :min_version_3_9 checks backend1 version. The test below checks frontend |
| 1262 |
my ($maj, $min) = Cassandane::Instance->get_version('murder'); |
| 1263 |
if ($maj < 3 || ($maj == 3 && $min < 9)) { |
| 1264 |
return; |
| 1265 |
} |
| 1266 |
|
| 1267 |
my ($self) = @_; |
| 1268 |
|
| 1269 |
my $shared = 'shared'; |
| 1270 |
|
| 1271 |
my $admintalk = $self->{backend2_adminstore}->get_client(); |
| 1272 |
|
| 1273 |
# create a shared folder (on backend2) |
| 1274 |
$admintalk->create($shared); |
| 1275 |
$self->assert_str_equals('ok', $admintalk->get_last_completion_response()); |
| 1276 |
$admintalk->setacl($shared, 'anyone', 'lrswi'); |
| 1277 |
$self->assert_str_equals('ok', $admintalk->get_last_completion_response()); |
| 1278 |
|
| 1279 |
# put some messages into the INBOX |
| 1280 |
$self->make_message("Message A", store => $self->{frontend_store}); |
| 1281 |
$self->make_message("Message B", store => $self->{frontend_store}); |
| 1282 |
|
| 1283 |
my $frontend = $self->{frontend_store}->get_client(); |
| 1284 |
|
| 1285 |
my $res = $frontend->select('INBOX'); |
| 1286 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 1287 |
|
| 1288 |
# expunge the first message so that seqno != uid |
| 1289 |
$frontend->store('1', '+flags', '(\\Deleted)'); |
| 1290 |
$frontend->expunge(); |
| 1291 |
|
| 1292 |
my %exp; |
| 1293 |
$exp{C} = $self->{gen}->generate(subject => "Message C", uid => 1); |
| 1294 |
|
| 1295 |
$res = $frontend->_imap_cmd('REPLACE', 0, '', "1", "shared", |
| 1296 |
{ Literal => $exp{C}->as_string() }); |
| 1297 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 1298 |
|
| 1299 |
$self->check_messages({}); |
| 1300 |
|
| 1301 |
$self->{frontend_store}->set_folder($shared); |
| 1302 |
$self->check_messages(\%exp, store => $self->{frontend_store}); |
| 1303 |
} |
| 1304 |
|
| 1305 |
sub test_proxy_search |
| 1306 |
{ |
| 1307 |
my ($self) = @_; |
| 1308 |
my $result; |
| 1309 |
|
| 1310 |
xlog $self, "append some messages"; |
| 1311 |
my %exp; |
| 1312 |
my $N = 10; |
| 1313 |
for (1..$N) |
| 1314 |
{ |
| 1315 |
my $msg = $self->make_message("Message $_"); |
| 1316 |
$exp{$_} = $msg; |
| 1317 |
} |
| 1318 |
xlog $self, "check the messages got there"; |
| 1319 |
$self->check_messages(\%exp); |
| 1320 |
|
| 1321 |
my $imaptalk = $self->{store}->get_client(); |
| 1322 |
|
| 1323 |
xlog $self, "EXPUNGE the 1st, 6th, and 10th"; |
| 1324 |
$imaptalk->store('1,6,10', '+FLAGS', '(\\Deleted)'); |
| 1325 |
$self->assert_str_equals('ok', $imaptalk->get_last_completion_response()); |
| 1326 |
$imaptalk->expunge(); |
| 1327 |
$self->assert_str_equals('ok', $imaptalk->get_last_completion_response()); |
| 1328 |
|
| 1329 |
my $frontend = $self->{frontend_store}->get_client(); |
| 1330 |
$frontend->examine('INBOX'); |
| 1331 |
|
| 1332 |
xlog $self, "SEARCH ALL"; |
| 1333 |
my $res = $frontend->search('all'); |
| 1334 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 1335 |
$self->assert_str_equals($res->[0], "1"); |
| 1336 |
$self->assert_str_equals($res->[1], "2"); |
| 1337 |
$self->assert_str_equals($res->[2], "3"); |
| 1338 |
$self->assert_str_equals($res->[3], "4"); |
| 1339 |
$self->assert_str_equals($res->[4], "5"); |
| 1340 |
$self->assert_str_equals($res->[5], "6"); |
| 1341 |
$self->assert_str_equals($res->[6], "7"); |
| 1342 |
|
| 1343 |
xlog $self, "UID SEARCH ALL"; |
| 1344 |
$frontend->uid(1); |
| 1345 |
$res = $frontend->search('all'); |
| 1346 |
$self->assert_str_equals('ok', $frontend->get_last_completion_response()); |
| 1347 |
$self->assert_str_equals($res->[0], "2"); |
| 1348 |
$self->assert_str_equals($res->[1], "3"); |
| 1349 |
$self->assert_str_equals($res->[2], "4"); |
| 1350 |
$self->assert_str_equals($res->[3], "5"); |
| 1351 |
$self->assert_str_equals($res->[4], "7"); |
| 1352 |
$self->assert_str_equals($res->[5], "8"); |
| 1353 |
$self->assert_str_equals($res->[6], "9"); |
| 1354 |
|
| 1355 |
xlog $self, "ESEARCH ALL"; |
| 1356 |
my @results = (); |
| 1357 |
my %handlers = |
| 1358 |
( |
| 1359 |
esearch => sub |
| 1360 |
{ |
| 1361 |
my (undef, $esearch) = @_; |
| 1362 |
push(@results, $esearch); |
| 1363 |
}, |
| 1364 |
); |
| 1365 |
|
| 1366 |
$res = $frontend->_imap_cmd('ESEARCH', 0, \%handlers, 'ALL'); |
| 1367 |
$self->assert_str_equals('ok', $res); |
| 1368 |
$self->assert_str_equals($results[0][3], "2:5,7:9"); |
| 1369 |
} |
| 1370 |
|
| 1371 |
1; |