diff options
author | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2024-09-04 22:24:19 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-09-05 23:54:01 +0200 |
commit | 0308001118462f5a6369fed313b844f631a43bcb (patch) | |
tree | 7dc9e9a883e8b0e61b14e33381191ee58bd064fa /tests | |
parent | 9aafc0f989ea78e3536299da96861ea8a6c13f43 (diff) | |
download | nextcloud-server-0308001118462f5a6369fed313b844f631a43bcb.tar.gz nextcloud-server-0308001118462f5a6369fed313b844f631a43bcb.zip |
fix(files): Check if the target path is a descendant of the shared folder path
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
fix: tests
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
fix: fix tests
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
fix: add tests
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
fix: tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/ViewTest.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 196de3397d4..e9e4d0e7573 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(); |