[Share 2.0] Fix OCS endpoint
This commit is contained in:
parent
96662c4d0d
commit
c1841892d0
|
@ -26,35 +26,41 @@ use OCP\IRequest;
|
|||
use OCP\IURLGenerator;
|
||||
use OCP\IUser;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Share\IManager;
|
||||
|
||||
use OCP\Share\Exceptions\ShareNotFound;
|
||||
use OCP\Share\Exceptions\GenericShareException;
|
||||
|
||||
class Share20OCS {
|
||||
|
||||
/** @var \OC\Share20\Manager */
|
||||
/** @var IManager */
|
||||
private $shareManager;
|
||||
|
||||
/** @var IGroupManager */
|
||||
private $groupManager;
|
||||
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
|
||||
/** @var IRequest */
|
||||
private $request;
|
||||
|
||||
/** @var IRootFolder */
|
||||
private $rootFolder;
|
||||
|
||||
/** @var IUrlGenerator */
|
||||
private $urlGenerator;
|
||||
|
||||
/** @var IUser */
|
||||
private $currentUser;
|
||||
|
||||
/**
|
||||
* Share20OCS constructor.
|
||||
*
|
||||
* @param IManager $shareManager
|
||||
* @param IGroupManager $groupManager
|
||||
* @param IUserManager $userManager
|
||||
* @param IRequest $request
|
||||
* @param IRootFolder $rootFolder
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param IUser $currentUser
|
||||
*/
|
||||
public function __construct(
|
||||
\OC\Share20\Manager $shareManager,
|
||||
IManager $shareManager,
|
||||
IGroupManager $groupManager,
|
||||
IUserManager $userManager,
|
||||
IRequest $request,
|
||||
|
@ -78,22 +84,24 @@ class Share20OCS {
|
|||
* @return array
|
||||
*/
|
||||
protected function formatShare(\OCP\Share\IShare $share) {
|
||||
$sharedBy = $this->userManager->get($share->getSharedBy());
|
||||
$shareOwner = $this->userManager->get($share->getShareOwner());
|
||||
$result = [
|
||||
'id' => $share->getId(),
|
||||
'share_type' => $share->getShareType(),
|
||||
'uid_owner' => $share->getSharedBy()->getUID(),
|
||||
'displayname_owner' => $share->getSharedBy()->getDisplayName(),
|
||||
'uid_owner' => $share->getSharedBy(),
|
||||
'displayname_owner' => $sharedBy->getDisplayName(),
|
||||
'permissions' => $share->getPermissions(),
|
||||
'stime' => $share->getShareTime()->getTimestamp(),
|
||||
'parent' => null,
|
||||
'expiration' => null,
|
||||
'token' => null,
|
||||
'uid_file_owner' => $share->getShareOwner()->getUID(),
|
||||
'displayname_file_owner' => $share->getShareOwner()->getDisplayName(),
|
||||
'uid_file_owner' => $share->getShareOwner(),
|
||||
'displayname_file_owner' => $shareOwner->getDisplayName(),
|
||||
];
|
||||
|
||||
$node = $share->getNode();
|
||||
$result['path'] = $this->rootFolder->getUserFolder($share->getShareOwner()->getUID())->getRelativePath($node->getPath());
|
||||
$result['path'] = $this->rootFolder->getUserFolder($share->getShareOwner())->getRelativePath($node->getPath());
|
||||
if ($node instanceOf \OCP\Files\Folder) {
|
||||
$result['item_type'] = 'folder';
|
||||
} else {
|
||||
|
@ -107,13 +115,12 @@ class Share20OCS {
|
|||
$result['file_target'] = $share->getTarget();
|
||||
|
||||
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
|
||||
$sharedWith = $share->getSharedWith();
|
||||
$sharedWith = $this->userManager->get($share->getSharedWith());
|
||||
$result['share_with'] = $sharedWith->getUID();
|
||||
$result['share_with_displayname'] = $sharedWith->getDisplayName();
|
||||
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
|
||||
$sharedWith = $share->getSharedWith();
|
||||
$result['share_with'] = $sharedWith->getGID();
|
||||
$result['share_with_displayname'] = $sharedWith->getGID();
|
||||
$result['share_with'] = $share->getSharedWith();
|
||||
$result['share_with_displayname'] = $share->getSharedWith();
|
||||
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
|
||||
|
||||
$result['share_with'] = $share->getPassword();
|
||||
|
@ -250,14 +257,14 @@ class Share20OCS {
|
|||
if ($shareWith === null || !$this->userManager->userExists($shareWith)) {
|
||||
return new \OC_OCS_Result(null, 404, 'please specify a valid user');
|
||||
}
|
||||
$share->setSharedWith($this->userManager->get($shareWith));
|
||||
$share->setSharedWith($shareWith);
|
||||
$share->setPermissions($permissions);
|
||||
} else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
|
||||
// Valid group is required to share
|
||||
if ($shareWith === null || !$this->groupManager->groupExists($shareWith)) {
|
||||
return new \OC_OCS_Result(null, 404, 'please specify a valid group');
|
||||
}
|
||||
$share->setSharedWith($this->groupManager->get($shareWith));
|
||||
$share->setSharedWith($shareWith);
|
||||
$share->setPermissions($permissions);
|
||||
} else if ($shareType === \OCP\Share::SHARE_TYPE_LINK) {
|
||||
//Can we even share links?
|
||||
|
@ -313,7 +320,7 @@ class Share20OCS {
|
|||
}
|
||||
|
||||
$share->setShareType($shareType);
|
||||
$share->setSharedBy($this->currentUser);
|
||||
$share->setSharedBy($this->currentUser->getUID());
|
||||
|
||||
try {
|
||||
$share = $this->shareManager->createShare($share);
|
||||
|
@ -333,8 +340,8 @@ class Share20OCS {
|
|||
* @return \OC_OCS_Result
|
||||
*/
|
||||
private function getSharedWithMe($node = null) {
|
||||
$userShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, -1, 0);
|
||||
$groupShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
|
||||
$userShares = $this->shareManager->getSharedWith($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $node, -1, 0);
|
||||
$groupShares = $this->shareManager->getSharedWith($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
|
||||
|
||||
$shares = array_merge($userShares, $groupShares);
|
||||
|
||||
|
@ -361,9 +368,9 @@ class Share20OCS {
|
|||
/** @var \OCP\Share\IShare[] $shares */
|
||||
$shares = [];
|
||||
foreach ($nodes as $node) {
|
||||
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
|
||||
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
|
||||
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
|
||||
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
|
||||
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
|
||||
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
|
||||
//TODO: Add federated shares
|
||||
|
||||
}
|
||||
|
@ -417,9 +424,9 @@ class Share20OCS {
|
|||
}
|
||||
|
||||
// Get all shares
|
||||
$userShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
|
||||
$groupShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
|
||||
$linkShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
|
||||
$userShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
|
||||
$groupShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
|
||||
$linkShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
|
||||
//TODO: Add federated shares
|
||||
|
||||
$shares = array_merge($userShares, $groupShares, $linkShares);
|
||||
|
@ -538,14 +545,6 @@ class Share20OCS {
|
|||
return new \OC_OCS_Result($this->formatShare($share));
|
||||
}
|
||||
|
||||
public function validatePermissions($permissions) {
|
||||
if ($permissions < 0 || $permissions > \OCP\Constants::PERMISSION_ALL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \OCP\Share\IShare $share
|
||||
* @return bool
|
||||
|
@ -557,22 +556,24 @@ class Share20OCS {
|
|||
}
|
||||
|
||||
// Owner of the file and the sharer of the file can always get share
|
||||
if ($share->getShareOwner() === $this->currentUser ||
|
||||
$share->getSharedBy() === $this->currentUser
|
||||
if ($share->getShareOwner() === $this->currentUser->getUID() ||
|
||||
$share->getSharedBy() === $this->currentUser->getUID()
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the share is shared with you (or a group you are a member of)
|
||||
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
|
||||
$share->getSharedWith() === $this->currentUser) {
|
||||
$share->getSharedWith() === $this->currentUser->getUID()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP &&
|
||||
$share->getSharedWith()->inGroup($this->currentUser)) {
|
||||
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
|
||||
$sharedWith = $this->groupManager->get($share->getSharedWith());
|
||||
if ($sharedWith->inGroup($this->currentUser)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
private $ocs;
|
||||
|
||||
protected function setUp() {
|
||||
$this->shareManager = $this->getMockBuilder('OC\Share20\Manager')
|
||||
$this->shareManager = $this->getMockBuilder('OCP\Share\IManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->groupManager = $this->getMock('OCP\IGroupManager');
|
||||
|
@ -91,6 +91,10 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
->getMock();
|
||||
}
|
||||
|
||||
private function newShare() {
|
||||
return \OC::$server->getShareManager()->newShare();
|
||||
}
|
||||
|
||||
public function testDeleteShareShareNotFound() {
|
||||
$this->shareManager
|
||||
->expects($this->once())
|
||||
|
@ -103,8 +107,8 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testDeleteShare() {
|
||||
$share = $this->getMock('OCP\Share\IShare');
|
||||
$share->method('getSharedBy')->willReturn($this->currentUser);
|
||||
$share = $this->newShare();
|
||||
$share->setSharedBy($this->currentUser->getUID());
|
||||
$this->shareManager
|
||||
->expects($this->once())
|
||||
->method('getShareById')
|
||||
|
@ -137,7 +141,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions,
|
||||
$shareTime, $expiration, $parent, $target, $mail_send, $token=null,
|
||||
$password=null) {
|
||||
$share = $this->getMock('OCP\Share\IShare');
|
||||
$share = $this->getMock('\OCP\Share\IShare');
|
||||
$share->method('getId')->willReturn($id);
|
||||
$share->method('getShareType')->willReturn($shareType);
|
||||
$share->method('getSharedWith')->willReturn($sharedWith);
|
||||
|
@ -166,21 +170,6 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
public function dataGetShare() {
|
||||
$data = [];
|
||||
|
||||
$initiator = $this->getMock('OCP\IUser');
|
||||
$initiator->method('getUID')->willReturn('initiatorId');
|
||||
$initiator->method('getDisplayName')->willReturn('initiatorDisplay');
|
||||
|
||||
$owner = $this->getMock('OCP\IUser');
|
||||
$owner->method('getUID')->willReturn('ownerId');
|
||||
$owner->method('getDisplayName')->willReturn('ownerDisplay');
|
||||
|
||||
$user = $this->getMock('OCP\IUser');
|
||||
$user->method('getUID')->willReturn('userId');
|
||||
$user->method('getDisplayName')->willReturn('userDisplay');
|
||||
|
||||
$group = $this->getMock('OCP\IGroup');
|
||||
$group->method('getGID')->willReturn('groupId');
|
||||
|
||||
$cache = $this->getMockBuilder('OC\Files\Cache\Cache')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
@ -211,9 +200,9 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
$share = $this->createShare(
|
||||
100,
|
||||
\OCP\Share::SHARE_TYPE_USER,
|
||||
$user,
|
||||
$initiator,
|
||||
$owner,
|
||||
'userId',
|
||||
'initiatorId',
|
||||
'ownerId',
|
||||
$file,
|
||||
4,
|
||||
5,
|
||||
|
@ -252,9 +241,9 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
$share = $this->createShare(
|
||||
101,
|
||||
\OCP\Share::SHARE_TYPE_GROUP,
|
||||
$group,
|
||||
$initiator,
|
||||
$owner,
|
||||
'groupId',
|
||||
'initiatorId',
|
||||
'ownerId',
|
||||
$folder,
|
||||
4,
|
||||
5,
|
||||
|
@ -295,8 +284,8 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
101,
|
||||
\OCP\Share::SHARE_TYPE_LINK,
|
||||
null,
|
||||
$initiator,
|
||||
$owner,
|
||||
'initiatorId',
|
||||
'ownerId',
|
||||
$folder,
|
||||
4,
|
||||
5,
|
||||
|
@ -367,29 +356,53 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
->will($this->returnArgument(0));
|
||||
|
||||
$this->rootFolder->method('getUserFolder')
|
||||
->with($share->getShareOwner()->getUID())
|
||||
->with($share->getShareOwner())
|
||||
->willReturn($userFolder);
|
||||
|
||||
$this->urlGenerator
|
||||
->method('linkToRouteAbsolute')
|
||||
->willReturn('url');
|
||||
|
||||
$initiator = $this->getMock('OCP\IUser');
|
||||
$initiator->method('getUID')->willReturn('initiatorId');
|
||||
$initiator->method('getDisplayName')->willReturn('initiatorDisplay');
|
||||
|
||||
$owner = $this->getMock('OCP\IUser');
|
||||
$owner->method('getUID')->willReturn('ownerId');
|
||||
$owner->method('getDisplayName')->willReturn('ownerDisplay');
|
||||
|
||||
$user = $this->getMock('OCP\IUser');
|
||||
$user->method('getUID')->willReturn('userId');
|
||||
$user->method('getDisplayName')->willReturn('userDisplay');
|
||||
|
||||
$group = $this->getMock('OCP\IGroup');
|
||||
$group->method('getGID')->willReturn('groupId');
|
||||
|
||||
$this->userManager->method('get')->will($this->returnValueMap([
|
||||
['userId', $user],
|
||||
['initiatorId', $initiator],
|
||||
['ownerId', $owner],
|
||||
]));
|
||||
$this->groupManager->method('get')->will($this->returnValueMap([
|
||||
['group', $group],
|
||||
]));
|
||||
|
||||
$expected = new \OC_OCS_Result($result);
|
||||
$this->assertEquals($expected->getData(), $ocs->getShare($share->getId())->getData());
|
||||
}
|
||||
|
||||
public function testCanAccessShare() {
|
||||
$share = $this->getMock('OCP\Share\IShare');
|
||||
$share->method('getShareOwner')->willReturn($this->currentUser);
|
||||
$share->method('getShareOwner')->willReturn($this->currentUser->getUID());
|
||||
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
|
||||
|
||||
$share = $this->getMock('OCP\Share\IShare');
|
||||
$share->method('getSharedBy')->willReturn($this->currentUser);
|
||||
$share->method('getSharedBy')->willReturn($this->currentUser->getUID());
|
||||
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
|
||||
|
||||
$share = $this->getMock('OCP\Share\IShare');
|
||||
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
|
||||
$share->method('getSharedWith')->willReturn($this->currentUser);
|
||||
$share->method('getSharedWith')->willReturn($this->currentUser->getUID());
|
||||
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
|
||||
|
||||
$share = $this->getMock('OCP\Share\IShare');
|
||||
|
@ -399,16 +412,25 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = $this->getMock('OCP\Share\IShare');
|
||||
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
|
||||
$share->method('getSharedWith')->willReturn('group');
|
||||
|
||||
$group = $this->getMock('OCP\IGroup');
|
||||
$group->method('inGroup')->with($this->currentUser)->willReturn(true);
|
||||
$share->method('getSharedWith')->willReturn($group);
|
||||
$group2 = $this->getMock('OCP\IGroup');
|
||||
$group2->method('inGroup')->with($this->currentUser)->willReturn(false);
|
||||
|
||||
|
||||
$this->groupManager->method('get')->will($this->returnValueMap([
|
||||
['group', $group],
|
||||
['group2', $group2],
|
||||
]));
|
||||
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
|
||||
|
||||
$share = $this->getMock('OCP\Share\IShare');
|
||||
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
|
||||
$group = $this->getMock('OCP\IGroup');
|
||||
$group->method('inGroup')->with($this->currentUser)->willReturn(false);
|
||||
$share->method('getSharedWith')->willReturn($group);
|
||||
$share->method('getSharedWith')->willReturn('group2');
|
||||
|
||||
$this->groupManager->method('get')->with('group2')->willReturn($group);
|
||||
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
|
||||
|
||||
$share = $this->getMock('OCP\Share\IShare');
|
||||
|
@ -587,7 +609,6 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$user = $this->getMock('\OCP\IUser');
|
||||
$this->userManager->method('userExists')->with('validUser')->willReturn(true);
|
||||
$this->userManager->method('get')->with('validUser')->willReturn($user);
|
||||
|
||||
$share->method('setPath')->with($path);
|
||||
$share->method('setPermissions')
|
||||
|
@ -596,8 +617,8 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
~\OCP\Constants::PERMISSION_DELETE &
|
||||
~\OCP\Constants::PERMISSION_CREATE);
|
||||
$share->method('setShareType')->with(\OCP\Share::SHARE_TYPE_USER);
|
||||
$share->method('setSharedWith')->with($user);
|
||||
$share->method('setSharedBy')->with($this->currentUser);
|
||||
$share->method('setSharedWith')->with('validUser');
|
||||
$share->method('setSharedBy')->with('currentUser');
|
||||
|
||||
$expected = new \OC_OCS_Result();
|
||||
$result = $ocs->createShare();
|
||||
|
@ -680,13 +701,12 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$group = $this->getMock('\OCP\IGroup');
|
||||
$this->groupManager->method('groupExists')->with('validGroup')->willReturn(true);
|
||||
$this->groupManager->method('get')->with('validGroup')->willReturn($group);
|
||||
|
||||
$share->method('setPath')->with($path);
|
||||
$share->method('setPermissions')->with(\OCP\Constants::PERMISSION_ALL);
|
||||
$share->method('setShareType')->with(\OCP\Share::SHARE_TYPE_GROUP);
|
||||
$share->method('setSharedWith')->with($group);
|
||||
$share->method('setSharedBy')->with($this->currentUser);
|
||||
$share->method('setSharedWith')->with('validGroup');
|
||||
$share->method('setSharedBy')->with('currentUser');
|
||||
|
||||
$expected = new \OC_OCS_Result();
|
||||
$result = $ocs->createShare();
|
||||
|
@ -784,14 +804,12 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
$currentUser = $this->currentUser;
|
||||
|
||||
$this->shareManager->expects($this->once())->method('createShare')->with(
|
||||
$this->callback(function (\OCP\Share\IShare $share) use ($path, $currentUser) {
|
||||
$this->callback(function (\OCP\Share\IShare $share) use ($path) {
|
||||
return $share->getNode() === $path &&
|
||||
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
|
||||
$share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE &&
|
||||
$share->getSharedBy() === $currentUser &&
|
||||
$share->getSharedBy() === 'currentUser' &&
|
||||
$share->getPassword() === null &&
|
||||
$share->getExpirationDate() === null;
|
||||
})
|
||||
|
@ -825,14 +843,12 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
$currentUser = $this->currentUser;
|
||||
|
||||
$this->shareManager->expects($this->once())->method('createShare')->with(
|
||||
$this->callback(function (\OCP\Share\IShare $share) use ($path, $currentUser) {
|
||||
$this->callback(function (\OCP\Share\IShare $share) use ($path) {
|
||||
return $share->getNode() === $path &&
|
||||
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
|
||||
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
|
||||
$share->getSharedBy() === $currentUser &&
|
||||
$share->getSharedBy() === 'currentUser' &&
|
||||
$share->getPassword() === 'password' &&
|
||||
$share->getExpirationDate() === null;
|
||||
})
|
||||
|
@ -866,17 +882,15 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
$currentUser = $this->currentUser;
|
||||
|
||||
$this->shareManager->expects($this->once())->method('createShare')->with(
|
||||
$this->callback(function (\OCP\Share\IShare $share) use ($path, $currentUser) {
|
||||
$this->callback(function (\OCP\Share\IShare $share) use ($path) {
|
||||
$date = new \DateTime('2000-01-01');
|
||||
$date->setTime(0,0,0);
|
||||
|
||||
return $share->getNode() === $path &&
|
||||
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
|
||||
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
|
||||
$share->getSharedBy() === $currentUser &&
|
||||
$share->getSharedBy() === 'currentUser' &&
|
||||
$share->getPassword() === null &&
|
||||
$share->getExpirationDate() == $date;
|
||||
})
|
||||
|
@ -932,7 +946,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
public function testUpdateNoParametersLink() {
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK);
|
||||
|
||||
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
|
||||
|
@ -947,7 +961,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
public function testUpdateNoParametersOther() {
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
|
||||
|
||||
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
|
||||
|
@ -964,7 +978,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setPassword('password')
|
||||
->setExpirationDate(new \DateTime())
|
||||
|
@ -1002,7 +1016,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setNode($folder);
|
||||
|
||||
|
@ -1042,7 +1056,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setNode($folder);
|
||||
|
||||
|
@ -1071,7 +1085,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setNode($folder);
|
||||
|
||||
|
@ -1100,7 +1114,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setNode($file);
|
||||
|
||||
|
@ -1130,7 +1144,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setPassword('password')
|
||||
->setExpirationDate($date)
|
||||
|
@ -1164,7 +1178,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setPassword('password')
|
||||
->setExpirationDate(new \DateTime())
|
||||
|
@ -1205,7 +1219,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setPassword('password')
|
||||
->setExpirationDate($date)
|
||||
|
@ -1245,7 +1259,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setPassword('password')
|
||||
->setExpirationDate($date)
|
||||
|
@ -1285,7 +1299,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setPassword('password')
|
||||
->setExpirationDate($date)
|
||||
|
@ -1315,7 +1329,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setSharedBy($this->currentUser->getUID())
|
||||
->setShareType(\OCP\Share::SHARE_TYPE_USER)
|
||||
->setNode($file);
|
||||
|
||||
|
|
Loading…
Reference in New Issue