Skip to content

Commit

Permalink
Merge pull request #4995 from ksmurchison/sieve_processcalendar
Browse files Browse the repository at this point in the history
Sieve: update to latest processcalendar spec
  • Loading branch information
ksmurchison committed Aug 19, 2024
2 parents fdfb24a + 262a1fc commit 120682c
Show file tree
Hide file tree
Showing 55 changed files with 976 additions and 312 deletions.
2 changes: 1 addition & 1 deletion cassandane/Cassandane/Cyrus/Sieve.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ sub new
}
$config->set(sievenotifier => 'mailto');
$config->set(caldav_realm => 'Cassandane');
$config->set(httpmodules => ['caldav', 'jmap']);
$config->set(httpmodules => ['caldav', 'carddav', 'jmap']);
$config->set(calendar_user_address_set => 'example.com');
$config->set(httpallowcompress => 'no');
$config->set(caldav_historical_age => -1);
Expand Down
7 changes: 3 additions & 4 deletions cassandane/tiny-tests/Sieve/imip_add
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use Cassandane::Tiny;

sub test_imip_add
:needs_component_sieve :needs_component_httpd :min_version_3_7
:want_service_http
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

Expand All @@ -19,9 +18,9 @@ sub test_imip_add

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["body", "variables", "imap4flags", "vnd.cyrus.imip"];
require ["body", "variables", "imap4flags", "processcalendar"];
if body :content "text/calendar" :contains "\nMETHOD:" {
processimip :outcome "outcome";
processcalendar :outcome "outcome";
if string "\${outcome}" "updated" {
setflag "\\\\Flagged";
}
Expand Down
65 changes: 65 additions & 0 deletions cassandane/tiny-tests/Sieve/imip_allow_public
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!perl
use Cassandane::Tiny;

sub test_imip_allow_public
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

my $IMAP = $self->{store}->get_client();
$self->{store}->_select();
$self->assert_num_equals(1, $IMAP->uid());
$self->{store}->set_fetch_attributes(qw(uid flags));

xlog $self, "Create calendar user";
my $CalDAV = $self->{caldav};
my $CalendarId = 'Default';
my $uuid = "6de280c9-edff-4019-8ebd-cfebc73f8201";

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["variables", "imap4flags", "processcalendar"];
processcalendar :allowpublic :outcome "outcome";
if string "\${outcome}" "added" {
setflag "\\\\Flagged";
}
EOF
);

my $imip = <<EOF;
Date: Thu, 23 Sep 2021 09:06:18 -0400
To: Cassandane <cassandane\@example.com>
Message-ID: <$uuid\@example.net>
Content-Type: text/calendar; component=VEVENT
X-Cassandane-Unique: $uuid
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.10.4//EN
BEGIN:VEVENT
CREATED:20210923T034327Z
UID:$uuid
DTEND;TZID=America/New_York:20210923T183000
TRANSP:OPAQUE
SUMMARY:An Event
DTSTART;TZID=America/New_York:20210923T153000
DTSTAMP:20210923T034327Z
SEQUENCE:0
END:VEVENT
END:VCALENDAR
EOF

xlog $self, "Deliver iMIP invite";
my $msg = Cassandane::Message->new(raw => $imip);
$msg->set_attribute(uid => 1,
flags => [ '\\Recent', '\\Flagged' ]);
$self->{instance}->deliver($msg);

xlog $self, "Check that the message made it to INBOX";
$self->check_messages({ 1 => $msg }, check_guid => 0);

xlog $self, "Check that the event made it to calendar";
my $events = $CalDAV->GetEvents($CalendarId);
$self->assert_equals(1, scalar @$events);
$self->assert_str_equals($uuid, $events->[0]{uid});
}
7 changes: 3 additions & 4 deletions cassandane/tiny-tests/Sieve/imip_cancel
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use Cassandane::Tiny;

sub test_imip_cancel
:needs_component_sieve :needs_component_httpd :min_version_3_5
:want_service_http
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

