Skip to content

Commit

Permalink
DO NOT MERGE: perltidy all the cassandane tiny tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbs committed Jul 8, 2024
1 parent 0fa4acf commit 7e34ed3
Show file tree
Hide file tree
Showing 1,367 changed files with 95,267 additions and 82,214 deletions.
181 changes: 97 additions & 84 deletions cassandane/tiny-tests/Caldav/alarm_peruser
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
use Cassandane::Tiny;

sub test_alarm_peruser
:MagicPlus :min_version_3_0 :needs_component_httpd :NoAltNameSpace :NoVirtDomains
{
my ($self) = @_;

my $CalDAV = $self->{caldav};

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

$admintalk->create("user.manifold");
$admintalk->setacl("user.manifold", admin => 'lrswipkxtecdan');
$admintalk->setacl("user.manifold", manifold => 'lrswipkxtecdn');

my $service = $self->{instance}->get_service("http");
my $mantalk = Net::CalDAVTalk->new(
user => "manifold",
password => 'pass',
host => $service->host(),
port => $service->port(),
scheme => 'http',
url => '/',
expandurl => 1,
);

my $invite = <<EOF;
: MagicPlus : min_version_3_0 : needs_component_httpd : NoAltNameSpace :
NoVirtDomains {
my ($self) = @_;

my $CalDAV = $self->{caldav};

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

$admintalk->create("user.manifold");
$admintalk->setacl("user.manifold", admin => 'lrswipkxtecdan');
$admintalk->setacl("user.manifold", manifold => 'lrswipkxtecdn');

my $service = $self->{instance}->get_service("http");
my $mantalk = Net::CalDAVTalk->new(
user => "manifold",
password => 'pass',
host => $service->host(),
port => $service->port(),
scheme => 'http',
url => '/',
expandurl => 1,
);

my $invite = <<EOF;
<?xml version="1.0" encoding="utf-8" ?>
<D:share-resource xmlns:D="DAV:">
<D:sharee>
Expand All @@ -41,7 +41,7 @@ sub test_alarm_peruser
</D:share-resource>
EOF

my $reply = <<EOF;
my $reply = <<EOF;
<?xml version="1.0" encoding="utf-8" ?>
<D:invite-reply xmlns:D="DAV:">
<D:invite-accepted />
Expand All @@ -52,37 +52,37 @@ EOF
</D:invite-reply>
EOF

xlog $self, "create calendar";
my $CalendarId = $mantalk->NewCalendar({name => 'Manifold Calendar'});
$self->assert_not_null($CalendarId);

xlog $self, "share to user";
$mantalk->Request('POST', $CalendarId, $invite,
'Content-Type' => 'application/davsharing+xml');

xlog $self, "fetch invite";
my ($adds) = $CalDAV->SyncEventLinks("/dav/notifications/user/cassandane");
$self->assert_equals(scalar %$adds, 1);
my $notification = (keys %$adds)[0];

xlog $self, "accept invite";
$CalDAV->Request('POST', $notification, $reply,
'Content-Type' => 'application/davsharing+xml');

xlog $self, "get calendars as manifold";
my $ManCal = $mantalk->GetCalendars();
$self->assert_num_equals(2, scalar @$ManCal);
my $names = join "/", sort map { $_->{name} } @$ManCal;
$self->assert_str_equals($names, "Manifold Calendar/personal");

xlog $self, "get calendars as cassandane";
my $CasCal = $CalDAV->GetCalendars();
$self->assert_num_equals(2, scalar @$CasCal);
$names = join "/", sort map { $_->{name} } @$CasCal;
$self->assert_str_equals($names, "Manifold Calendar/personal");

my $uuid = 'fb7b57d1-8a49-4af8-8597-2c17bab1f987';
my $event = <<EOF;
xlog $self, "create calendar";
my $CalendarId = $mantalk->NewCalendar({ name => 'Manifold Calendar' });
$self->assert_not_null($CalendarId);

xlog $self, "share to user";
$mantalk->Request('POST', $CalendarId, $invite,
'Content-Type' => 'application/davsharing+xml');

xlog $self, "fetch invite";
my ($adds) = $CalDAV->SyncEventLinks("/dav/notifications/user/cassandane");
$self->assert_equals(scalar %$adds, 1);
my $notification = (keys %$adds)[0];

xlog $self, "accept invite";
$CalDAV->Request('POST', $notification, $reply,
'Content-Type' => 'application/davsharing+xml');

xlog $self, "get calendars as manifold";
my $ManCal = $mantalk->GetCalendars();
$self->assert_num_equals(2, scalar @$ManCal);
my $names = join "/", sort map { $_->{name} } @$ManCal;
$self->assert_str_equals($names, "Manifold Calendar/personal");

xlog $self, "get calendars as cassandane";
my $CasCal = $CalDAV->GetCalendars();
$self->assert_num_equals(2, scalar @$CasCal);
$names = join "/", sort map { $_->{name} } @$CasCal;
$self->assert_str_equals($names, "Manifold Calendar/personal");

my $uuid = 'fb7b57d1-8a49-4af8-8597-2c17bab1f987';
my $event = <<EOF;
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.9.5//EN
Expand Down Expand Up @@ -124,39 +124,52 @@ END:VEVENT
END:VCALENDAR
EOF

my $nonallday = <<EOF;
my $nonallday = <<EOF;
DTSTART;TZID=Europe/Vienna:20160928T160000
DTEND;TZID=Europe/Vienna:20160928T170000
EOF

my $allday = <<EOF;
my $allday = <<EOF;
DTSTART;TYPE=DATE:20160928
DURATION:P1D
EOF
my $nonallevent = $event;
$nonallevent =~ s/XXDATESXX/$nonallday/;
my $allevent = $event;
$allevent =~ s/XXDATESXX/$allday/;

xlog $self, "Create an event as cassandane with an alarm";
my ($cal) = grep { $_->{name} eq 'Manifold Calendar' } @$CasCal;
$CalDAV->Request('PUT', "$cal->{id}/$uuid.ics", $nonallevent, 'Content-Type' => 'text/calendar');

my $plusstore = $self->{instance}->get_service('imap')->create_store(username => 'cassandane+dav');
my $plustalk = $plusstore->get_client();

my @list = $plustalk->list("", "*");

my @bits = split /\./, $cal->{id};
$plustalk->select("user.manifold.#calendars.$bits[1]");
my $res = $plustalk->fetch('1', '(rfc822.peek annotation (/* value.priv))');

$self->assert_does_not_match(qr/VALARM/, $res->{1}{'rfc822'});
$self->assert_matches(qr/VALARM/, $res->{1}{'annotation'}{'/vendor/cmu/cyrus-httpd/<http://cyrusimap.org/ns/>per-user-calendar-data'}{'value.priv'});

$CalDAV->Request('PUT', "$cal->{id}/$uuid.ics", $allevent, 'Content-Type' => 'text/calendar');

$res = $plustalk->fetch('2', '(rfc822.peek annotation (/* value.priv))');
$self->assert_does_not_match(qr/VALARM/, $res->{2}{'rfc822'});
$self->assert_matches(qr/VALARM/, $res->{2}{'annotation'}{'/vendor/cmu/cyrus-httpd/<http://cyrusimap.org/ns/>per-user-calendar-data'}{'value.priv'});
my $nonallevent = $event;
$nonallevent =~ s/XXDATESXX/$nonallday/;
my $allevent = $event;
$allevent =~ s/XXDATESXX/$allday/;

xlog $self, "Create an event as cassandane with an alarm";
my ($cal) = grep { $_->{name} eq 'Manifold Calendar' } @$CasCal;
$CalDAV->Request('PUT', "$cal->{id}/$uuid.ics", $nonallevent,
'Content-Type' => 'text/calendar');

my $plusstore = $self->{instance}->get_service('imap')
->create_store(username => 'cassandane+dav');
my $plustalk = $plusstore->get_client();

my @list = $plustalk->list("", "*");

my @bits = split /\./, $cal->{id};
$plustalk->select("user.manifold.#calendars.$bits[1]");
my $res = $plustalk->fetch('1', '(rfc822.peek annotation (/* value.priv))');

$self->assert_does_not_match(qr/VALARM/, $res->{1}{'rfc822'});
$self->assert_matches(
qr/VALARM/,
$res->{1}{'annotation'}{
'/vendor/cmu/cyrus-httpd/<http://cyrusimap.org/ns/>per-user-calendar-data'
}{'value.priv'}
);

$CalDAV->Request('PUT', "$cal->{id}/$uuid.ics", $allevent,
'Content-Type' => 'text/calendar');

$res = $plustalk->fetch('2', '(rfc822.peek annotation (/* value.priv))');
$self->assert_does_not_match(qr/VALARM/, $res->{2}{'rfc822'});
$self->assert_matches(
qr/VALARM/,
$res->{2}{'annotation'}{
'/vendor/cmu/cyrus-httpd/<http://cyrusimap.org/ns/>per-user-calendar-data'
}{'value.priv'}
);
}
25 changes: 12 additions & 13 deletions cassandane/tiny-tests/Caldav/apple_location_notz
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
use Cassandane::Tiny;

sub test_apple_location_notz
:needs_component_httpd
{
my ($self) = @_;
: needs_component_httpd {
my ($self) = @_;

my $CalDAV = $self->{caldav};
my $CalDAV = $self->{caldav};

my $CalendarId = $CalDAV->NewCalendar({name => 'foo'});
$self->assert_not_null($CalendarId);
my $CalendarId = $CalDAV->NewCalendar({ name => 'foo' });
$self->assert_not_null($CalendarId);

my $uuid = "574E2CD0-2D2A-4554-8B63-C7504481D3A9";
my $href = "$CalendarId/$uuid.ics";
my $card = <<EOF;
my $uuid = "574E2CD0-2D2A-4554-8B63-C7504481D3A9";
my $href = "$CalendarId/$uuid.ics";
my $card = <<EOF;
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.10.4//EN
Expand All @@ -36,11 +35,11 @@ END:VEVENT
END:VCALENDAR
EOF

$CalDAV->Request('PUT', $href, $card, 'Content-Type' => 'text/calendar');
$CalDAV->Request('PUT', $href, $card, 'Content-Type' => 'text/calendar');

my $response = $CalDAV->Request('GET', $href);
my $response = $CalDAV->Request('GET', $href);

my $newcard = $response->{content};
my $newcard = $response->{content};

$self->assert_matches(qr/geo:-37.810551,144.962840/, $newcard);
$self->assert_matches(qr/geo:-37.810551,144.962840/, $newcard);
}
25 changes: 12 additions & 13 deletions cassandane/tiny-tests/Caldav/apple_location_tz
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
use Cassandane::Tiny;

sub test_apple_location_tz
:needs_component_httpd
{
my ($self) = @_;
: needs_component_httpd {
my ($self) = @_;

my $CalDAV = $self->{caldav};
my $CalDAV = $self->{caldav};

my $CalendarId = $CalDAV->NewCalendar({name => 'foo'});
$self->assert_not_null($CalendarId);
my $CalendarId = $CalDAV->NewCalendar({ name => 'foo' });
$self->assert_not_null($CalendarId);

my $uuid = "574E2CD0-2D2A-4554-8B63-C7504481D3A9";
my $href = "$CalendarId/$uuid.ics";
my $card = <<EOF;
my $uuid = "574E2CD0-2D2A-4554-8B63-C7504481D3A9";
my $href = "$CalendarId/$uuid.ics";
my $card = <<EOF;
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.10.4//EN
Expand Down Expand Up @@ -53,11 +52,11 @@ END:VEVENT
END:VCALENDAR
EOF

$CalDAV->Request('PUT', $href, $card, 'Content-Type' => 'text/calendar');
$CalDAV->Request('PUT', $href, $card, 'Content-Type' => 'text/calendar');

my $response = $CalDAV->Request('GET', $href);
my $response = $CalDAV->Request('GET', $href);

my $newcard = $response->{content};
my $newcard = $response->{content};

$self->assert_matches(qr/geo:-37.810551,144.962840/, $newcard);
$self->assert_matches(qr/geo:-37.810551,144.962840/, $newcard);
}
49 changes: 24 additions & 25 deletions cassandane/tiny-tests/Caldav/attendee_exdate
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,42 @@
use Cassandane::Tiny;

sub test_attendee_exdate
:needs_component_httpd
{
my ($self) = @_;
my $CalDAV = $self->{caldav};
: needs_component_httpd {
my ($self) = @_;
my $CalDAV = $self->{caldav};

my $CalendarId = $CalDAV->NewCalendar({name => 'test'});
$self->assert_not_null($CalendarId);
my $CalendarId = $CalDAV->NewCalendar({ name => 'test' });
$self->assert_not_null($CalendarId);

xlog $self, "recurring event";
{
my $uuid = $CalDAV->genuuid();
$self->_put_event($CalendarId, uuid => $uuid, lines => <<EOF);
xlog $self, "recurring event";
{
my $uuid = $CalDAV->genuuid();
$self->_put_event($CalendarId, uuid => $uuid, lines => <<EOF);
ATTENDEE;CN=Test User;PARTSTAT=ACCEPTED:MAILTO:cassandane\@example.com
ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:test1\@example.com
RRULE:FREQ=WEEKLY
ORGANIZER:MAILTO:test1\@example.com
EOF
$self->{instance}->getnotify();
$self->_put_event($CalendarId, uuid => $uuid, lines => <<EOF);
$self->{instance}->getnotify();
$self->_put_event($CalendarId, uuid => $uuid, lines => <<EOF);
ATTENDEE;CN=Test User;PARTSTAT=ACCEPTED:MAILTO:cassandane\@example.com
ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:test1\@example.com
ORGANIZER:MAILTO:test1\@example.com
RRULE:FREQ=WEEKLY
EXDATE;TZID=Australia/Melbourne:20160608T153000
EOF

# should this send a PARTSTAT=DECLINED instead?
$self->assert_caldav_notified(
{
recipient => "test1\@example.com",
method => 'REPLY',
event => {
uid => $uuid,
replyTo => { imip => "mailto:test1\@example.com" },
recurrenceOverrides => { '2016-06-08T15:30:00' => undef },
},
},
);
}
# should this send a PARTSTAT=DECLINED instead?
$self->assert_caldav_notified(
{
recipient => "test1\@example.com",
method => 'REPLY',
event => {
uid => $uuid,
replyTo => { imip => "mailto:test1\@example.com" },
recurrenceOverrides => { '2016-06-08T15:30:00' => undef },
},
},
);
}
}
11 changes: 5 additions & 6 deletions cassandane/tiny-tests/Caldav/caldavcreate
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
use Cassandane::Tiny;

sub test_caldavcreate
:needs_component_httpd
{
my ($self) = @_;
: needs_component_httpd {
my ($self) = @_;

my $CalDAV = $self->{caldav};
my $CalDAV = $self->{caldav};

my $CalendarId = $CalDAV->NewCalendar({name => 'foo'});
$self->assert_not_null($CalendarId);
my $CalendarId = $CalDAV->NewCalendar({ name => 'foo' });
$self->assert_not_null($CalendarId);
}
Loading

0 comments on commit 7e34ed3

Please sign in to comment.