#!perl
use Cassandane::Tiny;

sub test_localdelete_other
    :UnixHierarchySep :AltNamespace
    ($self)
{
    $self->{instance}->create_user("other");

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

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

    # shouldn't be able to delete another user's mailbox
    $imaptalk->delete('Other Users/other/foo');
    $self->assert_str_equals('no', $imaptalk->get_last_completion_response());
    $self->assert_matches(qr{Permission denied}, $imaptalk->get_last_error());

    # shouldn't be able to localdelete it either!
    $imaptalk->localdelete('Other Users/other/foo');
    $self->assert_str_equals('no', $imaptalk->get_last_completion_response());
    $self->assert_matches(qr{Permission denied}, $imaptalk->get_last_error());
}
