summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-02-09 14:54:32 +0100
committerGitHub <noreply@github.com>2017-02-09 14:54:32 +0100
commitbf88060a98ce397768d4afa7935b80751e4533f8 (patch)
tree6baaf10832fa68999eea01ab3df5241fdd3ece0a /apps/federatedfilesharing
parent4a5a3681d921adad8c4cb5bb29180514446ea2b9 (diff)
parent0d8d658b7e3885d92103a6e6248b37863f9acf1b (diff)
downloadnextcloud-server-bf88060a98ce397768d4afa7935b80751e4533f8.tar.gz
nextcloud-server-bf88060a98ce397768d4afa7935b80751e4533f8.zip
Merge pull request #3297 from nextcloud/cloud-id-resolve
Add a single public api for resolving a cloud id to a user and remote and back
Diffstat (limited to 'apps/federatedfilesharing')
-rw-r--r--apps/federatedfilesharing/lib/AddressHandler.php73
-rw-r--r--apps/federatedfilesharing/lib/AppInfo/Application.php12
-rw-r--r--apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php3
-rw-r--r--apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php13
-rw-r--r--apps/federatedfilesharing/lib/Controller/RequestHandlerController.php13
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php26
-rw-r--r--apps/federatedfilesharing/lib/Notifier.php28
-rw-r--r--apps/federatedfilesharing/tests/AddressHandlerTest.php30
-rw-r--r--apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php9
-rw-r--r--apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php13
-rw-r--r--apps/federatedfilesharing/tests/FederatedShareProviderTest.php13
11 files changed, 115 insertions, 118 deletions
diff --git a/apps/federatedfilesharing/lib/AddressHandler.php b/apps/federatedfilesharing/lib/AddressHandler.php
index 5fc41c2c804..6c59df06863 100644
--- a/apps/federatedfilesharing/lib/AddressHandler.php
+++ b/apps/federatedfilesharing/lib/AddressHandler.php
@@ -22,6 +22,7 @@
namespace OCA\FederatedFileSharing;
use OC\HintException;
+use OCP\Federation\ICloudIdManager;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -38,18 +39,24 @@ class AddressHandler {
/** @var IURLGenerator */
private $urlGenerator;
+ /** @var ICloudIdManager */
+ private $cloudIdManager;
+
/**
* AddressHandler constructor.
*
* @param IURLGenerator $urlGenerator
* @param IL10N $il10n
+ * @param ICloudIdManager $cloudIdManager
*/
public function __construct(
IURLGenerator $urlGenerator,
- IL10N $il10n
+ IL10N $il10n,
+ ICloudIdManager $cloudIdManager
) {
$this->l = $il10n;
$this->urlGenerator = $urlGenerator;
+ $this->cloudIdManager = $cloudIdManager;
}
/**
@@ -60,44 +67,13 @@ class AddressHandler {
* @throws HintException
*/
public function splitUserRemote($address) {
- if (strpos($address, '@') === false) {
+ try {
+ $cloudId = $this->cloudIdManager->resolveCloudId($address);
+ return [$cloudId->getUser(), $cloudId->getRemote()];
+ } catch (\InvalidArgumentException $e) {
$hint = $this->l->t('Invalid Federated Cloud ID');
- throw new HintException('Invalid Federated Cloud ID', $hint);
- }
-
- // Find the first character that is not allowed in user names
- $id = str_replace('\\', '/', $address);
- $posSlash = strpos($id, '/');
- $posColon = strpos($id, ':');
-
- if ($posSlash === false && $posColon === false) {
- $invalidPos = strlen($id);
- } else if ($posSlash === false) {
- $invalidPos = $posColon;
- } else if ($posColon === false) {
- $invalidPos = $posSlash;
- } else {
- $invalidPos = min($posSlash, $posColon);
- }
-
- // Find the last @ before $invalidPos
- $pos = $lastAtPos = 0;
- while ($lastAtPos !== false && $lastAtPos <= $invalidPos) {
- $pos = $lastAtPos;
- $lastAtPos = strpos($id, '@', $pos + 1);
+ throw new HintException('Invalid Federated Cloud ID', $hint, 0, $e);
}
-
- if ($pos !== false) {
- $user = substr($id, 0, $pos);
- $remote = substr($id, $pos + 1);
- $remote = $this->fixRemoteURL($remote);
- if (!empty($user) && !empty($remote)) {
- return array($user, $remote);
- }
- }
-
- $hint = $this->l->t('Invalid Federated Cloud ID');
- throw new HintException('Invalid Federated Cloud ID', $hint);
}
/**
@@ -175,27 +151,4 @@ class AddressHandler {
return false;
}
-
- /**
- * Strips away a potential file names and trailing slashes:
- * - http://localhost
- * - http://localhost/
- * - http://localhost/index.php
- * - http://localhost/index.php/s/{shareToken}
- *
- * all return: http://localhost
- *
- * @param string $remote
- * @return string
- */
- protected function fixRemoteURL($remote) {
- $remote = str_replace('\\', '/', $remote);
- if ($fileNamePosition = strpos($remote, '/index.php')) {
- $remote = substr($remote, 0, $fileNamePosition);
- }
- $remote = rtrim($remote, '/');
-
- return $remote;
- }
-
}
diff --git a/apps/federatedfilesharing/lib/AppInfo/Application.php b/apps/federatedfilesharing/lib/AppInfo/Application.php
index c37cb9b87bb..3e97edeada0 100644
--- a/apps/federatedfilesharing/lib/AppInfo/Application.php
+++ b/apps/federatedfilesharing/lib/AppInfo/Application.php
@@ -45,7 +45,8 @@ class Application extends App {
$container->registerService('RequestHandlerController', function(SimpleContainer $c) use ($server) {
$addressHandler = new AddressHandler(
$server->getURLGenerator(),
- $server->getL10N('federatedfilesharing')
+ $server->getL10N('federatedfilesharing'),
+ $server->getCloudIdManager()
);
$notification = new Notifications(
$addressHandler,
@@ -64,7 +65,8 @@ class Application extends App {
$server->getShareManager(),
$notification,
$addressHandler,
- $server->getUserManager()
+ $server->getUserManager(),
+ $server->getCloudIdManager()
);
});
}
@@ -94,7 +96,8 @@ class Application extends App {
protected function initFederatedShareProvider() {
$addressHandler = new \OCA\FederatedFileSharing\AddressHandler(
\OC::$server->getURLGenerator(),
- \OC::$server->getL10N('federatedfilesharing')
+ \OC::$server->getL10N('federatedfilesharing'),
+ \OC::$server->getCloudIdManager()
);
$discoveryManager = new \OCA\FederatedFileSharing\DiscoveryManager(
\OC::$server->getMemCacheFactory(),
@@ -119,7 +122,8 @@ class Application extends App {
\OC::$server->getLogger(),
\OC::$server->getLazyRootFolder(),
\OC::$server->getConfig(),
- \OC::$server->getUserManager()
+ \OC::$server->getUserManager(),
+ \OC::$server->getCloudIdManager()
);
}
diff --git a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
index 26afcae32b7..2356c569d87 100644
--- a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
+++ b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
@@ -65,7 +65,8 @@ class RetryJob extends Job {
} else {
$addressHandler = new AddressHandler(
\OC::$server->getURLGenerator(),
- \OC::$server->getL10N('federatedfilesharing')
+ \OC::$server->getL10N('federatedfilesharing'),
+ \OC::$server->getCloudIdManager()
);
$discoveryManager = new DiscoveryManager(
\OC::$server->getMemCacheFactory(),
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
index 3c399268124..dd2e88d2dae 100644
--- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
+++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
@@ -35,6 +35,7 @@ use OCA\Files_Sharing\External\Manager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\Federation\ICloudIdManager;
use OCP\Files\StorageInvalidException;
use OCP\Http\Client\IClientService;
use OCP\IL10N;
@@ -74,6 +75,9 @@ class MountPublicLinkController extends Controller {
/** @var IClientService */
private $clientService;
+ /** @var ICloudIdManager */
+ private $cloudIdManager;
+
/**
* MountPublicLinkController constructor.
*
@@ -86,6 +90,7 @@ class MountPublicLinkController extends Controller {
* @param IL10N $l
* @param IUserSession $userSession
* @param IClientService $clientService
+ * @param ICloudIdManager $cloudIdManager
*/
public function __construct($appName,
IRequest $request,
@@ -95,7 +100,8 @@ class MountPublicLinkController extends Controller {
ISession $session,
IL10N $l,
IUserSession $userSession,
- IClientService $clientService
+ IClientService $clientService,
+ ICloudIdManager $cloudIdManager
) {
parent::__construct($appName, $request);
@@ -106,6 +112,7 @@ class MountPublicLinkController extends Controller {
$this->l = $l;
$this->userSession = $userSession;
$this->clientService = $clientService;
+ $this->cloudIdManager = $cloudIdManager;
}
/**
@@ -177,7 +184,7 @@ class MountPublicLinkController extends Controller {
return new JSONResponse(['message' => $this->l->t('Server to server sharing is not enabled on this server')], Http::STATUS_BAD_REQUEST);
}
- $shareWith = $this->userSession->getUser()->getUID() . '@' . $this->addressHandler->generateRemoteURL();
+ $cloudId = $this->cloudIdManager->getCloudId($this->userSession->getUser()->getUID(), $this->addressHandler->generateRemoteURL());
$httpClient = $this->clientService->newClient();
@@ -187,7 +194,7 @@ class MountPublicLinkController extends Controller {
'body' =>
[
'token' => $token,
- 'shareWith' => rtrim($shareWith, '/'),
+ 'shareWith' => rtrim($cloudId->getId(), '/'),
'password' => $password
],
'connect_timeout' => 10,
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
index 750415077a8..a5e75e145c8 100644
--- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
+++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
@@ -38,6 +38,7 @@ use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\Constants;
+use OCP\Federation\ICloudIdManager;
use OCP\Files\NotFoundException;
use OCP\IDBConnection;
use OCP\IRequest;
@@ -68,6 +69,9 @@ class RequestHandlerController extends OCSController {
/** @var string */
private $shareTable = 'share';
+ /** @var ICloudIdManager */
+ private $cloudIdManager;
+
/**
* Server2Server constructor.
*
@@ -79,6 +83,7 @@ class RequestHandlerController extends OCSController {
* @param Notifications $notifications
* @param AddressHandler $addressHandler
* @param IUserManager $userManager
+ * @param ICloudIdManager $cloudIdManager
*/
public function __construct($appName,
IRequest $request,
@@ -87,7 +92,8 @@ class RequestHandlerController extends OCSController {
Share\IManager $shareManager,
Notifications $notifications,
AddressHandler $addressHandler,
- IUserManager $userManager
+ IUserManager $userManager,
+ ICloudIdManager $cloudIdManager
) {
parent::__construct($appName, $request);
@@ -97,6 +103,7 @@ class RequestHandlerController extends OCSController {
$this->notifications = $notifications;
$this->addressHandler = $addressHandler;
$this->userManager = $userManager;
+ $this->cloudIdManager = $cloudIdManager;
}
/**
@@ -164,7 +171,7 @@ class RequestHandlerController extends OCSController {
$shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external');
if ($ownerFederatedId === null) {
- $ownerFederatedId = $owner . '@' . $this->cleanupRemote($remote);
+ $ownerFederatedId = $this->cloudIdManager->getCloudId($owner, $this->cleanupRemote($remote))->getId();
}
// if the owner of the share and the initiator are the same user
// we also complete the federated share ID for the initiator
@@ -424,7 +431,7 @@ class RequestHandlerController extends OCSController {
$remote = $this->cleanupRemote($share['remote']);
- $owner = $share['owner'] . '@' . $remote;
+ $owner = $this->cloudIdManager->getCloudId($share['owner'], $remote);
$mountpoint = $share['mountpoint'];
$user = $share['user'];
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index 61f1b1c8f18..fb49978b7af 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -27,6 +27,7 @@
namespace OCA\FederatedFileSharing;
use OC\Share20\Share;
+use OCP\Federation\ICloudIdManager;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\IConfig;
@@ -80,6 +81,9 @@ class FederatedShareProvider implements IShareProvider {
/** @var IUserManager */
private $userManager;
+ /** @var ICloudIdManager */
+ private $cloudIdManager;
+
/**
* DefaultShareProvider constructor.
*
@@ -92,6 +96,7 @@ class FederatedShareProvider implements IShareProvider {
* @param IRootFolder $rootFolder
* @param IConfig $config
* @param IUserManager $userManager
+ * @param ICloudIdManager $cloudIdManager
*/
public function __construct(
IDBConnection $connection,
@@ -102,7 +107,8 @@ class FederatedShareProvider implements IShareProvider {
ILogger $logger,
IRootFolder $rootFolder,
IConfig $config,
- IUserManager $userManager
+ IUserManager $userManager,
+ ICloudIdManager $cloudIdManager
) {
$this->dbConnection = $connection;
$this->addressHandler = $addressHandler;
@@ -113,6 +119,7 @@ class FederatedShareProvider implements IShareProvider {
$this->rootFolder = $rootFolder;
$this->config = $config;
$this->userManager = $userManager;
+ $this->cloudIdManager = $cloudIdManager;
}
/**
@@ -153,17 +160,18 @@ class FederatedShareProvider implements IShareProvider {
// don't allow federated shares if source and target server are the same
- list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
+ $cloudId = $this->cloudIdManager->resolveCloudId($shareWith);
$currentServer = $this->addressHandler->generateRemoteURL();
$currentUser = $sharedBy;
- if ($this->addressHandler->compareAddresses($user, $remote, $currentUser, $currentServer)) {
+ if ($this->addressHandler->compareAddresses($cloudId->getUser(), $cloudId->getRemote(), $currentUser, $currentServer)) {
$message = 'Not allowed to create a federated share with the same user.';
$message_t = $this->l->t('Not allowed to create a federated share with the same user');
$this->logger->debug($message, ['app' => 'Federated File Sharing']);
throw new \Exception($message_t);
}
- $share->setSharedWith($user . '@' . $remote);
+
+ $share->setSharedWith($cloudId->getId());
try {
$remoteShare = $this->getShareFromExternalShareTable($share);
@@ -173,8 +181,8 @@ class FederatedShareProvider implements IShareProvider {
if ($remoteShare) {
try {
- $uidOwner = $remoteShare['owner'] . '@' . $remoteShare['remote'];
- $shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, 'tmp_token_' . time());
+ $ownerCloudId = $this->cloudIdManager->getCloudId($remoteShare['owner'], $remoteShare['remote']);
+ $shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time());
$share->setId($shareId);
list($token, $remoteId) = $this->askOwnerToReShare($shareWith, $share, $shareId);
// remote share was create successfully if we get a valid token as return
@@ -227,15 +235,17 @@ class FederatedShareProvider implements IShareProvider {
try {
$sharedByFederatedId = $share->getSharedBy();
if ($this->userManager->userExists($sharedByFederatedId)) {
- $sharedByFederatedId = $sharedByFederatedId . '@' . $this->addressHandler->generateRemoteURL();
+ $cloudId = $this->cloudIdManager->getCloudId($sharedByFederatedId, $this->addressHandler->generateRemoteURL());
+ $sharedByFederatedId = $cloudId->getId();
}
+ $ownerCloudId = $this->cloudIdManager->getCloudId($share->getShareOwner(), $this->addressHandler->generateRemoteURL());
$send = $this->notifications->sendRemoteShare(
$token,
$share->getSharedWith(),
$share->getNode()->getName(),
$shareId,
$share->getShareOwner(),
- $share->getShareOwner() . '@' . $this->addressHandler->generateRemoteURL(),
+ $ownerCloudId->getId(),
$share->getSharedBy(),
$sharedByFederatedId
);
diff --git a/apps/federatedfilesharing/lib/Notifier.php b/apps/federatedfilesharing/lib/Notifier.php
index 507dd98330e..faf79480b7e 100644
--- a/apps/federatedfilesharing/lib/Notifier.php
+++ b/apps/federatedfilesharing/lib/Notifier.php
@@ -27,6 +27,8 @@ namespace OCA\FederatedFileSharing;
use OC\HintException;
use OC\Share\Helper;
use OCP\Contacts\IManager;
+use OCP\Federation\ICloudId;
+use OCP\Federation\ICloudIdManager;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Notification\INotification;
@@ -41,16 +43,20 @@ class Notifier implements INotifier {
protected $url;
/** @var array */
protected $federatedContacts;
+ /** @var ICloudIdManager */
+ protected $cloudIdManager;
/**
* @param IFactory $factory
* @param IManager $contactsManager
* @param IURLGenerator $url
+ * @param ICloudIdManager $cloudIdManager
*/
- public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url) {
+ public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) {
$this->factory = $factory;
$this->contactsManager = $contactsManager;
$this->url = $url;
+ $this->cloudIdManager = $cloudIdManager;
}
/**
@@ -140,8 +146,10 @@ class Notifier implements INotifier {
protected function createRemoteUser($cloudId) {
$displayName = $cloudId;
try {
- list($user, $server) = Helper::splitUserRemote($cloudId);
- $displayName = $this->getDisplayName($user, $server);
+ $resolvedId = $this->cloudIdManager->resolveCloudId($cloudId);
+ $displayName = $this->getDisplayName($resolvedId);
+ $user = $resolvedId->getUser();
+ $server = $resolvedId->getRemote();
} catch (HintException $e) {
$user = $cloudId;
$server = '';
@@ -158,14 +166,12 @@ class Notifier implements INotifier {
/**
* Try to find the user in the contacts
*
- * @param string $user
- * @param string $server
+ * @param ICloudId $cloudId
* @return string
- * @throws \OutOfBoundsException when there is no contact for the id
*/
- protected function getDisplayName($user, $server) {
- $server = strtolower(rtrim($server, '/'));
-
+ protected function getDisplayName(ICloudId $cloudId) {
+ $server = $cloudId->getRemote();
+ $user = $cloudId->getUser();
if (strpos($server, 'http://') === 0) {
$server = substr($server, strlen('http://'));
} else if (strpos($server, 'https://') === 0) {
@@ -173,7 +179,7 @@ class Notifier implements INotifier {
}
try {
- return $this->getDisplayNameFromContact($user . '@' . $server);
+ return $this->getDisplayNameFromContact($cloudId->getId());
} catch (\OutOfBoundsException $e) {
}
@@ -187,7 +193,7 @@ class Notifier implements INotifier {
} catch (\OutOfBoundsException $e) {
}
- return $user . '@' . $server;
+ return $cloudId->getId();
}
/**
diff --git a/apps/federatedfilesharing/tests/AddressHandlerTest.php b/apps/federatedfilesharing/tests/AddressHandlerTest.php
index f62f3b62e03..6d215d40156 100644
--- a/apps/federatedfilesharing/tests/AddressHandlerTest.php
+++ b/apps/federatedfilesharing/tests/AddressHandlerTest.php
@@ -25,6 +25,7 @@
namespace OCA\FederatedFileSharing\Tests;
+use OC\Federation\CloudIdManager;
use OCA\FederatedFileSharing\AddressHandler;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -40,6 +41,9 @@ class AddressHandlerTest extends \Test\TestCase {
/** @var IL10N | \PHPUnit_Framework_MockObject_MockObject */
private $il10n;
+ /** @var CloudIdManager */
+ private $cloudIdManager;
+
public function setUp() {
parent::setUp();
@@ -48,7 +52,9 @@ class AddressHandlerTest extends \Test\TestCase {
$this->il10n = $this->getMockBuilder('OCP\IL10N')
->getMock();
- $this->addressHandler = new AddressHandler($this->urlGenerator, $this->il10n);
+ $this->cloudIdManager = new CloudIdManager();
+
+ $this->addressHandler = new AddressHandler($this->urlGenerator, $this->il10n, $this->cloudIdManager);
}
public function dataTestSplitUserRemote() {
@@ -196,26 +202,4 @@ class AddressHandlerTest extends \Test\TestCase {
['httpserver.com', false],
];
}
-
- /**
- * @dataProvider dataTestFixRemoteUrl
- *
- * @param string $url
- * @param string $expected
- */
- public function testFixRemoteUrl($url, $expected) {
- $this->assertSame($expected,
- $this->invokePrivate($this->addressHandler, 'fixRemoteURL', [$url])
- );
- }
-
- public function dataTestFixRemoteUrl() {
- return [
- ['http://localhost', 'http://localhost'],
- ['http://localhost/', 'http://localhost'],
- ['http://localhost/index.php', 'http://localhost'],
- ['http://localhost/index.php/s/AShareToken', 'http://localhost'],
- ];
- }
-
}
diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
index bd091bed410..7714ff4731c 100644
--- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
+++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
@@ -25,11 +25,13 @@
namespace OCA\FederatedFileSharing\Tests\Controller;
+use OC\Federation\CloudIdManager;
use OC\HintException;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\Controller\MountPublicLinkController;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\AppFramework\Http;
+use OCP\Federation\ICloudIdManager;
use OCP\Files\IRootFolder;
use OCP\Http\Client\IClientService;
use OCP\IL10N;
@@ -77,6 +79,9 @@ class MountPublicLinkControllerTest extends \Test\TestCase {
/** @var IShare */
private $share;
+ /** @var ICloudIdManager */
+ private $cloudIdManager;
+
public function setUp() {
parent::setUp();
@@ -93,6 +98,7 @@ class MountPublicLinkControllerTest extends \Test\TestCase {
$this->l10n = $this->getMockBuilder('OCP\IL10N')->disableOriginalConstructor()->getMock();
$this->userSession = $this->getMockBuilder('OCP\IUserSession')->disableOriginalConstructor()->getMock();
$this->clientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->disableOriginalConstructor()->getMock();
+ $this->cloudIdManager = new CloudIdManager();
$this->controller = new MountPublicLinkController(
'federatedfilesharing', $this->request,
@@ -102,7 +108,8 @@ class MountPublicLinkControllerTest extends \Test\TestCase {
$this->session,
$this->l10n,
$this->userSession,
- $this->clientService
+ $this->clientService,
+ $this->cloudIdManager
);
}
diff --git a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php
index 18d698d398e..61f87e9ec67 100644
--- a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php
+++ b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php
@@ -27,10 +27,12 @@
namespace OCA\FederatedFileSharing\Tests;
+use OC\Federation\CloudIdManager;
use OC\Files\Filesystem;
use OCA\FederatedFileSharing\DiscoveryManager;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\FederatedFileSharing\Controller\RequestHandlerController;
+use OCP\Federation\ICloudIdManager;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
@@ -72,6 +74,9 @@ class RequestHandlerControllerTest extends TestCase {
/** @var IShare|\PHPUnit_Framework_MockObject_MockObject */
private $share;
+ /** @var ICloudIdManager */
+ private $cloudIdManager;
+
protected function setUp() {
parent::setUp();
@@ -100,6 +105,8 @@ class RequestHandlerControllerTest extends TestCase {
$this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler')
->disableOriginalConstructor()->getMock();
$this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock();
+
+ $this->cloudIdManager = new CloudIdManager();
$this->registerHttpHelper($httpHelperMock);
@@ -111,7 +118,8 @@ class RequestHandlerControllerTest extends TestCase {
\OC::$server->getShareManager(),
$this->notifications,
$this->addressHandler,
- $this->userManager
+ $this->userManager,
+ $this->cloudIdManager
);
$this->connection = \OC::$server->getDatabaseConnection();
@@ -190,7 +198,8 @@ class RequestHandlerControllerTest extends TestCase {
\OC::$server->getShareManager(),
$this->notifications,
$this->addressHandler,
- $this->userManager
+ $this->userManager,
+ $this->cloudIdManager
]
)->setMethods(['executeDeclineShare', 'verifyShare'])->getMock();
diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
index 874d4b48a5c..97d8ccd65c3 100644
--- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
+++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
@@ -25,10 +25,12 @@
namespace OCA\FederatedFileSharing\Tests;
+use OC\Federation\CloudIdManager;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\FederatedFileSharing\Notifications;
use OCA\FederatedFileSharing\TokenHandler;
+use OCP\Federation\ICloudIdManager;
use OCP\Files\IRootFolder;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -69,6 +71,9 @@ class FederatedShareProviderTest extends \Test\TestCase {
/** @var FederatedShareProvider */
protected $provider;
+ /** @var ICloudIdManager */
+ private $cloudIdManager;
+
public function setUp() {
parent::setUp();
@@ -94,6 +99,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);
+ $this->cloudIdManager = new CloudIdManager();
+
$this->provider = new FederatedShareProvider(
$this->connection,
$this->addressHandler,
@@ -103,7 +110,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
$this->logger,
$this->rootFolder,
$this->config,
- $this->userManager
+ $this->userManager,
+ $this->cloudIdManager
);
$this->shareManager = \OC::$server->getShareManager();
@@ -400,7 +408,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
$this->logger,
$this->rootFolder,
$this->config,
- $this->userManager
+ $this->userManager,
+ $this->cloudIdManager
]
)->setMethods(['sendPermissionUpdate'])->getMock();