diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-12-15 13:24:30 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-01-08 11:54:31 +0100 |
commit | ab549970cadc8557f55a32d802c608ddf44238c8 (patch) | |
tree | d376e6c0cd98812d44b7184b6f60c83547b146a8 /apps/files_external/tests | |
parent | 88c4cba1f52a63da78da56e50ac9f22a643a5be0 (diff) | |
download | nextcloud-server-ab549970cadc8557f55a32d802c608ddf44238c8.tar.gz nextcloud-server-ab549970cadc8557f55a32d802c608ddf44238c8.zip |
fix setting mountpoint and auth backend of external storages
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r-- | apps/files_external/tests/service/dbconfigservicetest.php | 28 | ||||
-rw-r--r-- | apps/files_external/tests/service/storagesservicetest.php | 29 |
2 files changed, 57 insertions, 0 deletions
diff --git a/apps/files_external/tests/service/dbconfigservicetest.php b/apps/files_external/tests/service/dbconfigservicetest.php index d5b4ff1585d..bfb564c6663 100644 --- a/apps/files_external/tests/service/dbconfigservicetest.php +++ b/apps/files_external/tests/service/dbconfigservicetest.php @@ -230,4 +230,32 @@ class DBConfigServiceTest extends TestCase { $this->assertEquals($id1, $mounts[0]['mount_id']); $this->assertEquals([['type' => DBConfigService::APPLICABLE_TYPE_GLOBAL, 'value' => null, 'mount_id' => $id1]], $mounts[0]['applicable']); } + + public function testSetMountPoint() { + $id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN); + $id2 = $this->addMount('/foo', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN); + + $this->dbConfig->setMountPoint($id1, '/asd'); + + $mount = $this->dbConfig->getMountById($id1); + $this->assertEquals('/asd', $mount['mount_point']); + + // remains unchanged + $mount = $this->dbConfig->getMountById($id2); + $this->assertEquals('/foo', $mount['mount_point']); + } + + public function testSetAuthBackend() { + $id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN); + $id2 = $this->addMount('/foo', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN); + + $this->dbConfig->setAuthBackend($id1, 'none'); + + $mount = $this->dbConfig->getMountById($id1); + $this->assertEquals('none', $mount['auth_backend']); + + // remains unchanged + $mount = $this->dbConfig->getMountById($id2); + $this->assertEquals('bar', $mount['auth_backend']); + } } diff --git a/apps/files_external/tests/service/storagesservicetest.php b/apps/files_external/tests/service/storagesservicetest.php index 7847bd45d4a..d5430982899 100644 --- a/apps/files_external/tests/service/storagesservicetest.php +++ b/apps/files_external/tests/service/storagesservicetest.php @@ -465,4 +465,33 @@ abstract class StoragesServiceTest extends \Test\TestCase { $params[Filesystem::signal_param_users] ); } + + public function testUpdateStorageMountPoint() { + $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']); + + $savedStorage = $this->service->addStorage($storage); + + $newAuthMechanism = $this->backendService->getAuthMechanism('identifier:\Other\Auth\Mechanism'); + + $updatedStorage = new StorageConfig($savedStorage->getId()); + $updatedStorage->setMountPoint('mountpoint2'); + $updatedStorage->setBackend($backend); + $updatedStorage->setAuthMechanism($newAuthMechanism); + $updatedStorage->setBackendOptions(['password' => 'password2']); + + $this->service->updateStorage($updatedStorage); + + $savedStorage = $this->service->getStorage($updatedStorage->getId()); + + $this->assertEquals('/mountpoint2', $savedStorage->getMountPoint()); + $this->assertEquals($newAuthMechanism, $savedStorage->getAuthMechanism()); + $this->assertEquals('password2', $savedStorage->getBackendOption('password')); + } } |