| 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::List; |
| 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 |
$Data::Dumper::Sortkeys = 1; |
| 54 |
|
| 55 |
sub new |
| 56 |
{ |
| 57 |
my ($class, @args) = @_; |
| 58 |
|
| 59 |
my $config = Cassandane::Config->default()->clone(); |
| 60 |
|
| 61 |
return $class->SUPER::new({ config => $config, adminstore => 1 }, @args); |
| 62 |
} |
| 63 |
|
| 64 |
sub set_up |
| 65 |
{ |
| 66 |
my ($self) = @_; |
| 67 |
|
| 68 |
$self->SUPER::set_up(); |
| 69 |
} |
| 70 |
|
| 71 |
sub tear_down |
| 72 |
{ |
| 73 |
my ($self) = @_; |
| 74 |
|
| 75 |
$self->SUPER::tear_down(); |
| 76 |
} |
| 77 |
|
| 78 |
# tests based on rfc 5258 examples: |
| 79 |
# https://tools.ietf.org/html/rfc5258#section-5 |
| 80 |
|
| 81 |
# TODO not sure how to set up test data for remote mailboxes... |
| 82 |
#sub test_rfc5258_ex04_remote_children |
| 83 |
#{ |
| 84 |
# my ($self) = @_; |
| 85 |
# $self->assert(0, 'FIXME test not implemented'); |
| 86 |
#} |
| 87 |
|
| 88 |
#sub test_rfc5258_ex05_remote_subscribed |
| 89 |
#{ |
| 90 |
# my ($self) = @_; |
| 91 |
# $self->assert(0, 'FIXME test not implemented'); |
| 92 |
#} |
| 93 |
|
| 94 |
#sub test_rfc5258_ex06_remote_return_subscribed |
| 95 |
#{ |
| 96 |
# my ($self) = @_; |
| 97 |
# $self->assert(0, 'FIXME test not implemented'); |
| 98 |
#} |
| 99 |
|
| 100 |
#sub test_rfc5258_ex09_childinfo |
| 101 |
#{ |
| 102 |
# my ($self) = @_; |
| 103 |
# $self->assert(0, 'FIXME test not implemented'); |
| 104 |
#} |
| 105 |
|
| 106 |
#sub test_rfc5258_ex10_multiple_mailbox_patterns_childinfo |
| 107 |
#{ |
| 108 |
# my ($self) = @_; |
| 109 |
# $self->assert(0, 'FIXME test not implemented'); |
| 110 |
#} |
| 111 |
|
| 112 |
#sub test_rfc5258_ex11_missing_hierarchy_elements |
| 113 |
#{ |
| 114 |
# my ($self) = @_; |
| 115 |
# $self->assert(0, 'FIXME test not implemented'); |
| 116 |
#} |
| 117 |
|
| 118 |
# tests based on rfc 6154 examples: |
| 119 |
# https://tools.ietf.org/html/rfc6154#section-5 |
| 120 |
|
| 121 |
# "An IMAP server that supports this extension MAY include any or all of the |
| 122 |
# following attributes in responses to the non-extended IMAP LIST command." |
| 123 |
# |
| 124 |
# Cyrus does not (at least, not at the moment), so this test is disabled. |
| 125 |
sub bogus_test_rfc6154_ex01_list_non_extended |
| 126 |
:UnixHierarchySep :AltNamespace |
| 127 |
{ |
| 128 |
my ($self) = @_; |
| 129 |
|
| 130 |
my $imaptalk = $self->{store}->get_client(); |
| 131 |
|
| 132 |
$self->setup_mailbox_structure($imaptalk, [ |
| 133 |
[ 'create' => [qw( ToDo Projects Projects/Foo SentMail MyDrafts Trash) ] ], |
| 134 |
]); |
| 135 |
|
| 136 |
$imaptalk->setmetadata("SentMail", "/private/specialuse", "\\Sent"); |
| 137 |
$self->assert_equals('ok', $imaptalk->get_last_completion_response()); |
| 138 |
|
| 139 |
$imaptalk->setmetadata("MyDrafts", "/private/specialuse", "\\Drafts"); |
| 140 |
$self->assert_equals('ok', $imaptalk->get_last_completion_response()); |
| 141 |
|
| 142 |
$imaptalk->setmetadata("Trash", "/private/specialuse", "\\Trash"); |
| 143 |
$self->assert_equals('ok', $imaptalk->get_last_completion_response()); |
| 144 |
|
| 145 |
my $alldata = $imaptalk->list("", "%"); |
| 146 |
|
| 147 |
$self->assert_mailbox_structure($alldata, '/', { |
| 148 |
'INBOX' => [qw( \\HasNoChildren )], |
| 149 |
'ToDo' => [qw( \\HasNoChildren )], |
| 150 |
'Projects' => [qw( \\HasChildren )], |
| 151 |
'SentMail' => [qw( \\Sent \\HasNoChildren )], |
| 152 |
'MyDrafts' => [qw( \\Drafts \\HasNoChildren )], |
| 153 |
'Trash' => [qw( \\Trash \\HasNoChildren )], |
| 154 |
}); |
| 155 |
} |
| 156 |
|
| 157 |
use Cassandane::Tiny::Loader 'tiny-tests/List'; |
| 158 |
|
| 159 |
1; |