Merge pull request #24163 from owncloud/fix-birthday_calendar-acl-stable9
[stable9] Birthday calendar should never have write acl
This commit is contained in:
commit
7a2a6ce609
|
@ -28,14 +28,6 @@ use Sabre\DAV\PropPatch;
|
|||
|
||||
class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
||||
|
||||
public function __construct(BackendInterface $caldavBackend, $calendarInfo) {
|
||||
parent::__construct($caldavBackend, $calendarInfo);
|
||||
|
||||
if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) {
|
||||
$this->calendarInfo['{http://sabredav.org/ns}read-only'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the list of shares.
|
||||
*
|
||||
|
@ -92,11 +84,13 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
|||
'principal' => $this->getOwner(),
|
||||
'protected' => true,
|
||||
]];
|
||||
$acl[] = [
|
||||
'privilege' => '{DAV:}write',
|
||||
'principal' => $this->getOwner(),
|
||||
'protected' => true,
|
||||
];
|
||||
if ($this->getName() !== BirthdayService::BIRTHDAY_CALENDAR_URI) {
|
||||
$acl[] = [
|
||||
'privilege' => '{DAV:}write',
|
||||
'principal' => $this->getOwner(),
|
||||
'protected' => true,
|
||||
];
|
||||
}
|
||||
if ($this->getOwner() !== parent::getOwner()) {
|
||||
$acl[] = [
|
||||
'privilege' => '{DAV:}read',
|
||||
|
|
|
@ -25,6 +25,7 @@ use DateTimeZone;
|
|||
use OCA\DAV\CalDAV\CalDavBackend;
|
||||
use OCA\DAV\CalDAV\Calendar;
|
||||
use OCA\DAV\Connector\Sabre\Principal;
|
||||
use OCP\IL10N;
|
||||
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
|
||||
use Sabre\DAV\PropPatch;
|
||||
use Sabre\DAV\Xml\Property\Href;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
namespace OCA\DAV\Tests\Unit\CalDAV;
|
||||
|
||||
use OCA\DAV\CalDAV\BirthdayService;
|
||||
use OCA\DAV\CalDAV\CalDavBackend;
|
||||
use OCA\DAV\CalDAV\Calendar;
|
||||
use Sabre\DAV\PropPatch;
|
||||
|
@ -107,14 +108,14 @@ class CalendarTest extends TestCase {
|
|||
/**
|
||||
* @dataProvider providesReadOnlyInfo
|
||||
*/
|
||||
public function testAcl($expectsWrite, $readOnlyValue, $hasOwnerSet) {
|
||||
public function testAcl($expectsWrite, $readOnlyValue, $hasOwnerSet, $uri = 'default') {
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
|
||||
$backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock();
|
||||
$backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
|
||||
$calendarInfo = [
|
||||
'principaluri' => 'user2',
|
||||
'id' => 666,
|
||||
'uri' => 'default'
|
||||
'uri' => $uri
|
||||
];
|
||||
if (!is_null($readOnlyValue)) {
|
||||
$calendarInfo['{http://owncloud.org/ns}read-only'] = $readOnlyValue;
|
||||
|
@ -135,6 +136,13 @@ class CalendarTest extends TestCase {
|
|||
'principal' => $hasOwnerSet ? 'user1' : 'user2',
|
||||
'protected' => true
|
||||
]];
|
||||
if ($uri === BirthdayService::BIRTHDAY_CALENDAR_URI) {
|
||||
$expectedAcl = [[
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => $hasOwnerSet ? 'user1' : 'user2',
|
||||
'protected' => true
|
||||
]];
|
||||
}
|
||||
if ($hasOwnerSet) {
|
||||
$expectedAcl[] = [
|
||||
'privilege' => '{DAV:}read',
|
||||
|
@ -161,6 +169,7 @@ class CalendarTest extends TestCase {
|
|||
'read-only property not set and no owner' => [true, null, false],
|
||||
'read-only property is false and no owner' => [true, false, false],
|
||||
'read-only property is true and no owner' => [false, true, false],
|
||||
'birthday calendar' => [false, false, false, BirthdayService::BIRTHDAY_CALENDAR_URI]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue