#!perl
use Cassandane::Tiny;

sub test_calendar_get_freebusy_only
    :min_version_3_5 :JMAPExtensions :NoAltNameSpace
    ($self)
{
    my $jmap = $self->default_user->jmap;
    my $default_cal_id = $self->default_user->calendars->default->id;

    xlog $self, "create other user";
    my $admintalk = $self->{adminstore}->get_client();
    $admintalk->create('user.other');
    $admintalk->setacl('user.other', admin => 'lrswipkxtecdan') or die;
    $admintalk->setacl('user.other', other => 'lrswipkxtecdn') or die;

    my $other_user = $self->{instance}->create_user_without_setup('other');
    my $otherJmap = $other_user->jmap;
    $otherJmap->DefaultUsing([
        'urn:ietf:params:jmap:core',
        'https://cyrusimap.org/ns/jmap/calendars',
    ]);

    my $res = $otherJmap->CallMethods([
        ['Calendar/get', {
            properties => ['id'],
        }, 'R1'],
    ]);
    $admintalk->setacl('user.other.#calendars.Default', cassandane => 'l9') or die;

    my $session = $jmap->get_client_session->client_session;

    my $capabilities = $session->{accounts}{other}{accountCapabilities};
    $self->assert_not_null($capabilities->{'https://cyrusimap.org/ns/jmap/calendars'});

    $res = $jmap->CallMethods([
        ['Calendar/get', {
            accountId => 'other',
            properties => ['id'],
        }, 'R1'],
    ]);
    $self->assert_deep_equals([], $res->[0][1]{list});
}
