Debian Codegraph @

cassandane/Cassandane/Cyrus/QResync.pm

raw
1 #!/usr/bin/perl
2 #
3 # Copyright (c) 2011-2020 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::QResync;
41 use strict;
42 use warnings;
43 use Cwd qw(abs_path);
44 use File::Path qw(mkpath);
45 use DateTime;
46 use Data::Dumper;
47
48 use lib '.';
49 use base qw(Cassandane::Cyrus::TestCase);
50 use Cassandane::Util::Log;
51 use Cassandane::Util::NetString;
52
53
54 sub new
55 {
56 my $class = shift;
57 return $class->SUPER::new({ adminstore => 1, services => ['smmap', 'imap'] }, @_);
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 $self->SUPER::tear_down();
70 }
71
72 sub test_qresync_simple
73 {
74 my ($self) = @_;
75
76 xlog $self, "Make some messages";
77 my $uid = 1;
78 my %msgs;
79 for (1..50)
80 {
81 $msgs{$uid} = $self->make_message("Message $uid");
82 $msgs{$uid}->set_attribute('uid', $uid);
83 $uid++;
84 }
85
86 my $talk = $self->{store}->get_client();
87 $talk->select("INBOX");
88 my $uidvalidity = $talk->get_response_code('uidvalidity');
89
90 xlog $self, "Mark some messages \\Deleted";
91 $talk->enable("qresync");
92 $talk->store('5:10,25:45', '+flags', '(\\Deleted)');
93
94 xlog $self, "Expunge messages";
95 $talk->expunge();
96 my @vanished = $talk->get_response_code('vanished');
97 $self->assert_equals("5:10,25:45", $vanished[0][0]);
98
99 xlog "QResync mailbox";
100 $talk->unselect();
101 $talk->select("INBOX", "(QRESYNC ($uidvalidity 0))" => 1);
102 @vanished = $talk->get_response_code('vanished');
103 $self->assert_num_equals(23, $talk->get_response_code('exists'));
104 $self->assert_equals("5:10,25:45", $vanished[0][1]);
105 }
106
107 1;