Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,10 @@ public function getNodeForPath($path): INode {
// to the node API
/** @psalm-suppress InternalMethod */
$info = $this->fileView->getFileInfo($scanPath, false);
if (!$info) {
throw new \Sabre\DAV\Exception\NotFound('File with name ' . $destinationPath
. ' could not be located');
}
$directory = new Directory($this->fileView, $info, $this->tree, $this->shareManager);
$readable = $directory->getNode()->isReadable();
if (!$readable) {
Expand Down
44 changes: 44 additions & 0 deletions apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,50 @@ public function testGetNodeForPathFailsWithNoReadPermissionsForParent(): void {
$dir->getNodeForPath('/my/deep/folder/');
}

public function testGetNodeForPathFailsWithNoReadPermissionsForMissingParentInfo(): void {
$directoryNode = $this->createMock(Folder::class);
$pathNode = $this->createMock(Folder::class);
$storage = $this->createMock(IStorage::class);

$directoryNode->expects($this->once())
->method('getStorage')
->willReturn($storage);
$storage->expects($this->once())
->method('instanceOfStorage')
->willReturn(false);

$directoryNode->expects($this->once())
->method('isReadable')
->willReturn(true);
$directoryNode->expects($this->once())
->method('getPath')
->willReturn('/admin/files/');
$directoryNode->expects($this->once())
->method('get')
->willReturn($pathNode);

$pathNode->expects($this->once())
->method('getPath')
->willReturn('/admin/files/my/deep/folder/');
$pathNode->expects($this->once())
->method('getMimetype')
->willReturn(FileInfo::MIMETYPE_FOLDER);

$this->view->method('getRelativePath')
->willReturnCallback(function ($path) {
return str_replace('/admin/files/', '', $path);
});

$this->view->expects($this->once())
->method('getFileInfo')
->willReturn(false);

$this->expectException(NotFound::class);

$dir = new Directory($this->view, $directoryNode);
$dir->getNodeForPath('/my/deep/folder/');
}

public function testGetNodeForPathFailsWithNoReadPermissionsForPath(): void {
$this->view
->method('getRelativePath')
Expand Down