diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php index 9baea2d027c5e..f4e8ee1d99a77 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -531,15 +531,6 @@ public function getNodeForPath($path): INode { throw new InvalidPath($ex->getMessage(), false, $ex); } - // if not in a public share with no read permissions, throw Forbidden - if (!$allowDirectory && !$info->isReadable()) { - if (Server::get(IAppManager::class)->isEnabledForAnyone('files_accesscontrol')) { - throw new Forbidden('No read permissions. This might be caused by files_accesscontrol, check your configured rules'); - } - - throw new Forbidden('No read permissions'); - } - if ($info->getMimeType() === FileInfo::MIMETYPE_FOLDER) { $node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this->tree, $this->shareManager); } else { diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index 845d5fc5f02dd..e2567af602d6a 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -299,9 +299,6 @@ public function testGetNodeForPath(): void { $pathNode->expects($this->once()) ->method('getPath') ->willReturn('/admin/files/my/deep/folder/'); - $pathNode->expects($this->once()) - ->method('isReadable') - ->willReturn(true); $pathNode->expects($this->once()) ->method('getMimetype') ->willReturn(FileInfo::MIMETYPE_FOLDER); @@ -352,9 +349,6 @@ public function testGetNodeForPathFailsWithNoReadPermissionsForParent(): void { $pathNode->expects($this->once()) ->method('getPath') ->willReturn('/admin/files/my/deep/folder/'); - $pathNode->expects($this->once()) - ->method('isReadable') - ->willReturn(true); $pathNode->expects($this->once()) ->method('getMimetype') ->willReturn(FileInfo::MIMETYPE_FOLDER); @@ -393,9 +387,15 @@ public function testGetNodeForPathFailsWithNoReadPermissionsForPath(): void { ->method('instanceOfStorage') ->willReturn(false); - $directoryNode->expects($this->once()) + $invokedCount = $this->exactly(2); + $directoryNode->expects($invokedCount) ->method('isReadable') - ->willReturn(true); + ->willReturnCallback(function () use ($invokedCount) { + return match ($invokedCount->numberOfInvocations()) { + 1 => true, + 2 => false, + }; + }); $directoryNode->expects($this->once()) ->method('getPath') ->willReturn('/admin/files/'); @@ -403,11 +403,7 @@ public function testGetNodeForPathFailsWithNoReadPermissionsForPath(): void { ->method('get') ->willReturn($pathNode); - $pathNode->expects($this->once()) - ->method('isReadable') - ->willReturn(false); - - $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->expectException(\Sabre\DAV\Exception\NotFound::class); $dir = new Directory($this->view, $directoryNode); $dir->getNodeForPath('/my/deep/folder/');