[Pkg-owncloud-commits] [php-sabredav] 03/17: Freebusy was throwing an error when targetting accounts that have no calendars. Fixes #567
David Prévot
taffit at moszumanska.debian.org
Thu Dec 11 15:10:56 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit d514781b8a64236283878a89e23a639b602f816d
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Mon Nov 24 00:26:10 2014 -0500
Freebusy was throwing an error when targetting accounts that have no calendars. Fixes #567
---
ChangeLog.md | 3 +-
lib/CalDAV/Schedule/Plugin.php | 4 +-
.../Sabre/CalDAV/Schedule/FreeBusyRequestTest.php | 61 +++++++++++++++++++++-
3 files changed, 63 insertions(+), 5 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 3533bd5..64b1739 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -7,7 +7,8 @@ ChangeLog
* #566: Another issue related to the migration script, which would cause
scheduling to not work well for events that were already added before the
migration.
-
+* #567: Doing freebusy requests on accounts that had 0 calendars would throw
+ a `E_NOTICE`.
2.1.1 (2014-11-22)
------------------
diff --git a/lib/CalDAV/Schedule/Plugin.php b/lib/CalDAV/Schedule/Plugin.php
index f762e63..ed65240 100644
--- a/lib/CalDAV/Schedule/Plugin.php
+++ b/lib/CalDAV/Schedule/Plugin.php
@@ -788,6 +788,8 @@ class Plugin extends ServerPlugin {
// Grabbing the calendar list
$objects = [];
+ $calendarTimeZone = new DateTimeZone('UTC');
+
foreach($this->server->tree->getNodeForPath($homeSet)->getChildren() as $node) {
if (!$node instanceof ICalendar) {
continue;
@@ -808,8 +810,6 @@ class Plugin extends ServerPlugin {
if (isset($props[$ctz])) {
$vtimezoneObj = VObject\Reader::read($props[$ctz]);
$calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
- } else {
- $calendarTimeZone = new DateTimeZone('UTC');
}
// Getting the list of object uris within the time-range
diff --git a/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php b/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
index e342772..cd2635c 100644
--- a/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
+++ b/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
@@ -16,6 +16,7 @@ class FreeBusyRequestTest extends \PHPUnit_Framework_TestCase {
protected $aclPlugin;
protected $request;
protected $authPlugin;
+ protected $caldavBackend;
function setUp() {
@@ -58,11 +59,11 @@ END:VCALENDAR',
);
$principalBackend = new DAVACL\PrincipalBackend\Mock();
- $caldavBackend = new CalDAV\Backend\MockScheduling($calendars, $calendarobjects);
+ $this->caldavBackend = new CalDAV\Backend\MockScheduling($calendars, $calendarobjects);
$tree = array(
new DAVACL\PrincipalCollection($principalBackend),
- new CalDAV\CalendarRoot($principalBackend, $caldavBackend),
+ new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend),
);
$this->request = HTTP\Sapi::createFromServerArray([
@@ -315,6 +316,62 @@ ICS;
}
+ /**
+ * Testing if the freebusy request still works, even if there are no
+ * calendars in the target users' account.
+ */
+ function testSucceedNoCalendars() {
+
+ // Deleting calendars
+ $this->caldavBackend->deleteCalendar(1);
+ $this->caldavBackend->deleteCalendar(2);
+
+ $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';
+
+ $this->assertFalse(
+ $this->plugin->httpPost($this->server->httpRequest, $this->response)
+ );
+
+ $this->assertEquals(200, $this->response->status);
+ $this->assertEquals(array(
+ 'Content-Type' => ['application/xml'],
+ ), $this->response->getHeaders());
+
+ $strings = array(
+ '<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 testNoPrivilege() {
--
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