Skip to content

Commit

Permalink
Merge branch 'cyrusimap:master' into gk/exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
GuidoKiener committed Dec 18, 2023
2 parents 0799088 + 9360217 commit cd0db98
Show file tree
Hide file tree
Showing 18 changed files with 223 additions and 634 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ imap/imapd
imap/ipurge
imap/jmap_err.c
imap/jmap_err.h
imap/jmap_expire
imap/lmtp_err.c
imap/lmtp_err.h
imap/lmtpd
Expand Down
7 changes: 0 additions & 7 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,6 @@ endif # SERVER

endif # SIEVE

if JMAP
sbin_PROGRAMS += imap/jmap_expire
endif # JMAP

EXTRA_DIST = \
COPYING \
README.md \
Expand Down Expand Up @@ -965,9 +961,6 @@ imap_idled_LDADD = $(LD_UTILITY_ADD)
imap_calalarmd_SOURCES = imap/calalarmd.c imap/mutex_fake.c
imap_calalarmd_LDADD = $(LD_SERVER_ADD)

imap_jmap_expire_SOURCES = imap/cli_fatal.c imap/jmap_expire.c imap/mutex_fake.c
imap_jmap_expire_LDADD = $(LD_UTILITY_ADD)

imap_imapd_SOURCES = \
imap/imap_proxy.c \
imap/imap_proxy.h \
Expand Down
5 changes: 5 additions & 0 deletions cassandane/Cassandane/Cyrus/TestCase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ magic(NoCheckSyslog => sub {
my $self = shift;
$self->{no_check_syslog} = 1;
});
magic(JmapMaxCalendarEventNotifs => sub {
my $conf = shift;
# set to some small number
$conf->config_set('jmap_max_calendareventnotifs' => 10);
});

# Run any magic handlers indicated by the test name or attributes
sub _run_magic
Expand Down
128 changes: 128 additions & 0 deletions cassandane/tiny-tests/JMAPCalendars/calendareventnotification-prune
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!perl
use Cassandane::Tiny;

sub test_calendareventnotification_prune
:min_version_3_9 :needs_component_jmap :JmapMaxCalendarEventNotifs
{
my ($self) = @_;
my $jmap = $self->{jmap};

my $jmap_max_calendareventnotifs = $self->{instance}->{
config}->get('jmap_max_calendareventnotifs');
$self->assert_not_null($jmap_max_calendareventnotifs);

my ($manJmap) = $self->create_user('manifold');
$manJmap->DefaultUsing([
'urn:ietf:params:jmap:core',
'urn:ietf:params:jmap:calendars',
'urn:ietf:params:jmap:principals',
'https://cyrusimap.org/ns/jmap/calendars',
]);

xlog $self, "Share calendar";
my $res = $jmap->CallMethods([
['Calendar/set', {
update => {
Default => {
shareWith => {
manifold => {
mayReadFreeBusy => JSON::true,
mayReadItems => JSON::true,
mayUpdatePrivate => JSON::true,
mayWriteOwn => JSON::true,
mayAdmin => JSON::false
},
},
},
},
}, 'R1'],
]);
$self->assert(exists $res->[0][1]{updated}{Default});

xlog $self, "Create event notification";
my $res = $jmap->CallMethods([
['CalendarEvent/set', {
create => {
event1 => {
title => 'event1',
calendarIds => {
Default => JSON::true,
},
start => '2011-01-01T04:05:06',
duration => 'PT1H',
},
},
}, 'R1'],
]);
$self->assert_not_null($res->[0][1]{created}{event1});

xlog $self, "Get event notification";
$res = $manJmap->CallMethods([
['CalendarEventNotification/get', {
accountId => 'cassandane',
}, 'R1'],
]);
$self->assert_num_equals(1, scalar @{$res->[0][1]{list}});
my $notif1Id = $res->[0][1]{list}[0]{id};
$self->assert_not_null($notif1Id);

xlog $self, "Create maximum count of allowed notifications";
for my $i (2 .. $jmap_max_calendareventnotifs) {
my $res = $jmap->CallMethods([
['CalendarEvent/set', {
create => {
"event$i" => {
title => "event$i",
calendarIds => {
Default => JSON::true,
},
start => '2011-01-01T04:05:06',
duration => 'PT1H',
},
},
}, 'R1'],
]);
$self->assert_not_null($res->[0][1]{created}{"event$i"});
}

xlog $self, "Get event notifications";
$res = $manJmap->CallMethods([
['CalendarEventNotification/get', {
accountId => 'cassandane',
properties => ['id'],
}, 'R1'],
]);
$self->assert_num_equals($jmap_max_calendareventnotifs, scalar @{$res->[0][1]{list}});

xlog $self, "Assert first event notification exists";
$self->assert_equals(1, scalar grep { $_->{id} eq $notif1Id } @{$res->[0][1]{list}});

xlog $self, "Create one more event notification";
my $res = $jmap->CallMethods([
['CalendarEvent/set', {
create => {
eventX => {
title => 'eventX',
calendarIds => {
Default => JSON::true,
},
start => '2011-01-01T04:05:06',
duration => 'PT1H',
},
},
}, 'R1'],
]);
$self->assert_not_null($res->[0][1]{created}{eventX});

xlog $self, "Get event notifications";
$res = $manJmap->CallMethods([
['CalendarEventNotification/get', {
accountId => 'cassandane',
properties => ['id'],
}, 'R1'],
]);
$self->assert_num_equals($jmap_max_calendareventnotifs, scalar @{$res->[0][1]{list}});

xlog $self, "Assert first event notification does not exist";
$self->assert_equals(0, scalar grep { $_->{id} eq $notif1Id } @{$res->[0][1]{list}});
}
16 changes: 0 additions & 16 deletions changes/next/cyr_expire_jmap

