| 1 |
#!/usr/bin/perl |
| 2 |
# |
| 3 |
# Copyright (c) 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" 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 |
# Level 1, 91 William St |
| 23 |
# Melbourne 3000 |
| 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 |
| 32 |
# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 33 |
# AND FITNESS, IN NO EVENT SHALL OPERA SOFTWARE AUSTRALIA BE LIABLE |
| 34 |
# FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 35 |
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN |
| 36 |
# AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING |
| 37 |
# OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 38 |
# |
| 39 |
|
| 40 |
package Cassandane::Cyrus::Move; |
| 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::Instance; |
| 49 |
|
| 50 |
sub new |
| 51 |
{ |
| 52 |
my $class = shift; |
| 53 |
my $config = Cassandane::Config::default()->clone(); |
| 54 |
$config->set("conversations", "yes"); |
| 55 |
$config->set("reverseacls", "yes"); |
| 56 |
$config->set("annotation_allow_undefined", "yes"); |
| 57 |
return $class->SUPER::new({ config => $config, adminstore => 1 }, @_); |
| 58 |
} |
| 59 |
|
| 60 |
sub set_up |
| 61 |
{ |
| 62 |
my ($self) = @_; |
| 63 |
$self->SUPER::set_up(); |
| 64 |
} |
| 65 |
|
| 66 |
sub tear_down |
| 67 |
{ |
| 68 |
my ($self) = @_; |
| 69 |
|
| 70 |
$self->SUPER::tear_down(); |
| 71 |
} |
| 72 |
|
| 73 |
sub test_move_new_user |
| 74 |
:NoAltNameSpace |
| 75 |
{ |
| 76 |
# test whether the imap_admins setting works correctly |
| 77 |
my ($self) = @_; |
| 78 |
|
| 79 |
my $admintalk = $self->{adminstore}->get_client(); |
| 80 |
my $talk = $self->{store}->get_client(); |
| 81 |
|
| 82 |
$admintalk->create("user.user2"); |
| 83 |
$admintalk->create("user.user2.sub"); |
| 84 |
$admintalk->setacl("user.user2.sub", "cassandane", "lrswited"); |
| 85 |
|
| 86 |
$talk->enable("QRESYNC"); |
| 87 |
$talk->select("INBOX"); |
| 88 |
|
| 89 |
xlog $self, "create a message and mark it \\Seen"; |
| 90 |
$self->make_message("Message foo"); |
| 91 |
$talk->store("1", "+flags", "\\Seen"); |
| 92 |
|
| 93 |
xlog $self, "moving to second user works"; |
| 94 |
$talk->move("1", "user.user2.sub"); |
| 95 |
$talk->select("user.user2.sub"); |
| 96 |
my $res = $talk->fetch("1", "(flags)"); |
| 97 |
my $flags = $res->{1}->{flags}; |
| 98 |
$self->assert(grep { $_ eq "\\Seen" } @$flags); |
| 99 |
|
| 100 |
xlog $self, "moving back works"; |
| 101 |
$talk->move("1", "INBOX"); |
| 102 |
$talk->select("INBOX"); |
| 103 |
$res = $talk->fetch("1", "(flags)"); |
| 104 |
$flags = $res->{1}->{flags}; |
| 105 |
$self->assert(grep { $_ eq "\\Seen" } @$flags); |
| 106 |
} |
| 107 |
|
| 108 |
1; |