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 <vincent@nextcloud.com>2021-12-06 13:18:59 +0300
committerVincent Petry <vincent@nextcloud.com>2021-12-15 11:15:31 +0300
commitea302975526ba8fcb5abcca76daa6038439d053e (patch)
treef00714de6e983897719b98cb3c56ed5476156823 /apps/files_external/tests/Controller/StoragesControllerTest.php
parenta47da9722dfaec8d83e9c8543ed0c31138a909da (diff)
Add option to disallow creation of local storages
Introduce a new config option to prevent web UI admins to create or edit external storages of type "local". Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'apps/files_external/tests/Controller/StoragesControllerTest.php')
-rw-r--r--apps/files_external/tests/Controller/StoragesControllerTest.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php
index 7dc2d287b43..bb9be2f2d4a 100644
--- a/apps/files_external/tests/Controller/StoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/StoragesControllerTest.php
@@ -130,6 +130,36 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->assertEquals($storageConfig, $data);
}
+ public function testAddLocalStorageWhenDisabled() {
+ $authMech = $this->getAuthMechMock();
+ $backend = $this->getBackendMock();
+
+ $storageConfig = new StorageConfig(1);
+ $storageConfig->setMountPoint('mount');
+ $storageConfig->setBackend($backend);
+ $storageConfig->setAuthMechanism($authMech);
+ $storageConfig->setBackendOptions([]);
+
+ $this->service->expects($this->never())
+ ->method('createStorage');
+ $this->service->expects($this->never())
+ ->method('addStorage');
+
+ $response = $this->controller->create(
+ 'mount',
+ 'local',
+ '\OCA\Files_External\Lib\Auth\NullMechanism',
+ [],
+ [],
+ [],
+ [],
+ null
+ );
+
+ $data = $response->getData();
+ $this->assertEquals(Http::STATUS_FORBIDDEN, $response->getStatus());
+ }
+
public function testUpdateStorage() {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')