2014-10-31 13:41:07 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 19:13:36 +03:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
2016-01-12 17:02:16 +03:00
|
|
|
* @author Robin McCorkell <robin@mccorkell.me.uk>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-10-05 21:54:56 +03:00
|
|
|
* @author Vincent Petry <pvince81@owncloud.com>
|
2014-10-31 13:41:07 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* @license AGPL-3.0
|
2014-10-31 13:41:07 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
2014-10-31 13:41:07 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2014-10-31 13:41:07 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-03-26 13:44:34 +03:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2014-10-31 13:41:07 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2014-10-31 13:41:07 +03:00
|
|
|
*
|
|
|
|
*/
|
2017-09-06 18:11:21 +03:00
|
|
|
|
2016-05-13 12:22:28 +03:00
|
|
|
namespace OCA\Files_External\Tests\Service;
|
2014-10-31 13:41:07 +03:00
|
|
|
|
2019-11-22 22:52:10 +03:00
|
|
|
use OC\Files\Filesystem;
|
2014-10-31 13:41:07 +03:00
|
|
|
|
2017-10-24 16:26:53 +03:00
|
|
|
use OCA\Files_External\Lib\Auth\AuthMechanism;
|
2017-09-06 18:11:21 +03:00
|
|
|
use OCA\Files_External\Lib\Auth\InvalidAuth;
|
2017-10-24 16:26:53 +03:00
|
|
|
use OCA\Files_External\Lib\Backend\Backend;
|
2017-09-06 18:11:21 +03:00
|
|
|
use OCA\Files_External\Lib\Backend\InvalidBackend;
|
2016-05-13 12:56:47 +03:00
|
|
|
use OCA\Files_External\Lib\StorageConfig;
|
2019-11-22 22:52:10 +03:00
|
|
|
use OCA\Files_External\NotFoundException;
|
2015-11-02 15:13:06 +03:00
|
|
|
use OCA\Files_External\Service\BackendService;
|
|
|
|
use OCA\Files_External\Service\DBConfigService;
|
2016-05-13 12:22:28 +03:00
|
|
|
use OCA\Files_External\Service\StoragesService;
|
2016-09-02 11:37:20 +03:00
|
|
|
use OCP\AppFramework\IAppContainer;
|
|
|
|
use OCP\Files\Config\IUserMountCache;
|
2014-10-31 13:41:07 +03:00
|
|
|
|
2015-11-02 15:13:06 +03:00
|
|
|
class CleaningDBConfig extends DBConfigService {
|
|
|
|
private $mountIds = [];
|
|
|
|
|
|
|
|
public function addMount($mountPoint, $storageBackend, $authBackend, $priority, $type) {
|
|
|
|
$id = parent::addMount($mountPoint, $storageBackend, $authBackend, $priority, $type); // TODO: Change the autogenerated stub
|
|
|
|
$this->mountIds[] = $id;
|
|
|
|
return $id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function clean() {
|
|
|
|
foreach ($this->mountIds as $id) {
|
|
|
|
$this->removeMount($id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group DB
|
|
|
|
*/
|
2014-10-31 13:41:07 +03:00
|
|
|
abstract class StoragesServiceTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var StoragesService
|
|
|
|
*/
|
|
|
|
protected $service;
|
|
|
|
|
2015-08-11 20:45:07 +03:00
|
|
|
/** @var BackendService */
|
|
|
|
protected $backendService;
|
|
|
|
|
2014-10-31 13:41:07 +03:00
|
|
|
/**
|
|
|
|
* Data directory
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $dataDir;
|
|
|
|
|
2015-11-02 15:13:06 +03:00
|
|
|
/** @var CleaningDBConfig */
|
|
|
|
protected $dbConfig;
|
|
|
|
|
2014-10-31 13:41:07 +03:00
|
|
|
/**
|
|
|
|
* Hook calls
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected static $hookCalls;
|
|
|
|
|
2016-01-13 17:29:53 +03:00
|
|
|
/**
|
|
|
|
* @var \PHPUnit_Framework_MockObject_MockObject|\OCP\Files\Config\IUserMountCache
|
|
|
|
*/
|
|
|
|
protected $mountCache;
|
|
|
|
|
2019-11-27 17:27:18 +03:00
|
|
|
protected function setUp(): void {
|
2015-11-02 15:13:06 +03:00
|
|
|
parent::setUp();
|
2016-02-11 15:55:22 +03:00
|
|
|
$this->dbConfig = new CleaningDBConfig(\OC::$server->getDatabaseConnection(), \OC::$server->getCrypto());
|
2014-10-31 13:41:07 +03:00
|
|
|
self::$hookCalls = array();
|
|
|
|
$config = \OC::$server->getConfig();
|
|
|
|
$this->dataDir = $config->getSystemValue(
|
|
|
|
'datadirectory',
|
|
|
|
\OC::$SERVERROOT . '/data/'
|
|
|
|
);
|
|
|
|
\OC_Mount_Config::$skipTest = true;
|
|
|
|
|
2016-09-02 11:37:20 +03:00
|
|
|
$this->mountCache = $this->createMock(IUserMountCache::class);
|
2016-01-13 17:29:53 +03:00
|
|
|
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
// prepare BackendService mock
|
2015-08-11 20:45:07 +03:00
|
|
|
$this->backendService =
|
|
|
|
$this->getMockBuilder('\OCA\Files_External\Service\BackendService')
|
2015-11-02 15:13:06 +03:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
2015-08-11 20:45:07 +03:00
|
|
|
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
$authMechanisms = [
|
2015-08-12 22:03:11 +03:00
|
|
|
'identifier:\Auth\Mechanism' => $this->getAuthMechMock('null', '\Auth\Mechanism'),
|
|
|
|
'identifier:\Other\Auth\Mechanism' => $this->getAuthMechMock('null', '\Other\Auth\Mechanism'),
|
|
|
|
'identifier:\OCA\Files_External\Lib\Auth\NullMechanism' => $this->getAuthMechMock(),
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
];
|
|
|
|
$this->backendService->method('getAuthMechanism')
|
2015-11-02 15:13:06 +03:00
|
|
|
->will($this->returnCallback(function ($class) use ($authMechanisms) {
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
if (isset($authMechanisms[$class])) {
|
|
|
|
return $authMechanisms[$class];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}));
|
|
|
|
$this->backendService->method('getAuthMechanismsByScheme')
|
2015-11-02 15:13:06 +03:00
|
|
|
->will($this->returnCallback(function ($schemes) use ($authMechanisms) {
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
return array_filter($authMechanisms, function ($authMech) use ($schemes) {
|
|
|
|
return in_array($authMech->getScheme(), $schemes, true);
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
$this->backendService->method('getAuthMechanisms')
|
|
|
|
->will($this->returnValue($authMechanisms));
|
|
|
|
|
2016-04-14 01:18:07 +03:00
|
|
|
$sftpBackend = $this->getBackendMock('\OCA\Files_External\Lib\Backend\SFTP', '\OCA\Files_External\Lib\Storage\SFTP');
|
2015-08-11 20:45:07 +03:00
|
|
|
$backends = [
|
2018-06-21 17:00:58 +03:00
|
|
|
'identifier:\OCA\Files_External\Lib\Backend\DAV' => $this->getBackendMock('\OCA\Files_External\Lib\Backend\DAV', '\OC\Files\Storage\DAV'),
|
2016-04-14 01:18:07 +03:00
|
|
|
'identifier:\OCA\Files_External\Lib\Backend\SMB' => $this->getBackendMock('\OCA\Files_External\Lib\Backend\SMB', '\OCA\Files_External\Lib\Storage\SMB'),
|
2015-08-12 22:03:11 +03:00
|
|
|
'identifier:\OCA\Files_External\Lib\Backend\SFTP' => $sftpBackend,
|
|
|
|
'identifier:sftp_alias' => $sftpBackend,
|
2015-08-11 20:45:07 +03:00
|
|
|
];
|
2015-08-12 22:03:11 +03:00
|
|
|
$backends['identifier:\OCA\Files_External\Lib\Backend\SFTP']->method('getLegacyAuthMechanism')
|
|
|
|
->willReturn($authMechanisms['identifier:\Other\Auth\Mechanism']);
|
2015-08-11 20:45:07 +03:00
|
|
|
$this->backendService->method('getBackend')
|
2015-11-02 15:13:06 +03:00
|
|
|
->will($this->returnCallback(function ($backendClass) use ($backends) {
|
2015-08-11 20:45:07 +03:00
|
|
|
if (isset($backends[$backendClass])) {
|
|
|
|
return $backends[$backendClass];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}));
|
|
|
|
$this->backendService->method('getBackends')
|
|
|
|
->will($this->returnValue($backends));
|
|
|
|
|
2014-10-31 13:41:07 +03:00
|
|
|
\OCP\Util::connectHook(
|
|
|
|
Filesystem::CLASSNAME,
|
|
|
|
Filesystem::signal_create_mount,
|
|
|
|
get_class($this), 'createHookCallback');
|
|
|
|
\OCP\Util::connectHook(
|
|
|
|
Filesystem::CLASSNAME,
|
|
|
|
Filesystem::signal_delete_mount,
|
|
|
|
get_class($this), 'deleteHookCallback');
|
|
|
|
|
2016-09-02 11:37:20 +03:00
|
|
|
$containerMock = $this->createMock(IAppContainer::class);
|
2015-08-12 22:03:11 +03:00
|
|
|
$containerMock->method('query')
|
2015-11-02 15:13:06 +03:00
|
|
|
->will($this->returnCallback(function ($name) {
|
2015-08-12 22:03:11 +03:00
|
|
|
if ($name === 'OCA\Files_External\Service\BackendService') {
|
|
|
|
return $this->backendService;
|
|
|
|
}
|
|
|
|
}));
|
2015-08-12 23:43:29 +03:00
|
|
|
|
|
|
|
\OC_Mount_Config::$app = $this->getMockBuilder('\OCA\Files_External\Appinfo\Application')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
\OC_Mount_Config::$app->method('getContainer')
|
|
|
|
->willReturn($containerMock);
|
2014-10-31 13:41:07 +03:00
|
|
|
}
|
|
|
|
|
2019-11-27 17:27:18 +03:00
|
|
|
protected function tearDown(): void {
|
2014-10-31 13:41:07 +03:00
|
|
|
\OC_Mount_Config::$skipTest = false;
|
|
|
|
self::$hookCalls = array();
|
2015-11-02 15:13:06 +03:00
|
|
|
if ($this->dbConfig) {
|
|
|
|
$this->dbConfig->clean();
|
|
|
|
}
|
2014-10-31 13:41:07 +03:00
|
|
|
}
|
|
|
|
|
2016-04-14 01:18:07 +03:00
|
|
|
protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') {
|
2017-10-24 16:26:53 +03:00
|
|
|
$backend = $this->getMockBuilder(Backend::class)
|
2015-08-11 20:45:07 +03:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$backend->method('getStorageClass')
|
|
|
|
->willReturn($storageClass);
|
2015-08-12 22:03:11 +03:00
|
|
|
$backend->method('getIdentifier')
|
2015-11-02 15:13:06 +03:00
|
|
|
->willReturn('identifier:' . $class);
|
2015-08-11 20:45:07 +03:00
|
|
|
return $backend;
|
|
|
|
}
|
|
|
|
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') {
|
2017-10-24 16:26:53 +03:00
|
|
|
$authMech = $this->getMockBuilder(AuthMechanism::class)
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$authMech->method('getScheme')
|
|
|
|
->willReturn($scheme);
|
2015-08-12 22:03:11 +03:00
|
|
|
$authMech->method('getIdentifier')
|
2015-11-02 15:13:06 +03:00
|
|
|
->willReturn('identifier:' . $class);
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
|
|
|
|
return $authMech;
|
|
|
|
}
|
|
|
|
|
2014-10-31 13:41:07 +03:00
|
|
|
/**
|
|
|
|
* Creates a StorageConfig instance based on array data
|
|
|
|
*
|
2017-10-24 16:26:53 +03:00
|
|
|
* @param array $data
|
2014-10-31 13:41:07 +03:00
|
|
|
*
|
|
|
|
* @return StorageConfig storage config instance
|
|
|
|
*/
|
|
|
|
protected function makeStorageConfig($data) {
|
|
|
|
$storage = new StorageConfig();
|
|
|
|
if (isset($data['id'])) {
|
|
|
|
$storage->setId($data['id']);
|
|
|
|
}
|
|
|
|
$storage->setMountPoint($data['mountPoint']);
|
2015-08-11 20:45:07 +03:00
|
|
|
if (!isset($data['backend'])) {
|
|
|
|
// data providers are run before $this->backendService is initialised
|
|
|
|
// so $data['backend'] can be specified directly
|
2015-08-12 22:03:11 +03:00
|
|
|
$data['backend'] = $this->backendService->getBackend($data['backendIdentifier']);
|
|
|
|
}
|
|
|
|
if (!isset($data['backend'])) {
|
|
|
|
throw new \Exception('oops, no backend');
|
|
|
|
}
|
|
|
|
if (!isset($data['authMechanism'])) {
|
|
|
|
$data['authMechanism'] = $this->backendService->getAuthMechanism($data['authMechanismIdentifier']);
|
2015-08-11 20:45:07 +03:00
|
|
|
}
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
if (!isset($data['authMechanism'])) {
|
2015-08-12 22:03:11 +03:00
|
|
|
throw new \Exception('oops, no auth mechanism');
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
}
|
2015-08-11 20:45:07 +03:00
|
|
|
$storage->setBackend($data['backend']);
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
$storage->setAuthMechanism($data['authMechanism']);
|
2014-10-31 13:41:07 +03:00
|
|
|
$storage->setBackendOptions($data['backendOptions']);
|
|
|
|
if (isset($data['applicableUsers'])) {
|
|
|
|
$storage->setApplicableUsers($data['applicableUsers']);
|
|
|
|
}
|
|
|
|
if (isset($data['applicableGroups'])) {
|
|
|
|
$storage->setApplicableGroups($data['applicableGroups']);
|
|
|
|
}
|
|
|
|
if (isset($data['priority'])) {
|
|
|
|
$storage->setPriority($data['priority']);
|
|
|
|
}
|
2015-03-13 14:49:11 +03:00
|
|
|
if (isset($data['mountOptions'])) {
|
|
|
|
$storage->setMountOptions($data['mountOptions']);
|
|
|
|
}
|
2014-10-31 13:41:07 +03:00
|
|
|
return $storage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-27 15:47:39 +03:00
|
|
|
protected function ActualNonExistingStorageTest() {
|
2015-08-12 22:03:11 +03:00
|
|
|
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
|
|
|
|
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
|
2014-10-31 13:41:07 +03:00
|
|
|
$storage = new StorageConfig(255);
|
|
|
|
$storage->setMountPoint('mountpoint');
|
2015-08-11 20:45:07 +03:00
|
|
|
$storage->setBackend($backend);
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
$storage->setAuthMechanism($authMechanism);
|
2014-10-31 13:41:07 +03:00
|
|
|
$this->service->updateStorage($storage);
|
|
|
|
}
|
|
|
|
|
2019-11-27 15:47:39 +03:00
|
|
|
public function testNonExistingStorage() {
|
|
|
|
$this->expectException(\OCA\Files_External\NotFoundException::class);
|
|
|
|
|
|
|
|
$this->ActualNonExistingStorageTest();
|
|
|
|
}
|
|
|
|
|
2015-10-06 17:47:59 +03:00
|
|
|
public function deleteStorageDataProvider() {
|
|
|
|
return [
|
|
|
|
// regular case, can properly delete the oc_storages entry
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'host' => 'example.com',
|
|
|
|
'user' => 'test',
|
|
|
|
'password' => 'testPassword',
|
|
|
|
'root' => 'someroot',
|
|
|
|
],
|
2018-06-21 17:00:58 +03:00
|
|
|
'webdav::test@example.com//someroot/',
|
2015-10-06 17:47:59 +03:00
|
|
|
0
|
|
|
|
],
|
|
|
|
// special case with $user vars, cannot auto-remove the oc_storages entry
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'host' => 'example.com',
|
|
|
|
'user' => '$user',
|
|
|
|
'password' => 'testPassword',
|
|
|
|
'root' => 'someroot',
|
|
|
|
],
|
2018-06-21 17:00:58 +03:00
|
|
|
'webdav::someone@example.com//someroot/',
|
2015-10-06 17:47:59 +03:00
|
|
|
1
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider deleteStorageDataProvider
|
|
|
|
*/
|
|
|
|
public function testDeleteStorage($backendOptions, $rustyStorageId, $expectedCountAfterDeletion) {
|
2018-06-21 17:00:58 +03:00
|
|
|
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\DAV');
|
2015-08-12 22:03:11 +03:00
|
|
|
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
|
2014-10-31 13:41:07 +03:00
|
|
|
$storage = new StorageConfig(255);
|
|
|
|
$storage->setMountPoint('mountpoint');
|
2015-08-11 20:45:07 +03:00
|
|
|
$storage->setBackend($backend);
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
$storage->setAuthMechanism($authMechanism);
|
2015-10-06 17:47:59 +03:00
|
|
|
$storage->setBackendOptions($backendOptions);
|
2014-10-31 13:41:07 +03:00
|
|
|
|
|
|
|
$newStorage = $this->service->addStorage($storage);
|
2015-11-02 15:13:06 +03:00
|
|
|
$id = $newStorage->getId();
|
2014-10-31 13:41:07 +03:00
|
|
|
|
2015-10-06 17:47:59 +03:00
|
|
|
// manually trigger storage entry because normally it happens on first
|
|
|
|
// access, which isn't possible within this test
|
|
|
|
$storageCache = new \OC\Files\Cache\Storage($rustyStorageId);
|
|
|
|
|
|
|
|
// get numeric id for later check
|
|
|
|
$numericId = $storageCache->getNumericId();
|
|
|
|
|
2015-11-02 15:13:06 +03:00
|
|
|
$this->service->removeStorage($id);
|
2014-10-31 13:41:07 +03:00
|
|
|
|
|
|
|
$caught = false;
|
|
|
|
try {
|
|
|
|
$this->service->getStorage(1);
|
|
|
|
} catch (NotFoundException $e) {
|
|
|
|
$caught = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertTrue($caught);
|
2015-10-06 17:47:59 +03:00
|
|
|
|
|
|
|
// storage id was removed from oc_storages
|
|
|
|
$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
|
|
|
|
$storageCheckQuery = $qb->select('*')
|
|
|
|
->from('storages')
|
|
|
|
->where($qb->expr()->eq('numeric_id', $qb->expr()->literal($numericId)));
|
2018-06-21 17:02:51 +03:00
|
|
|
$storages = $storageCheckQuery->execute()->fetchAll();
|
|
|
|
$this->assertCount($expectedCountAfterDeletion, $storages, "expected $expectedCountAfterDeletion storages, got " . json_encode($storages));
|
2014-10-31 13:41:07 +03:00
|
|
|
}
|
|
|
|
|
2019-11-27 15:47:39 +03:00
|
|
|
protected function actualDeletedUnexistingStorageTest() {
|
|
|
|
$this->service->removeStorage(255);
|
|
|
|
}
|
|
|
|
|
2014-10-31 13:41:07 +03:00
|
|
|
public function testDeleteUnexistingStorage() {
|
2019-11-27 17:27:18 +03:00
|
|
|
$this->expectException(\OCA\Files_External\NotFoundException::class);
|
|
|
|
|
2019-11-27 15:47:39 +03:00
|
|
|
$this->actualDeletedUnexistingStorageTest();
|
2014-10-31 13:41:07 +03:00
|
|
|
}
|
|
|
|
|
2015-08-12 12:00:37 +03:00
|
|
|
public function testCreateStorage() {
|
|
|
|
$mountPoint = 'mount';
|
|
|
|
$backendIdentifier = 'identifier:\OCA\Files_External\Lib\Backend\SMB';
|
|
|
|
$authMechanismIdentifier = 'identifier:\Auth\Mechanism';
|
|
|
|
$backendOptions = ['param' => 'foo', 'param2' => 'bar'];
|
|
|
|
$mountOptions = ['option' => 'foobar'];
|
|
|
|
$applicableUsers = ['user1', 'user2'];
|
|
|
|
$applicableGroups = ['group'];
|
|
|
|
$priority = 123;
|
|
|
|
|
|
|
|
$backend = $this->backendService->getBackend($backendIdentifier);
|
|
|
|
$authMechanism = $this->backendService->getAuthMechanism($authMechanismIdentifier);
|
|
|
|
|
|
|
|
$storage = $this->service->createStorage(
|
|
|
|
$mountPoint,
|
|
|
|
$backendIdentifier,
|
|
|
|
$authMechanismIdentifier,
|
|
|
|
$backendOptions,
|
|
|
|
$mountOptions,
|
|
|
|
$applicableUsers,
|
|
|
|
$applicableGroups,
|
|
|
|
$priority
|
|
|
|
);
|
|
|
|
|
2015-11-02 15:13:06 +03:00
|
|
|
$this->assertEquals('/' . $mountPoint, $storage->getMountPoint());
|
2015-08-12 12:00:37 +03:00
|
|
|
$this->assertEquals($backend, $storage->getBackend());
|
|
|
|
$this->assertEquals($authMechanism, $storage->getAuthMechanism());
|
|
|
|
$this->assertEquals($backendOptions, $storage->getBackendOptions());
|
|
|
|
$this->assertEquals($mountOptions, $storage->getMountOptions());
|
|
|
|
$this->assertEquals($applicableUsers, $storage->getApplicableUsers());
|
|
|
|
$this->assertEquals($applicableGroups, $storage->getApplicableGroups());
|
|
|
|
$this->assertEquals($priority, $storage->getPriority());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreateStorageInvalidClass() {
|
2017-09-06 18:11:21 +03:00
|
|
|
$storage = $this->service->createStorage(
|
2015-08-12 12:00:37 +03:00
|
|
|
'mount',
|
|
|
|
'identifier:\OC\Not\A\Backend',
|
|
|
|
'identifier:\Auth\Mechanism',
|
|
|
|
[]
|
|
|
|
);
|
2017-09-06 18:11:21 +03:00
|
|
|
$this->assertInstanceOf(InvalidBackend::class, $storage->getBackend());
|
2015-08-12 12:00:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreateStorageInvalidAuthMechanismClass() {
|
2017-09-06 18:11:21 +03:00
|
|
|
$storage = $this->service->createStorage(
|
2015-08-12 12:00:37 +03:00
|
|
|
'mount',
|
|
|
|
'identifier:\OCA\Files_External\Lib\Backend\SMB',
|
|
|
|
'identifier:\Not\An\Auth\Mechanism',
|
|
|
|
[]
|
|
|
|
);
|
2017-09-06 18:11:21 +03:00
|
|
|
$this->assertInstanceOf(InvalidAuth::class, $storage->getAuthMechanism());
|
2015-08-12 12:00:37 +03:00
|
|
|
}
|
|
|
|
|
2015-09-23 18:00:21 +03:00
|
|
|
public function testGetStoragesBackendNotVisible() {
|
|
|
|
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
|
|
|
|
$backend->expects($this->once())
|
|
|
|
->method('isVisibleFor')
|
|
|
|
->with($this->service->getVisibilityType())
|
|
|
|
->willReturn(false);
|
|
|
|
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
|
|
|
|
$authMechanism->method('isVisibleFor')
|
|
|
|
->with($this->service->getVisibilityType())
|
|
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
$storage = new StorageConfig(255);
|
|
|
|
$storage->setMountPoint('mountpoint');
|
|
|
|
$storage->setBackend($backend);
|
|
|
|
$storage->setAuthMechanism($authMechanism);
|
|
|
|
$storage->setBackendOptions(['password' => 'testPassword']);
|
|
|
|
|
|
|
|
$newStorage = $this->service->addStorage($storage);
|
|
|
|
|
|
|
|
$this->assertCount(1, $this->service->getAllStorages());
|
|
|
|
$this->assertEmpty($this->service->getStorages());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetStoragesAuthMechanismNotVisible() {
|
|
|
|
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
|
|
|
|
$backend->method('isVisibleFor')
|
|
|
|
->with($this->service->getVisibilityType())
|
|
|
|
->willReturn(true);
|
|
|
|
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
|
|
|
|
$authMechanism->expects($this->once())
|
|
|
|
->method('isVisibleFor')
|
|
|
|
->with($this->service->getVisibilityType())
|
|
|
|
->willReturn(false);
|
|
|
|
|
|
|
|
$storage = new StorageConfig(255);
|
|
|
|
$storage->setMountPoint('mountpoint');
|
|
|
|
$storage->setBackend($backend);
|
|
|
|
$storage->setAuthMechanism($authMechanism);
|
|
|
|
$storage->setBackendOptions(['password' => 'testPassword']);
|
|
|
|
|
|
|
|
$newStorage = $this->service->addStorage($storage);
|
|
|
|
|
|
|
|
$this->assertCount(1, $this->service->getAllStorages());
|
|
|
|
$this->assertEmpty($this->service->getStorages());
|
|
|
|
}
|
|
|
|
|
2014-10-31 13:41:07 +03:00
|
|
|
public static function createHookCallback($params) {
|
|
|
|
self::$hookCalls[] = array(
|
|
|
|
'signal' => Filesystem::signal_create_mount,
|
|
|
|
'params' => $params
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function deleteHookCallback($params) {
|
|
|
|
self::$hookCalls[] = array(
|
|
|
|
'signal' => Filesystem::signal_delete_mount,
|
|
|
|
'params' => $params
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asserts hook call
|
|
|
|
*
|
|
|
|
* @param array $callData hook call data to check
|
|
|
|
* @param string $signal signal name
|
|
|
|
* @param string $mountPath mount path
|
|
|
|
* @param string $mountType mount type
|
|
|
|
* @param string $applicable applicable users
|
|
|
|
*/
|
|
|
|
protected function assertHookCall($callData, $signal, $mountPath, $mountType, $applicable) {
|
|
|
|
$this->assertEquals($signal, $callData['signal']);
|
|
|
|
$params = $callData['params'];
|
|
|
|
$this->assertEquals(
|
|
|
|
$mountPath,
|
|
|
|
$params[Filesystem::signal_param_path]
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
$mountType,
|
|
|
|
$params[Filesystem::signal_param_mount_type]
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
$applicable,
|
|
|
|
$params[Filesystem::signal_param_users]
|
|
|
|
);
|
|
|
|
}
|
2015-12-15 15:24:30 +03:00
|
|
|
|
|
|
|
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'));
|
|
|
|
}
|
2014-10-31 13:41:07 +03:00
|
|
|
}
|