Expand All @@ -19,9 +18,9 @@ sub test_imip_cancel

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["body", "variables", "imap4flags", "vnd.cyrus.imip"];
require ["body", "variables", "imap4flags", "processcalendar"];
if body :content "text/calendar" :contains "\nMETHOD:" {
processimip :outcome "outcome";
processcalendar :outcome "outcome";
if string "\${outcome}" "updated" {
setflag "\\\\Flagged";
}
Expand Down
7 changes: 3 additions & 4 deletions cassandane/tiny-tests/Sieve/imip_cancel_delete
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use Cassandane::Tiny;

sub test_imip_cancel_delete
:needs_component_sieve :needs_component_httpd :min_version_3_5
:want_service_http
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

Expand All @@ -19,9 +18,9 @@ sub test_imip_cancel_delete

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["body", "variables", "imap4flags", "vnd.cyrus.imip"];
require ["body", "variables", "imap4flags", "processcalendar"];
if body :content "text/calendar" :contains "\nMETHOD:" {
processimip :deletecanceled :outcome "outcome";
processcalendar :deletecanceled :outcome "outcome";
if string "\${outcome}" "deleted" {
setflag "\\\\Flagged";
}
Expand Down
7 changes: 3 additions & 4 deletions cassandane/tiny-tests/Sieve/imip_cancel_instance
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use Cassandane::Tiny;

sub test_imip_cancel_instance
:needs_component_sieve :needs_component_httpd :min_version_3_7
:want_service_http
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

Expand All @@ -19,9 +18,9 @@ sub test_imip_cancel_instance

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["body", "variables", "imap4flags", "vnd.cyrus.imip"];
require ["body", "variables", "imap4flags", "processcalendar"];
if body :content "text/calendar" :contains "\nMETHOD:" {
processimip :deletecanceled :outcome "outcome";
processcalendar :deletecanceled :outcome "outcome";
if string "\${outcome}" "updated" {
setflag "\\\\Flagged";
}
Expand Down
7 changes: 3 additions & 4 deletions cassandane/tiny-tests/Sieve/imip_cancel_to_organizer
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use Cassandane::Tiny;

sub test_imip_cancel_to_organizer
:needs_component_sieve :needs_component_httpd :min_version_3_5
:want_service_http
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

Expand All @@ -19,9 +18,9 @@ sub test_imip_cancel_to_organizer

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["body", "variables", "imap4flags", "vnd.cyrus.imip"];
require ["body", "variables", "imap4flags", "processcalendar"];
if body :content "text/calendar" :contains "\nMETHOD:" {
processimip :outcome "outcome";
processcalendar :outcome "outcome";
if string "\${outcome}" "updated" {
setflag "\\\\Flagged";
}
Expand Down
64 changes: 64 additions & 0 deletions cassandane/tiny-tests/Sieve/imip_disallow_public
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!perl
use Cassandane::Tiny;

sub test_imip_disallow_public
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

my $IMAP = $self->{store}->get_client();
$self->{store}->_select();
$self->assert_num_equals(1, $IMAP->uid());
$self->{store}->set_fetch_attributes(qw(uid flags));

xlog $self, "Create calendar user";
my $CalDAV = $self->{caldav};
my $CalendarId = 'Default';
my $uuid = "6de280c9-edff-4019-8ebd-cfebc73f8201";

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["variables", "imap4flags", "processcalendar"];
processcalendar :outcome "outcome";
if string "\${outcome}" "failed" {
setflag "\\\\Flagged";
}
EOF
);

my $imip = <<EOF;
Date: Thu, 23 Sep 2021 09:06:18 -0400
To: Cassandane <cassandane\@example.com>
Message-ID: <$uuid\@example.net>
Content-Type: text/calendar; component=VEVENT
X-Cassandane-Unique: $uuid
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.10.4//EN
BEGIN:VEVENT
CREATED:20210923T034327Z
UID:$uuid
DTEND;TZID=America/New_York:20210923T183000
TRANSP:OPAQUE
SUMMARY:An Event
DTSTART;TZID=America/New_York:20210923T153000
DTSTAMP:20210923T034327Z
SEQUENCE:0
END:VEVENT
END:VCALENDAR
EOF

xlog $self, "Deliver iMIP invite";
my $msg = Cassandane::Message->new(raw => $imip);
$msg->set_attribute(uid => 1,
flags => [ '\\Recent', '\\Flagged' ]);
$self->{instance}->deliver($msg);

xlog $self, "Check that the message made it to INBOX";
$self->check_messages({ 1 => $msg }, check_guid => 0);

xlog $self, "Check that the event DID NOT make it to calendar";
my $events = $CalDAV->GetEvents($CalendarId);
$self->assert_equals(0, scalar @$events);
}
7 changes: 3 additions & 4 deletions cassandane/tiny-tests/Sieve/imip_invite
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use Cassandane::Tiny;

sub test_imip_invite
:needs_component_sieve :needs_component_httpd :min_version_3_5
:want_service_http
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

Expand All @@ -19,9 +18,9 @@ sub test_imip_invite

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["body", "variables", "imap4flags", "vnd.cyrus.imip"];
require ["body", "variables", "imap4flags", "processcalendar"];
if body :content "text/calendar" :contains "\nMETHOD:" {
processimip :outcome "outcome";
processcalendar :outcome "outcome";
if string "\${outcome}" "added" {
setflag "\\\\Flagged";
}
Expand Down
7 changes: 3 additions & 4 deletions cassandane/tiny-tests/Sieve/imip_invite_base64
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use Cassandane::Tiny;

sub test_imip_invite_base64
:needs_component_sieve :needs_component_httpd :min_version_3_5
:want_service_http
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

Expand All @@ -19,9 +18,9 @@ sub test_imip_invite_base64

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["body", "variables", "imap4flags", "vnd.cyrus.imip"];
require ["body", "variables", "imap4flags", "processcalendar"];
if body :content "text/calendar" :contains "\nMETHOD:" {
processimip :outcome "outcome";
processcalendar :outcome "outcome";
if string "\${outcome}" "added" {
setflag "\\\\Flagged";
}
Expand Down
7 changes: 3 additions & 4 deletions cassandane/tiny-tests/Sieve/imip_invite_calendarid
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use Cassandane::Tiny;

sub test_imip_invite_calendarid
:needs_component_sieve :needs_component_httpd :min_version_3_5
:want_service_http
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

Expand All @@ -21,9 +20,9 @@ sub test_imip_invite_calendarid

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["body", "variables", "imap4flags", "vnd.cyrus.imip"];
require ["body", "variables", "imap4flags", "processcalendar"];
if body :content "text/calendar" :contains "\nMETHOD:" {
processimip :calendarid "$CalendarId" :outcome "outcome";
processcalendar :calendarid "$CalendarId" :outcome "outcome";
if string "\${outcome}" "added" {
setflag "\\\\Flagged";
}
Expand Down
7 changes: 3 additions & 4 deletions cassandane/tiny-tests/Sieve/imip_invite_funky_uid
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use Cassandane::Tiny;

sub test_imip_invite_funky_uid
:needs_component_sieve :needs_component_httpd :min_version_3_7
:want_service_http
:needs_component_sieve :needs_component_httpd :want_service_http
{
my ($self) = @_;

Expand All @@ -19,9 +18,9 @@ sub test_imip_invite_funky_uid

xlog $self, "Install a sieve script to process iMIP";
$self->{instance}->install_sieve_script(<<EOF
require ["body", "variables", "imap4flags", "vnd.cyrus.imip"];
require ["body", "variables", "imap4flags", "processcalendar"];
if body :content "text/calendar" :contains "\nMETHOD:" {
processimip :outcome "outcome";
processcalendar :outcome "outcome";
if string "\${outcome}" "added" {
setflag "\\\\Flagged";
}
Expand Down
Loading

0 comments on commit 120682c

Please sign in to comment.