#!perl
use Cassandane::Tiny;

sub test_mailbox_set_parent_acl
    :min_version_3_1
{
    my ($self) = @_;

    my $jmap = $self->{jmap};
    my $admintalk = $self->{adminstore}->get_client();

    xlog $self, "get inbox";
    my $res = $jmap->CallMethods([['Mailbox/get', { }, "R1"]]);
    my $inbox = $res->[0][1]{list}[0];
    $self->assert_str_equals("Inbox", $inbox->{name});

    xlog $self, "get inbox ACL";
    my $parentacl = $admintalk->getacl("user.cassandane");

    xlog $self, "create mailbox";
    $res = $jmap->CallMethods([
            ['Mailbox/set', { create => { "1" => {
                            name => "foo",
                            role => undef
             }}}, "R1"]
    ]);
    $self->assert_not_null($res->[0][1]{created});

    xlog $self, "get new mailbox ACL";
    my $myacl = $admintalk->getacl("user.cassandane.foo");

    xlog $self, "assert ACL matches parent ACL";
    $self->assert_deep_equals($parentacl, $myacl);
}
