#!perl
use Cassandane::Tiny;

sub test_log_missing_acl ($self)
{
    $self->start_my_instances();

    my $imap = $self->{store}->get_client();
    my $admin = $self->{adminstore}->get_client();

    $self->{instance}->create_user("other");

    my @testCases = ({
        flag => '$Artisanal',
        acl => 'lrsitne',
        need_rights => 'w'
    }, {
        flag => '\Seen',
        acl => 'lritne',
        need_rights => 's'
    });

    foreach (@testCases) {
        $admin->setacl("user.other", "cassandane", $_->{acl}) or die;

        $self->{instance}->getsyslog();
        $self->{store}->set_folder('Other Users.other');
        $self->make_message("Email", body => "set_flag $_->{flag}\r\n",
            store => $self->{store}) or die;
        # logfmt escapes the backslash in a system flag like \Seen, and
        # quotes any value it had to escape
        my $flag = $_->{flag} =~ s{\\}{\\\\}gr;
        my $wantLog = qr{
            event=append\.flag\.denied
            .*
            \smsg\.flag="?\Q$flag\E"?
            \sacl\.needed=\Q$_->{need_rights}\E
        }x;
        $self->assert_syslog_matches($self->{instance}, $wantLog);
    }
}
