diff options
author | Robin Appelman <robin@icewind.nl> | 2023-06-28 15:48:55 +0200 |
---|---|---|
committer | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2023-12-05 09:47:03 +0100 |
commit | fbc0f657112c58fa1f3b2c58b9b4606d27d129b5 (patch) | |
tree | 123cffca1484e04d3a79242aaed464d1b46dfced /apps | |
parent | 4e2e475bd3a811d5f74bce3656d16523a0d448d4 (diff) | |
download | nextcloud-server-fbc0f657112c58fa1f3b2c58b9b4606d27d129b5.tar.gz nextcloud-server-fbc0f657112c58fa1f3b2c58b9b4606d27d129b5.zip |
add more checks to ensure mounts aren't empty
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/External/Manager.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/tests/External/ManagerTest.php | 13 |
2 files changed, 14 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index d2e113c8bb3..63c2c19d25b 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -606,6 +606,10 @@ class Manager { $this->logger->error('Mount point to remove share not found', ['mountPoint' => $mountPoint]); return false; } + if (!$mountPointObj instanceof Mount) { + $this->logger->error('Mount point to remove share is not an external share, share probably doesn\'t exist', ['mountPoint' => $mountPoint]); + return false; + } $id = $mountPointObj->getStorage()->getCache()->getId(''); $mountPoint = $this->stripPath($mountPoint); diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 86386144932..0e80479eafe 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -31,8 +31,10 @@ namespace OCA\Files_Sharing\Tests\External; use OC\Federation\CloudIdManager; +use OC\Files\Mount\MountPoint; use OC\Files\SetupManagerFactory; use OC\Files\Storage\StorageFactory; +use OC\Files\Storage\Temporary; use OCA\Files_Sharing\External\Manager; use OCA\Files_Sharing\External\MountProvider; use OCA\Files_Sharing\Tests\TestCase; @@ -191,13 +193,18 @@ class ManagerTest extends TestCase { } private function setupMounts() { - $this->mountManager->clear(); + $this->clearMounts(); $mounts = $this->testMountProvider->getMountsForUser($this->user, new StorageFactory()); foreach ($mounts as $mount) { $this->mountManager->addMount($mount); } } + private function clearMounts() { + $this->mountManager->clear(); + $this->mountManager->addMount(new MountPoint(Temporary::class, '', [])); + } + public function testAddUserShare() { $this->doTestAddShare([ 'remote' => 'http://localhost', @@ -235,7 +242,7 @@ class ManagerTest extends TestCase { if ($isGroup) { $this->manager->expects($this->never())->method('tryOCMEndPoint'); } else { - $this->manager->expects($this->any())->method('tryOCMEndPoint') + $this->manager->method('tryOCMEndPoint') ->withConsecutive( ['http://localhost', 'token1', '2342', 'accept'], ['http://localhost', 'token3', '2342', 'decline'], @@ -415,7 +422,7 @@ class ManagerTest extends TestCase { $this->assertEmpty(self::invokePrivate($this->manager, 'getShares', [null]), 'Asserting all shares for the user have been deleted'); - $this->mountManager->clear(); + $this->clearMounts(); self::invokePrivate($this->manager, 'setupMounts'); $this->assertNotMount($shareData1['name']); $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}'); |