summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Scherzinger <info@andy-scherzinger.de>2024-09-15 21:25:30 +0200
committerGitHub <noreply@github.com>2024-09-15 21:25:30 +0200
commitfa355386f779428a90c40dbf6467c3d924bff24b (patch)
tree5e3c2bbea3fd0199a3ec13f6d5f62e35bd79c87e /tests
parent9561834b9652a154efcb80fdb0f7e00c1445ddd7 (diff)
parent2bb8c023c2eafd0f17065dfbf38e7f70d2a2fa84 (diff)
downloadnextcloud-server-fa355386f779428a90c40dbf6467c3d924bff24b.tar.gz
nextcloud-server-fa355386f779428a90c40dbf6467c3d924bff24b.zip
Merge pull request #47796 from nextcloud/backport/47756/stable30
[stable30] fix(files): Check if target path is a descendant of the shared folder
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/ViewTest.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 379a8389355..2dfbf61641a 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -1668,17 +1668,24 @@ class ViewTest extends \Test\TestCase {
public function testMoveMountPointIntoSharedFolder() {
self::loginAsUser($this->user);
- [$mount1] = $this->createTestMovableMountPoints([
+ [$mount1, $mount2] = $this->createTestMovableMountPoints([
$this->user . '/files/mount1',
+ $this->user . '/files/mount2',
]);
$mount1->expects($this->never())
->method('moveMount');
+ $mount2->expects($this->once())
+ ->method('moveMount')
+ ->willReturn(true);
+
$view = new View('/' . $this->user . '/files/');
$view->mkdir('shareddir');
$view->mkdir('shareddir/sub');
$view->mkdir('shareddir/sub2');
+ // Create a similar named but non-shared folder
+ $view->mkdir('shareddir notshared');
$fileId = $view->getFileInfo('shareddir')->getId();
$userObject = \OC::$server->getUserManager()->createUser('test2', 'IHateNonMockableStaticClasses');
@@ -1697,6 +1704,7 @@ class ViewTest extends \Test\TestCase {
$this->assertFalse($view->rename('mount1', 'shareddir'), 'Cannot overwrite shared folder');
$this->assertFalse($view->rename('mount1', 'shareddir/sub'), 'Cannot move mount point into shared folder');
$this->assertFalse($view->rename('mount1', 'shareddir/sub/sub2'), 'Cannot move mount point into shared subfolder');
+ $this->assertTrue($view->rename('mount2', 'shareddir notshared/sub'), 'Can move mount point into a similarly named but non-shared folder');
$shareManager->deleteShare($share);
$userObject->delete();