Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2017-01-25 14:22:09 +0300
committerLukas Reschke <lukas@statuscode.ch>2017-05-23 00:16:18 +0300
commitcbeedbfb83efc12947651fd34fc10940bf135951 (patch)
treecab67ccd6918146a98e7b857a3b7f53b25711283 /apps/files_sharing
parentcaa48bc98458c4bb4f4b19bb25b945e86109f7b7 (diff)
Ignore NoUserException for shares from ghosts
Add unit tests for FailedStorage init from SharedStorage Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/SharedStorage.php8
-rw-r--r--apps/files_sharing/tests/SharedStorageTest.php38
2 files changed, 44 insertions, 2 deletions
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index 888cbfda143..560c195d8ba 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -32,15 +32,14 @@
namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
-use OC\Files\Cache\FailedCache;
use OC\Files\Storage\Wrapper\PermissionsMask;
-use OCA\Files_Sharing\ISharedStorage;
use OC\Files\Storage\FailedStorage;
use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider;
+use OC\User\NoUserException;
/**
* Convert target path to source path and pass the function call to the correct storage provider
@@ -121,6 +120,11 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
'mask' => $this->superShare->getPermissions()
]);
} catch (NotFoundException $e) {
+ // original file not accessible or deleted, set FailedStorage
+ $this->storage = new FailedStorage(['exception' => $e]);
+ $this->rootPath = '';
+ } catch (NoUserException $e) {
+ // sharer user deleted, set FailedStorage
$this->storage = new FailedStorage(['exception' => $e]);
$this->rootPath = '';
} catch (\Exception $e) {
diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php
index eaa138b0f70..ad6243c46b1 100644
--- a/apps/files_sharing/tests/SharedStorageTest.php
+++ b/apps/files_sharing/tests/SharedStorageTest.php
@@ -28,6 +28,11 @@
namespace OCA\Files_Sharing\Tests;
+use OCA\Files_Sharing\SharedStorage;
+use OCP\Share\IShare;
+use OC\Files\View;
+use OCP\Files\NotFoundException;
+
/**
* Class SharedStorageTest
*
@@ -559,4 +564,37 @@ class SharedStorageTest extends TestCase {
$this->shareManager->deleteShare($share);
}
+
+ public function testInitWithNonExistingUser() {
+ $share = $this->createMock(IShare::class);
+ $share->method('getShareOwner')->willReturn('unexist');
+ $ownerView = $this->createMock(View::class);
+ $storage = new SharedStorage([
+ 'ownerView' => $ownerView,
+ 'superShare' => $share,
+ 'groupedShares' => [$share],
+ 'user' => 'user1',
+ ]);
+
+ // trigger init
+ $this->assertInstanceOf(\OC\Files\Cache\FailedCache::class, $storage->getCache());
+ $this->assertInstanceOf(\OC\Files\Storage\FailedStorage::class, $storage->getSourceStorage());
+ }
+
+ public function testInitWithNotFoundSource() {
+ $share = $this->createMock(IShare::class);
+ $share->method('getShareOwner')->willReturn(self::TEST_FILES_SHARING_API_USER1);
+ $ownerView = $this->createMock(View::class);
+ $ownerView->method('getPath')->will($this->throwException(new NotFoundException()));
+ $storage = new SharedStorage([
+ 'ownerView' => $ownerView,
+ 'superShare' => $share,
+ 'groupedShares' => [$share],
+ 'user' => 'user1',
+ ]);
+
+ // trigger init
+ $this->assertInstanceOf(\OC\Files\Cache\FailedCache::class, $storage->getCache());
+ $this->assertInstanceOf(\OC\Files\Storage\FailedStorage::class, $storage->getSourceStorage());
+ }
}