#!perl
use Cassandane::Tiny;

sub test_lookup_only_shared
    :UnixHierarchySep :AltNamespace
{
    my ($self) = @_;

    my $admintalk = $self->{adminstore}->get_client();
    $admintalk->create('shared');
    $self->assert_str_equals('ok',
        $admintalk->get_last_completion_response());
    $admintalk->setacl('shared',
        'cassandane' => 'l');
    $self->assert_str_equals('ok',
        $admintalk->get_last_completion_response());

    my $imaptalk = $self->{store}->get_client();

    my $data = $imaptalk->list("", "*");
    $self->assert_mailbox_structure($data, '/', {
        'INBOX' => [qw( \\HasNoChildren )],
        'Shared Folders/shared' => [qw( \\HasNoChildren )],
    });

    # implicit "anyone:r" on shared mailboxes means that the
    # cassandane user can also select this, despite only having
    # "l" of their own
    $imaptalk->select('Shared Folders/shared');
    $self->assert_str_equals('ok',
        $imaptalk->get_last_completion_response());
}
