2016-02-04 18:14:17 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2020-08-24 15:54:25 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 19:13:36 +03:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-02-04 18:14:17 +03:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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/>
|
2016-02-04 18:14:17 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Files_External\Tests\Command;
|
|
|
|
|
|
|
|
use OCA\Files_External\Command\ListCommand;
|
|
|
|
use OCA\Files_External\Lib\Auth\NullMechanism;
|
|
|
|
use OCA\Files_External\Lib\Auth\Password\Password;
|
2016-02-16 17:22:23 +03:00
|
|
|
use OCA\Files_External\Lib\Auth\Password\SessionCredentials;
|
2016-02-04 18:14:17 +03:00
|
|
|
use OCA\Files_External\Lib\Backend\Local;
|
2016-05-13 12:56:47 +03:00
|
|
|
use OCA\Files_External\Lib\StorageConfig;
|
2016-12-19 23:40:08 +03:00
|
|
|
use OCA\Files_External\Service\GlobalStoragesService;
|
|
|
|
use OCA\Files_External\Service\UserStoragesService;
|
2017-01-02 15:13:20 +03:00
|
|
|
use OCP\Authentication\LoginCredentials\IStore;
|
2016-12-19 23:40:08 +03:00
|
|
|
use OCP\IL10N;
|
2016-09-02 11:37:20 +03:00
|
|
|
use OCP\ISession;
|
|
|
|
use OCP\IUserManager;
|
|
|
|
use OCP\IUserSession;
|
|
|
|
use OCP\Security\ICrypto;
|
2016-02-04 18:14:17 +03:00
|
|
|
use Symfony\Component\Console\Output\BufferedOutput;
|
|
|
|
|
|
|
|
class ListCommandTest extends CommandTest {
|
|
|
|
/**
|
2020-08-11 22:32:18 +03:00
|
|
|
* @return ListCommand|\PHPUnit\Framework\MockObject\MockObject
|
2016-02-04 18:14:17 +03:00
|
|
|
*/
|
|
|
|
private function getInstance() {
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var GlobalStoragesService|\PHPUnit\Framework\MockObject\MockObject $globalService */
|
2016-12-19 23:40:08 +03:00
|
|
|
$globalService = $this->createMock(GlobalStoragesService::class);
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var UserStoragesService|\PHPUnit\Framework\MockObject\MockObject $userService */
|
2016-12-19 23:40:08 +03:00
|
|
|
$userService = $this->createMock(UserStoragesService::class);
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */
|
2016-09-02 11:37:20 +03:00
|
|
|
$userManager = $this->createMock(IUserManager::class);
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */
|
2016-09-02 11:37:20 +03:00
|
|
|
$userSession = $this->createMock(IUserSession::class);
|
2016-02-04 18:14:17 +03:00
|
|
|
|
|
|
|
return new ListCommand($globalService, $userService, $userSession, $userManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testListAuthIdentifier() {
|
2016-12-19 23:40:08 +03:00
|
|
|
$l10n = $this->createMock(IL10N::class);
|
2016-09-02 11:37:20 +03:00
|
|
|
$session = $this->createMock(ISession::class);
|
|
|
|
$crypto = $this->createMock(ICrypto::class);
|
2016-02-04 18:14:17 +03:00
|
|
|
$instance = $this->getInstance();
|
|
|
|
$mount1 = new StorageConfig();
|
|
|
|
$mount1->setAuthMechanism(new Password($l10n));
|
|
|
|
$mount1->setBackend(new Local($l10n, new NullMechanism($l10n)));
|
|
|
|
$mount2 = new StorageConfig();
|
2017-01-02 15:13:20 +03:00
|
|
|
$credentialStore = $this->createMock(IStore::class);
|
|
|
|
$mount2->setAuthMechanism(new SessionCredentials($l10n, $credentialStore));
|
2016-02-04 18:14:17 +03:00
|
|
|
$mount2->setBackend(new Local($l10n, new NullMechanism($l10n)));
|
|
|
|
$input = $this->getInput($instance, [], [
|
|
|
|
'output' => 'json'
|
|
|
|
]);
|
|
|
|
$output = new BufferedOutput();
|
|
|
|
|
|
|
|
$instance->listMounts('', [$mount1, $mount2], $input, $output);
|
|
|
|
$output = json_decode($output->fetch(), true);
|
|
|
|
|
|
|
|
$this->assertNotEquals($output[0]['authentication_type'], $output[1]['authentication_type']);
|
|
|
|
}
|
|
|
|
}
|