[Share 2.0] Fix shareManager

This commit is contained in:
Roeland Jago Douma 2016-02-02 21:02:09 +01:00
parent eb904c7aa9
commit 96662c4d0d
4 changed files with 250 additions and 229 deletions

View File

@ -617,7 +617,8 @@ class Server extends ServerContainer implements IServerContainer {
$c->getMountManager(), $c->getMountManager(),
$c->getGroupManager(), $c->getGroupManager(),
$c->getL10N('core'), $c->getL10N('core'),
$factory $factory,
$c->getUserManager()
); );
return $manager; return $manager;

View File

@ -21,7 +21,7 @@
namespace OC\Share20; namespace OC\Share20;
use OCP\Files\Node; use OCP\IUserManager;
use OCP\Share\IManager; use OCP\Share\IManager;
use OCP\Share\IProviderFactory; use OCP\Share\IProviderFactory;
use OC\Share20\Exception\BackendError; use OC\Share20\Exception\BackendError;
@ -34,7 +34,6 @@ use OCP\Files\Mount\IMountManager;
use OCP\IGroupManager; use OCP\IGroupManager;
use OCP\Files\File; use OCP\Files\File;
use OCP\Files\Folder; use OCP\Files\Folder;
use OCP\IUser;
use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\Exceptions\GenericShareException; use OCP\Share\Exceptions\GenericShareException;
@ -68,6 +67,9 @@ class Manager implements IManager {
/** @var IL10N */ /** @var IL10N */
private $l; private $l;
/** @var IUserManager */
private $userManager;
/** /**
* Manager constructor. * Manager constructor.
* *
@ -79,6 +81,7 @@ class Manager implements IManager {
* @param IGroupManager $groupManager * @param IGroupManager $groupManager
* @param IL10N $l * @param IL10N $l
* @param IProviderFactory $factory * @param IProviderFactory $factory
* @param IUserManager $userManager
*/ */
public function __construct( public function __construct(
ILogger $logger, ILogger $logger,
@ -88,7 +91,8 @@ class Manager implements IManager {
IMountManager $mountManager, IMountManager $mountManager,
IGroupManager $groupManager, IGroupManager $groupManager,
IL10N $l, IL10N $l,
IProviderFactory $factory IProviderFactory $factory,
IUserManager $userManager
) { ) {
$this->logger = $logger; $this->logger = $logger;
$this->config = $config; $this->config = $config;
@ -98,6 +102,7 @@ class Manager implements IManager {
$this->groupManager = $groupManager; $this->groupManager = $groupManager;
$this->l = $l; $this->l = $l;
$this->factory = $factory; $this->factory = $factory;
$this->userManager = $userManager;
} }
/** /**
@ -150,13 +155,13 @@ class Manager implements IManager {
protected function generalCreateChecks(\OCP\Share\IShare $share) { protected function generalCreateChecks(\OCP\Share\IShare $share) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
// We expect a valid user as sharedWith for user shares // We expect a valid user as sharedWith for user shares
if (!($share->getSharedWith() instanceof \OCP\IUser)) { if (!$this->userManager->userExists($share->getSharedWith())) {
throw new \InvalidArgumentException('SharedWith should be an IUser'); throw new \InvalidArgumentException('SharedWith is not a valid user');
} }
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
// We expect a valid group as sharedWith for group shares // We expect a valid group as sharedWith for group shares
if (!($share->getSharedWith() instanceof \OCP\IGroup)) { if (!$this->groupManager->groupExists($share->getSharedWith())) {
throw new \InvalidArgumentException('SharedWith should be an IGroup'); throw new \InvalidArgumentException('SharedWith is not a valid group');
} }
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
if ($share->getSharedWith() !== null) { if ($share->getSharedWith() !== null) {
@ -173,7 +178,8 @@ class Manager implements IManager {
} }
// Cannot share with yourself // Cannot share with yourself
if ($share->getSharedWith() === $share->getSharedBy()) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
$share->getSharedWith() === $share->getSharedBy()) {
throw new \InvalidArgumentException('Can\'t share with yourself'); throw new \InvalidArgumentException('Can\'t share with yourself');
} }
@ -215,7 +221,7 @@ class Manager implements IManager {
* Validate if the expiration date fits the system settings * Validate if the expiration date fits the system settings
* *
* @param \OCP\Share\IShare $share The share to validate the expiration date of * @param \OCP\Share\IShare $share The share to validate the expiration date of
* @return \DateTime|null The expiration date or null if $expireDate was null and it is not required * @return \OCP\Share\IShare The expiration date or null if $expireDate was null and it is not required
* @throws GenericShareException * @throws GenericShareException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @throws \Exception * @throws \Exception
@ -285,10 +291,12 @@ class Manager implements IManager {
protected function userCreateChecks(\OCP\Share\IShare $share) { protected function userCreateChecks(\OCP\Share\IShare $share) {
// Check if we can share with group members only // Check if we can share with group members only
if ($this->shareWithGroupMembersOnly()) { if ($this->shareWithGroupMembersOnly()) {
$sharedBy = $this->userManager->get($share->getSharedBy());
$sharedWith = $this->userManager->get($share->getSharedWith());
// Verify we can share with this user // Verify we can share with this user
$groups = array_intersect( $groups = array_intersect(
$this->groupManager->getUserGroupIds($share->getSharedBy()), $this->groupManager->getUserGroupIds($sharedBy),
$this->groupManager->getUserGroupIds($share->getSharedWith()) $this->groupManager->getUserGroupIds($sharedWith)
); );
if (empty($groups)) { if (empty($groups)) {
throw new \Exception('Only sharing with group members is allowed'); throw new \Exception('Only sharing with group members is allowed');
@ -314,10 +322,13 @@ class Manager implements IManager {
} }
// The share is already shared with this user via a group share // The share is already shared with this user via a group share
if ($existingShare->getShareType() === \OCP\Share::SHARE_TYPE_GROUP && if ($existingShare->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
$existingShare->getSharedWith()->inGroup($share->getSharedWith()) && $group = $this->groupManager->get($existingShare->getSharedWith());
$existingShare->getShareOwner() !== $share->getShareOwner()) { $user = $this->userManager->get($share->getSharedWith());
throw new \Exception('Path already shared with this user');
if ($group->inGroup($user) && $existingShare->getShareOwner() !== $share->getShareOwner()) {
throw new \Exception('Path already shared with this user');
}
} }
} }
} }
@ -331,7 +342,9 @@ class Manager implements IManager {
protected function groupCreateChecks(\OCP\Share\IShare $share) { protected function groupCreateChecks(\OCP\Share\IShare $share) {
// Verify if the user can share with this group // Verify if the user can share with this group
if ($this->shareWithGroupMembersOnly()) { if ($this->shareWithGroupMembersOnly()) {
if (!$share->getSharedWith()->inGroup($share->getSharedBy())) { $sharedBy = $this->userManager->get($share->getSharedBy());
$sharedWith = $this->groupManager->get($share->getSharedWith());
if (!$sharedWith->inGroup($sharedBy)) {
throw new \Exception('Only sharing within your own groups is allowed'); throw new \Exception('Only sharing within your own groups is allowed');
} }
} }
@ -468,10 +481,11 @@ class Manager implements IManager {
$this->pathCreateChecks($share->getNode()); $this->pathCreateChecks($share->getNode());
// On creation of a share the owner is always the owner of the path // On creation of a share the owner is always the owner of the path
$share->setShareOwner($share->getNode()->getOwner()); $share->setShareOwner($share->getNode()->getOwner()->getUID());
// Cannot share with the owner // Cannot share with the owner
if ($share->getSharedWith() === $share->getShareOwner()) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
$share->getSharedWith() === $share->getShareOwner()) {
throw new \InvalidArgumentException('Can\'t share with the share owner'); throw new \InvalidArgumentException('Can\'t share with the share owner');
} }
@ -480,16 +494,6 @@ class Manager implements IManager {
$target = \OC\Files\Filesystem::normalizePath($target); $target = \OC\Files\Filesystem::normalizePath($target);
$share->setTarget($target); $share->setTarget($target);
//Get sharewith for hooks
$sharedWith = null;
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$sharedWith = $share->getSharedWith()->getUID();
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
$sharedWith = $share->getSharedWith()->getGID();
} else {
$sharedWith = $share->getSharedWith();
}
// Pre share hook // Pre share hook
$run = true; $run = true;
$error = ''; $error = '';
@ -497,13 +501,13 @@ class Manager implements IManager {
'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
'itemSource' => $share->getNode()->getId(), 'itemSource' => $share->getNode()->getId(),
'shareType' => $share->getShareType(), 'shareType' => $share->getShareType(),
'uidOwner' => $share->getSharedBy()->getUID(), 'uidOwner' => $share->getSharedBy(),
'permissions' => $share->getPermissions(), 'permissions' => $share->getPermissions(),
'fileSource' => $share->getNode()->getId(), 'fileSource' => $share->getNode()->getId(),
'expiration' => $share->getExpirationDate(), 'expiration' => $share->getExpirationDate(),
'token' => $share->getToken(), 'token' => $share->getToken(),
'itemTarget' => $share->getTarget(), 'itemTarget' => $share->getTarget(),
'shareWith' => $sharedWith, 'shareWith' => $share->getSharedWith(),
'run' => &$run, 'run' => &$run,
'error' => &$error, 'error' => &$error,
]; ];
@ -521,13 +525,13 @@ class Manager implements IManager {
'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
'itemSource' => $share->getNode()->getId(), 'itemSource' => $share->getNode()->getId(),
'shareType' => $share->getShareType(), 'shareType' => $share->getShareType(),
'uidOwner' => $share->getSharedBy()->getUID(), 'uidOwner' => $share->getSharedBy(),
'permissions' => $share->getPermissions(), 'permissions' => $share->getPermissions(),
'fileSource' => $share->getNode()->getId(), 'fileSource' => $share->getNode()->getId(),
'expiration' => $share->getExpirationDate(), 'expiration' => $share->getExpirationDate(),
'token' => $share->getToken(), 'token' => $share->getToken(),
'id' => $share->getId(), 'id' => $share->getId(),
'shareWith' => $sharedWith, 'shareWith' => $share->getSharedWith(),
'itemTarget' => $share->getTarget(), 'itemTarget' => $share->getTarget(),
'fileTarget' => $share->getTarget(), 'fileTarget' => $share->getTarget(),
]; ];
@ -542,6 +546,7 @@ class Manager implements IManager {
* *
* @param \OCP\Share\IShare $share * @param \OCP\Share\IShare $share
* @return \OCP\Share\IShare The share object * @return \OCP\Share\IShare The share object
* @throws \InvalidArgumentException
*/ */
public function updateShare(\OCP\Share\IShare $share) { public function updateShare(\OCP\Share\IShare $share) {
$expirationDateUpdated = false; $expirationDateUpdated = false;
@ -564,7 +569,8 @@ class Manager implements IManager {
} }
// Cannot share with the owner // Cannot share with the owner
if ($share->getSharedWith() === $share->getShareOwner()) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
$share->getSharedWith() === $share->getShareOwner()) {
throw new \InvalidArgumentException('Can\'t share with the share owner'); throw new \InvalidArgumentException('Can\'t share with the share owner');
} }
@ -606,7 +612,7 @@ class Manager implements IManager {
'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
'itemSource' => $share->getNode()->getId(), 'itemSource' => $share->getNode()->getId(),
'date' => $share->getExpirationDate(), 'date' => $share->getExpirationDate(),
'uidOwner' => $share->getSharedBy()->getUID(), 'uidOwner' => $share->getSharedBy(),
]); ]);
} }
@ -651,9 +657,9 @@ class Manager implements IManager {
$shareType = $share->getShareType(); $shareType = $share->getShareType();
$sharedWith = ''; $sharedWith = '';
if ($shareType === \OCP\Share::SHARE_TYPE_USER) { if ($shareType === \OCP\Share::SHARE_TYPE_USER) {
$sharedWith = $share->getSharedWith()->getUID(); $sharedWith = $share->getSharedWith();
} else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { } else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
$sharedWith = $share->getSharedWith()->getGID(); $sharedWith = $share->getSharedWith();
} else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) { } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
$sharedWith = $share->getSharedWith(); $sharedWith = $share->getSharedWith();
} }
@ -665,7 +671,7 @@ class Manager implements IManager {
'shareType' => $shareType, 'shareType' => $shareType,
'shareWith' => $sharedWith, 'shareWith' => $sharedWith,
'itemparent' => $share->getParent(), 'itemparent' => $share->getParent(),
'uidOwner' => $share->getSharedBy()->getUID(), 'uidOwner' => $share->getSharedBy(),
'fileSource' => $share->getNode()->getId(), 'fileSource' => $share->getNode()->getId(),
'fileTarget' => $share->getTarget() 'fileTarget' => $share->getTarget()
]; ];
@ -706,38 +712,45 @@ class Manager implements IManager {
* handle this. * handle this.
* *
* @param \OCP\Share\IShare $share * @param \OCP\Share\IShare $share
* @param IUser $recipient * @param string $recipientId
*/ */
public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient) { public function deleteFromSelf(\OCP\Share\IShare $share, $recipientId) {
list($providerId, $id) = $this->splitFullId($share->getId()); list($providerId, ) = $this->splitFullId($share->getId());
$provider = $this->factory->getProvider($providerId); $provider = $this->factory->getProvider($providerId);
$provider->deleteFromSelf($share, $recipient); $provider->deleteFromSelf($share, $recipientId);
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function moveShare(\OCP\Share\IShare $share, IUser $recipient) { public function moveShare(\OCP\Share\IShare $share, $recipientId) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
throw new \InvalidArgumentException('Can\'t change target of link share'); throw new \InvalidArgumentException('Can\'t change target of link share');
} }
if (($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() !== $recipient) || if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() !== $recipientId) {
($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP && !$share->getSharedWith()->inGroup($recipient))) {
throw new \InvalidArgumentException('Invalid recipient'); throw new \InvalidArgumentException('Invalid recipient');
} }
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
$sharedWith = $this->groupManager->get($share->getSharedWith());
$recipient = $this->userManager->get($recipientId);
if (!$sharedWith->inGroup($recipient)) {
throw new \InvalidArgumentException('Invalid recipient');
}
}
list($providerId, ) = $this->splitFullId($share->getId()); list($providerId, ) = $this->splitFullId($share->getId());
$provider = $this->factory->getProvider($providerId); $provider = $this->factory->getProvider($providerId);
$provider->move($share, $recipient); $provider->move($share, $recipientId);
} }
/** /**
* Get shares shared by (initiated) by the provided user. * Get shares shared by (initiated) by the provided user.
* *
* @param IUser $user * @param string $userId
* @param int $shareType * @param int $shareType
* @param \OCP\Files\File|\OCP\Files\Folder $path * @param \OCP\Files\File|\OCP\Files\Folder $path
* @param bool $reshares * @param bool $reshares
@ -745,7 +758,7 @@ class Manager implements IManager {
* @param int $offset * @param int $offset
* @return \OCP\Share\IShare[] * @return \OCP\Share\IShare[]
*/ */
public function getSharesBy(IUser $user, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0) { public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0) {
if ($path !== null && if ($path !== null &&
!($path instanceof \OCP\Files\File) && !($path instanceof \OCP\Files\File) &&
!($path instanceof \OCP\Files\Folder)) { !($path instanceof \OCP\Files\Folder)) {
@ -754,16 +767,16 @@ class Manager implements IManager {
$provider = $this->factory->getProviderForType($shareType); $provider = $this->factory->getProviderForType($shareType);
return $provider->getSharesBy($user, $shareType, $path, $reshares, $limit, $offset); return $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset);
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function getSharedWith(IUser $user, $shareType, $node = null, $limit = 50, $offset = 0) { public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0) {
$provider = $this->factory->getProviderForType($shareType); $provider = $this->factory->getProviderForType($shareType);
return $provider->getSharedWith($user, $shareType, $node, $limit, $offset); return $provider->getSharedWith($userId, $shareType, $node, $limit, $offset);
} }
/** /**
@ -955,10 +968,10 @@ class Manager implements IManager {
* *
* TODO: Deprecate fuction from OC_Util * TODO: Deprecate fuction from OC_Util
* *
* @param IUser $user * @param string $userId
* @return bool * @return bool
*/ */
public function sharingDisabledForUser(IUser $user) { public function sharingDisabledForUser($userId) {
if ($this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') { if ($this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') {
$groupsList = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); $groupsList = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
$excludedGroups = json_decode($groupsList); $excludedGroups = json_decode($groupsList);
@ -967,6 +980,7 @@ class Manager implements IManager {
$newValue = json_encode($excludedGroups); $newValue = json_encode($excludedGroups);
$this->config->setAppValue('core', 'shareapi_exclude_groups_list', $newValue); $this->config->setAppValue('core', 'shareapi_exclude_groups_list', $newValue);
} }
$user = $this->userManager->get($userId);
$usersGroups = $this->groupManager->getUserGroupIds($user); $usersGroups = $this->groupManager->getUserGroupIds($user);
if (!empty($usersGroups)) { if (!empty($usersGroups)) {
$remainingGroups = array_diff($usersGroups, $excludedGroups); $remainingGroups = array_diff($usersGroups, $excludedGroups);

View File

@ -69,27 +69,27 @@ interface IManager {
* handle this. * handle this.
* *
* @param IShare $share * @param IShare $share
* @param IUser $recipient * @param string $recipientId
* @since 9.0.0 * @since 9.0.0
*/ */
public function deleteFromSelf(IShare $share, IUser $recipient); public function deleteFromSelf(IShare $share, $recipientId);
/** /**
* Move the share as a recipient of the share. * Move the share as a recipient of the share.
* This is updating the share target. So where the recipient has the share mounted. * This is updating the share target. So where the recipient has the share mounted.
* *
* @param IShare $share * @param IShare $share
* @param IUser $recipient * @param string $recipientId
* @return IShare * @return IShare
* @throws \InvalidArgumentException If $share is a link share or the $recipient does not match * @throws \InvalidArgumentException If $share is a link share or the $recipient does not match
* @since 9.0.0 * @since 9.0.0
*/ */
public function moveShare(IShare $share, IUser $recipient); public function moveShare(IShare $share, $recipientId);
/** /**
* Get shares shared by (initiated) by the provided user. * Get shares shared by (initiated) by the provided user.
* *
* @param IUser $user * @param string $userId
* @param int $shareType * @param int $shareType
* @param \OCP\Files\File|\OCP\Files\Folder $path * @param \OCP\Files\File|\OCP\Files\Folder $path
* @param bool $reshares * @param bool $reshares
@ -98,13 +98,13 @@ interface IManager {
* @return IShare[] * @return IShare[]
* @since 9.0.0 * @since 9.0.0
*/ */
public function getSharesBy(IUser $user, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0); public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
/** /**
* Get shares shared with $user. * Get shares shared with $user.
* Filter by $node if provided * Filter by $node if provided
* *
* @param IUser $user * @param string $userId
* @param int $shareType * @param int $shareType
* @param File|Folder|null $node * @param File|Folder|null $node
* @param int $limit The maximum number of shares returned, -1 for all * @param int $limit The maximum number of shares returned, -1 for all
@ -112,7 +112,7 @@ interface IManager {
* @return IShare[] * @return IShare[]
* @since 9.0.0 * @since 9.0.0
*/ */
public function getSharedWith(IUser $user, $shareType, $node = null, $limit = 50, $offset = 0); public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
/** /**
* Retrieve a share by the share id. * Retrieve a share by the share id.
@ -223,10 +223,10 @@ interface IManager {
/** /**
* Check if sharing is disabled for the given user * Check if sharing is disabled for the given user
* *
* @param IUser $user * @param string $userId
* @return bool * @return bool
* @since 9.0.0 * @since 9.0.0
*/ */
public function sharingDisabledForUser(IUser $user); public function sharingDisabledForUser($userId);
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace Test\Share20; namespace Test\Share20;
use OCP\IUserManager;
use OCP\Share\IProviderFactory; use OCP\Share\IProviderFactory;
use OCP\Share\IShare; use OCP\Share\IShare;
use OC\Share20\Manager; use OC\Share20\Manager;
@ -74,6 +75,9 @@ class ManagerTest extends \Test\TestCase {
/** @var DummyFactory */ /** @var DummyFactory */
protected $factory; protected $factory;
/** @var IUserManager */
protected $userManager;
public function setUp() { public function setUp() {
$this->logger = $this->getMock('\OCP\ILogger'); $this->logger = $this->getMock('\OCP\ILogger');
@ -82,6 +86,7 @@ class ManagerTest extends \Test\TestCase {
$this->hasher = $this->getMock('\OCP\Security\IHasher'); $this->hasher = $this->getMock('\OCP\Security\IHasher');
$this->mountManager = $this->getMock('\OCP\Files\Mount\IMountManager'); $this->mountManager = $this->getMock('\OCP\Files\Mount\IMountManager');
$this->groupManager = $this->getMock('\OCP\IGroupManager'); $this->groupManager = $this->getMock('\OCP\IGroupManager');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->l = $this->getMock('\OCP\IL10N'); $this->l = $this->getMock('\OCP\IL10N');
$this->l->method('t') $this->l->method('t')
@ -99,7 +104,8 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager, $this->mountManager,
$this->groupManager, $this->groupManager,
$this->l, $this->l,
$this->factory $this->factory,
$this->userManager
); );
$this->defaultProvider = $this->getMockBuilder('\OC\Share20\DefaultShareProvider') $this->defaultProvider = $this->getMockBuilder('\OC\Share20\DefaultShareProvider')
@ -124,7 +130,8 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager, $this->mountManager,
$this->groupManager, $this->groupManager,
$this->l, $this->l,
$this->factory $this->factory,
$this->userManager
]); ]);
} }
@ -151,24 +158,21 @@ class ManagerTest extends \Test\TestCase {
$group->method('getGID')->willReturn('sharedWithGroup'); $group->method('getGID')->willReturn('sharedWithGroup');
return [ return [
[\OCP\Share::SHARE_TYPE_USER, $user, 'sharedWithUser'], [\OCP\Share::SHARE_TYPE_USER, 'sharedWithUser'],
[\OCP\Share::SHARE_TYPE_GROUP, $group, 'sharedWithGroup'], [\OCP\Share::SHARE_TYPE_GROUP, 'sharedWithGroup'],
[\OCP\Share::SHARE_TYPE_LINK, '', ''], [\OCP\Share::SHARE_TYPE_LINK, ''],
[\OCP\Share::SHARE_TYPE_REMOTE, 'foo@bar.com', 'foo@bar.com'], [\OCP\Share::SHARE_TYPE_REMOTE, 'foo@bar.com'],
]; ];
} }
/** /**
* @dataProvider dataTestDelete * @dataProvider dataTestDelete
*/ */
public function testDelete($shareType, $sharedWith, $sharedWith_string) { public function testDelete($shareType, $sharedWith) {
$manager = $this->createManagerMock() $manager = $this->createManagerMock()
->setMethods(['getShareById', 'deleteChildren']) ->setMethods(['getShareById', 'deleteChildren'])
->getMock(); ->getMock();
$sharedBy = $this->getMock('\OCP\IUser');
$sharedBy->method('getUID')->willReturn('sharedBy');
$path = $this->getMock('\OCP\Files\File'); $path = $this->getMock('\OCP\Files\File');
$path->method('getId')->willReturn(1); $path->method('getId')->willReturn(1);
@ -177,7 +181,7 @@ class ManagerTest extends \Test\TestCase {
->setProviderId('prov') ->setProviderId('prov')
->setShareType($shareType) ->setShareType($shareType)
->setSharedWith($sharedWith) ->setSharedWith($sharedWith)
->setSharedBy($sharedBy) ->setSharedBy('sharedBy')
->setNode($path) ->setNode($path)
->setTarget('myTarget'); ->setTarget('myTarget');
@ -198,7 +202,7 @@ class ManagerTest extends \Test\TestCase {
'itemType' => 'file', 'itemType' => 'file',
'itemSource' => 1, 'itemSource' => 1,
'shareType' => $shareType, 'shareType' => $shareType,
'shareWith' => $sharedWith_string, 'shareWith' => $sharedWith,
'itemparent' => null, 'itemparent' => null,
'uidOwner' => 'sharedBy', 'uidOwner' => 'sharedBy',
'fileSource' => 1, 'fileSource' => 1,
@ -210,7 +214,7 @@ class ManagerTest extends \Test\TestCase {
'itemType' => 'file', 'itemType' => 'file',
'itemSource' => 1, 'itemSource' => 1,
'shareType' => $shareType, 'shareType' => $shareType,
'shareWith' => $sharedWith_string, 'shareWith' => $sharedWith,
'itemparent' => null, 'itemparent' => null,
'uidOwner' => 'sharedBy', 'uidOwner' => 'sharedBy',
'fileSource' => 1, 'fileSource' => 1,
@ -221,7 +225,7 @@ class ManagerTest extends \Test\TestCase {
'itemType' => 'file', 'itemType' => 'file',
'itemSource' => 1, 'itemSource' => 1,
'shareType' => $shareType, 'shareType' => $shareType,
'shareWith' => $sharedWith_string, 'shareWith' => $sharedWith,
'itemparent' => null, 'itemparent' => null,
'uidOwner' => 'sharedBy', 'uidOwner' => 'sharedBy',
'fileSource' => 1, 'fileSource' => 1,
@ -248,18 +252,6 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['getShareById']) ->setMethods(['getShareById'])
->getMock(); ->getMock();
$sharedBy1 = $this->getMock('\OCP\IUser');
$sharedBy1->method('getUID')->willReturn('sharedBy1');
$sharedBy2 = $this->getMock('\OCP\IUser');
$sharedBy2->method('getUID')->willReturn('sharedBy2');
$sharedBy3 = $this->getMock('\OCP\IUser');
$sharedBy3->method('getUID')->willReturn('sharedBy3');
$sharedWith1 = $this->getMock('\OCP\IUser');
$sharedWith1->method('getUID')->willReturn('sharedWith1');
$sharedWith2 = $this->getMock('\OCP\IGroup');
$sharedWith2->method('getGID')->willReturn('sharedWith2');
$path = $this->getMock('\OCP\Files\File'); $path = $this->getMock('\OCP\Files\File');
$path->method('getId')->willReturn(1); $path->method('getId')->willReturn(1);
@ -267,8 +259,8 @@ class ManagerTest extends \Test\TestCase {
$share1->setId(42) $share1->setId(42)
->setProviderId('prov') ->setProviderId('prov')
->setShareType(\OCP\Share::SHARE_TYPE_USER) ->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedWith($sharedWith1) ->setSharedWith('sharedWith1')
->setSharedBy($sharedBy1) ->setSharedBy('sharedBy1')
->setNode($path) ->setNode($path)
->setTarget('myTarget1'); ->setTarget('myTarget1');
@ -276,8 +268,8 @@ class ManagerTest extends \Test\TestCase {
$share2->setId(43) $share2->setId(43)
->setProviderId('prov') ->setProviderId('prov')
->setShareType(\OCP\Share::SHARE_TYPE_GROUP) ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
->setSharedWith($sharedWith2) ->setSharedWith('sharedWith2')
->setSharedBy($sharedBy2) ->setSharedBy('sharedBy2')
->setNode($path) ->setNode($path)
->setTarget('myTarget2') ->setTarget('myTarget2')
->setParent(42); ->setParent(42);
@ -286,7 +278,7 @@ class ManagerTest extends \Test\TestCase {
$share3->setId(44) $share3->setId(44)
->setProviderId('prov') ->setProviderId('prov')
->setShareType(\OCP\Share::SHARE_TYPE_LINK) ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setSharedBy($sharedBy3) ->setSharedBy('sharedBy3')
->setNode($path) ->setNode($path)
->setTarget('myTarget3') ->setTarget('myTarget3')
->setParent(43); ->setParent(43);
@ -504,72 +496,72 @@ class ManagerTest extends \Test\TestCase {
} }
public function dataGeneralChecks() { public function dataGeneralChecks() {
$user = $this->getMock('\OCP\IUser'); $user0 = 'user0';
$user2 = $this->getMock('\OCP\IUser'); $user2 = 'user1';
$group = $this->getMock('\OCP\IGroup'); $group0 = 'group0';
$file = $this->getMock('\OCP\Files\File'); $file = $this->getMock('\OCP\Files\File');
$node = $this->getMock('\OCP\Files\Node'); $node = $this->getMock('\OCP\Files\Node');
$data = [ $data = [
[$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, null, $user, $user, 31, null, null), 'SharedWith should be an IUser', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $group, $user, $user, 31, null, null), 'SharedWith should be an IUser', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, 'foo@bar.com', $user, $user, 31, null, null), 'SharedWith should be an IUser', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, null, $user, $user, 31, null, null), 'SharedWith should be an IGroup', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $user2, $user, $user, 31, null, null), 'SharedWith should be an IGroup', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, 'foo@bar.com', $user, $user, 31, null, null), 'SharedWith should be an IGroup', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $user2, $user, $user, 31, null, null), 'SharedWith should be empty', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $group, $user, $user, 31, null, null), 'SharedWith should be empty', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, 'foo@bar.com', $user, $user, 31, null, null), 'SharedWith should be empty', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
[$this->createShare(null, -1, $file, null, $user, $user, 31, null, null), 'unkown share type', true], [$this->createShare(null, -1, $file, null, $user0, $user0, 31, null, null), 'unkown share type', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user2, null, $user, 31, null, null), 'SharedBy should be set', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user2, null, $user0, 31, null, null), 'SharedBy should be set', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $group, null, $user, 31, null, null), 'SharedBy should be set', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $group0, null, $user0, 31, null, null), 'SharedBy should be set', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, null, null, $user, 31, null, null), 'SharedBy should be set', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, null, null, $user0, 31, null, null), 'SharedBy should be set', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user, $user, $user, 31, null, null), 'Can\'t share with yourself', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user0, $user0, $user0, 31, null, null), 'Can\'t share with yourself', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, null, $user2, $user, $user, 31, null, null), 'Path should be set', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, null, $user2, $user0, $user0, 31, null, null), 'Path should be set', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, null, $group, $user, $user, 31, null, null), 'Path should be set', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, null, $group0, $user0, $user0, 31, null, null), 'Path should be set', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, null, null, $user, $user, 31, null, null), 'Path should be set', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, null, null, $user0, $user0, 31, null, null), 'Path should be set', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $node, $user2, $user, $user, 31, null, null), 'Path should be either a file or a folder', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $node, $user2, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $node, $group, $user, $user, 31, null, null), 'Path should be either a file or a folder', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $node, $group0, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $node, null, $user, $user, 31, null, null), 'Path should be either a file or a folder', true], [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $node, null, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
]; ];
$nonShareAble = $this->getMock('\OCP\Files\Folder'); $nonShareAble = $this->getMock('\OCP\Files\Folder');
$nonShareAble->method('isShareable')->willReturn(false); $nonShareAble->method('isShareable')->willReturn(false);
$nonShareAble->method('getPath')->willReturn('path'); $nonShareAble->method('getPath')->willReturn('path');
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonShareAble, $user2, $user, $user, 31, null, null), 'You are not allowed to share path', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonShareAble, $group, $user, $user, 31, null, null), 'You are not allowed to share path', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $nonShareAble, null, $user, $user, 31, null, null), 'You are not allowed to share path', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
$limitedPermssions = $this->getMock('\OCP\Files\File'); $limitedPermssions = $this->getMock('\OCP\Files\File');
$limitedPermssions->method('isShareable')->willReturn(true); $limitedPermssions->method('isShareable')->willReturn(true);
$limitedPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ); $limitedPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
$limitedPermssions->method('getPath')->willReturn('path'); $limitedPermssions->method('getPath')->willReturn('path');
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user, $user, null, null, null), 'A share requires permissions', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, null, null, null), 'A share requires permissions', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group, $user, $user, null, null, null), 'A share requires permissions', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, null, null, null), 'A share requires permissions', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user, $user, null, null, null), 'A share requires permissions', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, null, null, null), 'A share requires permissions', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user, $user, 31, null, null), 'Cannot increase permissions of path', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, 31, null, null), 'Cannot increase permissions of path', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group, $user, $user, 17, null, null), 'Cannot increase permissions of path', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Cannot increase permissions of path', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user, $user, 3, null, null), 'Cannot increase permissions of path', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Cannot increase permissions of path', true];
$allPermssions = $this->getMock('\OCP\Files\Folder'); $allPermssions = $this->getMock('\OCP\Files\Folder');
$allPermssions->method('isShareable')->willReturn(true); $allPermssions->method('isShareable')->willReturn(true);
$allPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL); $allPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL);
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user, $user, 30, null, null), 'Shares need at least read permissions', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 30, null, null), 'Shares need at least read permissions', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group, $user, $user, 2, null, null), 'Shares need at least read permissions', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 2, null, null), 'Shares need at least read permissions', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user, $user, 16, null, null), 'Shares need at least read permissions', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user0, $user0, 16, null, null), 'Shares need at least read permissions', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user, $user, 31, null, null), null, false]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 31, null, null), null, false];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group, $user, $user, 3, null, null), null, false]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 3, null, null), null, false];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user, $user, 17, null, null), null, false]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user0, $user0, 17, null, null), null, false];
return $data; return $data;
} }
@ -583,6 +575,15 @@ class ManagerTest extends \Test\TestCase {
public function testGeneralChecks($share, $exceptionMessage, $exception) { public function testGeneralChecks($share, $exceptionMessage, $exception) {
$thrown = null; $thrown = null;
$this->userManager->method('userExists')->will($this->returnValueMap([
['user0', true],
['user1', true],
]));
$this->groupManager->method('groupExists')->will($this->returnValueMap([
['group0', true],
]));
try { try {
$this->invokePrivate($this->manager, 'generalCreateChecks', [$share]); $this->invokePrivate($this->manager, 'generalCreateChecks', [$share]);
$thrown = false; $thrown = false;
@ -795,7 +796,7 @@ class ManagerTest extends \Test\TestCase {
$sharedBy = $this->getMock('\OCP\IUser'); $sharedBy = $this->getMock('\OCP\IUser');
$sharedWith = $this->getMock('\OCP\IUser'); $sharedWith = $this->getMock('\OCP\IUser');
$share->setSharedBy($sharedBy)->setSharedWith($sharedWith); $share->setSharedBy('sharedBy')->setSharedWith('sharedWith');
$this->groupManager $this->groupManager
->method('getUserGroupIds') ->method('getUserGroupIds')
@ -806,6 +807,11 @@ class ManagerTest extends \Test\TestCase {
]) ])
); );
$this->userManager->method('get')->will($this->returnValueMap([
['sharedBy', $sharedBy],
['sharedWith', $sharedWith],
]));
$this->config $this->config
->method('getAppValue') ->method('getAppValue')
->will($this->returnValueMap([ ->will($this->returnValueMap([
@ -820,7 +826,7 @@ class ManagerTest extends \Test\TestCase {
$sharedBy = $this->getMock('\OCP\IUser'); $sharedBy = $this->getMock('\OCP\IUser');
$sharedWith = $this->getMock('\OCP\IUser'); $sharedWith = $this->getMock('\OCP\IUser');
$share->setSharedBy($sharedBy)->setSharedWith($sharedWith); $share->setSharedBy('sharedBy')->setSharedWith('sharedWith');
$path = $this->getMock('\OCP\Files\Node'); $path = $this->getMock('\OCP\Files\Node');
$share->setNode($path); $share->setNode($path);
@ -834,6 +840,11 @@ class ManagerTest extends \Test\TestCase {
]) ])
); );
$this->userManager->method('get')->will($this->returnValueMap([
['sharedBy', $sharedBy],
['sharedWith', $sharedWith],
]));
$this->config $this->config
->method('getAppValue') ->method('getAppValue')
->will($this->returnValueMap([ ->will($this->returnValueMap([
@ -859,10 +870,10 @@ class ManagerTest extends \Test\TestCase {
$sharedWith = $this->getMock('\OCP\IUser'); $sharedWith = $this->getMock('\OCP\IUser');
$path = $this->getMock('\OCP\Files\Node'); $path = $this->getMock('\OCP\Files\Node');
$share->setSharedWith($sharedWith)->setNode($path) $share->setSharedWith('sharedWith')->setNode($path)
->setProviderId('foo')->setId('bar'); ->setProviderId('foo')->setId('bar');
$share2->setSharedWith($sharedWith)->setNode($path) $share2->setSharedWith('sharedWith')->setNode($path)
->setProviderId('foo')->setId('baz'); ->setProviderId('foo')->setId('baz');
$this->defaultProvider $this->defaultProvider
@ -881,28 +892,32 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$sharedWith = $this->getMock('\OCP\IUser'); $sharedWith = $this->getMock('\OCP\IUser');
$owner = $this->getMock('\OCP\IUser'); $sharedWith->method('getUID')->willReturn('sharedWith');
$this->userManager->method('get')->with('sharedWith')->willReturn($sharedWith);
$path = $this->getMock('\OCP\Files\Node'); $path = $this->getMock('\OCP\Files\Node');
$share->setSharedWith($sharedWith) $share->setSharedWith('sharedWith')
->setNode($path) ->setNode($path)
->setShareOwner($owner) ->setShareOwner('shareOwner')
->setProviderId('foo') ->setProviderId('foo')
->setId('bar'); ->setId('bar');
$share2 = new \OC\Share20\Share(); $share2 = new \OC\Share20\Share();
$owner2 = $this->getMock('\OCP\IUser'); $owner2 = $this->getMock('\OCP\IUser');
$share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP) $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
->setShareOwner($owner2) ->setShareOwner('shareOwner2')
->setProviderId('foo') ->setProviderId('foo')
->setId('baz'); ->setId('baz')
->setSharedWith('group');
$group = $this->getMock('\OCP\IGroup'); $group = $this->getMock('\OCP\IGroup');
$group->method('inGroup') $group->method('inGroup')
->with($sharedWith) ->with($sharedWith)
->willReturn(true); ->willReturn(true);
$share2->setSharedWith($group); $this->groupManager->method('get')->with('group')->willReturn($group);
$this->defaultProvider $this->defaultProvider
->method('getSharesByPath') ->method('getSharesByPath')
@ -915,18 +930,18 @@ class ManagerTest extends \Test\TestCase {
public function testUserCreateChecksIdenticalPathNotSharedWithUser() { public function testUserCreateChecksIdenticalPathNotSharedWithUser() {
$share = new \OC\Share20\Share(); $share = new \OC\Share20\Share();
$sharedWith = $this->getMock('\OCP\IUser'); $sharedWith = $this->getMock('\OCP\IUser');
$owner = $this->getMock('\OCP\IUser');
$path = $this->getMock('\OCP\Files\Node'); $path = $this->getMock('\OCP\Files\Node');
$share->setSharedWith($sharedWith) $share->setSharedWith('sharedWith')
->setNode($path) ->setNode($path)
->setShareOwner($owner) ->setShareOwner('shareOwner')
->setProviderId('foo') ->setProviderId('foo')
->setId('bar'); ->setId('bar');
$this->userManager->method('get')->with('sharedWith')->willReturn($sharedWith);
$share2 = new \OC\Share20\Share(); $share2 = new \OC\Share20\Share();
$owner2 = $this->getMock('\OCP\IUser');
$share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP) $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
->setShareOwner($owner2) ->setShareOwner('shareOwner2')
->setProviderId('foo') ->setProviderId('foo')
->setId('baz'); ->setId('baz');
@ -935,7 +950,9 @@ class ManagerTest extends \Test\TestCase {
->with($sharedWith) ->with($sharedWith)
->willReturn(false); ->willReturn(false);
$share2->setSharedWith($group); $this->groupManager->method('get')->with('group')->willReturn($group);
$share2->setSharedWith('group');
$this->defaultProvider $this->defaultProvider
->method('getSharesByPath') ->method('getSharesByPath')
@ -952,11 +969,14 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksShareWithGroupMembersOnlyNotInGroup() { public function testGroupCreateChecksShareWithGroupMembersOnlyNotInGroup() {
$share = new \OC\Share20\Share(); $share = new \OC\Share20\Share();
$sharedBy = $this->getMock('\OCP\IUser'); $user = $this->getMock('\OCP\IUser');
$sharedWith = $this->getMock('\OCP\IGroup'); $group = $this->getMock('\OCP\IGroup');
$share->setSharedBy($sharedBy)->setSharedWith($sharedWith); $share->setSharedBy('user')->setSharedWith('group');
$sharedWith->method('inGroup')->with($sharedBy)->willReturn(false); $group->method('inGroup')->with($user)->willReturn(false);
$this->groupManager->method('get')->with('group')->willReturn($group);
$this->userManager->method('get')->with('user')->willReturn($user);
$this->config $this->config
->method('getAppValue') ->method('getAppValue')
@ -970,11 +990,14 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksShareWithGroupMembersOnlyInGroup() { public function testGroupCreateChecksShareWithGroupMembersOnlyInGroup() {
$share = new \OC\Share20\Share(); $share = new \OC\Share20\Share();
$sharedBy = $this->getMock('\OCP\IUser'); $user = $this->getMock('\OCP\IUser');
$sharedWith = $this->getMock('\OCP\IGroup'); $group = $this->getMock('\OCP\IGroup');
$share->setSharedBy($sharedBy)->setSharedWith($sharedWith); $share->setSharedBy('user')->setSharedWith('group');
$sharedWith->method('inGroup')->with($sharedBy)->willReturn(true); $this->userManager->method('get')->with('user')->willReturn($user);
$this->groupManager->method('get')->with('group')->willReturn($group);
$group->method('inGroup')->with($user)->willReturn(true);
$path = $this->getMock('\OCP\Files\Node'); $path = $this->getMock('\OCP\Files\Node');
$share->setNode($path); $share->setNode($path);
@ -999,15 +1022,14 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksPathAlreadySharedWithSameGroup() { public function testGroupCreateChecksPathAlreadySharedWithSameGroup() {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$sharedWith = $this->getMock('\OCP\IGroup');
$path = $this->getMock('\OCP\Files\Node'); $path = $this->getMock('\OCP\Files\Node');
$share->setSharedWith($sharedWith) $share->setSharedWith('sharedWith')
->setNode($path) ->setNode($path)
->setProviderId('foo') ->setProviderId('foo')
->setId('bar'); ->setId('bar');
$share2 = new \OC\Share20\Share(); $share2 = new \OC\Share20\Share();
$share2->setSharedWith($sharedWith) $share2->setSharedWith('sharedWith')
->setProviderId('foo') ->setProviderId('foo')
->setId('baz'); ->setId('baz');
@ -1021,15 +1043,13 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksPathAlreadySharedWithDifferentGroup() { public function testGroupCreateChecksPathAlreadySharedWithDifferentGroup() {
$share = new \OC\Share20\Share(); $share = new \OC\Share20\Share();
$sharedWith = $this->getMock('\OCP\IGroup'); $share->setSharedWith('sharedWith');
$share->setSharedWith($sharedWith);
$path = $this->getMock('\OCP\Files\Node'); $path = $this->getMock('\OCP\Files\Node');
$share->setNode($path); $share->setNode($path);
$share2 = new \OC\Share20\Share(); $share2 = new \OC\Share20\Share();
$sharedWith2 = $this->getMock('\OCP\IGroup'); $share2->setSharedWith('sharedWith2');
$share2->setSharedWith($sharedWith2);
$this->defaultProvider->method('getSharesByPath') $this->defaultProvider->method('getSharesByPath')
->with($path) ->with($path)
@ -1238,7 +1258,9 @@ class ManagerTest extends \Test\TestCase {
->with($user) ->with($user)
->willReturn($groupIds); ->willReturn($groupIds);
$res = $this->manager->sharingDisabledForUser($user); $this->userManager->method('get')->with('user')->willReturn($user);
$res = $this->manager->sharingDisabledForUser('user');
$this->assertEquals($expected, $res); $this->assertEquals($expected, $res);
} }
@ -1278,7 +1300,7 @@ class ManagerTest extends \Test\TestCase {
$user = $this->getMock('\OCP\IUser'); $user = $this->getMock('\OCP\IUser');
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setSharedBy($user); $share->setSharedBy('user');
$res = $this->invokePrivate($manager, 'canShare', [$share]); $res = $this->invokePrivate($manager, 'canShare', [$share]);
$this->assertEquals($expected, $res); $this->assertEquals($expected, $res);
@ -1303,9 +1325,8 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['canShare', 'generalCreateChecks', 'userCreateChecks', 'pathCreateChecks']) ->setMethods(['canShare', 'generalCreateChecks', 'userCreateChecks', 'pathCreateChecks'])
->getMock(); ->getMock();
$sharedWith = $this->getMock('\OCP\IUser');
$sharedBy = $this->getMock('\OCP\IUser');
$shareOwner = $this->getMock('\OCP\IUser'); $shareOwner = $this->getMock('\OCP\IUser');
$shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->getMock('\OCP\Files\File'); $path = $this->getMock('\OCP\Files\File');
$path->method('getOwner')->willReturn($shareOwner); $path->method('getOwner')->willReturn($shareOwner);
@ -1315,8 +1336,8 @@ class ManagerTest extends \Test\TestCase {
null, null,
\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_USER,
$path, $path,
$sharedWith, 'sharedWith',
$sharedBy, 'sharedBy',
null, null,
\OCP\Constants::PERMISSION_ALL); \OCP\Constants::PERMISSION_ALL);
@ -1342,7 +1363,7 @@ class ManagerTest extends \Test\TestCase {
$share->expects($this->once()) $share->expects($this->once())
->method('setShareOwner') ->method('setShareOwner')
->with($shareOwner); ->with('shareOwner');
$share->expects($this->once()) $share->expects($this->once())
->method('setTarget') ->method('setTarget')
->with('/target'); ->with('/target');
@ -1355,9 +1376,8 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['canShare', 'generalCreateChecks', 'groupCreateChecks', 'pathCreateChecks']) ->setMethods(['canShare', 'generalCreateChecks', 'groupCreateChecks', 'pathCreateChecks'])
->getMock(); ->getMock();
$sharedWith = $this->getMock('\OCP\IGroup');
$sharedBy = $this->getMock('\OCP\IUser');
$shareOwner = $this->getMock('\OCP\IUser'); $shareOwner = $this->getMock('\OCP\IUser');
$shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->getMock('\OCP\Files\File'); $path = $this->getMock('\OCP\Files\File');
$path->method('getOwner')->willReturn($shareOwner); $path->method('getOwner')->willReturn($shareOwner);
@ -1367,8 +1387,8 @@ class ManagerTest extends \Test\TestCase {
null, null,
\OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_GROUP,
$path, $path,
$sharedWith, 'sharedWith',
$sharedBy, 'sharedBy',
null, null,
\OCP\Constants::PERMISSION_ALL); \OCP\Constants::PERMISSION_ALL);
@ -1394,7 +1414,7 @@ class ManagerTest extends \Test\TestCase {
$share->expects($this->once()) $share->expects($this->once())
->method('setShareOwner') ->method('setShareOwner')
->with($shareOwner); ->with('shareOwner');
$share->expects($this->once()) $share->expects($this->once())
->method('setTarget') ->method('setTarget')
->with('/target'); ->with('/target');
@ -1414,9 +1434,8 @@ class ManagerTest extends \Test\TestCase {
]) ])
->getMock(); ->getMock();
$sharedBy = $this->getMock('\OCP\IUser');
$sharedBy->method('getUID')->willReturn('sharedBy');
$shareOwner = $this->getMock('\OCP\IUser'); $shareOwner = $this->getMock('\OCP\IUser');
$shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->getMock('\OCP\Files\File'); $path = $this->getMock('\OCP\Files\File');
$path->method('getOwner')->willReturn($shareOwner); $path->method('getOwner')->willReturn($shareOwner);
@ -1428,7 +1447,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_LINK) $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setNode($path) ->setNode($path)
->setSharedBy($sharedBy) ->setSharedBy('sharedBy')
->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setExpirationDate($date) ->setExpirationDate($date)
->setPassword('password'); ->setPassword('password');
@ -1515,7 +1534,7 @@ class ManagerTest extends \Test\TestCase {
/** @var IShare $share */ /** @var IShare $share */
$share = $manager->createShare($share); $share = $manager->createShare($share);
$this->assertSame($shareOwner, $share->getShareOwner()); $this->assertSame('shareOwner', $share->getShareOwner());
$this->assertEquals('/target', $share->getTarget()); $this->assertEquals('/target', $share->getTarget());
$this->assertSame($date, $share->getExpirationDate()); $this->assertSame($date, $share->getExpirationDate());
$this->assertEquals('token', $share->getToken()); $this->assertEquals('token', $share->getToken());
@ -1536,9 +1555,8 @@ class ManagerTest extends \Test\TestCase {
]) ])
->getMock(); ->getMock();
$sharedWith = $this->getMock('\OCP\IUser');
$sharedBy = $this->getMock('\OCP\IUser');
$shareOwner = $this->getMock('\OCP\IUser'); $shareOwner = $this->getMock('\OCP\IUser');
$shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->getMock('\OCP\Files\File'); $path = $this->getMock('\OCP\Files\File');
$path->method('getOwner')->willReturn($shareOwner); $path->method('getOwner')->willReturn($shareOwner);
@ -1548,8 +1566,8 @@ class ManagerTest extends \Test\TestCase {
null, null,
\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_USER,
$path, $path,
$sharedWith, 'sharedWith',
$sharedBy, 'sharedBy',
null, null,
\OCP\Constants::PERMISSION_ALL); \OCP\Constants::PERMISSION_ALL);
@ -1569,7 +1587,7 @@ class ManagerTest extends \Test\TestCase {
$share->expects($this->once()) $share->expects($this->once())
->method('setShareOwner') ->method('setShareOwner')
->with($shareOwner); ->with('shareOwner');
$share->expects($this->once()) $share->expects($this->once())
->method('setTarget') ->method('setTarget')
->with('/target'); ->with('/target');
@ -1591,7 +1609,8 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager, $this->mountManager,
$this->groupManager, $this->groupManager,
$this->l, $this->l,
$factory $factory,
$this->userManager
); );
$share = $this->getMock('\OCP\Share\IShare'); $share = $this->getMock('\OCP\Share\IShare');
@ -1718,12 +1737,9 @@ class ManagerTest extends \Test\TestCase {
]) ])
->getMock(); ->getMock();
$origGroup = $this->getMock('\OCP\IGroup');
$newGroup = $this->getMock('\OCP\IGroup');
$originalShare = new \OC\Share20\Share(); $originalShare = new \OC\Share20\Share();
$originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP) $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
->setSharedWith($origGroup); ->setSharedWith('origGroup');
$manager->expects($this->once())->method('canShare')->willReturn(true); $manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare); $manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
@ -1732,7 +1748,7 @@ class ManagerTest extends \Test\TestCase {
$share->setProviderId('foo') $share->setProviderId('foo')
->setId('42') ->setId('42')
->setShareType(\OCP\Share::SHARE_TYPE_GROUP) ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
->setSharedWith($newGroup); ->setSharedWith('newGroup');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -1749,12 +1765,9 @@ class ManagerTest extends \Test\TestCase {
]) ])
->getMock(); ->getMock();
$origUser = $this->getMock('\OCP\IUser');
$newUser = $this->getMock('\OCP\IUser');
$originalShare = new \OC\Share20\Share(); $originalShare = new \OC\Share20\Share();
$originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER) $originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedWith($origUser); ->setSharedWith('sharedWith');
$manager->expects($this->once())->method('canShare')->willReturn(true); $manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare); $manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
@ -1763,8 +1776,8 @@ class ManagerTest extends \Test\TestCase {
$share->setProviderId('foo') $share->setProviderId('foo')
->setId('42') ->setId('42')
->setShareType(\OCP\Share::SHARE_TYPE_USER) ->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedWith($newUser) ->setSharedWith('newUser')
->setShareOwner($newUser); ->setShareOwner('newUser');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -1780,12 +1793,9 @@ class ManagerTest extends \Test\TestCase {
]) ])
->getMock(); ->getMock();
$origUser = $this->getMock('\OCP\IUser');
$newUser = $this->getMock('\OCP\IUser');
$originalShare = new \OC\Share20\Share(); $originalShare = new \OC\Share20\Share();
$originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER) $originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedWith($origUser); ->setSharedWith('origUser');
$manager->expects($this->once())->method('canShare')->willReturn(true); $manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare); $manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
@ -1794,8 +1804,8 @@ class ManagerTest extends \Test\TestCase {
$share->setProviderId('foo') $share->setProviderId('foo')
->setId('42') ->setId('42')
->setShareType(\OCP\Share::SHARE_TYPE_USER) ->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedWith($origUser) ->setSharedWith('origUser')
->setShareOwner($newUser); ->setShareOwner('newUser');
$this->defaultProvider->expects($this->once()) $this->defaultProvider->expects($this->once())
->method('update') ->method('update')
@ -1821,12 +1831,9 @@ class ManagerTest extends \Test\TestCase {
]) ])
->getMock(); ->getMock();
$origGroup = $this->getMock('\OCP\IGroup');
$user = $this->getMock('\OCP\IUser');
$originalShare = new \OC\Share20\Share(); $originalShare = new \OC\Share20\Share();
$originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP) $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
->setSharedWith($origGroup); ->setSharedWith('origUser');
$manager->expects($this->once())->method('canShare')->willReturn(true); $manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare); $manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
@ -1835,8 +1842,8 @@ class ManagerTest extends \Test\TestCase {
$share->setProviderId('foo') $share->setProviderId('foo')
->setId('42') ->setId('42')
->setShareType(\OCP\Share::SHARE_TYPE_GROUP) ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
->setSharedWith($origGroup) ->setSharedWith('origUser')
->setShareOwner($user); ->setShareOwner('owner');
$this->defaultProvider->expects($this->once()) $this->defaultProvider->expects($this->once())
->method('update') ->method('update')
@ -1864,9 +1871,6 @@ class ManagerTest extends \Test\TestCase {
]) ])
->getMock(); ->getMock();
$user = $this->getMock('\OCP\IUser');
$user->method('getUID')->willReturn('owner');
$originalShare = new \OC\Share20\Share(); $originalShare = new \OC\Share20\Share();
$originalShare->setShareType(\OCP\Share::SHARE_TYPE_LINK); $originalShare->setShareType(\OCP\Share::SHARE_TYPE_LINK);
@ -1881,8 +1885,8 @@ class ManagerTest extends \Test\TestCase {
$share->setProviderId('foo') $share->setProviderId('foo')
->setId('42') ->setId('42')
->setShareType(\OCP\Share::SHARE_TYPE_LINK) ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setSharedBy($user) ->setSharedBy('owner')
->setShareOwner($user) ->setShareOwner('owner')
->setPassword('password') ->setPassword('password')
->setExpirationDate($tomorrow) ->setExpirationDate($tomorrow)
->setNode($file); ->setNode($file);
@ -1930,24 +1934,20 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_USER); $share->setShareType(\OCP\Share::SHARE_TYPE_USER);
$sharedWith = $this->getMock('\OCP\IUser'); $share->setSharedWith('sharedWith');
$share->setSharedWith($sharedWith);
$recipient = $this->getMock('\OCP\IUser'); $this->manager->moveShare($share, 'recipient');
$this->manager->moveShare($share, $recipient);
} }
public function testMoveShareUser() { public function testMoveShareUser() {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_USER); $share->setShareType(\OCP\Share::SHARE_TYPE_USER);
$recipient = $this->getMock('\OCP\IUser'); $share->setSharedWith('recipient');
$share->setSharedWith($recipient);
$this->defaultProvider->method('move')->with($share, $recipient)->will($this->returnArgument(0)); $this->defaultProvider->method('move')->with($share, 'recipient')->will($this->returnArgument(0));
$this->manager->moveShare($share, $recipient); $this->manager->moveShare($share, 'recipient');
} }
/** /**
@ -1959,27 +1959,33 @@ class ManagerTest extends \Test\TestCase {
$share->setShareType(\OCP\Share::SHARE_TYPE_GROUP); $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
$sharedWith = $this->getMock('\OCP\IGroup'); $sharedWith = $this->getMock('\OCP\IGroup');
$share->setSharedWith($sharedWith); $share->setSharedWith('shareWith');
$recipient = $this->getMock('\OCP\IUser'); $recipient = $this->getMock('\OCP\IUser');
$sharedWith->method('inGroup')->with($recipient)->willReturn(false); $sharedWith->method('inGroup')->with($recipient)->willReturn(false);
$this->manager->moveShare($share, $recipient); $this->groupManager->method('get')->with('shareWith')->willReturn($sharedWith);
$this->userManager->method('get')->with('recipient')->willReturn($recipient);
$this->manager->moveShare($share, 'recipient');
} }
public function testMoveShareGroup() { public function testMoveShareGroup() {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_GROUP); $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
$sharedWith = $this->getMock('\OCP\IGroup'); $group = $this->getMock('\OCP\IGroup');
$share->setSharedWith($sharedWith); $share->setSharedWith('group');
$recipient = $this->getMock('\OCP\IUser'); $recipient = $this->getMock('\OCP\IUser');
$sharedWith->method('inGroup')->with($recipient)->willReturn(true); $group->method('inGroup')->with($recipient)->willReturn(true);
$this->defaultProvider->method('move')->with($share, $recipient)->will($this->returnArgument(0)); $this->groupManager->method('get')->with('group')->willReturn($group);
$this->userManager->method('get')->with('recipient')->willReturn($recipient);
$this->manager->moveShare($share, $recipient); $this->defaultProvider->method('move')->with($share, 'recipient')->will($this->returnArgument(0));
$this->manager->moveShare($share, 'recipient');
} }
} }