This file was deleted.

15 changes: 15 additions & 0 deletions changes/next/prune_calendareventnotifs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Description:

Prune JMAP CalendarEventNotification objects each time a new one is created.


Config changes:

jmap_max_calendareventnotifs


Upgrade instructions:

The default maximum count of CalendarEventNotifications is set to 200
per account. Installations that need any other count or want to not
prune notifications must update the jmap_max_calendareventnotifs config.
13 changes: 13 additions & 0 deletions cunit/message.testc
Original file line number Diff line number Diff line change
Expand Up @@ -1391,4 +1391,17 @@ static void test_parse_bogus_charset_params(void)
#undef TESTCASE
}

/*
* Verifies that message_parse_received_date() does not read
* uninitialized data in the second call to message_parse_string()
*/
static void test_parse_received_semicolon(void)
{
static const char msg[] = "Received: abc;\r\n\r\nd";
struct body body;
memset(&body, 0x45, sizeof(body));
CU_ASSERT_EQUAL(message_parse_mapped(msg, sizeof(msg)-1, &body, NULL), 0);
CU_ASSERT_PTR_NULL(body.received_date);
message_free_body(&body);
}
/* vim: set ft=c: */
5 changes: 0 additions & 5 deletions doc/examples/cyrus_conf/normal-master.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ EVENTS {

# this is only necessary if caching TLS sessions
tlsprune cmd="tls_prune" at=0400

# this is only necessary if CalDAV or JMAP are enabled
# expire JMAP notifications after 7 days and
# unlink expired JMAP notifications after 1 day
jmapprune cmd="jmap_expire -E 7d -X 1d" at 0500
}

DAEMON {
Expand Down
5 changes: 0 additions & 5 deletions doc/examples/cyrus_conf/normal-replica.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ EVENTS {

# this is only necessary if caching TLS sessions
tlsprune cmd="tls_prune" at=0400

# this is only necessary if CalDAV or JMAP are enabled
# expire JMAP notifications after 7 days and
# unlink expired JMAP notifications after 1 day
jmapprune cmd="jmap_expire -E 7d -X 1d" at 0500
}

DAEMON {
Expand Down
5 changes: 0 additions & 5 deletions doc/examples/cyrus_conf/normal.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ EVENTS {

# this is only necessary if caching TLS sessions
tlsprune cmd="tls_prune" at=0400

# this is only necessary if CalDAV or JMAP are enabled
# expire JMAP notifications after 7 days and
# unlink expired JMAP notifications after 1 day
jmapprune cmd="jmap_expire -E 7d -X 1d" at 0500
}

DAEMON {
Expand Down
5 changes: 0 additions & 5 deletions doc/examples/cyrus_conf/small.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ EVENTS {

# this is only necessary if caching TLS sessions
tlsprune cmd="tls_prune" at=0400

# this is only necessary if CalDAV or JMAP are enabled
# expire JMAP notifications after 7 days and
# unlink expired JMAP notifications after 1 day
jmapprune cmd="jmap_expire -E 7d -X 1d" at 0500
}

DAEMON {
Expand Down
Loading

0 comments on commit cd0db98

Please sign in to comment.