diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-04-23 13:54:58 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-05-30 13:27:51 +0200 |
commit | 0f88f3f00eb9347393490ea75d1fc75a8c2e1003 (patch) | |
tree | b8770cee2b540035d940a849858a94d5a64e6d5f /apps | |
parent | 3a133b151fe790c3e4a227f17a75a37b44b8e50a (diff) | |
download | nextcloud-server-0f88f3f00eb9347393490ea75d1fc75a8c2e1003.tar.gz nextcloud-server-0f88f3f00eb9347393490ea75d1fc75a8c2e1003.zip |
CalDAV and CardDAV plugins need to be registered for the principals collection as well
https://github.com/owncloud/core/pull/30149/commits/9f2e6431b88a9635b291b0e824abf74ba766616d
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/Server.php | 22 | ||||
-rw-r--r-- | apps/dav/tests/unit/ServerTest.php | 20 |
2 files changed, 29 insertions, 13 deletions
diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php index 5a4b1d1dcf5..ef8949485e0 100644 --- a/apps/dav/lib/Server.php +++ b/apps/dav/lib/Server.php @@ -73,7 +73,7 @@ class Server { private $baseUri; /** @var Connector\Sabre\Server */ - private $server; + public $server; public function __construct(IRequest $request, $baseUri) { $this->request = $request; @@ -138,7 +138,7 @@ class Server { $this->server->addPlugin($acl); // calendar plugins - if ($this->requestIsForSubtree('calendars')) { + if ($this->requestIsForSubtree(['calendars', 'principals'])) { $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); @@ -155,7 +155,8 @@ class Server { } // addressbook plugins - if ($this->requestIsForSubtree('addressbooks')) { + if ($this->requestIsForSubtree(['addressbooks', 'principals'])) { + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); $this->server->addPlugin(new VCFExportPlugin()); $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); @@ -286,12 +287,13 @@ class Server { $this->server->exec(); } - /** - * @param string $subTree - * @return bool - */ - private function requestIsForSubtree($subTree) { - $subTree = trim($subTree, " /"); - return strpos($this->server->getRequestUri(), "$subTree/") === 0; + private function requestIsForSubtree(array $subTrees): bool { + foreach ($subTrees as $subTree) { + $subTree = trim($subTree, ' /'); + if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) { + return true; + } + } + return false; } } diff --git a/apps/dav/tests/unit/ServerTest.php b/apps/dav/tests/unit/ServerTest.php index d502b24adcf..986899a2107 100644 --- a/apps/dav/tests/unit/ServerTest.php +++ b/apps/dav/tests/unit/ServerTest.php @@ -38,10 +38,24 @@ use OCA\DAV\AppInfo\PluginManager; */ class ServerTest extends \Test\TestCase { - public function test() { - /** @var IRequest $r */ + /** + * @dataProvider providesUris + */ + public function test($uri, array $plugins) { + /** @var IRequest | \PHPUnit_Framework_MockObject_MockObject $r */ $r = $this->createMock(IRequest::class); + $r->expects($this->any())->method('getRequestUri')->willReturn($uri); $s = new Server($r, '/'); - $this->assertInstanceOf('OCA\DAV\Server', $s); + $this->assertNotNull($s->server); + foreach ($plugins as $plugin) { + $this->assertNotNull($s->server->getPlugin($plugin)); + } + } + public function providesUris() { + return [ + 'principals' => ['principals/users/admin', ['caldav', 'oc-resource-sharing', 'carddav']], + 'calendars' => ['calendars/admin', ['caldav', 'oc-resource-sharing']], + 'addressbooks' => ['addressbooks/admin', ['carddav', 'oc-resource-sharing']], + ]; } } |