summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2016-11-21 21:58:24 +0100
committerGeorg Ehrke <developer@georgehrke.com>2016-11-21 22:10:51 +0100
commit3a8c4230be2d7311ca012f09538cdad2147fae75 (patch)
tree0d2752c96a95d7bb01093d9f3d2fac5c42a4cb48
parentde983e61e3660964154d1c7f447ca8a2055cc2d6 (diff)
downloadnextcloud-server-3a8c4230be2d7311ca012f09538cdad2147fae75.tar.gz
nextcloud-server-3a8c4230be2d7311ca012f09538cdad2147fae75.zip
fix PropPatch requests on calendars
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
-rw-r--r--apps/dav/lib/CalDAV/Calendar.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/CalendarTest.php25
2 files changed, 19 insertions, 8 deletions
diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php
index 9fedbe6f91f..ef8e21be83a 100644
--- a/apps/dav/lib/CalDAV/Calendar.php
+++ b/apps/dav/lib/CalDAV/Calendar.php
@@ -177,7 +177,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
function propPatch(PropPatch $propPatch) {
$mutations = $propPatch->getMutations();
// If this is a shared calendar, the user can only change the enabled property, to hide it.
- if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal']) && (sizeof($mutations) !== 1 || !isset($mutations['{http://owncloud.org/ns}calendar-enabled']))) {
+ if ($this->isShared() && (sizeof($mutations) !== 1 || !isset($mutations['{http://owncloud.org/ns}calendar-enabled']))) {
throw new Forbidden();
}
parent::propPatch($propPatch);
diff --git a/apps/dav/tests/unit/CalDAV/CalendarTest.php b/apps/dav/tests/unit/CalDAV/CalendarTest.php
index e585a23a9a2..d0fb2d19243 100644
--- a/apps/dav/tests/unit/CalDAV/CalendarTest.php
+++ b/apps/dav/tests/unit/CalDAV/CalendarTest.php
@@ -106,29 +106,40 @@ class CalendarTest extends TestCase {
public function dataPropPatch() {
return [
- [[], true],
- [[
+ ['user1', 'user2', [], true],
+ ['user1', 'user2', [
'{http://owncloud.org/ns}calendar-enabled' => true,
], false],
- [[
+ ['user1', 'user2', [
'{DAV:}displayname' => true,
], true],
- [[
+ ['user1', 'user2', [
'{DAV:}displayname' => true,
'{http://owncloud.org/ns}calendar-enabled' => true,
], true],
+ ['user1', 'user1', [], false],
+ ['user1', 'user1', [
+ '{http://owncloud.org/ns}calendar-enabled' => true,
+ ], false],
+ ['user1', 'user1', [
+ '{DAV:}displayname' => true,
+ ], false],
+ ['user1', 'user1', [
+ '{DAV:}displayname' => true,
+ '{http://owncloud.org/ns}calendar-enabled' => true,
+ ], false],
];
}
/**
* @dataProvider dataPropPatch
*/
- public function testPropPatch($mutations, $throws) {
+ public function testPropPatch($ownerPrincipal, $principalUri, $mutations, $throws) {
/** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
$backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock();
$calendarInfo = [
- '{http://owncloud.org/ns}owner-principal' => 'user1',
- 'principaluri' => 'user2',
+ '{http://owncloud.org/ns}owner-principal' => $ownerPrincipal,
+ 'principaluri' => $principalUri,
'id' => 666,
'uri' => 'default'
];