| 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::Objectid; |
| 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 |
use Cassandane::Util::Log; |
| 49 |
use Cassandane::Generator; |
| 50 |
use Cassandane::MessageStoreFactory; |
| 51 |
use Cassandane::Instance; |
| 52 |
|
| 53 |
sub new |
| 54 |
{ |
| 55 |
my $class = shift; |
| 56 |
return $class->SUPER::new({adminstore => 1}, @_); |
| 57 |
} |
| 58 |
|
| 59 |
sub set_up |
| 60 |
{ |
| 61 |
my ($self) = @_; |
| 62 |
$self->SUPER::set_up(); |
| 63 |
} |
| 64 |
|
| 65 |
sub tear_down |
| 66 |
{ |
| 67 |
my ($self) = @_; |
| 68 |
$self->SUPER::tear_down(); |
| 69 |
} |
| 70 |
|
| 71 |
# |
| 72 |
# Test uniqueid and rename |
| 73 |
# |
| 74 |
sub test_uniqueid |
| 75 |
:AltNamespace :min_version_3_1 |
| 76 |
{ |
| 77 |
my ($self) = @_; |
| 78 |
|
| 79 |
my $admintalk = $self->{adminstore}->get_client(); |
| 80 |
my $talk = $self->{store}->get_client(); |
| 81 |
|
| 82 |
$talk->create('foo'); |
| 83 |
$talk->create('bar'); |
| 84 |
$talk->create('foo'); |
| 85 |
my $status1 = $talk->status('foo', "(mailboxid)"); |
| 86 |
my $status2 = $talk->status('bar', "(mailboxid)"); |
| 87 |
|
| 88 |
$talk->rename('foo', 'renamed'); |
| 89 |
my $status3 = $talk->status('renamed', "(mailboxid)"); |
| 90 |
my $status4 = $talk->status('bar', "(mailboxid)"); |
| 91 |
|
| 92 |
$self->assert_str_equals($status1->{mailboxid}[0], $status3->{mailboxid}[0]); |
| 93 |
$self->assert_str_equals($status2->{mailboxid}[0], $status4->{mailboxid}[0]); |
| 94 |
|
| 95 |
$talk->list('', '*', 'return', [ "status", [ "mailboxid" ] ]); |
| 96 |
} |
| 97 |
|
| 98 |
# |
| 99 |
# Test uniqueid and rename |
| 100 |
# |
| 101 |
sub test_emailid_threadid |
| 102 |
:AltNamespace :Conversations :min_version_3_1 |
| 103 |
{ |
| 104 |
my ($self) = @_; |
| 105 |
|
| 106 |
my $admintalk = $self->{adminstore}->get_client(); |
| 107 |
my $talk = $self->{store}->get_client(); |
| 108 |
|
| 109 |
$talk->create('foo'); |
| 110 |
|
| 111 |
# check IMAP server has the XCONVERSATIONS capability |
| 112 |
$self->assert($self->{store}->get_client()->capability()->{xconversations}); |
| 113 |
|
| 114 |
my %exp; |
| 115 |
|
| 116 |
$self->{store}->set_fetch_attributes('uid', 'cid'); |
| 117 |
|
| 118 |
xlog $self, "generating message A"; |
| 119 |
$exp{A} = $self->make_message("Message A"); |
| 120 |
$exp{A}->set_attributes(uid => 1, cid => $exp{A}->make_cid()); |
| 121 |
$self->check_messages(\%exp); |
| 122 |
|
| 123 |
xlog $self, "generating message B"; |
| 124 |
$exp{B} = $self->make_message("Re: Message A", references => [ $exp{A} ]); |
| 125 |
$exp{B}->set_attributes(uid => 2, cid => $exp{A}->make_cid()); |
| 126 |
$self->check_messages(\%exp); |
| 127 |
|
| 128 |
xlog $self, "generating message C"; |
| 129 |
$exp{C} = $self->make_message("Message C"); |
| 130 |
$exp{C}->set_attributes(uid => 3, cid => $exp{C}->make_cid()); |
| 131 |
$self->check_messages(\%exp); |
| 132 |
|
| 133 |
$talk->select('INBOX'); |
| 134 |
my $data = $talk->fetch('1:*', "(emailid threadid)"); |
| 135 |
|
| 136 |
$talk->search('emailid', $data->{1}{emailid}); |
| 137 |
$talk->search('threadid', $data->{1}{threadid}); |
| 138 |
|
| 139 |
$talk->move("2", "foo"); |
| 140 |
|
| 141 |
$talk->fetch('1:*', "(emailid threadid)"); |
| 142 |
|
| 143 |
$talk->select('foo'); |
| 144 |
$talk->fetch('1:*', "(emailid threadid)"); |
| 145 |
|
| 146 |
$talk->select('INBOX'); |
| 147 |
|
| 148 |
my $email = <<EOF; |
| 149 |
Subject: foo |
| 150 |
Date: bar |
| 151 |
From: <foobar\@example.com> |
| 152 |
|
| 153 |
Body |
| 154 |
EOF |
| 155 |
|
| 156 |
my $email2 = <<EOF; |
| 157 |
Subject: foo |
| 158 |
Date: bar |
| 159 |
From: <foobar\@example.com> |
| 160 |
|
| 161 |
Body2 |
| 162 |
EOF |
| 163 |
|
| 164 |
$email =~ s/\r?\n/\r\n/gs; |
| 165 |
$email2 =~ s/\r?\n/\r\n/gs; |
| 166 |
|
| 167 |
$talk->append("INBOX", "()", " 7-Feb-1994 22:43:04 -0800", { Literal => "$email" }, |
| 168 |
"()", " 7-Feb-1994 22:43:04 -0800", { Literal => "$email2" }); |
| 169 |
|
| 170 |
# XXX and then what??? is this test incomplete? |
| 171 |
} |
| 172 |
|
| 173 |
1; |