2016-02-04 10:14:17 -05:00
|
|
|
<?php
|
2025-05-17 05:46:26 -04:00
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2016-02-04 10:14:17 -05:00
|
|
|
/**
|
2024-06-06 03:55:47 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2016-02-04 10:14:17 -05: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 09:22:23 -05:00
|
|
|
use OCA\Files_External\Lib\Auth\Password\SessionCredentials;
|
2016-02-04 10:14:17 -05:00
|
|
|
use OCA\Files_External\Lib\Backend\Local;
|
2016-05-13 05:56:47 -04:00
|
|
|
use OCA\Files_External\Lib\StorageConfig;
|
2016-12-19 15:40:08 -05:00
|
|
|
use OCA\Files_External\Service\GlobalStoragesService;
|
|
|
|
|
use OCA\Files_External\Service\UserStoragesService;
|
2017-01-02 07:13:20 -05:00
|
|
|
use OCP\Authentication\LoginCredentials\IStore;
|
2016-12-19 15:40:08 -05:00
|
|
|
use OCP\IL10N;
|
2016-09-02 04:37:20 -04:00
|
|
|
use OCP\IUserManager;
|
|
|
|
|
use OCP\IUserSession;
|
2025-05-17 05:46:26 -04:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2016-02-04 10:14:17 -05:00
|
|
|
use Symfony\Component\Console\Output\BufferedOutput;
|
|
|
|
|
|
2025-05-17 05:46:26 -04:00
|
|
|
class ListCommandTest extends CommandTestCase {
|
|
|
|
|
private function getInstance(): ListCommand {
|
|
|
|
|
/** @var GlobalStoragesService&MockObject $globalService */
|
2016-12-19 15:40:08 -05:00
|
|
|
$globalService = $this->createMock(GlobalStoragesService::class);
|
2025-05-17 05:46:26 -04:00
|
|
|
/** @var UserStoragesService&MockObject $userService */
|
2016-12-19 15:40:08 -05:00
|
|
|
$userService = $this->createMock(UserStoragesService::class);
|
2025-05-17 05:46:26 -04:00
|
|
|
/** @var IUserManager&MockObject $userManager */
|
2016-09-02 04:37:20 -04:00
|
|
|
$userManager = $this->createMock(IUserManager::class);
|
2025-05-17 05:46:26 -04:00
|
|
|
/** @var IUserSession&MockObject $userSession */
|
2016-09-02 04:37:20 -04:00
|
|
|
$userSession = $this->createMock(IUserSession::class);
|
2016-02-04 10:14:17 -05:00
|
|
|
|
|
|
|
|
return new ListCommand($globalService, $userService, $userSession, $userManager);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testListAuthIdentifier(): void {
|
2016-12-19 15:40:08 -05:00
|
|
|
$l10n = $this->createMock(IL10N::class);
|
2016-02-04 10:14:17 -05: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 07:13:20 -05:00
|
|
|
$credentialStore = $this->createMock(IStore::class);
|
|
|
|
|
$mount2->setAuthMechanism(new SessionCredentials($l10n, $credentialStore));
|
2016-02-04 10:14:17 -05: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']);
|
|
|
|
|
}
|
|
|
|
|
}
|