Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/federatedfilesharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public function __construct() {
$notification,
$addressHandler,
$server->getUserManager(),
$server->getCloudIdManager()
$server->getCloudIdManager(),
$server->getLogger()
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use OCP\Federation\ICloudIdManager;
use OCP\Files\NotFoundException;
use OCP\IDBConnection;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\Share;
Expand Down Expand Up @@ -74,6 +75,9 @@ class RequestHandlerController extends OCSController {
/** @var ICloudIdManager */
private $cloudIdManager;

/** @var ILogger */
private $logger;

/**
* Server2Server constructor.
*
Expand All @@ -95,7 +99,8 @@ public function __construct($appName,
Notifications $notifications,
AddressHandler $addressHandler,
IUserManager $userManager,
ICloudIdManager $cloudIdManager
ICloudIdManager $cloudIdManager,
ILogger $logger
) {
parent::__construct($appName, $request);

Expand All @@ -106,6 +111,7 @@ public function __construct($appName,
$this->addressHandler = $addressHandler;
$this->userManager = $userManager;
$this->cloudIdManager = $cloudIdManager;
$this->logger = $logger;
}

/**
Expand Down Expand Up @@ -140,14 +146,13 @@ public function createShare() {
}

// FIXME this should be a method in the user management instead
$logger = \OC::$server->getLogger();
$logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']);
$this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']);
\OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
array('uid' => &$shareWith)
);
$logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']);
$this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']);

if (!\OC::$server->getUserManager()->userExists($shareWith)) {
throw new OCSException('User does not exists', 400);
Expand Down Expand Up @@ -210,7 +215,7 @@ public function createShare() {

return new Http\DataResponse();
} catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, [
$this->logger->logException($e, [
'message' => 'Server can not add remote share.',
'level' => \OCP\Util::ERROR,
'app' => 'files_sharing'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\IConfig;
use OCP\ILogger;
use OCP\IUserManager;
use OCP\Share\IShare;

Expand Down Expand Up @@ -79,6 +80,9 @@ class RequestHandlerControllerTest extends TestCase {
/** @var ICloudIdManager */
private $cloudIdManager;

/** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
private $logger;

protected function setUp() {
parent::setUp();

Expand All @@ -103,6 +107,8 @@ protected function setUp() {

$this->cloudIdManager = new CloudIdManager();

$this->logger = $this->createMock(ILogger::class);

$this->s2s = new RequestHandlerController(
'federatedfilesharing',
\OC::$server->getRequest(),
Expand All @@ -112,7 +118,8 @@ protected function setUp() {
$this->notifications,
$this->addressHandler,
$this->userManager,
$this->cloudIdManager
$this->cloudIdManager,
$this->logger
);

$this->connection = \OC::$server->getDatabaseConnection();
Expand Down Expand Up @@ -177,7 +184,8 @@ function testDeclineShare() {
$this->notifications,
$this->addressHandler,
$this->userManager,
$this->cloudIdManager
$this->cloudIdManager,
$this->logger,
]
)->setMethods(['executeDeclineShare', 'verifyShare'])->getMock();

Expand Down