summaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-01-05 16:40:34 +0100
committerRobin Appelman <icewind@owncloud.com>2016-01-08 15:30:45 +0100
commit88bfe1477d10b35ae454741876a8d6a1dc8385f9 (patch)
tree9a27b227b6e543bbc2c20435fdb74205492679d5 /apps/files_external/tests
parent427dbdabbac4c2f476c991acddcfd56c2f47cce8 (diff)
downloadnextcloud-server-88bfe1477d10b35ae454741876a8d6a1dc8385f9.tar.gz
nextcloud-server-88bfe1477d10b35ae454741876a8d6a1dc8385f9.zip
Filter getStorage to make sure the user has access to it
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r--apps/files_external/tests/service/userglobalstoragesservicetest.php8
-rw-r--r--apps/files_external/tests/service/userstoragesservicetest.php30
2 files changed, 38 insertions, 0 deletions
diff --git a/apps/files_external/tests/service/userglobalstoragesservicetest.php b/apps/files_external/tests/service/userglobalstoragesservicetest.php
index 8057762cb28..d4c48b3f691 100644
--- a/apps/files_external/tests/service/userglobalstoragesservicetest.php
+++ b/apps/files_external/tests/service/userglobalstoragesservicetest.php
@@ -21,6 +21,7 @@
*/
namespace OCA\Files_External\Tests\Service;
+use OCA\Files_external\NotFoundException;
use OCA\Files_external\Service\StoragesService;
use \OCA\Files_External\Service\UserGlobalStoragesService;
use \OCP\IGroupManager;
@@ -140,6 +141,13 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
$this->assertEquals('/mountpoint', $retrievedStorage->getMountPoint());
} else {
$this->assertEquals(0, count($storages));
+
+ try {
+ $this->service->getStorage($newStorage->getId());
+ $this->fail('Failed asserting that storage can\'t be accessed by id');
+ } catch (NotFoundException $e) {
+
+ }
}
}
diff --git a/apps/files_external/tests/service/userstoragesservicetest.php b/apps/files_external/tests/service/userstoragesservicetest.php
index 6b6e6313e77..a2d3819427c 100644
--- a/apps/files_external/tests/service/userstoragesservicetest.php
+++ b/apps/files_external/tests/service/userstoragesservicetest.php
@@ -23,6 +23,8 @@ namespace OCA\Files_external\Tests\Service;
use \OC\Files\Filesystem;
+use OCA\Files_external\Service\GlobalStoragesService;
+use OCA\Files_external\Service\StoragesService;
use \OCA\Files_external\Service\UserStoragesService;
use \OCA\Files_external\NotFoundException;
use \OCA\Files_external\Lib\StorageConfig;
@@ -38,9 +40,16 @@ class UserStoragesServiceTest extends StoragesServiceTest {
private $userId;
+ /**
+ * @var StoragesService
+ */
+ protected $globalStoragesService;
+
public function setUp() {
parent::setUp();
+ $this->globalStoragesService = new GlobalStoragesService($this->backendService, $this->dbConfig);
+
$this->userId = $this->getUniqueID('user_');
$this->createUser($this->userId, $this->userId);
$this->user = \OC::$server->getUserManager()->get($this->userId);
@@ -174,4 +183,25 @@ class UserStoragesServiceTest extends StoragesServiceTest {
$this->userId
);
}
+
+ /**
+ * @expectedException \OCA\Files_external\NotFoundException
+ */
+ public function testGetAdminStorage() {
+ $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
+ $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
+
+ $storage = new StorageConfig();
+ $storage->setMountPoint('mountpoint');
+ $storage->setBackend($backend);
+ $storage->setAuthMechanism($authMechanism);
+ $storage->setBackendOptions(['password' => 'testPassword']);
+ $storage->setApplicableUsers([$this->userId]);
+
+ $newStorage = $this->globalStoragesService->addStorage($storage);
+
+ $this->assertInstanceOf('\OCA\Files_external\Lib\StorageConfig', $this->globalStoragesService->getStorage($newStorage->getId()));
+
+ $this->service->getStorage($newStorage->getId());
+ }
}