2015-03-17 18:51:07 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Bjoern Schiessle <bjoern@schiessle.org>
|
2020-04-29 12:57:22 +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 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-01-12 17:02:16 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2015-03-17 18:51:07 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* @license AGPL-3.0
|
2015-03-17 18:51: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.
|
2015-03-17 18:51:07 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2015-03-17 18:51: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.
|
2015-03-17 18:51: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/>
|
2015-03-17 18:51:07 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Files_Sharing\Tests\External;
|
|
|
|
|
2017-01-27 14:52:17 +03:00
|
|
|
use OC\Federation\CloudIdManager;
|
2015-03-24 19:26:38 +03:00
|
|
|
use OC\Files\Storage\StorageFactory;
|
2015-04-27 18:14:52 +03:00
|
|
|
use OCA\Files_Sharing\External\Manager;
|
2015-10-05 17:43:10 +03:00
|
|
|
use OCA\Files_Sharing\External\MountProvider;
|
2015-03-17 18:51:07 +03:00
|
|
|
use OCA\Files_Sharing\Tests\TestCase;
|
2020-07-13 16:43:42 +03:00
|
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
2018-06-12 17:20:53 +03:00
|
|
|
use OCP\Federation\ICloudFederationFactory;
|
|
|
|
use OCP\Federation\ICloudFederationProviderManager;
|
2016-08-23 11:16:33 +03:00
|
|
|
use OCP\Http\Client\IClientService;
|
2019-11-22 15:23:56 +03:00
|
|
|
use OCP\Http\Client\IResponse;
|
2018-07-04 11:39:13 +03:00
|
|
|
use OCP\IGroupManager;
|
|
|
|
use OCP\IUserManager;
|
2020-06-24 17:49:16 +03:00
|
|
|
use OCP\Share\IShare;
|
2015-10-05 17:18:14 +03:00
|
|
|
use Test\Traits\UserTrait;
|
2015-03-17 18:51:07 +03:00
|
|
|
|
2015-11-03 03:52:41 +03:00
|
|
|
/**
|
|
|
|
* Class ManagerTest
|
|
|
|
*
|
|
|
|
* @group DB
|
|
|
|
*
|
|
|
|
* @package OCA\Files_Sharing\Tests\External
|
|
|
|
*/
|
2015-03-17 18:51:07 +03:00
|
|
|
class ManagerTest extends TestCase {
|
2015-10-05 17:18:14 +03:00
|
|
|
use UserTrait;
|
2015-03-17 18:51:07 +03:00
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var Manager|\PHPUnit\Framework\MockObject\MockObject **/
|
2015-03-17 18:51:07 +03:00
|
|
|
private $manager;
|
|
|
|
|
2015-03-24 19:26:38 +03:00
|
|
|
/** @var \OC\Files\Mount\Manager */
|
|
|
|
private $mountManager;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IClientService|\PHPUnit\Framework\MockObject\MockObject */
|
2016-08-23 11:16:33 +03:00
|
|
|
private $clientService;
|
2015-04-27 18:14:52 +03:00
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ICloudFederationProviderManager|\PHPUnit\Framework\MockObject\MockObject */
|
2018-06-12 17:20:53 +03:00
|
|
|
private $cloudFederationProviderManager;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ICloudFederationFactory|\PHPUnit\Framework\MockObject\MockObject */
|
2018-06-12 17:20:53 +03:00
|
|
|
private $cloudFederationFactory;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var \PHPUnit\Framework\MockObject\MockObject|IGroupManager */
|
2018-07-04 11:39:13 +03:00
|
|
|
private $groupManager;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var \PHPUnit\Framework\MockObject\MockObject|IUserManager */
|
2018-07-04 11:39:13 +03:00
|
|
|
private $userManager;
|
|
|
|
|
2015-03-17 18:51:07 +03:00
|
|
|
private $uid;
|
|
|
|
|
2015-10-05 17:18:14 +03:00
|
|
|
/**
|
|
|
|
* @var \OCP\IUser
|
|
|
|
*/
|
|
|
|
private $user;
|
2016-09-20 16:27:40 +03:00
|
|
|
private $testMountProvider;
|
2020-07-13 16:43:42 +03:00
|
|
|
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
|
|
|
|
private $eventDispatcher;
|
2015-10-05 17:18:14 +03:00
|
|
|
|
2019-11-21 18:40:38 +03:00
|
|
|
protected function setUp(): void {
|
2015-03-17 18:51:07 +03:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->uid = $this->getUniqueID('user');
|
2015-10-05 17:18:14 +03:00
|
|
|
$this->createUser($this->uid, '');
|
|
|
|
$this->user = \OC::$server->getUserManager()->get($this->uid);
|
2015-03-24 19:26:38 +03:00
|
|
|
$this->mountManager = new \OC\Files\Mount\Manager();
|
2017-10-24 16:26:53 +03:00
|
|
|
$this->clientService = $this->getMockBuilder(IClientService::class)
|
2016-08-23 11:16:33 +03:00
|
|
|
->disableOriginalConstructor()->getMock();
|
2018-06-12 17:20:53 +03:00
|
|
|
$this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class);
|
|
|
|
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
|
2018-07-04 11:39:13 +03:00
|
|
|
$this->groupManager = $this->createMock(IGroupManager::class);
|
|
|
|
$this->userManager = $this->createMock(IUserManager::class);
|
2020-07-13 16:43:42 +03:00
|
|
|
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
|
2018-06-12 17:20:53 +03:00
|
|
|
|
|
|
|
$this->manager = $this->getMockBuilder(Manager::class)
|
|
|
|
->setConstructorArgs(
|
|
|
|
[
|
|
|
|
\OC::$server->getDatabaseConnection(),
|
|
|
|
$this->mountManager,
|
|
|
|
new StorageFactory(),
|
|
|
|
$this->clientService,
|
|
|
|
\OC::$server->getNotificationManager(),
|
|
|
|
\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
|
|
|
|
$this->cloudFederationProviderManager,
|
|
|
|
$this->cloudFederationFactory,
|
2018-07-04 11:39:13 +03:00
|
|
|
$this->groupManager,
|
|
|
|
$this->userManager,
|
2020-07-13 16:43:42 +03:00
|
|
|
$this->uid,
|
|
|
|
$this->eventDispatcher,
|
2018-06-12 17:20:53 +03:00
|
|
|
]
|
|
|
|
)->setMethods(['tryOCMEndPoint'])->getMock();
|
2017-03-10 17:37:21 +03:00
|
|
|
|
2020-04-09 14:53:40 +03:00
|
|
|
$this->testMountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function () {
|
2015-10-05 17:43:10 +03:00
|
|
|
return $this->manager;
|
2017-01-27 14:52:17 +03:00
|
|
|
}, new CloudIdManager());
|
2015-03-17 18:51:07 +03:00
|
|
|
}
|
|
|
|
|
2015-10-05 17:18:14 +03:00
|
|
|
private function setupMounts() {
|
2016-09-20 16:27:40 +03:00
|
|
|
$mounts = $this->testMountProvider->getMountsForUser($this->user, new StorageFactory());
|
2015-10-05 17:18:14 +03:00
|
|
|
foreach ($mounts as $mount) {
|
|
|
|
$this->mountManager->addMount($mount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-17 18:51:07 +03:00
|
|
|
public function testAddShare() {
|
|
|
|
$shareData1 = [
|
2015-03-24 19:26:38 +03:00
|
|
|
'remote' => 'http://localhost',
|
2015-03-17 18:51:07 +03:00
|
|
|
'token' => 'token1',
|
|
|
|
'password' => '',
|
|
|
|
'name' => '/SharedFolder',
|
|
|
|
'owner' => 'foobar',
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_USER,
|
2015-03-17 18:51:07 +03:00
|
|
|
'accepted' => false,
|
|
|
|
'user' => $this->uid,
|
|
|
|
];
|
|
|
|
$shareData2 = $shareData1;
|
|
|
|
$shareData2['token'] = 'token2';
|
|
|
|
$shareData3 = $shareData1;
|
|
|
|
$shareData3['token'] = 'token3';
|
|
|
|
|
2018-07-11 11:21:00 +03:00
|
|
|
$this->userManager->expects($this->any())->method('get')->willReturn($this->user);
|
|
|
|
$this->groupManager->expects($this->any())->method(('getUserGroups'))->willReturn([]);
|
|
|
|
|
2018-06-12 17:20:53 +03:00
|
|
|
$this->manager->expects($this->at(0))->method('tryOCMEndPoint')->with('http://localhost', 'token1', -1, 'accept')->willReturn(false);
|
|
|
|
$this->manager->expects($this->at(1))->method('tryOCMEndPoint')->with('http://localhost', 'token3', -1, 'decline')->willReturn(false);
|
|
|
|
|
2015-03-17 18:51:07 +03:00
|
|
|
// Add a share for "user"
|
|
|
|
$this->assertSame(null, call_user_func_array([$this->manager, 'addShare'], $shareData1));
|
|
|
|
$openShares = $this->manager->getOpenShares();
|
|
|
|
$this->assertCount(1, $openShares);
|
|
|
|
$this->assertExternalShareEntry($shareData1, $openShares[0], 1, '{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
|
|
|
|
|
2015-10-05 17:18:14 +03:00
|
|
|
$this->setupMounts();
|
2015-03-24 19:26:38 +03:00
|
|
|
$this->assertNotMount('SharedFolder');
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
|
|
|
|
|
2015-03-17 18:51:07 +03:00
|
|
|
// Add a second share for "user" with the same name
|
|
|
|
$this->assertSame(null, call_user_func_array([$this->manager, 'addShare'], $shareData2));
|
|
|
|
$openShares = $this->manager->getOpenShares();
|
|
|
|
$this->assertCount(2, $openShares);
|
|
|
|
$this->assertExternalShareEntry($shareData1, $openShares[0], 1, '{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
|
|
|
|
// New share falls back to "-1" appendix, because the name is already taken
|
|
|
|
$this->assertExternalShareEntry($shareData2, $openShares[1], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1');
|
|
|
|
|
2015-10-05 17:18:14 +03:00
|
|
|
$this->setupMounts();
|
2015-03-24 19:26:38 +03:00
|
|
|
$this->assertNotMount('SharedFolder');
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
|
|
|
|
|
2016-08-23 11:16:33 +03:00
|
|
|
$client = $this->getMockBuilder('OCP\Http\Client\IClient')
|
|
|
|
->disableOriginalConstructor()->getMock();
|
|
|
|
$this->clientService->expects($this->at(0))
|
|
|
|
->method('newClient')
|
|
|
|
->willReturn($client);
|
2019-11-22 15:23:56 +03:00
|
|
|
$response = $this->createMock(IResponse::class);
|
|
|
|
$response->method('getBody')
|
|
|
|
->willReturn(json_encode([
|
|
|
|
'ocs' => [
|
|
|
|
'meta' => [
|
|
|
|
'statuscode' => 200,
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]));
|
2016-08-23 11:16:33 +03:00
|
|
|
$client->expects($this->once())
|
2015-04-28 15:56:13 +03:00
|
|
|
->method('post')
|
2017-03-10 17:37:21 +03:00
|
|
|
->with($this->stringStartsWith('http://localhost/ocs/v2.php/cloud/shares/' . $openShares[0]['remote_id']), $this->anything())
|
2016-08-23 11:16:33 +03:00
|
|
|
->willReturn($response);
|
2015-04-28 15:56:13 +03:00
|
|
|
|
2015-03-17 18:51:07 +03:00
|
|
|
// Accept the first share
|
|
|
|
$this->manager->acceptShare($openShares[0]['id']);
|
|
|
|
|
|
|
|
// Check remaining shares - Accepted
|
2015-06-03 13:03:02 +03:00
|
|
|
$acceptedShares = self::invokePrivate($this->manager, 'getShares', [true]);
|
2015-03-17 18:51:07 +03:00
|
|
|
$this->assertCount(1, $acceptedShares);
|
|
|
|
$shareData1['accepted'] = true;
|
|
|
|
$this->assertExternalShareEntry($shareData1, $acceptedShares[0], 1, $shareData1['name']);
|
|
|
|
// Check remaining shares - Open
|
|
|
|
$openShares = $this->manager->getOpenShares();
|
|
|
|
$this->assertCount(1, $openShares);
|
|
|
|
$this->assertExternalShareEntry($shareData2, $openShares[0], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1');
|
|
|
|
|
2015-10-05 17:18:14 +03:00
|
|
|
$this->setupMounts();
|
2015-03-24 19:26:38 +03:00
|
|
|
$this->assertMount($shareData1['name']);
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
|
|
|
|
|
2015-03-17 18:51:07 +03:00
|
|
|
// Add another share for "user" with the same name
|
|
|
|
$this->assertSame(null, call_user_func_array([$this->manager, 'addShare'], $shareData3));
|
|
|
|
$openShares = $this->manager->getOpenShares();
|
|
|
|
$this->assertCount(2, $openShares);
|
|
|
|
$this->assertExternalShareEntry($shareData2, $openShares[0], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1');
|
|
|
|
// New share falls back to the original name (no "-\d", because the name is not taken)
|
|
|
|
$this->assertExternalShareEntry($shareData3, $openShares[1], 3, '{{TemporaryMountPointName#' . $shareData3['name'] . '}}');
|
|
|
|
|
2015-10-05 17:18:14 +03:00
|
|
|
$this->setupMounts();
|
2015-03-24 19:26:38 +03:00
|
|
|
$this->assertMount($shareData1['name']);
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
|
|
|
|
|
2016-08-23 11:16:33 +03:00
|
|
|
$client = $this->getMockBuilder('OCP\Http\Client\IClient')
|
|
|
|
->disableOriginalConstructor()->getMock();
|
|
|
|
$this->clientService->expects($this->at(0))
|
|
|
|
->method('newClient')
|
|
|
|
->willReturn($client);
|
2019-11-22 15:23:56 +03:00
|
|
|
$response = $this->createMock(IResponse::class);
|
|
|
|
$response->method('getBody')
|
|
|
|
->willReturn(json_encode([
|
|
|
|
'ocs' => [
|
|
|
|
'meta' => [
|
|
|
|
'statuscode' => 200,
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]));
|
2016-08-23 11:16:33 +03:00
|
|
|
$client->expects($this->once())
|
2015-04-28 15:56:13 +03:00
|
|
|
->method('post')
|
2017-03-10 17:37:21 +03:00
|
|
|
->with($this->stringStartsWith('http://localhost/ocs/v2.php/cloud/shares/' . $openShares[1]['remote_id'] . '/decline'), $this->anything())
|
2016-08-23 11:16:33 +03:00
|
|
|
->willReturn($response);
|
2015-04-28 15:56:13 +03:00
|
|
|
|
2015-03-17 18:51:07 +03:00
|
|
|
// Decline the third share
|
|
|
|
$this->manager->declineShare($openShares[1]['id']);
|
|
|
|
|
2015-10-05 17:18:14 +03:00
|
|
|
$this->setupMounts();
|
2015-03-24 19:26:38 +03:00
|
|
|
$this->assertMount($shareData1['name']);
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
|
|
|
|
|
2015-03-17 18:51:07 +03:00
|
|
|
// Check remaining shares - Accepted
|
2015-06-03 13:03:02 +03:00
|
|
|
$acceptedShares = self::invokePrivate($this->manager, 'getShares', [true]);
|
2015-03-17 18:51:07 +03:00
|
|
|
$this->assertCount(1, $acceptedShares);
|
|
|
|
$shareData1['accepted'] = true;
|
|
|
|
$this->assertExternalShareEntry($shareData1, $acceptedShares[0], 1, $shareData1['name']);
|
|
|
|
// Check remaining shares - Open
|
|
|
|
$openShares = $this->manager->getOpenShares();
|
|
|
|
$this->assertCount(1, $openShares);
|
|
|
|
$this->assertExternalShareEntry($shareData2, $openShares[0], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1');
|
|
|
|
|
2015-10-05 17:18:14 +03:00
|
|
|
$this->setupMounts();
|
2015-03-24 19:26:38 +03:00
|
|
|
$this->assertMount($shareData1['name']);
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
|
|
|
|
|
2016-08-23 11:16:33 +03:00
|
|
|
$client1 = $this->getMockBuilder('OCP\Http\Client\IClient')
|
|
|
|
->disableOriginalConstructor()->getMock();
|
|
|
|
$client2 = $this->getMockBuilder('OCP\Http\Client\IClient')
|
|
|
|
->disableOriginalConstructor()->getMock();
|
|
|
|
$this->clientService->expects($this->at(0))
|
|
|
|
->method('newClient')
|
|
|
|
->willReturn($client1);
|
|
|
|
$this->clientService->expects($this->at(1))
|
|
|
|
->method('newClient')
|
|
|
|
->willReturn($client2);
|
2019-11-22 15:23:56 +03:00
|
|
|
$response = $this->createMock(IResponse::class);
|
|
|
|
$response->method('getBody')
|
|
|
|
->willReturn(json_encode([
|
|
|
|
'ocs' => [
|
|
|
|
'meta' => [
|
|
|
|
'statuscode' => 200,
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]));
|
2016-08-23 11:16:33 +03:00
|
|
|
$client1->expects($this->once())
|
2015-04-28 15:56:13 +03:00
|
|
|
->method('post')
|
2017-03-10 17:37:21 +03:00
|
|
|
->with($this->stringStartsWith('http://localhost/ocs/v2.php/cloud/shares/' . $openShares[0]['remote_id'] . '/decline'), $this->anything())
|
2016-08-23 11:16:33 +03:00
|
|
|
->willReturn($response);
|
|
|
|
$client2->expects($this->once())
|
2015-04-28 15:56:13 +03:00
|
|
|
->method('post')
|
2017-03-10 17:37:21 +03:00
|
|
|
->with($this->stringStartsWith('http://localhost/ocs/v2.php/cloud/shares/' . $acceptedShares[0]['remote_id'] . '/decline'), $this->anything())
|
2016-08-23 11:16:33 +03:00
|
|
|
->willReturn($response);
|
2015-04-28 15:56:13 +03:00
|
|
|
|
2015-03-17 18:51:07 +03:00
|
|
|
$this->manager->removeUserShares($this->uid);
|
2015-06-03 13:03:02 +03:00
|
|
|
$this->assertEmpty(self::invokePrivate($this->manager, 'getShares', [null]), 'Asserting all shares for the user have been deleted');
|
2015-03-24 19:26:38 +03:00
|
|
|
|
|
|
|
$this->mountManager->clear();
|
2015-06-03 13:03:02 +03:00
|
|
|
self::invokePrivate($this->manager, 'setupMounts');
|
2015-03-24 19:26:38 +03:00
|
|
|
$this->assertNotMount($shareData1['name']);
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
|
|
|
|
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
|
2015-03-17 18:51:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $expected
|
|
|
|
* @param array $actual
|
|
|
|
* @param int $share
|
|
|
|
* @param string $mountPoint
|
|
|
|
*/
|
|
|
|
protected function assertExternalShareEntry($expected, $actual, $share, $mountPoint) {
|
|
|
|
$this->assertEquals($expected['remote'], $actual['remote'], 'Asserting remote of a share #' . $share);
|
|
|
|
$this->assertEquals($expected['token'], $actual['share_token'], 'Asserting token of a share #' . $share);
|
|
|
|
$this->assertEquals($expected['name'], $actual['name'], 'Asserting name of a share #' . $share);
|
|
|
|
$this->assertEquals($expected['owner'], $actual['owner'], 'Asserting owner of a share #' . $share);
|
|
|
|
$this->assertEquals($expected['accepted'], (int) $actual['accepted'], 'Asserting accept of a share #' . $share);
|
|
|
|
$this->assertEquals($expected['user'], $actual['user'], 'Asserting user of a share #' . $share);
|
|
|
|
$this->assertEquals($mountPoint, $actual['mountpoint'], 'Asserting mountpoint of a share #' . $share);
|
2015-03-24 19:26:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private function assertMount($mountPoint) {
|
|
|
|
$mountPoint = rtrim($mountPoint, '/');
|
|
|
|
$mount = $this->mountManager->find($this->getFullPath($mountPoint));
|
|
|
|
$this->assertInstanceOf('\OCA\Files_Sharing\External\Mount', $mount);
|
|
|
|
$this->assertInstanceOf('\OCP\Files\Mount\IMountPoint', $mount);
|
|
|
|
$this->assertEquals($this->getFullPath($mountPoint), rtrim($mount->getMountPoint(), '/'));
|
|
|
|
$storage = $mount->getStorage();
|
|
|
|
$this->assertInstanceOf('\OCA\Files_Sharing\External\Storage', $storage);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function assertNotMount($mountPoint) {
|
|
|
|
$mountPoint = rtrim($mountPoint, '/');
|
|
|
|
$mount = $this->mountManager->find($this->getFullPath($mountPoint));
|
|
|
|
if ($mount) {
|
|
|
|
$this->assertInstanceOf('\OCP\Files\Mount\IMountPoint', $mount);
|
|
|
|
$this->assertNotEquals($this->getFullPath($mountPoint), rtrim($mount->getMountPoint(), '/'));
|
|
|
|
} else {
|
|
|
|
$this->assertNull($mount);
|
|
|
|
}
|
|
|
|
}
|
2015-03-17 18:51:07 +03:00
|
|
|
|
2015-03-24 19:26:38 +03:00
|
|
|
private function getFullPath($path) {
|
|
|
|
return '/' . $this->uid . '/files' . $path;
|
2015-03-17 18:51:07 +03:00
|
|
|
}
|
|
|
|
}
|