[Pkg-owncloud-commits] [php-sabredav] 23/36: calendar-availability fully tested.
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:24 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 4a74926a6bed5211c3d18fccf07c5dc62897f7ef
Author: Evert Pot <me at evertpot.com>
Date: Sun Jul 19 18:39:28 2015 -0400
calendar-availability fully tested.
---
CHANGELOG.md | 2 +
.../Sabre/CalDAV/Schedule/FreeBusyRequestTest.php | 246 ++++++++++++++++++---
2 files changed, 217 insertions(+), 31 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4f8a67b..604f445 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ ChangeLog
* Now requires PHP 5.5
* Upgraded to vobject 4, which is a lot faster.
* Support for PHP 7.
+* Support for `calendar-availability`, draft 05. [reference][calendar-availability].
3.0.2 (2015-??-??)
@@ -2001,3 +2002,4 @@ ChangeLog
[mi20]: http://sabre.io/dav/upgrade/1.8-to-2.0/
[rfc6638]: http://tools.ietf.org/html/rfc6638 "CalDAV Scheduling"
[rfc7240]: http://tools.ietf.org/html/rfc7240
+[calendar-availability]: https://tools.ietf.org/html/draft-daboo-calendar-availability-05
diff --git a/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php b/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
index eec2b20..6276e87 100644
--- a/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
+++ b/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
@@ -2,12 +2,11 @@
namespace Sabre\CalDAV\Schedule;
-use
- Sabre\DAV,
- Sabre\DAVACL,
- Sabre\HTTP,
- Sabre\CalDAV,
- Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp;
+use Sabre\DAV;
+use Sabre\DAVACL;
+use Sabre\HTTP;
+use Sabre\CalDAV;
+use Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp;
class FreeBusyRequestTest extends \PHPUnit_Framework_TestCase {
@@ -20,23 +19,24 @@ class FreeBusyRequestTest extends \PHPUnit_Framework_TestCase {
function setUp() {
+ $caldavNS = '{' . CalDAV\Plugin::NS_CALDAV . '}';
$calendars = [
[
- 'principaluri' => 'principals/user2',
- 'id' => 1,
- 'uri' => 'calendar1',
- '{' . CalDAV\Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR",
+ 'principaluri' => 'principals/user2',
+ 'id' => 1,
+ 'uri' => 'calendar1',
+ $caldavNS . 'calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR",
],
[
- 'principaluri' => 'principals/user2',
- 'id' => 2,
- 'uri' => 'calendar2',
- '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp(ScheduleCalendarTransp::TRANSPARENT),
+ 'principaluri' => 'principals/user2',
+ 'id' => 2,
+ 'uri' => 'calendar2',
+ $caldavNS . 'schedule-calendar-transp' => new ScheduleCalendarTransp(ScheduleCalendarTransp::TRANSPARENT),
],
];
$calendarobjects = [
1 => [ '1.ics' => [
- 'uri' => '1.ics',
+ 'uri' => '1.ics',
'calendardata' => 'BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20110101T130000
@@ -46,7 +46,7 @@ END:VCALENDAR',
'calendarid' => 1,
]],
2 => [ '2.ics' => [
- 'uri' => '2.ics',
+ 'uri' => '2.ics',
'calendardata' => 'BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20110101T080000
@@ -80,7 +80,7 @@ END:VCALENDAR',
$authBackend = new DAV\Auth\Backend\Mock();
$authBackend->setPrincipal('principals/user1');
- $this->authPlugin = new DAV\Auth\Plugin($authBackend,'SabreDAV');
+ $this->authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV');
// Forcing authentication to work.
$this->authPlugin->beforeMethod($this->request, $this->response);
$this->server->addPlugin($this->authPlugin);
@@ -292,27 +292,27 @@ ICS;
);
$this->assertEquals(200, $this->response->status);
- $this->assertEquals(array(
+ $this->assertEquals([
'Content-Type' => ['application/xml'],
- ), $this->response->getHeaders());
+ ], $this->response->getHeaders());
- $strings = array(
+ $strings = [
'<d:href>mailto:user2.sabredav at sabredav.org</d:href>',
'<d:href>mailto:user3.sabredav at sabredav.org</d:href>',
'<cal:request-status>2.0;Success</cal:request-status>',
'<cal:request-status>3.7;Could not find principal</cal:request-status>',
'FREEBUSY:20110101T120000Z/20110101T130000Z',
- );
+ ];
- foreach($strings as $string) {
+ foreach ($strings as $string) {
$this->assertTrue(
- strpos($this->response->body, $string)!==false,
- 'The response body did not contain: ' . $string .'Full response: ' . $this->response->body
+ strpos($this->response->body, $string) !== false,
+ 'The response body did not contain: ' . $string . 'Full response: ' . $this->response->body
);
}
$this->assertTrue(
- strpos($this->response->body, 'FREEBUSY;FBTYPE=BUSY:20110101T080000Z/20110101T090000Z')==false,
+ strpos($this->response->body, 'FREEBUSY;FBTYPE=BUSY:20110101T080000Z/20110101T090000Z') == false,
'The response body did contain free busy info from a transparent calendar.'
);
@@ -356,19 +356,203 @@ ICS;
);
$this->assertEquals(200, $this->response->status);
- $this->assertEquals(array(
+ $this->assertEquals([
'Content-Type' => ['application/xml'],
- ), $this->response->getHeaders());
+ ], $this->response->getHeaders());
- $strings = array(
+ $strings = [
'<d:href>mailto:user2.sabredav at sabredav.org</d:href>',
'<cal:request-status>2.0;Success</cal:request-status>',
+ ];
+
+ foreach ($strings as $string) {
+ $this->assertTrue(
+ strpos($this->response->body, $string) !== false,
+ 'The response body did not contain: ' . $string . 'Full response: ' . $this->response->body
+ );
+ }
+
+ }
+
+ function testNoCalendarHomeFound() {
+
+ $this->server->httpRequest = new HTTP\Request(
+ 'POST',
+ '/calendars/user1/outbox',
+ ['Content-Type' => 'text/calendar']
);
- foreach($strings as $string) {
+ $body = <<<ICS
+BEGIN:VCALENDAR
+METHOD:REQUEST
+BEGIN:VFREEBUSY
+ORGANIZER:mailto:user1.sabredav at sabredav.org
+ATTENDEE:mailto:user2.sabredav at sabredav.org
+DTSTART:20110101T080000Z
+DTEND:20110101T180000Z
+END:VFREEBUSY
+END:VCALENDAR
+ICS;
+
+ $this->server->httpRequest->setBody($body);
+
+ // Lazily making the current principal an admin.
+ $this->aclPlugin->adminPrincipals[] = 'principals/user1';
+
+ // Removing the calendar home
+ $this->server->on('propFind', function(DAV\PropFind $propFind) {
+
+ $propFind->set('{' . Plugin::NS_CALDAV . '}calendar-home-set', null, 403);
+
+ });
+
+ $this->assertFalse(
+ $this->plugin->httpPost($this->server->httpRequest, $this->response)
+ );
+
+ $this->assertEquals(200, $this->response->status);
+ $this->assertEquals([
+ 'Content-Type' => ['application/xml'],
+ ], $this->response->getHeaders());
+
+ $strings = [
+ '<d:href>mailto:user2.sabredav at sabredav.org</d:href>',
+ '<cal:request-status>3.7;No calendar-home-set property found</cal:request-status>',
+ ];
+
+ foreach ($strings as $string) {
$this->assertTrue(
- strpos($this->response->body, $string)!==false,
- 'The response body did not contain: ' . $string .'Full response: ' . $this->response->body
+ strpos($this->response->body, $string) !== false,
+ 'The response body did not contain: ' . $string . 'Full response: ' . $this->response->body
+ );
+ }
+
+ }
+
+ function testNoInboxFound() {
+
+ $this->server->httpRequest = new HTTP\Request(
+ 'POST',
+ '/calendars/user1/outbox',
+ ['Content-Type' => 'text/calendar']
+ );
+
+ $body = <<<ICS
+BEGIN:VCALENDAR
+METHOD:REQUEST
+BEGIN:VFREEBUSY
+ORGANIZER:mailto:user1.sabredav at sabredav.org
+ATTENDEE:mailto:user2.sabredav at sabredav.org
+DTSTART:20110101T080000Z
+DTEND:20110101T180000Z
+END:VFREEBUSY
+END:VCALENDAR
+ICS;
+
+ $this->server->httpRequest->setBody($body);
+
+ // Lazily making the current principal an admin.
+ $this->aclPlugin->adminPrincipals[] = 'principals/user1';
+
+ // Removing the inbox
+ $this->server->on('propFind', function(DAV\PropFind $propFind) {
+
+ $propFind->set('{' . Plugin::NS_CALDAV . '}schedule-inbox-URL', null, 403);
+
+ });
+
+ $this->assertFalse(
+ $this->plugin->httpPost($this->server->httpRequest, $this->response)
+ );
+
+ $this->assertEquals(200, $this->response->status);
+ $this->assertEquals([
+ 'Content-Type' => ['application/xml'],
+ ], $this->response->getHeaders());
+
+ $strings = [
+ '<d:href>mailto:user2.sabredav at sabredav.org</d:href>',
+ '<cal:request-status>3.7;No schedule-inbox-URL property found</cal:request-status>',
+ ];
+
+ foreach ($strings as $string) {
+ $this->assertTrue(
+ strpos($this->response->body, $string) !== false,
+ 'The response body did not contain: ' . $string . 'Full response: ' . $this->response->body
+ );
+ }
+
+ }
+
+ function testSucceedUseVAVAILABILITY() {
+
+ $this->server->httpRequest = new HTTP\Request(
+ 'POST',
+ '/calendars/user1/outbox',
+ ['Content-Type' => 'text/calendar']
+ );
+
+ $body = <<<ICS
+BEGIN:VCALENDAR
+METHOD:REQUEST
+BEGIN:VFREEBUSY
+ORGANIZER:mailto:user1.sabredav at sabredav.org
+ATTENDEE:mailto:user2.sabredav at sabredav.org
+DTSTART:20110101T080000Z
+DTEND:20110101T180000Z
+END:VFREEBUSY
+END:VCALENDAR
+ICS;
+
+ $this->server->httpRequest->setBody($body);
+
+ // Lazily making the current principal an admin.
+ $this->aclPlugin->adminPrincipals[] = 'principals/user1';
+
+ // Adding VAVAILABILITY manually
+ $this->server->on('propFind', function(DAV\PropFind $propFind) {
+
+ $propFind->handle('{' . Plugin::NS_CALDAV . '}calendar-availability', function() {
+
+ $avail = <<<ICS
+BEGIN:VCALENDAR
+BEGIN:VAVAILABILITY
+DTSTART:20110101T000000Z
+DTEND:20110102T000000Z
+BEGIN:AVAILABLE
+DTSTART:20110101T090000Z
+DTEND:20110101T170000Z
+END:AVAILABLE
+END:VAVAILABILITY
+END:VCALENDAR
+ICS;
+ return $avail;
+
+ });
+
+ });
+
+ $this->assertFalse(
+ $this->plugin->httpPost($this->server->httpRequest, $this->response)
+ );
+
+ $this->assertEquals(200, $this->response->status);
+ $this->assertEquals([
+ 'Content-Type' => ['application/xml'],
+ ], $this->response->getHeaders());
+
+ $strings = [
+ '<d:href>mailto:user2.sabredav at sabredav.org</d:href>',
+ '<cal:request-status>2.0;Success</cal:request-status>',
+ 'FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:20110101T080000Z/20110101T090000Z',
+ 'FREEBUSY:20110101T120000Z/20110101T130000Z',
+ 'FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:20110101T170000Z/20110101T180000Z',
+ ];
+
+ foreach ($strings as $string) {
+ $this->assertTrue(
+ strpos($this->response->body, $string) !== false,
+ 'The response body did not contain: ' . $string . 'Full response: ' . $this->response->body
);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list