diff options
Diffstat (limited to 'apps/federatedfilesharing')
17 files changed, 30 insertions, 96 deletions
diff --git a/apps/federatedfilesharing/lib/AddressHandler.php b/apps/federatedfilesharing/lib/AddressHandler.php index 7ea3f304664..3a48e2adc86 100644 --- a/apps/federatedfilesharing/lib/AddressHandler.php +++ b/apps/federatedfilesharing/lib/AddressHandler.php @@ -149,7 +149,6 @@ class AddressHandler { public function urlContainProtocol($url) { if (strpos($url, 'https://') === 0 || strpos($url, 'http://') === 0) { - return true; } diff --git a/apps/federatedfilesharing/lib/AppInfo/Application.php b/apps/federatedfilesharing/lib/AppInfo/Application.php index 34666a62027..6dcb937605d 100644 --- a/apps/federatedfilesharing/lib/AppInfo/Application.php +++ b/apps/federatedfilesharing/lib/AppInfo/Application.php @@ -117,7 +117,6 @@ class Application extends App { } } ); - } /** @@ -170,5 +169,4 @@ class Application extends App { ); } - } diff --git a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php index ebbff7b9c34..8af2d587fae 100644 --- a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php +++ b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php @@ -79,7 +79,6 @@ class RetryJob extends Job { \OC::$server->getCloudFederationFactory() ); } - } /** @@ -89,7 +88,6 @@ class RetryJob extends Job { * @param ILogger|null $logger */ public function execute($jobList, ILogger $logger = null) { - if ($this->shouldRun($this->argument)) { parent::execute($jobList, $logger); $jobList->remove($this, $this->argument); @@ -144,5 +142,4 @@ class RetryJob extends Job { $lastRun = (int)$argument['lastRun']; return ((time() - $lastRun) > $this->interval); } - } diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php index b46fab19449..64e12fcd251 100644 --- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php +++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php @@ -127,7 +127,6 @@ class MountPublicLinkController extends Controller { * @return JSONResponse */ public function createFederatedShare($shareWith, $token, $password = '') { - if (!$this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) { return new JSONResponse( ['message' => 'This server doesn\'t support outgoing federated shares'], diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php index e772d088f24..fe0f1b45e53 100644 --- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php +++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php @@ -136,7 +136,6 @@ class RequestHandlerController extends OCSController { * @throws OCSException */ public function createShare() { - $remote = isset($_POST['remote']) ? $_POST['remote'] : null; $token = isset($_POST['token']) ? $_POST['token'] : null; $name = isset($_POST['name']) ? $_POST['name'] : null; @@ -197,7 +196,6 @@ class RequestHandlerController extends OCSController { * @throws OCSForbiddenException */ public function reShare($id) { - $token = $this->request->getParam('token', null); $shareWith = $this->request->getParam('shareWith', null); $permission = (int)$this->request->getParam('permission', null); @@ -251,7 +249,6 @@ class RequestHandlerController extends OCSController { * @throws \OC\HintException */ public function acceptShare($id) { - $token = isset($_POST['token']) ? $_POST['token'] : null; $notification = [ @@ -284,7 +281,6 @@ class RequestHandlerController extends OCSController { * @throws OCSException */ public function declineShare($id) { - $token = isset($_POST['token']) ? $_POST['token'] : null; $notification = [ @@ -317,7 +313,6 @@ class RequestHandlerController extends OCSController { * @throws OCSException */ public function unshare($id) { - if (!$this->isS2SEnabled()) { throw new OCSException('Server does not support federated cloud sharing', 503); } @@ -353,7 +348,6 @@ class RequestHandlerController extends OCSController { * @throws OCSBadRequestException */ public function revoke($id) { - $token = $this->request->getParam('token'); try { @@ -364,7 +358,6 @@ class RequestHandlerController extends OCSController { } catch (\Exception $e) { throw new OCSBadRequestException(); } - } /** @@ -374,7 +367,6 @@ class RequestHandlerController extends OCSController { * @return bool */ private function isS2SEnabled($incoming = false) { - $result = \OCP\App::isEnabled('files_sharing'); if ($incoming) { @@ -420,7 +412,6 @@ class RequestHandlerController extends OCSController { * @return array */ protected function ncPermissions2ocmPermissions($ncPermissions) { - $ocmPermissions = []; if ($ncPermissions & Constants::PERMISSION_SHARE) { @@ -437,7 +428,6 @@ class RequestHandlerController extends OCSController { } return $ocmPermissions; - } /** @@ -452,7 +442,6 @@ class RequestHandlerController extends OCSController { * @throws OCSException */ public function move($id) { - if (!$this->isS2SEnabled()) { throw new OCSException('Server does not support federated cloud sharing', 503); } diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index e1392b7a83a..aaa3e27cfd2 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -58,7 +58,6 @@ use OCP\Share\IShareProvider; * @package OCA\FederatedFileSharing */ class FederatedShareProvider implements IShareProvider { - const SHARE_TYPE_REMOTE = 6; /** @var IDBConnection */ @@ -165,7 +164,6 @@ class FederatedShareProvider implements IShareProvider { * @throws \Exception */ public function create(IShare $share) { - $shareWith = $share->getSharedWith(); $itemSource = $share->getNodeId(); $itemType = $share->getNodeType(); @@ -237,7 +235,6 @@ class FederatedShareProvider implements IShareProvider { $message_t = $this->l->t('File is already shared with %s', [$shareWith]); throw new \Exception($message_t); } - } else { $shareId = $this->createFederatedShare($share); } @@ -300,7 +297,7 @@ class FederatedShareProvider implements IShareProvider { $failure = true; } - if($failure) { + if ($failure) { $this->removeShareFromTableById($shareId); $message_t = $this->l->t('Sharing %1$s failed, could not find %2$s, maybe the server is currently unreachable or uses a self-signed certificate.', [$share->getNode()->getName(), $share->getSharedWith()]); @@ -308,7 +305,6 @@ class FederatedShareProvider implements IShareProvider { } return $shareId; - } /** @@ -319,7 +315,6 @@ class FederatedShareProvider implements IShareProvider { * @throws \Exception */ protected function askOwnerToReShare($shareWith, IShare $share, $shareId) { - $remoteShare = $this->getShareFromExternalShareTable($share); $token = $remoteShare['share_token']; $remoteId = $remoteShare['remote_id']; @@ -409,7 +404,7 @@ class FederatedShareProvider implements IShareProvider { * We allow updating the permissions of federated shares */ $qb = $this->dbConnection->getQueryBuilder(); - $qb->update('share') + $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) @@ -523,7 +518,7 @@ class FederatedShareProvider implements IShareProvider { ->orderBy('id'); $cursor = $qb->execute(); - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { $children[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -539,7 +534,6 @@ class FederatedShareProvider implements IShareProvider { * @throws \OC\HintException */ public function delete(IShare $share) { - list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedWith()); // if the local user is the owner we can send the unShare request directly... @@ -714,7 +708,7 @@ class FederatedShareProvider implements IShareProvider { $cursor = $qb->execute(); $shares = []; - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -767,7 +761,7 @@ class FederatedShareProvider implements IShareProvider { ->execute(); $shares = []; - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -806,7 +800,7 @@ class FederatedShareProvider implements IShareProvider { $cursor = $qb->execute(); - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -881,7 +875,6 @@ class FederatedShareProvider implements IShareProvider { * @throws ShareNotFound */ private function createShareObject($data) { - $share = new Share($this->rootFolder, $this->userManager); $share->setId((int)$data['id']) ->setShareType((int)$data['share_type']) @@ -1119,7 +1112,7 @@ class FederatedShareProvider implements IShareProvider { ); $cursor = $qb->execute(); - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { try { $share = $this->createShareObject($data); } catch (InvalidShare $e) { diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php index a70e947e3c1..6d11ea65096 100644 --- a/apps/federatedfilesharing/lib/Notifications.php +++ b/apps/federatedfilesharing/lib/Notifications.php @@ -94,7 +94,6 @@ class Notifications { * @throws \OC\ServerNotAvailableException */ public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) { - list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith); if ($user && $remote) { @@ -123,7 +122,6 @@ class Notifications { \OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $remote]); return true; } - } return false; @@ -144,7 +142,6 @@ class Notifications { * @throws \OC\ServerNotAvailableException */ public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename) { - $fields = [ 'shareWith' => $shareWith, 'token' => $token, @@ -251,7 +248,6 @@ class Notifications { * @return boolean */ public function sendUpdateToRemote($remote, $remoteId, $token, $action, $data = [], $try = 0) { - $fields = [ 'token' => $token, 'remoteId' => $remoteId @@ -309,7 +305,6 @@ class Notifications { * @throws \Exception */ protected function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, array $fields, $action="share") { - if ($this->addressHandler->urlContainProtocol($remoteDomain) === false) { $remoteDomain = 'https://' . $remoteDomain; } @@ -341,7 +336,6 @@ class Notifications { * @throws \Exception */ protected function tryLegacyEndPoint($remoteDomain, $urlSuffix, array $fields) { - $result = [ 'success' => false, 'result' => '', @@ -369,7 +363,6 @@ class Notifications { } return $result; - } /** @@ -440,6 +433,5 @@ class Notifications { } return false; - } } diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php index 821421294e5..eb7423a4964 100644 --- a/apps/federatedfilesharing/lib/Settings/Admin.php +++ b/apps/federatedfilesharing/lib/Settings/Admin.php @@ -53,7 +53,6 @@ class Admin implements ISettings { * @return TemplateResponse */ public function getForm() { - $parameters = [ 'internalOnly' => $this->gsConfig->onlyInternalFederation(), 'outgoingServer2serverShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverShareEnabled(), @@ -85,5 +84,4 @@ class Admin implements ISettings { public function getPriority() { return 20; } - } diff --git a/apps/federatedfilesharing/lib/TokenHandler.php b/apps/federatedfilesharing/lib/TokenHandler.php index 0e3fe7a049d..3922765aeba 100644 --- a/apps/federatedfilesharing/lib/TokenHandler.php +++ b/apps/federatedfilesharing/lib/TokenHandler.php @@ -30,7 +30,6 @@ use OCP\Security\ISecureRandom; * @package OCA\FederatedFileSharing */ class TokenHandler { - const TOKEN_LENGTH = 15; /** @var ISecureRandom */ @@ -56,5 +55,4 @@ class TokenHandler { ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS); return $token; } - } diff --git a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php index 8af95e888b4..0e9b9dbed62 100644 --- a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php @@ -170,7 +170,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @since 14.0.0 */ public function shareReceived(ICloudFederationShare $share) { - if (!$this->isS2SEnabled(true)) { throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE); } @@ -205,7 +204,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { } if ($remote && $token && $name && $owner && $remoteId && $shareWith) { - if (!Util::isValidFileName($name)) { throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST); } @@ -283,7 +281,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { } throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST); - } /** @@ -301,7 +298,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @since 14.0.0 */ public function notificationReceived($notificationType, $providerId, array $notification) { - switch ($notificationType) { case 'SHARE_ACCEPTED': return $this->shareAccepted($providerId, $notification); @@ -378,7 +374,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @throws \OC\HintException */ private function shareAccepted($id, array $notification) { - if (!$this->isS2SEnabled()) { throw new ActionNotSupportedException('Server does not support federated cloud sharing'); } @@ -408,7 +403,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { ); $this->cloudFederationProviderManager->sendNotification($remote, $notification); - } return []; @@ -450,7 +444,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * */ protected function shareDeclined($id, array $notification) { - if (!$this->isS2SEnabled()) { throw new ActionNotSupportedException('Server does not support federated cloud sharing'); } @@ -485,7 +478,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { $this->executeDeclineShare($share); return []; - } /** @@ -512,7 +504,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { ->setObject('files', $fileId, $file) ->setLink($link); $this->activityManager->publish($event); - } /** @@ -547,7 +538,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @throws BadRequestException */ private function unshare($id, array $notification) { - if (!$this->isS2SEnabled(true)) { throw new ActionNotSupportedException("incoming shares disabled!"); } @@ -572,7 +562,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { $result->closeCursor(); if ($token && $id && !empty($share)) { - $remote = $this->cleanupRemote($share['remote']); $owner = $this->cloudIdManager->getCloudId($share['owner'], $remote); @@ -639,7 +628,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @throws ShareNotFound */ protected function reshareRequested($id, array $notification) { - if (!isset($notification['sharedSecret'])) { throw new BadRequestException(['sharedSecret']); } @@ -681,7 +669,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { } else { throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id); } - } /** @@ -695,7 +682,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @throws BadRequestException */ protected function updateResharePermissions($id, array $notification) { - if (!isset($notification['sharedSecret'])) { throw new BadRequestException(['sharedSecret']); } @@ -725,7 +711,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { */ protected function ocmPermissions2ncPermissions(array $ocmPermissions) { $ncPermissions = 0; - foreach($ocmPermissions as $permission) { + foreach ($ocmPermissions as $permission) { switch (strtolower($permission)) { case 'read': $ncPermissions += Constants::PERMISSION_READ; @@ -739,7 +725,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { default: throw new BadRequestException(['permission']); } - } return $ncPermissions; @@ -779,7 +764,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { $link = Util::linkToAbsolute('files', 'index.php', $args); return [$file, $link]; - } /** @@ -836,7 +820,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @return bool */ private function isS2SEnabled($incoming = false) { - $result = $this->appManager->isEnabledForUser('files_sharing'); if ($incoming) { diff --git a/apps/federatedfilesharing/templates/settings-admin.php b/apps/federatedfilesharing/templates/settings-admin.php index fbbeecd88bf..a7041d90821 100644 --- a/apps/federatedfilesharing/templates/settings-admin.php +++ b/apps/federatedfilesharing/templates/settings-admin.php @@ -5,7 +5,7 @@ script('federatedfilesharing', 'settings-admin'); style('federatedfilesharing', 'settings-admin'); ?> -<?php if($_['internalOnly'] === false): ?> +<?php if ($_['internalOnly'] === false): ?> <div id="fileSharingSettings" class="section"> <h2> @@ -19,29 +19,37 @@ style('federatedfilesharing', 'settings-admin'); <p> <input type="checkbox" name="outgoing_server2server_share_enabled" id="outgoingServer2serverShareEnabled" class="checkbox" - value="1" <?php if ($_['outgoingServer2serverShareEnabled']) print_unescaped('checked="checked"'); ?> /> + value="1" <?php if ($_['outgoingServer2serverShareEnabled']) { + print_unescaped('checked="checked"'); +} ?> /> <label for="outgoingServer2serverShareEnabled"> <?php p($l->t('Allow users on this server to send shares to other servers'));?> </label> </p> <p> <input type="checkbox" name="incoming_server2server_share_enabled" id="incomingServer2serverShareEnabled" class="checkbox" - value="1" <?php if ($_['incomingServer2serverShareEnabled']) print_unescaped('checked="checked"'); ?> /> + value="1" <?php if ($_['incomingServer2serverShareEnabled']) { + print_unescaped('checked="checked"'); +} ?> /> <label for="incomingServer2serverShareEnabled"> <?php p($l->t('Allow users on this server to receive shares from other servers'));?> </label><br/> </p> - <?php if($_['federatedGroupSharingSupported']): ?> + <?php if ($_['federatedGroupSharingSupported']): ?> <p> <input type="checkbox" name="outgoing_server2server_group_share_enabled" id="outgoingServer2serverGroupShareEnabled" class="checkbox" - value="1" <?php if ($_['outgoingServer2serverGroupShareEnabled']) print_unescaped('checked="checked"'); ?> /> + value="1" <?php if ($_['outgoingServer2serverGroupShareEnabled']) { + print_unescaped('checked="checked"'); +} ?> /> <label for="outgoingServer2serverGroupShareEnabled"> <?php p($l->t('Allow users on this server to send shares to groups on other servers'));?> </label> </p> <p> <input type="checkbox" name="incoming_server2server_group_share_enabled" id="incomingServer2serverGroupShareEnabled" class="checkbox" - value="1" <?php if ($_['incomingServer2serverGroupShareEnabled']) print_unescaped('checked="checked"'); ?> /> + value="1" <?php if ($_['incomingServer2serverGroupShareEnabled']) { + print_unescaped('checked="checked"'); +} ?> /> <label for="incomingServer2serverGroupShareEnabled"> <?php p($l->t('Allow users on this server to receive group shares from other servers'));?> </label><br/> @@ -49,14 +57,18 @@ style('federatedfilesharing', 'settings-admin'); <?php endif; ?> <p> <input type="checkbox" name="lookupServerEnabled" id="lookupServerEnabled" class="checkbox" - value="1" <?php if ($_['lookupServerEnabled']) print_unescaped('checked="checked"'); ?> /> + value="1" <?php if ($_['lookupServerEnabled']) { + print_unescaped('checked="checked"'); +} ?> /> <label for="lookupServerEnabled"> <?php p($l->t('Search global and public address book for users'));?> </label><br/> </p> <p> <input type="checkbox" name="lookupServerUploadEnabled" id="lookupServerUploadEnabled" class="checkbox" - value="1" <?php if ($_['lookupServerUploadEnabled']) print_unescaped('checked="checked"'); ?> /> + value="1" <?php if ($_['lookupServerUploadEnabled']) { + print_unescaped('checked="checked"'); +} ?> /> <label for="lookupServerUploadEnabled"> <?php p($l->t('Allow users to publish their data to a global and public address book'));?> </label><br/> diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php index 123f669e74e..e6b4c09ccc5 100644 --- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php @@ -135,7 +135,6 @@ class MountPublicLinkControllerTest extends \Test\TestCase { $createSuccessful, $expectedReturnData ) { - $this->federatedShareProvider->expects($this->any()) ->method('isOutgoingServer2serverShareEnabled') ->willReturn($outgoingSharesAllowed); @@ -188,9 +187,7 @@ class MountPublicLinkControllerTest extends \Test\TestCase { $this->assertSame(Http::STATUS_OK, $result->getStatus()); $this->assertTrue(isset($result->getData()['remoteUrl'])); $this->assertSame($expectedReturnData, $result->getData()['remoteUrl']); - } - } public function dataTestCreateFederatedShare() { @@ -207,5 +204,4 @@ class MountPublicLinkControllerTest extends \Test\TestCase { ['user@server', false, true, 'token', true, true, 'This server doesn\'t support outgoing federated shares'], ]; } - } diff --git a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php index f8de6919be6..df138333de6 100644 --- a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php @@ -48,7 +48,6 @@ use OCP\Share\IShare; * @group DB */ class RequestHandlerControllerTest extends \Test\TestCase { - private $owner = 'owner'; private $user1 = 'user1'; private $user2 = 'user2'; @@ -102,7 +101,6 @@ class RequestHandlerControllerTest extends \Test\TestCase { private $cloudFederationShare; protected function setUp(): void { - $this->share = $this->getMockBuilder(IShare::class)->getMock(); $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') ->disableOriginalConstructor()->getMock(); @@ -144,7 +142,6 @@ class RequestHandlerControllerTest extends \Test\TestCase { $this->cloudFederationFactory, $this->cloudFederationProviderManager ); - } function testCreateShare() { @@ -186,11 +183,9 @@ class RequestHandlerControllerTest extends \Test\TestCase { $result = $this->requestHandler->createShare(); $this->assertInstanceOf(DataResponse::class, $result); - } function testDeclineShare() { - $id = 42; $_POST['token'] = 'token'; @@ -211,12 +206,10 @@ class RequestHandlerControllerTest extends \Test\TestCase { $result = $this->requestHandler->declineShare($id); $this->assertInstanceOf(DataResponse::class, $result); - } function testAcceptShare() { - $id = 42; $_POST['token'] = 'token'; @@ -237,8 +230,5 @@ class RequestHandlerControllerTest extends \Test\TestCase { $result = $this->requestHandler->acceptShare($id); $this->assertInstanceOf(DataResponse::class, $result); - } - - } diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 1c82c310c1f..825b8382d1e 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -415,7 +415,6 @@ class FederatedShareProviderTest extends \Test\TestCase { * */ public function testUpdate($owner, $sharedBy) { - $this->provider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') ->setConstructorArgs( [ @@ -468,7 +467,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $sharedBy . '@http://localhost/' )->willReturn(true); - if($owner === $sharedBy) { + if ($owner === $sharedBy) { $this->provider->expects($this->never())->method('sendPermissionUpdate'); } else { $this->provider->expects($this->once())->method('sendPermissionUpdate'); @@ -631,7 +630,7 @@ class FederatedShareProviderTest extends \Test\TestCase { return ['user', 'server.com']; } return ['user2', 'server.com']; - }); + }); $this->tokenHandler->method('generateToken')->willReturn('token'); $this->notifications diff --git a/apps/federatedfilesharing/tests/NotificationsTest.php b/apps/federatedfilesharing/tests/NotificationsTest.php index a835709c978..af48b594380 100644 --- a/apps/federatedfilesharing/tests/NotificationsTest.php +++ b/apps/federatedfilesharing/tests/NotificationsTest.php @@ -62,7 +62,6 @@ class NotificationsTest extends \Test\TestCase { ->disableOriginalConstructor()->getMock(); $this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class); $this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class); - } /** @@ -142,7 +141,6 @@ class NotificationsTest extends \Test\TestCase { $this->assertSame($expected, $instance->sendUpdateToRemote($remote, $id, $token, $action, ['data1Key' => 'data1Value'], $try) ); - } @@ -162,5 +160,4 @@ class NotificationsTest extends \Test\TestCase { [0, ['success' => false, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 400]]])], false], ]; } - } diff --git a/apps/federatedfilesharing/tests/TestCase.php b/apps/federatedfilesharing/tests/TestCase.php index 83393af69f6..813c3c8a15f 100644 --- a/apps/federatedfilesharing/tests/TestCase.php +++ b/apps/federatedfilesharing/tests/TestCase.php @@ -36,7 +36,6 @@ use OC\Group\Database; * Base class for sharing tests. */ abstract class TestCase extends \Test\TestCase { - const TEST_FILES_SHARING_API_USER1 = "test-share-user1"; const TEST_FILES_SHARING_API_USER2 = "test-share-user2"; @@ -91,7 +90,6 @@ abstract class TestCase extends \Test\TestCase { * @param bool $password */ protected static function loginHelper($user, $create = false, $password = false) { - if ($password === false) { $password = $user; } @@ -129,5 +127,4 @@ abstract class TestCase extends \Test\TestCase { $isInitialized->setValue($storage, false); $isInitialized->setAccessible(false); } - } diff --git a/apps/federatedfilesharing/tests/TokenHandlerTest.php b/apps/federatedfilesharing/tests/TokenHandlerTest.php index 8ddc4bc039b..50479654752 100644 --- a/apps/federatedfilesharing/tests/TokenHandlerTest.php +++ b/apps/federatedfilesharing/tests/TokenHandlerTest.php @@ -47,7 +47,6 @@ class TokenHandlerTest extends \Test\TestCase { } public function testGenerateToken() { - $this->secureRandom->expects($this->once())->method('generate') ->with( $this->expectedTokenLength, @@ -56,7 +55,5 @@ class TokenHandlerTest extends \Test\TestCase { ->willReturn('mytoken'); $this->assertSame('mytoken', $this->tokenHandler->generateToken()); - } - } |