2016-06-21 12:36:28 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Daniel Calviño Sánchez <danxuliu@gmail.com>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Maxence Lange <maxence@nextcloud.com>
|
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2016-06-21 12:36:28 +03:00
|
|
|
* @author Vincent Petry <pvince81@owncloud.com>
|
|
|
|
*
|
|
|
|
* @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-06-21 12:36:28 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Files_Sharing\Tests;
|
|
|
|
|
|
|
|
use OCA\Files_Sharing\MountProvider;
|
2016-09-02 11:38:39 +03:00
|
|
|
use OCP\Files\IRootFolder;
|
2016-06-21 12:36:28 +03:00
|
|
|
use OCP\Files\Storage\IStorageFactory;
|
|
|
|
use OCP\IConfig;
|
2016-06-21 14:55:11 +03:00
|
|
|
use OCP\ILogger;
|
2016-06-21 12:36:28 +03:00
|
|
|
use OCP\IUser;
|
2016-09-02 11:38:39 +03:00
|
|
|
use OCP\IUserManager;
|
2016-06-21 12:36:28 +03:00
|
|
|
use OCP\Share\IManager;
|
2019-11-22 22:52:10 +03:00
|
|
|
use OCP\Share\IShare;
|
2016-06-21 12:36:28 +03:00
|
|
|
|
2016-07-05 09:54:51 +03:00
|
|
|
/**
|
|
|
|
* @group DB
|
|
|
|
*/
|
2016-06-21 12:36:28 +03:00
|
|
|
class MountProviderTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
/** @var MountProvider */
|
|
|
|
private $provider;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
|
2016-06-21 12:36:28 +03:00
|
|
|
private $config;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
|
2016-06-21 12:36:28 +03:00
|
|
|
private $user;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IStorageFactory|\PHPUnit\Framework\MockObject\MockObject */
|
2016-06-21 12:36:28 +03:00
|
|
|
private $loader;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
|
2016-06-21 12:36:28 +03:00
|
|
|
private $shareManager;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ILogger | \PHPUnit\Framework\MockObject\MockObject */
|
2016-06-21 14:55:11 +03:00
|
|
|
private $logger;
|
|
|
|
|
2019-11-27 17:27:18 +03:00
|
|
|
protected function setUp(): void {
|
2016-06-21 12:36:28 +03:00
|
|
|
parent::setUp();
|
|
|
|
|
2017-10-24 16:26:53 +03:00
|
|
|
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
|
|
|
|
$this->user = $this->getMockBuilder(IUser::class)->getMock();
|
2016-07-15 13:22:53 +03:00
|
|
|
$this->loader = $this->getMockBuilder('OCP\Files\Storage\IStorageFactory')->getMock();
|
2017-10-24 16:26:53 +03:00
|
|
|
$this->shareManager = $this->getMockBuilder(IManager::class)->getMock();
|
|
|
|
$this->logger = $this->getMockBuilder(ILogger::class)->getMock();
|
2016-06-21 12:36:28 +03:00
|
|
|
|
2016-06-21 14:55:11 +03:00
|
|
|
$this->provider = new MountProvider($this->config, $this->shareManager, $this->logger);
|
2016-06-21 12:36:28 +03:00
|
|
|
}
|
|
|
|
|
2016-07-11 20:43:46 +03:00
|
|
|
private function makeMockShare($id, $nodeId, $owner = 'user2', $target = null, $permissions = 31) {
|
2016-09-02 11:38:39 +03:00
|
|
|
$share = $this->createMock(IShare::class);
|
2016-07-11 20:43:46 +03:00
|
|
|
$share->expects($this->any())
|
2016-06-21 12:36:28 +03:00
|
|
|
->method('getPermissions')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($permissions);
|
2016-07-11 20:43:46 +03:00
|
|
|
$share->expects($this->any())
|
2016-06-21 12:36:28 +03:00
|
|
|
->method('getShareOwner')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($owner);
|
2016-07-11 20:43:46 +03:00
|
|
|
$share->expects($this->any())
|
2016-06-21 12:36:28 +03:00
|
|
|
->method('getTarget')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($target);
|
2016-07-11 20:43:46 +03:00
|
|
|
$share->expects($this->any())
|
|
|
|
->method('getId')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($id);
|
2016-07-11 20:43:46 +03:00
|
|
|
$share->expects($this->any())
|
|
|
|
->method('getNodeId')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($nodeId);
|
2016-07-22 16:30:13 +03:00
|
|
|
$share->expects($this->any())
|
|
|
|
->method('getShareTime')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn(
|
2016-07-22 16:30:13 +03:00
|
|
|
// compute share time based on id, simulating share order
|
|
|
|
new \DateTime('@' . (1469193980 + 1000 * $id))
|
2020-03-26 00:21:27 +03:00
|
|
|
);
|
2016-07-11 20:43:46 +03:00
|
|
|
return $share;
|
|
|
|
}
|
2016-06-21 12:36:28 +03:00
|
|
|
|
2016-07-13 13:50:00 +03:00
|
|
|
/**
|
|
|
|
* Tests excluding shares from the current view. This includes:
|
|
|
|
* - shares that were opted out of (permissions === 0)
|
|
|
|
* - shares with a group in which the owner is already in
|
|
|
|
*/
|
2016-07-11 20:43:46 +03:00
|
|
|
public function testExcludeShares() {
|
2016-09-02 11:38:39 +03:00
|
|
|
$rootFolder = $this->createMock(IRootFolder::class);
|
|
|
|
$userManager = $this->createMock(IUserManager::class);
|
2016-07-11 20:43:46 +03:00
|
|
|
$userShares = [
|
|
|
|
$this->makeMockShare(1, 100, 'user2', '/share2', 0),
|
|
|
|
$this->makeMockShare(2, 100, 'user2', '/share2', 31),
|
|
|
|
];
|
|
|
|
$groupShares = [
|
2020-04-09 17:07:47 +03:00
|
|
|
$this->makeMockShare(3, 100, 'user2', '/share2', 0),
|
|
|
|
$this->makeMockShare(4, 101, 'user2', '/share4', 31),
|
|
|
|
$this->makeMockShare(5, 100, 'user1', '/share4', 31),
|
2016-07-11 20:43:46 +03:00
|
|
|
];
|
2018-06-29 14:50:25 +03:00
|
|
|
$roomShares = [
|
|
|
|
$this->makeMockShare(6, 102, 'user2', '/share6', 0),
|
|
|
|
$this->makeMockShare(7, 102, 'user1', '/share6', 31),
|
|
|
|
$this->makeMockShare(8, 102, 'user2', '/share6', 31),
|
|
|
|
$this->makeMockShare(9, 102, 'user2', '/share6', 31),
|
|
|
|
];
|
2017-03-17 22:48:33 +03:00
|
|
|
// tests regarding circles are made in the app itself.
|
|
|
|
$circleShares = [];
|
2016-06-21 12:36:28 +03:00
|
|
|
$this->user->expects($this->any())
|
|
|
|
->method('getUID')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('user1');
|
2016-06-21 12:36:28 +03:00
|
|
|
$this->shareManager->expects($this->at(0))
|
|
|
|
->method('getSharedWith')
|
2020-06-24 17:49:16 +03:00
|
|
|
->with('user1', IShare::TYPE_USER)
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($userShares);
|
2016-06-21 12:36:28 +03:00
|
|
|
$this->shareManager->expects($this->at(1))
|
|
|
|
->method('getSharedWith')
|
2020-06-24 17:49:16 +03:00
|
|
|
->with('user1', IShare::TYPE_GROUP, null, -1)
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($groupShares);
|
2017-03-17 22:48:33 +03:00
|
|
|
$this->shareManager->expects($this->at(2))
|
|
|
|
->method('getSharedWith')
|
2020-06-24 17:49:16 +03:00
|
|
|
->with('user1', IShare::TYPE_CIRCLE, null, -1)
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($circleShares);
|
2018-06-29 14:50:25 +03:00
|
|
|
$this->shareManager->expects($this->at(3))
|
|
|
|
->method('getSharedWith')
|
2020-06-24 17:49:16 +03:00
|
|
|
->with('user1', IShare::TYPE_ROOM, null, -1)
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($roomShares);
|
2016-07-11 20:43:46 +03:00
|
|
|
$this->shareManager->expects($this->any())
|
|
|
|
->method('newShare')
|
2020-04-09 14:53:40 +03:00
|
|
|
->willReturnCallback(function () use ($rootFolder, $userManager) {
|
2016-07-11 20:43:46 +03:00
|
|
|
return new \OC\Share20\Share($rootFolder, $userManager);
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
2016-06-21 12:36:28 +03:00
|
|
|
$mounts = $this->provider->getMountsForUser($this->user, $this->loader);
|
2018-06-29 14:50:25 +03:00
|
|
|
$this->assertCount(3, $mounts);
|
2016-07-11 20:43:46 +03:00
|
|
|
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[0]);
|
|
|
|
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[1]);
|
2018-06-29 14:50:25 +03:00
|
|
|
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[2]);
|
2016-07-11 20:43:46 +03:00
|
|
|
$mountedShare1 = $mounts[0]->getShare();
|
|
|
|
$this->assertEquals('2', $mountedShare1->getId());
|
|
|
|
$this->assertEquals('user2', $mountedShare1->getShareOwner());
|
|
|
|
$this->assertEquals(100, $mountedShare1->getNodeId());
|
|
|
|
$this->assertEquals('/share2', $mountedShare1->getTarget());
|
|
|
|
$this->assertEquals(31, $mountedShare1->getPermissions());
|
|
|
|
$mountedShare2 = $mounts[1]->getShare();
|
|
|
|
$this->assertEquals('4', $mountedShare2->getId());
|
|
|
|
$this->assertEquals('user2', $mountedShare2->getShareOwner());
|
2016-07-22 16:30:13 +03:00
|
|
|
$this->assertEquals(101, $mountedShare2->getNodeId());
|
2016-07-11 20:43:46 +03:00
|
|
|
$this->assertEquals('/share4', $mountedShare2->getTarget());
|
|
|
|
$this->assertEquals(31, $mountedShare2->getPermissions());
|
2018-06-29 14:50:25 +03:00
|
|
|
$mountedShare3 = $mounts[2]->getShare();
|
|
|
|
$this->assertEquals('8', $mountedShare3->getId());
|
|
|
|
$this->assertEquals('user2', $mountedShare3->getShareOwner());
|
|
|
|
$this->assertEquals(102, $mountedShare3->getNodeId());
|
|
|
|
$this->assertEquals('/share6', $mountedShare3->getTarget());
|
|
|
|
$this->assertEquals(31, $mountedShare3->getPermissions());
|
2016-06-21 12:36:28 +03:00
|
|
|
}
|
2016-07-13 13:50:00 +03:00
|
|
|
|
|
|
|
public function mergeSharesDataProvider() {
|
|
|
|
// note: the user in the specs here is the shareOwner not recipient
|
|
|
|
// the recipient is always "user1"
|
|
|
|
return [
|
|
|
|
// #0: share as outsider with "group1" and "user1" with same permissions
|
|
|
|
[
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[1, 100, 'user2', '/share2', 31],
|
2016-07-13 13:50:00 +03:00
|
|
|
],
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[2, 100, 'user2', '/share2', 31],
|
2016-07-13 13:50:00 +03:00
|
|
|
],
|
|
|
|
[
|
|
|
|
// combined, user share has higher priority
|
|
|
|
['1', 100, 'user2', '/share2', 31],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
// #1: share as outsider with "group1" and "user1" with different permissions
|
|
|
|
[
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[1, 100, 'user2', '/share', 31],
|
2016-07-13 13:50:00 +03:00
|
|
|
],
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[2, 100, 'user2', '/share', 15],
|
2016-07-13 13:50:00 +03:00
|
|
|
],
|
|
|
|
[
|
|
|
|
// use highest permissions
|
|
|
|
['1', 100, 'user2', '/share', 31],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
// #2: share as outsider with "group1" and "group2" with same permissions
|
|
|
|
[
|
|
|
|
[
|
|
|
|
],
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[1, 100, 'user2', '/share', 31],
|
|
|
|
[2, 100, 'user2', '/share', 31],
|
2016-07-13 13:50:00 +03:00
|
|
|
],
|
|
|
|
[
|
|
|
|
// combined, first group share has higher priority
|
|
|
|
['1', 100, 'user2', '/share', 31],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
// #3: share as outsider with "group1" and "group2" with different permissions
|
|
|
|
[
|
|
|
|
[
|
|
|
|
],
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[1, 100, 'user2', '/share', 31],
|
|
|
|
[2, 100, 'user2', '/share', 15],
|
2016-07-13 13:50:00 +03:00
|
|
|
],
|
|
|
|
[
|
|
|
|
// use higher permissions
|
|
|
|
['1', 100, 'user2', '/share', 31],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
// #4: share as insider with "group1"
|
|
|
|
[
|
|
|
|
[
|
|
|
|
],
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[1, 100, 'user1', '/share', 31],
|
2016-07-13 13:50:00 +03:00
|
|
|
],
|
|
|
|
[
|
|
|
|
// no received share since "user1" is the sharer/owner
|
|
|
|
],
|
|
|
|
],
|
|
|
|
// #5: share as insider with "group1" and "group2" with different permissions
|
|
|
|
[
|
|
|
|
[
|
|
|
|
],
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[1, 100, 'user1', '/share', 31],
|
|
|
|
[2, 100, 'user1', '/share', 15],
|
2016-07-13 13:50:00 +03:00
|
|
|
],
|
|
|
|
[
|
|
|
|
// no received share since "user1" is the sharer/owner
|
|
|
|
],
|
|
|
|
],
|
|
|
|
// #6: share as outside with "group1", recipient opted out
|
|
|
|
[
|
|
|
|
[
|
|
|
|
],
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[1, 100, 'user2', '/share', 0],
|
2016-07-13 13:50:00 +03:00
|
|
|
],
|
|
|
|
[
|
|
|
|
// no received share since "user1" opted out
|
|
|
|
],
|
|
|
|
],
|
2016-07-22 16:30:13 +03:00
|
|
|
// #7: share as outsider with "group1" and "user1" where recipient renamed in between
|
|
|
|
[
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[1, 100, 'user2', '/share2-renamed', 31],
|
2016-07-22 16:30:13 +03:00
|
|
|
],
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[2, 100, 'user2', '/share2', 31],
|
2016-07-22 16:30:13 +03:00
|
|
|
],
|
|
|
|
[
|
|
|
|
// use target of least recent share
|
|
|
|
['1', 100, 'user2', '/share2-renamed', 31],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
// #8: share as outsider with "group1" and "user1" where recipient renamed in between
|
|
|
|
[
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[2, 100, 'user2', '/share2', 31],
|
2016-07-22 16:30:13 +03:00
|
|
|
],
|
|
|
|
[
|
2020-04-09 17:07:47 +03:00
|
|
|
[1, 100, 'user2', '/share2-renamed', 31],
|
2016-07-22 16:30:13 +03:00
|
|
|
],
|
|
|
|
[
|
|
|
|
// use target of least recent share
|
|
|
|
['1', 100, 'user2', '/share2-renamed', 31],
|
|
|
|
],
|
|
|
|
],
|
2017-01-19 17:02:46 +03:00
|
|
|
// #9: share as outsider with "nullgroup" and "user1" where recipient renamed in between
|
|
|
|
[
|
|
|
|
[
|
|
|
|
[2, 100, 'user2', '/share2', 31],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[1, 100, 'nullgroup', '/share2-renamed', 31],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
// use target of least recent share
|
|
|
|
['1', 100, 'nullgroup', '/share2-renamed', 31],
|
|
|
|
],
|
|
|
|
true
|
|
|
|
],
|
2016-07-13 13:50:00 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests merging shares.
|
|
|
|
*
|
|
|
|
* Happens when sharing the same entry to a user through multiple ways,
|
|
|
|
* like several groups and also direct shares at the same time.
|
|
|
|
*
|
|
|
|
* @dataProvider mergeSharesDataProvider
|
|
|
|
*
|
|
|
|
* @param array $userShares array of user share specs
|
|
|
|
* @param array $groupShares array of group share specs
|
|
|
|
* @param array $expectedShares array of expected supershare specs
|
|
|
|
*/
|
2017-01-19 17:02:46 +03:00
|
|
|
public function testMergeShares($userShares, $groupShares, $expectedShares, $moveFails = false) {
|
2016-09-02 11:38:39 +03:00
|
|
|
$rootFolder = $this->createMock(IRootFolder::class);
|
|
|
|
$userManager = $this->createMock(IUserManager::class);
|
2016-07-13 13:50:00 +03:00
|
|
|
|
2020-04-09 14:53:40 +03:00
|
|
|
$userShares = array_map(function ($shareSpec) {
|
2016-07-13 13:50:00 +03:00
|
|
|
return $this->makeMockShare($shareSpec[0], $shareSpec[1], $shareSpec[2], $shareSpec[3], $shareSpec[4]);
|
|
|
|
}, $userShares);
|
2020-04-09 14:53:40 +03:00
|
|
|
$groupShares = array_map(function ($shareSpec) {
|
2016-07-13 13:50:00 +03:00
|
|
|
return $this->makeMockShare($shareSpec[0], $shareSpec[1], $shareSpec[2], $shareSpec[3], $shareSpec[4]);
|
|
|
|
}, $groupShares);
|
|
|
|
|
|
|
|
$this->user->expects($this->any())
|
|
|
|
->method('getUID')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('user1');
|
2016-07-13 13:50:00 +03:00
|
|
|
|
2017-03-17 22:48:33 +03:00
|
|
|
// tests regarding circles are made in the app itself.
|
|
|
|
$circleShares = [];
|
2018-06-29 14:50:25 +03:00
|
|
|
$roomShares = [];
|
2016-07-13 13:50:00 +03:00
|
|
|
$this->shareManager->expects($this->at(0))
|
|
|
|
->method('getSharedWith')
|
2020-06-24 17:49:16 +03:00
|
|
|
->with('user1', IShare::TYPE_USER)
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($userShares);
|
2016-07-13 13:50:00 +03:00
|
|
|
$this->shareManager->expects($this->at(1))
|
|
|
|
->method('getSharedWith')
|
2020-06-24 17:49:16 +03:00
|
|
|
->with('user1', IShare::TYPE_GROUP, null, -1)
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($groupShares);
|
2017-03-17 22:48:33 +03:00
|
|
|
$this->shareManager->expects($this->at(2))
|
|
|
|
->method('getSharedWith')
|
2020-06-24 17:49:16 +03:00
|
|
|
->with('user1', IShare::TYPE_CIRCLE, null, -1)
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($circleShares);
|
2018-06-29 14:50:25 +03:00
|
|
|
$this->shareManager->expects($this->at(3))
|
|
|
|
->method('getSharedWith')
|
2020-06-24 17:49:16 +03:00
|
|
|
->with('user1', IShare::TYPE_ROOM, null, -1)
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($roomShares);
|
2016-07-13 13:50:00 +03:00
|
|
|
$this->shareManager->expects($this->any())
|
|
|
|
->method('newShare')
|
2020-04-09 14:53:40 +03:00
|
|
|
->willReturnCallback(function () use ($rootFolder, $userManager) {
|
2016-07-13 13:50:00 +03:00
|
|
|
return new \OC\Share20\Share($rootFolder, $userManager);
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
2016-07-13 13:50:00 +03:00
|
|
|
|
2017-01-19 17:02:46 +03:00
|
|
|
if ($moveFails) {
|
|
|
|
$this->shareManager->expects($this->any())
|
|
|
|
->method('moveShare')
|
|
|
|
->will($this->throwException(new \InvalidArgumentException()));
|
|
|
|
}
|
|
|
|
|
2016-07-13 13:50:00 +03:00
|
|
|
$mounts = $this->provider->getMountsForUser($this->user, $this->loader);
|
|
|
|
|
|
|
|
$this->assertCount(count($expectedShares), $mounts);
|
|
|
|
|
|
|
|
foreach ($mounts as $index => $mount) {
|
|
|
|
$expectedShare = $expectedShares[$index];
|
|
|
|
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mount);
|
|
|
|
|
|
|
|
// supershare
|
|
|
|
$share = $mount->getShare();
|
|
|
|
|
|
|
|
$this->assertEquals($expectedShare[0], $share->getId());
|
|
|
|
$this->assertEquals($expectedShare[1], $share->getNodeId());
|
|
|
|
$this->assertEquals($expectedShare[2], $share->getShareOwner());
|
|
|
|
$this->assertEquals($expectedShare[3], $share->getTarget());
|
|
|
|
$this->assertEquals($expectedShare[4], $share->getPermissions());
|
|
|
|
}
|
|
|
|
}
|
2016-06-21 12:36:28 +03:00
|
|
|
}
|