[Share 2.0] Move IShare to OCP

This commit is contained in:
Roeland Jago Douma 2016-01-27 12:13:53 +01:00
parent 0832cca54e
commit 185b9c6edd
13 changed files with 192 additions and 150 deletions

View File

@ -20,8 +20,6 @@
*/ */
namespace OCA\Files_Sharing\API; namespace OCA\Files_Sharing\API;
use OC\Share20\IShare;
use OCP\IGroupManager; use OCP\IGroupManager;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\IRequest; use OCP\IRequest;
@ -73,10 +71,10 @@ class Share20OCS {
/** /**
* Convert an IShare to an array for OCS output * Convert an IShare to an array for OCS output
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @return array * @return array
*/ */
protected function formatShare($share) { protected function formatShare(\OCP\Share\IShare $share) {
$result = [ $result = [
'id' => $share->getId(), 'id' => $share->getId(),
'share_type' => $share->getShareType(), 'share_type' => $share->getShareType(),
@ -353,7 +351,7 @@ class Share20OCS {
} }
$nodes = $folder->getDirectoryListing(); $nodes = $folder->getDirectoryListing();
/** @var IShare[] $shares */ /** @var \OCP\Share\IShare[] $shares */
$shares = []; $shares = [];
foreach ($nodes as $node) { 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_USER, $node, false, -1, 0));
@ -494,10 +492,10 @@ class Share20OCS {
} }
/** /**
* @param IShare $share * @param \OCP\Share\IShare $share
* @return bool * @return bool
*/ */
protected function canAccessShare(IShare $share) { protected function canAccessShare(\OCP\Share\IShare $share) {
// A file with permissions 0 can't be accessed by us. So Don't show it // A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) { if ($share->getPermissions() === 0) {
return false; return false;

View File

@ -51,7 +51,6 @@ use OCA\Files_Sharing\Helper;
use OCP\Util; use OCP\Util;
use OCA\Files_Sharing\Activity; use OCA\Files_Sharing\Activity;
use \OCP\Files\NotFoundException; use \OCP\Files\NotFoundException;
use \OC\Share20\IShare;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
/** /**
@ -168,11 +167,11 @@ class ShareController extends Controller {
* This is a modified version of Helper::authenticate * This is a modified version of Helper::authenticate
* TODO: Try to merge back eventually with Helper::authenticate * TODO: Try to merge back eventually with Helper::authenticate
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @param string|null $password * @param string|null $password
* @return bool * @return bool
*/ */
private function linkShareAuth(IShare $share, $password = null) { private function linkShareAuth(\OCP\Share\IShare $share, $password = null) {
if ($password !== null) { if ($password !== null) {
if ($this->shareManager->checkPassword($share, $password)) { if ($this->shareManager->checkPassword($share, $password)) {
$this->session->set('public_link_authenticated', (string)$share->getId()); $this->session->set('public_link_authenticated', (string)$share->getId());

View File

@ -20,7 +20,6 @@
*/ */
namespace OCA\Files_Sharing\Tests\API; namespace OCA\Files_Sharing\Tests\API;
use OC\Share20\IShare;
use OCA\Files_Sharing\API\Share20OCS; use OCA\Files_Sharing\API\Share20OCS;
use OCP\IGroupManager; use OCP\IGroupManager;
use OCP\IUserManager; use OCP\IUserManager;
@ -90,7 +89,7 @@ class Share20OCSTest extends \Test\TestCase {
} }
public function testDeleteShareCouldNotDelete() { public function testDeleteShareCouldNotDelete() {
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getShareOwner')->willReturn($this->currentUser); $share->method('getShareOwner')->willReturn($this->currentUser);
$this->shareManager $this->shareManager
->expects($this->once()) ->expects($this->once())
@ -109,7 +108,7 @@ class Share20OCSTest extends \Test\TestCase {
} }
public function testDeleteShare() { public function testDeleteShare() {
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getSharedBy')->willReturn($this->currentUser); $share->method('getSharedBy')->willReturn($this->currentUser);
$this->shareManager $this->shareManager
->expects($this->once()) ->expects($this->once())
@ -143,7 +142,7 @@ class Share20OCSTest extends \Test\TestCase {
public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions, public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions,
$shareTime, $expiration, $parent, $target, $mail_send, $token=null, $shareTime, $expiration, $parent, $target, $mail_send, $token=null,
$password=null) { $password=null) {
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getId')->willReturn($id); $share->method('getId')->willReturn($id);
$share->method('getShareType')->willReturn($shareType); $share->method('getShareType')->willReturn($shareType);
$share->method('getSharedWith')->willReturn($sharedWith); $share->method('getSharedWith')->willReturn($sharedWith);
@ -345,7 +344,7 @@ class Share20OCSTest extends \Test\TestCase {
/** /**
* @dataProvider dataGetShare * @dataProvider dataGetShare
*/ */
public function testGetShare(\OC\Share20\IShare $share, array $result) { public function testGetShare(\OCP\Share\IShare $share, array $result) {
$ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS') $ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS')
->setConstructorArgs([ ->setConstructorArgs([
$this->shareManager, $this->shareManager,
@ -384,39 +383,39 @@ class Share20OCSTest extends \Test\TestCase {
} }
public function testCanAccessShare() { public function testCanAccessShare() {
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getShareOwner')->willReturn($this->currentUser); $share->method('getShareOwner')->willReturn($this->currentUser);
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getSharedBy')->willReturn($this->currentUser); $share->method('getSharedBy')->willReturn($this->currentUser);
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$share->method('getSharedWith')->willReturn($this->currentUser); $share->method('getSharedWith')->willReturn($this->currentUser);
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$share->method('getSharedWith')->willReturn($this->getMock('OCP\IUser')); $share->method('getSharedWith')->willReturn($this->getMock('OCP\IUser'));
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
$group = $this->getMock('OCP\IGroup'); $group = $this->getMock('OCP\IGroup');
$group->method('inGroup')->with($this->currentUser)->willReturn(true); $group->method('inGroup')->with($this->currentUser)->willReturn(true);
$share->method('getSharedWith')->willReturn($group); $share->method('getSharedWith')->willReturn($group);
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
$group = $this->getMock('OCP\IGroup'); $group = $this->getMock('OCP\IGroup');
$group->method('inGroup')->with($this->currentUser)->willReturn(false); $group->method('inGroup')->with($this->currentUser)->willReturn(false);
$share->method('getSharedWith')->willReturn($group); $share->method('getSharedWith')->willReturn($group);
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
} }
@ -457,7 +456,7 @@ class Share20OCSTest extends \Test\TestCase {
} }
public function testCreateShareInvalidPermissions() { public function testCreateShareInvalidPermissions() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$this->shareManager->method('newShare')->willReturn($share); $this->shareManager->method('newShare')->willReturn($share);
$this->request $this->request
@ -488,7 +487,7 @@ class Share20OCSTest extends \Test\TestCase {
} }
public function testCreateShareUserNoShareWith() { public function testCreateShareUserNoShareWith() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$this->shareManager->method('newShare')->willReturn($share); $this->shareManager->method('newShare')->willReturn($share);
$this->request $this->request
@ -520,7 +519,7 @@ class Share20OCSTest extends \Test\TestCase {
} }
public function testCreateShareUserNoValidShareWith() { public function testCreateShareUserNoValidShareWith() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$this->shareManager->method('newShare')->willReturn($share); $this->shareManager->method('newShare')->willReturn($share);
$this->request $this->request
@ -553,8 +552,9 @@ class Share20OCSTest extends \Test\TestCase {
} }
public function testCreateShareUser() { public function testCreateShareUser() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$this->shareManager->method('newShare')->willReturn($share); $this->shareManager->method('newShare')->willReturn($share);
$this->shareManager->method('createShare')->will($this->returnArgument(0));
$ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS') $ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS')
->setConstructorArgs([ ->setConstructorArgs([
@ -611,8 +611,9 @@ class Share20OCSTest extends \Test\TestCase {
} }
public function testCreateShareGroupNoValidShareWith() { public function testCreateShareGroupNoValidShareWith() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$this->shareManager->method('newShare')->willReturn($share); $this->shareManager->method('newShare')->willReturn($share);
$this->shareManager->method('createShare')->will($this->returnArgument(0));
$this->request $this->request
->method('getParam') ->method('getParam')
@ -644,8 +645,9 @@ class Share20OCSTest extends \Test\TestCase {
} }
public function testCreateShareGroup() { public function testCreateShareGroup() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$this->shareManager->method('newShare')->willReturn($share); $this->shareManager->method('newShare')->willReturn($share);
$this->shareManager->method('createShare')->will($this->returnArgument(0));
$ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS') $ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS')
->setConstructorArgs([ ->setConstructorArgs([

View File

@ -116,7 +116,7 @@ class ShareControllerTest extends \Test\TestCase {
} }
public function testShowAuthenticateNotAuthenticated() { public function testShowAuthenticateNotAuthenticated() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$this->shareManager $this->shareManager
->expects($this->once()) ->expects($this->once())
@ -130,7 +130,7 @@ class ShareControllerTest extends \Test\TestCase {
} }
public function testShowAuthenticateAuthenticatedForDifferentShare() { public function testShowAuthenticateAuthenticatedForDifferentShare() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getId')->willReturn(1); $share->method('getId')->willReturn(1);
$this->shareManager $this->shareManager
@ -148,7 +148,7 @@ class ShareControllerTest extends \Test\TestCase {
} }
public function testShowAuthenticateCorrectShare() { public function testShowAuthenticateCorrectShare() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getId')->willReturn(1); $share->method('getId')->willReturn(1);
$this->shareManager $this->shareManager
@ -183,7 +183,7 @@ class ShareControllerTest extends \Test\TestCase {
} }
public function testAuthenticateValidPassword() { public function testAuthenticateValidPassword() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getId')->willReturn(42); $share->method('getId')->willReturn(42);
$this->shareManager $this->shareManager
@ -214,7 +214,7 @@ class ShareControllerTest extends \Test\TestCase {
} }
public function testAuthenticateInvalidPassword() { public function testAuthenticateInvalidPassword() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getId')->willReturn(42); $share->method('getId')->willReturn(42);
$this->shareManager $this->shareManager
@ -252,7 +252,7 @@ class ShareControllerTest extends \Test\TestCase {
} }
public function testShowShareNotAuthenticated() { public function testShowShareNotAuthenticated() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getPassword')->willReturn('password'); $share->method('getPassword')->willReturn('password');
$this->shareManager $this->shareManager
@ -283,7 +283,7 @@ class ShareControllerTest extends \Test\TestCase {
$file->method('getMimetype')->willReturn('text/plain'); $file->method('getMimetype')->willReturn('text/plain');
$file->method('getSize')->willReturn(33); $file->method('getSize')->willReturn(33);
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getId')->willReturn('42'); $share->method('getId')->willReturn('42');
$share->method('getPassword')->willReturn('password'); $share->method('getPassword')->willReturn('password');
$share->method('getShareOwner')->willReturn($owner); $share->method('getShareOwner')->willReturn($owner);
@ -340,7 +340,7 @@ class ShareControllerTest extends \Test\TestCase {
} }
public function testDownloadShare() { public function testDownloadShare() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getPassword')->willReturn('password'); $share->method('getPassword')->willReturn('password');
$this->shareManager $this->shareManager

View File

@ -20,6 +20,7 @@
*/ */
namespace OC\Share20; namespace OC\Share20;
use OCP\Share\IShareProvider;
use OC\Share20\Exception\InvalidShare; use OC\Share20\Exception\InvalidShare;
use OC\Share20\Exception\ProviderException; use OC\Share20\Exception\ProviderException;
use OC\Share20\Exception\ShareNotFound; use OC\Share20\Exception\ShareNotFound;
@ -87,12 +88,12 @@ class DefaultShareProvider implements IShareProvider {
/** /**
* Share a path * Share a path
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @return IShare The share object * @return \OCP\Share\IShare The share object
* @throws ShareNotFound * @throws ShareNotFound
* @throws \Exception * @throws \Exception
*/ */
public function create(IShare $share) { public function create(\OCP\Share\IShare $share) {
$qb = $this->dbConn->getQueryBuilder(); $qb = $this->dbConn->getQueryBuilder();
$qb->insert('share'); $qb->insert('share');
@ -179,10 +180,10 @@ class DefaultShareProvider implements IShareProvider {
/** /**
* Update a share * Update a share
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @return IShare The share object * @return \OCP\Share\IShare The share object
*/ */
public function update(IShare $share) { public function update(\OCP\Share\IShare $share) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
/* /*
* We allow updating the recipient on user shares. * We allow updating the recipient on user shares.
@ -251,10 +252,10 @@ class DefaultShareProvider implements IShareProvider {
/** /**
* Get all children of this share * Get all children of this share
* *
* @param IShare $parent * @param \OCP\Share\IShare $parent
* @return IShare[] * @return IShare[]
*/ */
public function getChildren(IShare $parent) { public function getChildren(\OCP\Share\IShare $parent) {
$children = []; $children = [];
$qb = $this->dbConn->getQueryBuilder(); $qb = $this->dbConn->getQueryBuilder();
@ -286,10 +287,10 @@ class DefaultShareProvider implements IShareProvider {
/** /**
* Delete a share * Delete a share
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @throws BackendError * @throws BackendError
*/ */
public function delete(IShare $share) { public function delete(\OCP\Share\IShare $share) {
// Fetch share to make sure it exists // Fetch share to make sure it exists
$share = $this->getShareById($share->getId()); $share = $this->getShareById($share->getId());
@ -308,12 +309,12 @@ class DefaultShareProvider implements IShareProvider {
* Unshare a share from the recipient. If this is a group share * Unshare a share from the recipient. If this is a group share
* this means we need a special entry in the share db. * this means we need a special entry in the share db.
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @param IUser $recipient * @param IUser $recipient
* @throws BackendError * @throws BackendError
* @throws ProviderException * @throws ProviderException
*/ */
public function deleteFromSelf(IShare $share, IUser $recipient) { public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
/** @var IGroup $group */ /** @var IGroup $group */

View File

@ -20,9 +20,8 @@
*/ */
namespace OC\Share20; namespace OC\Share20;
use OCP\Share\IProviderFactory;
use OC\Share20\Exception\BackendError; use OC\Share20\Exception\BackendError;
use OC\Share20\Exception\ProviderException;
use OCP\IConfig; use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
@ -45,9 +44,6 @@ class Manager {
/** @var IProviderFactory */ /** @var IProviderFactory */
private $factory; private $factory;
/** @var array */
private $type2provider;
/** @var ILogger */ /** @var ILogger */
private $logger; private $logger;
@ -91,9 +87,6 @@ class Manager {
IL10N $l, IL10N $l,
IProviderFactory $factory IProviderFactory $factory
) { ) {
$this->providers = [];
$this->type2provider = [];
$this->logger = $logger; $this->logger = $logger;
$this->config = $config; $this->config = $config;
$this->secureRandom = $secureRandom; $this->secureRandom = $secureRandom;
@ -147,10 +140,10 @@ class Manager {
/** /**
* Check for generic requirements before creating a share * Check for generic requirements before creating a share
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @throws \Exception * @throws \Exception
*/ */
protected function generalCreateChecks(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 (!($share->getSharedWith() instanceof \OCP\IUser)) {
@ -266,10 +259,10 @@ class Manager {
/** /**
* Check for pre share requirements for user shares * Check for pre share requirements for user shares
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @throws \Exception * @throws \Exception
*/ */
protected function userCreateChecks(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()) {
// Verify we can share with this user // Verify we can share with this user
@ -312,10 +305,10 @@ class Manager {
/** /**
* Check for pre share requirements for group shares * Check for pre share requirements for group shares
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @throws \Exception * @throws \Exception
*/ */
protected function groupCreateChecks(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())) { if (!$share->getSharedWith()->inGroup($share->getSharedBy())) {
@ -344,10 +337,10 @@ class Manager {
/** /**
* Check for pre share requirements for link shares * Check for pre share requirements for link shares
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @throws \Exception * @throws \Exception
*/ */
protected function linkCreateChecks(IShare $share) { protected function linkCreateChecks(\OCP\Share\IShare $share) {
// Are link shares allowed? // Are link shares allowed?
if (!$this->shareApiAllowLinks()) { if (!$this->shareApiAllowLinks()) {
throw new \Exception('Link sharing not allowed'); throw new \Exception('Link sharing not allowed');
@ -388,10 +381,10 @@ class Manager {
/** /**
* Check if the user that is sharing can actually share * Check if the user that is sharing can actually share
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @return bool * @return bool
*/ */
protected function canShare(IShare $share) { protected function canShare(\OCP\Share\IShare $share) {
if (!$this->shareApiEnabled()) { if (!$this->shareApiEnabled()) {
return false; return false;
} }
@ -406,13 +399,13 @@ class Manager {
/** /**
* Share a path * Share a path
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @return Share The share object * @return Share The share object
* @throws \Exception * @throws \Exception
* *
* TODO: handle link share permissions or check them * TODO: handle link share permissions or check them
*/ */
public function createShare(IShare $share) { public function createShare(\OCP\Share\IShare $share) {
if (!$this->canShare($share)) { if (!$this->canShare($share)) {
throw new \Exception('The Share API is disabled'); throw new \Exception('The Share API is disabled');
} }
@ -528,10 +521,10 @@ class Manager {
/** /**
* Update a share * Update a share
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @return IShare The share object * @return \OCP\Share\IShare The share object
*/ */
public function updateShare(IShare $share) { public function updateShare(\OCP\Share\IShare $share) {
$expirationDateUpdated = false; $expirationDateUpdated = false;
if (!$this->canShare($share)) { if (!$this->canShare($share)) {
@ -604,10 +597,10 @@ class Manager {
/** /**
* Delete all the children of this share * Delete all the children of this share
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @return IShare[] List of deleted shares * @return \OCP\Share\IShare[] List of deleted shares
*/ */
protected function deleteChildren(IShare $share) { protected function deleteChildren(\OCP\Share\IShare $share) {
$deletedShares = []; $deletedShares = [];
$provider = $this->factory->getProviderForType($share->getShareType()); $provider = $this->factory->getProviderForType($share->getShareType());
@ -626,16 +619,16 @@ class Manager {
/** /**
* Delete a share * Delete a share
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @throws ShareNotFound * @throws ShareNotFound
* @throws BackendError * @throws BackendError
* @throws ShareNotFound * @throws ShareNotFound
*/ */
public function deleteShare(IShare $share) { public function deleteShare(\OCP\Share\IShare $share) {
// Just to make sure we have all the info // Just to make sure we have all the info
$share = $this->getShareById($share->getFullId()); $share = $this->getShareById($share->getFullId());
$formatHookParams = function(IShare $share) { $formatHookParams = function(\OCP\Share\IShare $share) {
// Prepare hook // Prepare hook
$shareType = $share->getShareType(); $shareType = $share->getShareType();
$sharedWith = ''; $sharedWith = '';
@ -694,10 +687,10 @@ class Manager {
* the users in a groups deletes that share. But the provider should * the users in a groups deletes that share. But the provider should
* handle this. * handle this.
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @param IUser $recipient * @param IUser $recipient
*/ */
public function deleteFromSelf(IShare $share, IUser $recipient) { public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient) {
list($providerId, $id) = $this->splitFullId($share->getId()); list($providerId, $id) = $this->splitFullId($share->getId());
$provider = $this->factory->getProvider($providerId); $provider = $this->factory->getProvider($providerId);
@ -713,7 +706,7 @@ class Manager {
* @param bool $reshares * @param bool $reshares
* @param int $limit The maximum number of returned results, -1 for all results * @param int $limit The maximum number of returned results, -1 for all results
* @param int $offset * @param int $offset
* @return IShare[] * @return \OCP\Share\IShare[]
*/ */
public function getSharesBy(IUser $user, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0) { public function getSharesBy(IUser $user, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0) {
if ($path !== null && if ($path !== null &&
@ -734,7 +727,7 @@ class Manager {
* @param int $shareType * @param int $shareType
* @param int $limit The maximum number of shares returned, -1 for all * @param int $limit The maximum number of shares returned, -1 for all
* @param int $offset * @param int $offset
* @return IShare[] * @return \OCP\Share\IShare[]
*/ */
public function getSharedWith(IUser $user, $shareType, $limit = 50, $offset = 0) { public function getSharedWith(IUser $user, $shareType, $limit = 50, $offset = 0) {
$provider = $this->factory->getProviderForType($shareType); $provider = $this->factory->getProviderForType($shareType);
@ -797,11 +790,11 @@ class Manager {
/** /**
* Verify the password of a public share * Verify the password of a public share
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @param string $password * @param string $password
* @return bool * @return bool
*/ */
public function checkPassword(IShare $share, $password) { public function checkPassword(\OCP\Share\IShare $share, $password) {
if ($share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK) { if ($share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK) {
//TODO maybe exception? //TODO maybe exception?
return false; return false;
@ -852,7 +845,7 @@ class Manager {
/** /**
* Create a new share * Create a new share
* @return IShare; * @return \OCP\Share\IShare;
*/ */
public function newShare() { public function newShare() {
return new \OC\Share20\Share(); return new \OC\Share20\Share();

View File

@ -20,6 +20,7 @@
*/ */
namespace OC\Share20; namespace OC\Share20;
use OCP\Share\IProviderFactory;
use OC\Share20\Exception\ProviderException; use OC\Share20\Exception\ProviderException;
use OCP\IServerContainer; use OCP\IServerContainer;

View File

@ -24,7 +24,7 @@ use OCP\Files\Node;
use OCP\IUser; use OCP\IUser;
use OCP\IGroup; use OCP\IGroup;
class Share implements IShare { class Share implements \OCP\Share\IShare {
/** @var string */ /** @var string */
private $id; private $id;

View File

@ -18,7 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */
namespace OC\Share20;
namespace OCP\Share;
use OC\Share20\Exception\ProviderException; use OC\Share20\Exception\ProviderException;
use OCP\IServerContainer; use OCP\IServerContainer;
@ -34,6 +35,7 @@ interface IProviderFactory {
/** /**
* IProviderFactory constructor. * IProviderFactory constructor.
* @param IServerContainer $serverContainer * @param IServerContainer $serverContainer
* @since 9.0.0
*/ */
public function __construct(IServerContainer $serverContainer); public function __construct(IServerContainer $serverContainer);
@ -41,6 +43,7 @@ interface IProviderFactory {
* @param string $id * @param string $id
* @return IShareProvider * @return IShareProvider
* @throws ProviderException * @throws ProviderException
* @since 9.0.0
*/ */
public function getProvider($id); public function getProvider($id);
@ -48,6 +51,7 @@ interface IProviderFactory {
* @param int $shareType * @param int $shareType
* @return IShareProvider * @return IShareProvider
* @throws ProviderException * @throws ProviderException
* @since 9.0.0
*/ */
public function getProviderForType($shareType); public function getProviderForType($shareType);
} }

View File

@ -18,7 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */
namespace OC\Share20;
namespace OCP\Share;
use OCP\Files\File; use OCP\Files\File;
use OCP\Files\Folder; use OCP\Files\Folder;
@ -26,12 +27,19 @@ use OCP\Files\Node;
use OCP\IUser; use OCP\IUser;
use OCP\IGroup; use OCP\IGroup;
/**
* Interface IShare
*
* @package OCP\Share
* @since 9.0.0
*/
interface IShare { interface IShare {
/** /**
* Get the id of the share * Get the id of the share
* *
* @return string * @return string
* @since 9.0.0
*/ */
public function getId(); public function getId();
@ -39,7 +47,8 @@ interface IShare {
* Set the id of the share * Set the id of the share
* *
* @param string $id * @param string $id
* @return IShare The modified share object * @return \OCP\Share\IShare The modified share object
* @since 9.0.0
*/ */
public function setId($id); public function setId($id);
@ -47,6 +56,7 @@ interface IShare {
* Get the full share id * Get the full share id
* *
* @return string * @return string
* @since 9.0.0
*/ */
public function getFullId(); public function getFullId();
@ -54,7 +64,8 @@ interface IShare {
* Set the provider id * Set the provider id
* *
* @param string $id * @param string $id
* @return IShare The modified share object * @return \OCP\Share\IShare The modified share object\
* @since 9.0.0
*/ */
public function setProviderId($id); public function setProviderId($id);
@ -62,14 +73,16 @@ interface IShare {
* Set the path of this share * Set the path of this share
* *
* @param Node $path * @param Node $path
* @return IShare The modified object * @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/ */
public function setPath(Node $path); public function setPath(Node $path);
/** /**
* Get the path of this share for the current user * Get the path of this share for the current user
* *
* @return File|Folder * @return File|Folder
* @since 9.0.0
*/ */
public function getPath(); public function getPath();
@ -77,14 +90,16 @@ interface IShare {
* Set the shareType * Set the shareType
* *
* @param int $shareType * @param int $shareType
* @return IShare The modified object * @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/ */
public function setShareType($shareType); public function setShareType($shareType);
/** /**
* Get the shareType * Get the shareType
* *
* @return int * @return int
* @since 9.0.0
*/ */
public function getShareType(); public function getShareType();
@ -92,7 +107,8 @@ interface IShare {
* Set the receiver of this share * Set the receiver of this share
* *
* @param IUser|IGroup|string * @param IUser|IGroup|string
* @return IShare The modified object * @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/ */
public function setSharedWith($sharedWith); public function setSharedWith($sharedWith);
@ -100,6 +116,7 @@ interface IShare {
* Get the receiver of this share * Get the receiver of this share
* *
* @return IUser|IGroup|string * @return IUser|IGroup|string
* @since 9.0.0
*/ */
public function getSharedWith(); public function getSharedWith();
@ -107,7 +124,8 @@ interface IShare {
* Set the permissions * Set the permissions
* *
* @param int $permissions * @param int $permissions
* @return IShare The modified object * @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/ */
public function setPermissions($permissions); public function setPermissions($permissions);
@ -115,6 +133,7 @@ interface IShare {
* Get the share permissions * Get the share permissions
* *
* @return int * @return int
* @since 9.0.0
*/ */
public function getPermissions(); public function getPermissions();
@ -122,7 +141,8 @@ interface IShare {
* Set the expiration date * Set the expiration date
* *
* @param \DateTime $expireDate * @param \DateTime $expireDate
* @return IShare The modified object * @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/ */
public function setExpirationDate($expireDate); public function setExpirationDate($expireDate);
@ -130,6 +150,7 @@ interface IShare {
* Get the share expiration date * Get the share expiration date
* *
* @return \DateTime * @return \DateTime
* @since 9.0.0
*/ */
public function getExpirationDate(); public function getExpirationDate();
@ -137,7 +158,8 @@ interface IShare {
* Set the sharer of the path * Set the sharer of the path
* *
* @param IUser|string $sharedBy * @param IUser|string $sharedBy
* @return IShare The modified object * @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/ */
public function setSharedBy($sharedBy); public function setSharedBy($sharedBy);
@ -145,6 +167,7 @@ interface IShare {
* Get share sharer * Get share sharer
* *
* @return IUser|string * @return IUser|string
* @since 9.0.0
*/ */
public function getSharedBy(); public function getSharedBy();
@ -152,15 +175,16 @@ interface IShare {
* Set the original share owner (who owns the path) * Set the original share owner (who owns the path)
* *
* @param IUser|string * @param IUser|string
* * @return \OCP\Share\IShare The modified object
* @return IShare The modified object * @since 9.0.0
*/ */
public function setShareOwner($shareOwner); public function setShareOwner($shareOwner);
/** /**
* Get the original share owner (who owns the path) * Get the original share owner (who owns the path)
* *
* @return IUser|string * @return IUser|string
* @since 9.0.0
*/ */
public function getShareOwner(); public function getShareOwner();
@ -168,8 +192,8 @@ interface IShare {
* Set the password * Set the password
* *
* @param string $password * @param string $password
* * @return \OCP\Share\IShare The modified object
* @return IShare The modified object * @since 9.0.0
*/ */
public function setPassword($password); public function setPassword($password);
@ -177,6 +201,7 @@ interface IShare {
* Is a password set for this share * Is a password set for this share
* *
* @return string * @return string
* @since 9.0.0
*/ */
public function getPassword(); public function getPassword();
@ -184,7 +209,8 @@ interface IShare {
* Set the token * Set the token
* *
* @param string $token * @param string $token
* @return IShare The modified object * @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/ */
public function setToken($token); public function setToken($token);
@ -192,6 +218,7 @@ interface IShare {
* Get the token * Get the token
* *
* @return string * @return string
* @since 9.0.0
*/ */
public function getToken(); public function getToken();
@ -199,6 +226,7 @@ interface IShare {
* Get the parent it * Get the parent it
* *
* @return int * @return int
* @since 9.0.0
*/ */
public function getParent(); public function getParent();
@ -206,7 +234,8 @@ interface IShare {
* Set the target of this share * Set the target of this share
* *
* @param string $target * @param string $target
* @return IShare The modified object * @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/ */
public function setTarget($target); public function setTarget($target);
@ -214,6 +243,7 @@ interface IShare {
* Get the target of this share * Get the target of this share
* *
* @return string * @return string
* @since 9.0.0
*/ */
public function getTarget(); public function getTarget();
@ -221,7 +251,8 @@ interface IShare {
* Set the time this share was created * Set the time this share was created
* *
* @param int $shareTime * @param int $shareTime
* @return IShare The modified object * @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/ */
public function setShareTime($shareTime); public function setShareTime($shareTime);
@ -229,6 +260,7 @@ interface IShare {
* Get the timestamp this share was created * Get the timestamp this share was created
* *
* @return int * @return int
* @since 9.0.0
*/ */
public function getShareTime(); public function getShareTime();
@ -236,7 +268,8 @@ interface IShare {
* Set mailSend * Set mailSend
* *
* @param bool $mailSend * @param bool $mailSend
* @return IShare The modified object * @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/ */
public function setMailSend($mailSend); public function setMailSend($mailSend);
@ -244,6 +277,7 @@ interface IShare {
* Get mailSend * Get mailSend
* *
* @return bool * @return bool
* @since 9.0.0
*/ */
public function getMailSend(); public function getMailSend();
} }

View File

@ -18,53 +18,64 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */
namespace OC\Share20;
namespace OCP\Share;
use OC\Share20\Exception\ShareNotFound; use OC\Share20\Exception\ShareNotFound;
use OC\Share20\Exception\BackendError; use OC\Share20\Exception\BackendError;
use OCP\IUser; use OCP\IUser;
/**
* Interface IShareProvider
*
* @package OCP\Share
* @since 9.0.0
*/
interface IShareProvider { interface IShareProvider {
/** /**
* Return the identifier of this provider. * Return the identifier of this provider.
* *
* @return string Containing only [a-zA-Z0-9] * @return string Containing only [a-zA-Z0-9]
* @since 9.0.0
*/ */
public function identifier(); public function identifier();
/** /**
* Share a path * Share a path
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @return IShare The share object * @return \OCP\Share\IShare The share object
* @since 9.0.0
*/ */
public function create(IShare $share); public function create(\OCP\Share\IShare $share);
/** /**
* Update a share * Update a share
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @return IShare The share object * @return \OCP\Share\IShare The share object
* @since 9.0.0
*/ */
public function update(IShare $share); public function update(\OCP\Share\IShare $share);
/** /**
* Delete a share * Delete a share
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @throws BackendError * @since 9.0.0
*/ */
public function delete(IShare $share); public function delete(\OCP\Share\IShare $share);
/** /**
* Unshare a file from self as recipient. * Unshare a file from self as recipient.
* This may require special handling. * This may require special handling.
* *
* @param IShare $share * @param \OCP\Share\IShare $share
* @param IUser $recipient * @param IUser $recipient
* @since 9.0.0
*/ */
public function deleteFromSelf(IShare $share, IUser $recipient); public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient);
/** /**
* Get all shares by the given user * Get all shares by the given user
@ -76,6 +87,7 @@ interface IShareProvider {
* @param int $limit The maximum number of shares to be returned, -1 for all shares * @param int $limit The maximum number of shares to be returned, -1 for all shares
* @param int $offset * @param int $offset
* @return Share[] * @return Share[]
* @since 9.0.0
*/ */
public function getSharesBy(IUser $user, $shareType, $node, $reshares, $limit, $offset); public function getSharesBy(IUser $user, $shareType, $node, $reshares, $limit, $offset);
@ -85,22 +97,16 @@ interface IShareProvider {
* @param int $id * @param int $id
* @return IShare * @return IShare
* @throws ShareNotFound * @throws ShareNotFound
* @since 9.0.0
*/ */
public function getShareById($id); public function getShareById($id);
/**
* Get children
*
* @param IShare $parent
* @return IShare[]
*/
public function getChildren(IShare $parent);
/** /**
* Get shares for a given path * Get shares for a given path
* *
* @param \OCP\Files\Node $path * @param \OCP\Files\Node $path
* @return IShare[] * @return IShare[]
* @since 9.0.0
*/ */
public function getSharesByPath(\OCP\Files\Node $path); public function getSharesByPath(\OCP\Files\Node $path);
@ -112,6 +118,7 @@ interface IShareProvider {
* @param int $limit The max number of entries returned, -1 for all * @param int $limit The max number of entries returned, -1 for all
* @param int $offset * @param int $offset
* @param Share * @param Share
* @since 9.0.0
*/ */
public function getSharedWith(IUser $user, $shareType, $limit, $offset); public function getSharedWith(IUser $user, $shareType, $limit, $offset);
@ -121,6 +128,7 @@ interface IShareProvider {
* @param string $token * @param string $token
* @return IShare * @return IShare
* @throws ShareNotFound * @throws ShareNotFound
* @since 9.0.0
*/ */
public function getShareByToken($token); public function getShareByToken($token);
} }

View File

@ -326,7 +326,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $qb->getLastInsertId(); $id = $qb->getLastInsertId();
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share->method('getId')->willReturn($id); $share->method('getId')->willReturn($id);
$provider = $this->getMockBuilder('OC\Share20\DefaultShareProvider') $provider = $this->getMockBuilder('OC\Share20\DefaultShareProvider')
@ -361,7 +361,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
* @expectedException \OC\Share20\Exception\BackendError * @expectedException \OC\Share20\Exception\BackendError
*/ */
public function testDeleteFails() { public function testDeleteFails() {
$share = $this->getMock('OC\Share20\IShare'); $share = $this->getMock('OCP\Share\IShare');
$share $share
->method('getId') ->method('getId')
->willReturn(42); ->willReturn(42);
@ -510,7 +510,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
['group1', $group1] ['group1', $group1]
])); ]));
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getId')->willReturn($id); $share->method('getId')->willReturn($id);
$children = $this->provider->getChildren($share); $children = $this->provider->getChildren($share);

View File

@ -20,8 +20,8 @@
*/ */
namespace Test\Share20; namespace Test\Share20;
use OC\Share20\IProviderFactory; use OCP\Share\IProviderFactory;
use OC\Share20\IShare; use OCP\Share\IShare;
use OC\Share20\Manager; use OC\Share20\Manager;
use OC\Share20\Exception; use OC\Share20\Exception;
@ -29,7 +29,7 @@ use OC\Share20\Share;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\IConfig; use OCP\IConfig;
use OC\Share20\IShareProvider; use OCP\Share\IShareProvider;
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;
use OCP\Security\IHasher; use OCP\Security\IHasher;
use OCP\Files\Mount\IMountManager; use OCP\Files\Mount\IMountManager;
@ -102,7 +102,9 @@ class ManagerTest extends \Test\TestCase {
$this->factory $this->factory
); );
$this->defaultProvider = $this->getMock('\OC\Share20\IShareProvider'); $this->defaultProvider = $this->getMockBuilder('\OC\Share20\DefaultShareProvider')
->disableOriginalConstructor()
->getMock();
$this->defaultProvider->method('identifier')->willReturn('default'); $this->defaultProvider->method('identifier')->willReturn('default');
$this->factory->setProvider($this->defaultProvider); $this->factory->setProvider($this->defaultProvider);
@ -130,7 +132,7 @@ class ManagerTest extends \Test\TestCase {
* @expectedException \OC\Share20\Exception\ShareNotFound * @expectedException \OC\Share20\Exception\ShareNotFound
*/ */
public function testDeleteNoShareId() { public function testDeleteNoShareId() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share $share
->expects($this->once()) ->expects($this->once())
@ -170,7 +172,7 @@ class ManagerTest extends \Test\TestCase {
$path = $this->getMock('\OCP\Files\File'); $path = $this->getMock('\OCP\Files\File');
$path->method('getId')->willReturn(1); $path->method('getId')->willReturn(1);
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getId')->willReturn(42); $share->method('getId')->willReturn(42);
$share->method('getFullId')->willReturn('prov:42'); $share->method('getFullId')->willReturn('prov:42');
$share->method('getShareType')->willReturn($shareType); $share->method('getShareType')->willReturn($shareType);
@ -261,7 +263,7 @@ class ManagerTest extends \Test\TestCase {
$path = $this->getMock('\OCP\Files\File'); $path = $this->getMock('\OCP\Files\File');
$path->method('getId')->willReturn(1); $path->method('getId')->willReturn(1);
$share1 = $this->getMock('\OC\Share20\IShare'); $share1 = $this->getMock('\OCP\Share\IShare');
$share1->method('getId')->willReturn(42); $share1->method('getId')->willReturn(42);
$share1->method('getFullId')->willReturn('prov:42'); $share1->method('getFullId')->willReturn('prov:42');
$share1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $share1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
@ -270,7 +272,7 @@ class ManagerTest extends \Test\TestCase {
$share1->method('getPath')->willReturn($path); $share1->method('getPath')->willReturn($path);
$share1->method('getTarget')->willReturn('myTarget1'); $share1->method('getTarget')->willReturn('myTarget1');
$share2 = $this->getMock('\OC\Share20\IShare'); $share2 = $this->getMock('\OCP\Share\IShare');
$share2->method('getId')->willReturn(43); $share2->method('getId')->willReturn(43);
$share2->method('getFullId')->willReturn('prov:43'); $share2->method('getFullId')->willReturn('prov:43');
$share2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); $share2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
@ -280,7 +282,7 @@ class ManagerTest extends \Test\TestCase {
$share2->method('getTarget')->willReturn('myTarget2'); $share2->method('getTarget')->willReturn('myTarget2');
$share2->method('getParent')->willReturn(42); $share2->method('getParent')->willReturn(42);
$share3 = $this->getMock('\OC\Share20\IShare'); $share3 = $this->getMock('\OCP\Share\IShare');
$share3->method('getId')->willReturn(44); $share3->method('getId')->willReturn(44);
$share3->method('getFullId')->willReturn('prov:44'); $share3->method('getFullId')->willReturn('prov:44');
$share3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); $share3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
@ -383,14 +385,14 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['deleteShare']) ->setMethods(['deleteShare'])
->getMock(); ->getMock();
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$child1 = $this->getMock('\OC\Share20\IShare'); $child1 = $this->getMock('\OCP\Share\IShare');
$child1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $child1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$child2 = $this->getMock('\OC\Share20\IShare'); $child2 = $this->getMock('\OCP\Share\IShare');
$child2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $child2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$child3 = $this->getMock('\OC\Share20\IShare'); $child3 = $this->getMock('\OCP\Share\IShare');
$child3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $child3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$shares = [ $shares = [
@ -419,7 +421,7 @@ class ManagerTest extends \Test\TestCase {
} }
public function testGetShareById() { public function testGetShareById() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$this->defaultProvider $this->defaultProvider
->expects($this->once()) ->expects($this->once())
@ -487,7 +489,7 @@ class ManagerTest extends \Test\TestCase {
public function createShare($id, $type, $path, $sharedWith, $sharedBy, $shareOwner, public function createShare($id, $type, $path, $sharedWith, $sharedBy, $shareOwner,
$permissions, $expireDate = null, $password = null) { $permissions, $expireDate = null, $password = null) {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getShareType')->willReturn($type); $share->method('getShareType')->willReturn($type);
$share->method('getSharedWith')->willReturn($sharedWith); $share->method('getSharedWith')->willReturn($sharedWith);
@ -1487,7 +1489,7 @@ class ManagerTest extends \Test\TestCase {
} }
public function testGetShareByToken() { public function testGetShareByToken() {
$factory = $this->getMock('\OC\Share20\IProviderFactory'); $factory = $this->getMock('\OCP\Share\IProviderFactory');
$manager = new Manager( $manager = new Manager(
$this->logger, $this->logger,
@ -1500,7 +1502,7 @@ class ManagerTest extends \Test\TestCase {
$factory $factory
); );
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$factory->expects($this->once()) $factory->expects($this->once())
->method('getProviderForType') ->method('getProviderForType')
@ -1517,13 +1519,13 @@ class ManagerTest extends \Test\TestCase {
} }
public function testCheckPasswordNoLinkShare() { public function testCheckPasswordNoLinkShare() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$this->assertFalse($this->manager->checkPassword($share, 'password')); $this->assertFalse($this->manager->checkPassword($share, 'password'));
} }
public function testCheckPasswordNoPassword() { public function testCheckPasswordNoPassword() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$this->assertFalse($this->manager->checkPassword($share, 'password')); $this->assertFalse($this->manager->checkPassword($share, 'password'));
@ -1532,7 +1534,7 @@ class ManagerTest extends \Test\TestCase {
} }
public function testCheckPasswordInvalidPassword() { public function testCheckPasswordInvalidPassword() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getPassword')->willReturn('password'); $share->method('getPassword')->willReturn('password');
@ -1542,7 +1544,7 @@ class ManagerTest extends \Test\TestCase {
} }
public function testCheckPasswordValidPassword() { public function testCheckPasswordValidPassword() {
$share = $this->getMock('\OC\Share20\IShare'); $share = $this->getMock('\OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getPassword')->willReturn('passwordHash'); $share->method('getPassword')->willReturn('passwordHash');