summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Connector/Sabre/Node.php11
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php20
-rw-r--r--apps/dav/tests/unit/Files/FileSearchBackendTest.php8
3 files changed, 30 insertions, 9 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php
index 1e32e74c325..2b5661eec63 100644
--- a/apps/dav/lib/Connector/Sabre/Node.php
+++ b/apps/dav/lib/Connector/Sabre/Node.php
@@ -100,11 +100,13 @@ abstract class Node implements \Sabre\DAV\INode {
if ($info instanceof Folder || $info instanceof File) {
$this->node = $info;
} else {
+ // The Node API assumes that the view passed doesn't have a fake root
+ $rootView = \OC::$server->get(View::class);
$root = \OC::$server->get(IRootFolder::class);
if ($info->getType() === FileInfo::TYPE_FOLDER) {
- $this->node = new Folder($root, $view, $this->path, $info);
+ $this->node = new Folder($root, $rootView, $this->fileView->getAbsolutePath($this->path), $info);
} else {
- $this->node = new File($root, $view, $this->path, $info);
+ $this->node = new File($root, $rootView, $this->fileView->getAbsolutePath($this->path), $info);
}
}
}
@@ -112,10 +114,11 @@ abstract class Node implements \Sabre\DAV\INode {
protected function refreshInfo() {
$this->info = $this->fileView->getFileInfo($this->path);
$root = \OC::$server->get(IRootFolder::class);
+ $rootView = \OC::$server->get(View::class);
if ($this->info->getType() === FileInfo::TYPE_FOLDER) {
- $this->node = new Folder($root, $this->fileView, $this->path, $this->info);
+ $this->node = new Folder($root, $rootView, $this->path, $this->info);
} else {
- $this->node = new File($root, $this->fileView, $this->path, $this->info);
+ $this->node = new File($root, $rootView, $this->path, $this->info);
}
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
index 1de82484ac4..1fb965dbd44 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
@@ -29,9 +29,12 @@
namespace OCA\DAV\Tests\Unit\Connector\Sabre;
use OC\Files\FileInfo;
+use OC\Files\Filesystem;
use OC\Files\Node\Node;
use OC\Files\Storage\Wrapper\Quota;
+use OC\Files\View;
use OCA\DAV\Connector\Sabre\Directory;
+use OCP\Constants;
use OCP\Files\ForbiddenException;
use OCP\Files\Mount\IMountPoint;
use Test\Traits\UserTrait;
@@ -92,6 +95,10 @@ class DirectoryTest extends \Test\TestCase {
->willReturn(Node::TYPE_FOLDER);
$this->info->method('getName')
->willReturn("folder");
+ $this->info->method('getPath')
+ ->willReturn("/admin/files/folder");
+ $this->info->method('getPermissions')
+ ->willReturn(Constants::PERMISSION_READ);
}
private function getDir($path = '/') {
@@ -208,12 +215,21 @@ class DirectoryTest extends \Test\TestCase {
$this->view->expects($this->once())
->method('getDirectoryContent')
- ->with('')
->willReturn([$info1, $info2]);
$this->view->expects($this->any())
->method('getRelativePath')
- ->willReturn('');
+ ->willReturnCallback(function ($path) {
+ return str_replace('/admin/files/', '', $path);
+ });
+
+ $this->view->expects($this->any())
+ ->method('getAbsolutePath')
+ ->willReturnCallback(function ($path) {
+ return Filesystem::normalizePath('/admin/files' . $path);
+ });
+
+ $this->overwriteService(View::class, $this->view);
$dir = new Directory($this->view, $this->info);
$nodes = $dir->getChildren();
diff --git a/apps/dav/tests/unit/Files/FileSearchBackendTest.php b/apps/dav/tests/unit/Files/FileSearchBackendTest.php
index b4245ac181b..b131fb0fa93 100644
--- a/apps/dav/tests/unit/Files/FileSearchBackendTest.php
+++ b/apps/dav/tests/unit/Files/FileSearchBackendTest.php
@@ -86,9 +86,11 @@ class FileSearchBackendTest extends TestCase {
->disableOriginalConstructor()
->getMock();
- $this->view = $this->getMockBuilder(View::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->view = $this->createMock(View::class);
+
+ $this->view->expects($this->any())
+ ->method('getRoot')
+ ->willReturn('');
$this->view->expects($this->any())
->method('getRelativePath')