From bb4264c565963f07c087a4aebc47ff6ca0d59686 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 12 Dec 2019 21:38:52 +0100 Subject: [PATCH] config.php setting to always accept internal shares Part of #18255 Signed-off-by: Roeland Jago Douma --- .../composer/composer/autoload_classmap.php | 1 + .../composer/composer/autoload_static.php | 1 + .../files_sharing/lib/AppInfo/Application.php | 13 ++- .../GlobalShareAcceptanceListener.php | 61 +++++++++++ config/config.sample.php | 7 ++ lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + lib/private/Server.php | 3 +- lib/private/Share20/Manager.php | 31 +++--- lib/public/Share/Events/ShareCreatedEvent.php | 53 ++++++++++ tests/lib/Share20/ManagerTest.php | 100 ++++++++++-------- 11 files changed, 211 insertions(+), 61 deletions(-) create mode 100644 apps/files_sharing/lib/Listener/GlobalShareAcceptanceListener.php create mode 100644 lib/public/Share/Events/ShareCreatedEvent.php diff --git a/apps/files_sharing/composer/composer/autoload_classmap.php b/apps/files_sharing/composer/composer/autoload_classmap.php index 3a2b1159320d7..0e02973b5d488 100644 --- a/apps/files_sharing/composer/composer/autoload_classmap.php +++ b/apps/files_sharing/composer/composer/autoload_classmap.php @@ -46,6 +46,7 @@ 'OCA\\Files_Sharing\\Helper' => $baseDir . '/../lib/Helper.php', 'OCA\\Files_Sharing\\Hooks' => $baseDir . '/../lib/Hooks.php', 'OCA\\Files_Sharing\\ISharedStorage' => $baseDir . '/../lib/ISharedStorage.php', + 'OCA\\Files_Sharing\\Listener\\GlobalShareAcceptanceListener' => $baseDir . '/../lib/Listener/GlobalShareAcceptanceListener.php', 'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => $baseDir . '/../lib/Listener/LoadAdditionalListener.php', 'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php', 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => $baseDir . '/../lib/Middleware/OCSShareAPIMiddleware.php', diff --git a/apps/files_sharing/composer/composer/autoload_static.php b/apps/files_sharing/composer/composer/autoload_static.php index 1c1322f6c3eff..3d30458350146 100644 --- a/apps/files_sharing/composer/composer/autoload_static.php +++ b/apps/files_sharing/composer/composer/autoload_static.php @@ -61,6 +61,7 @@ class ComposerStaticInitFiles_Sharing 'OCA\\Files_Sharing\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php', 'OCA\\Files_Sharing\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php', 'OCA\\Files_Sharing\\ISharedStorage' => __DIR__ . '/..' . '/../lib/ISharedStorage.php', + 'OCA\\Files_Sharing\\Listener\\GlobalShareAcceptanceListener' => __DIR__ . '/..' . '/../lib/Listener/GlobalShareAcceptanceListener.php', 'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalListener.php', 'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php', 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/OCSShareAPIMiddleware.php', diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 8b83fea2e8edb..840f8a809ffcd 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -35,6 +35,7 @@ use OCA\Files_Sharing\Controller\ExternalSharesController; use OCA\Files_Sharing\Controller\ShareController; use OCA\Files_Sharing\External\Manager; +use OCA\Files_Sharing\Listener\GlobalShareAcceptanceListener; use OCA\Files_Sharing\Listener\LoadAdditionalListener; use OCA\Files_Sharing\Listener\LoadSidebarListener; use OCA\Files_Sharing\Middleware\OCSShareAPIMiddleware; @@ -54,6 +55,7 @@ use OCP\IContainer; use OCP\IGroup; use OCP\IServerContainer; +use OCP\Share\Events\ShareCreatedEvent; use OCP\Util; use Symfony\Component\EventDispatcher\GenericEvent; @@ -210,6 +212,7 @@ protected function registerEventsScripts(IEventDispatcher $dispatcher) { $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function() { \OCP\Util::addScript('files_sharing', 'dist/collaboration'); }); + $dispatcher->addServiceListener(ShareCreatedEvent::class, GlobalShareAcceptanceListener::class); // notifications api to accept incoming user shares $dispatcher->addListener('OCP\Share::postShare', function(GenericEvent $event) { @@ -233,7 +236,7 @@ protected function setupSharingMenus() { } $sharingSublistArray = []; - + if (\OCP\Util::isSharingDisabledForUser() === false) { array_push($sharingSublistArray, [ 'id' => 'sharingout', @@ -243,7 +246,7 @@ protected function setupSharingMenus() { 'name' => $l->t('Shared with others'), ]); } - + array_push($sharingSublistArray, [ 'id' => 'sharingin', 'appname' => 'files_sharing', @@ -251,7 +254,7 @@ protected function setupSharingMenus() { 'order' => 15, 'name' => $l->t('Shared with you'), ]); - + if (\OCP\Util::isSharingDisabledForUser() === false) { // Check if sharing by link is enabled if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { @@ -264,7 +267,7 @@ protected function setupSharingMenus() { ]); } } - + array_push($sharingSublistArray, [ 'id' => 'deletedshares', 'appname' => 'files_sharing', @@ -272,7 +275,7 @@ protected function setupSharingMenus() { 'order' => 19, 'name' => $l->t('Deleted shares'), ]); - + // show_Quick_Access stored as string \OCA\Files\App::getNavigationManager()->add([ 'id' => 'shareoverview', diff --git a/apps/files_sharing/lib/Listener/GlobalShareAcceptanceListener.php b/apps/files_sharing/lib/Listener/GlobalShareAcceptanceListener.php new file mode 100644 index 0000000000000..d30801a8fd418 --- /dev/null +++ b/apps/files_sharing/lib/Listener/GlobalShareAcceptanceListener.php @@ -0,0 +1,61 @@ + + * + * @author Roeland Jago Douma + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Files_Sharing\Listener; + +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; +use OCP\IConfig; +use OCP\Share\Events\ShareCreatedEvent; +use OCP\Share\IManager; +use OCP\Share\IShare; + +class GlobalShareAcceptanceListener implements IEventListener { + + /** @var IConfig */ + private $config; + /** @var IManager */ + private $shareManager; + + public function __construct(IConfig $config, IManager $shareManager) { + $this->config = $config; + $this->shareManager = $shareManager; + } + + public function handle(Event $event): void { + if (!($event instanceof ShareCreatedEvent)) { + return; + } + + if ($this->config->getSystemValueBool('sharing.interal_shares_accepted', false)) { + $share = $event->getShare(); + + if ($share->getShareType() === IShare::TYPE_USER || $share->getShareType() === IShare::TYPE_GROUP) { + $share->setStatus(IShare::STATUS_ACCEPTED); + $this->shareManager->updateShare($share); + } + } + } + +} diff --git a/config/config.sample.php b/config/config.sample.php index d998ce560bc26..d297f86d73845 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -1338,6 +1338,13 @@ */ 'sharing.minSearchStringLength' => 0, +/** + * Starting with Nextcloud 18 also internal shares have to be accepted. Setting + * this setting to true forces all internal shares to be accepted directly. + * (resulting in pre 18 behavior). + */ +'sharing.interal_shares_accepted' => false, + /** * All other configuration options */ diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 016b3c360efab..bfc024e585168 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -418,6 +418,7 @@ 'OCP\\Settings\\ISettings' => $baseDir . '/lib/public/Settings/ISettings.php', 'OCP\\Settings\\ISubAdminSettings' => $baseDir . '/lib/public/Settings/ISubAdminSettings.php', 'OCP\\Share' => $baseDir . '/lib/public/Share.php', + 'OCP\\Share\\Events\\ShareCreatedEvent' => $baseDir . '/lib/public/Share/Events/ShareCreatedEvent.php', 'OCP\\Share\\Exceptions\\GenericShareException' => $baseDir . '/lib/public/Share/Exceptions/GenericShareException.php', 'OCP\\Share\\Exceptions\\IllegalIDChangeException' => $baseDir . '/lib/public/Share/Exceptions/IllegalIDChangeException.php', 'OCP\\Share\\Exceptions\\ShareNotFound' => $baseDir . '/lib/public/Share/Exceptions/ShareNotFound.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 5d63c7740eb70..6fe4529c295ad 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -447,6 +447,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Settings\\ISettings' => __DIR__ . '/../../..' . '/lib/public/Settings/ISettings.php', 'OCP\\Settings\\ISubAdminSettings' => __DIR__ . '/../../..' . '/lib/public/Settings/ISubAdminSettings.php', 'OCP\\Share' => __DIR__ . '/../../..' . '/lib/public/Share.php', + 'OCP\\Share\\Events\\ShareCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/Share/Events/ShareCreatedEvent.php', 'OCP\\Share\\Exceptions\\GenericShareException' => __DIR__ . '/../../..' . '/lib/public/Share/Exceptions/GenericShareException.php', 'OCP\\Share\\Exceptions\\IllegalIDChangeException' => __DIR__ . '/../../..' . '/lib/public/Share/Exceptions/IllegalIDChangeException.php', 'OCP\\Share\\Exceptions\\ShareNotFound' => __DIR__ . '/../../..' . '/lib/public/Share/Exceptions/ShareNotFound.php', diff --git a/lib/private/Server.php b/lib/private/Server.php index b8765654c3f45..0cc3b24992e7b 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -1171,7 +1171,8 @@ public function __construct($webRoot, \OC\Config $config) { $c->getEventDispatcher(), $c->getMailer(), $c->getURLGenerator(), - $c->getThemingDefaults() + $c->getThemingDefaults(), + $c->query(IEventDispatcher::class) ); return $manager; diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 42db0d8af5dc4..4c94cf26a4d29 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -44,6 +44,7 @@ use OC\Files\Mount\MoveableMount; use OC\HintException; use OC\Share20\Exception\ProviderException; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; @@ -101,7 +102,7 @@ class Manager implements IManager { /** @var CappedMemoryCache */ private $sharingDisabledForUsersCache; /** @var EventDispatcherInterface */ - private $eventDispatcher; + private $legacyDispatcher; /** @var LegacyHooks */ private $legacyHooks; /** @var IMailer */ @@ -110,6 +111,8 @@ class Manager implements IManager { private $urlGenerator; /** @var \OC_Defaults */ private $defaults; + /** @var IEventDispatcher */ + private $dispatcher; /** @@ -143,10 +146,11 @@ public function __construct( IProviderFactory $factory, IUserManager $userManager, IRootFolder $rootFolder, - EventDispatcherInterface $eventDispatcher, + EventDispatcherInterface $legacyDispatcher, IMailer $mailer, IURLGenerator $urlGenerator, - \OC_Defaults $defaults + \OC_Defaults $defaults, + IEventDispatcher $dispatcher ) { $this->logger = $logger; $this->config = $config; @@ -159,12 +163,13 @@ public function __construct( $this->factory = $factory; $this->userManager = $userManager; $this->rootFolder = $rootFolder; - $this->eventDispatcher = $eventDispatcher; + $this->legacyDispatcher = $legacyDispatcher; $this->sharingDisabledForUsersCache = new CappedMemoryCache(); - $this->legacyHooks = new LegacyHooks($this->eventDispatcher); + $this->legacyHooks = new LegacyHooks($this->legacyDispatcher); $this->mailer = $mailer; $this->urlGenerator = $urlGenerator; $this->defaults = $defaults; + $this->dispatcher = $dispatcher; } /** @@ -195,7 +200,7 @@ protected function verifyPassword($password) { // Let others verify the password try { - $this->eventDispatcher->dispatch(new ValidatePasswordPolicyEvent($password)); + $this->legacyDispatcher->dispatch(new ValidatePasswordPolicyEvent($password)); } catch (HintException $e) { throw new \Exception($e->getHint()); } @@ -766,7 +771,7 @@ public function createShare(\OCP\Share\IShare $share) { // Pre share event $event = new GenericEvent($share); - $this->eventDispatcher->dispatch('OCP\Share::preShare', $event); + $this->legacyDispatcher->dispatch('OCP\Share::preShare', $event); if ($event->isPropagationStopped() && $event->hasArgument('error')) { throw new \Exception($event->getArgument('error')); } @@ -779,7 +784,9 @@ public function createShare(\OCP\Share\IShare $share) { // Post share event $event = new GenericEvent($share); - $this->eventDispatcher->dispatch('OCP\Share::postShare', $event); + $this->legacyDispatcher->dispatch('OCP\Share::postShare', $event); + + $this->dispatcher->dispatchTyped(new Share\Events\ShareCreatedEvent($share)); if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { $mailSend = $share->getMailSend(); @@ -1041,7 +1048,7 @@ public function acceptShare(IShare $share, string $recipientId): IShare { } $provider->acceptShare($share, $recipientId); $event = new GenericEvent($share); - $this->eventDispatcher->dispatch('OCP\Share::postAcceptShare', $event); + $this->legacyDispatcher->dispatch('OCP\Share::postAcceptShare', $event); return $share; } @@ -1111,7 +1118,7 @@ public function deleteShare(\OCP\Share\IShare $share) { } $event = new GenericEvent($share); - $this->eventDispatcher->dispatch('OCP\Share::preUnshare', $event); + $this->legacyDispatcher->dispatch('OCP\Share::preUnshare', $event); // Get all children and delete them as well $deletedShares = $this->deleteChildren($share); @@ -1125,7 +1132,7 @@ public function deleteShare(\OCP\Share\IShare $share) { // Emit post hook $event->setArgument('deletedShares', $deletedShares); - $this->eventDispatcher->dispatch('OCP\Share::postUnshare', $event); + $this->legacyDispatcher->dispatch('OCP\Share::postUnshare', $event); } @@ -1144,7 +1151,7 @@ public function deleteFromSelf(\OCP\Share\IShare $share, $recipientId) { $provider->deleteFromSelf($share, $recipientId); $event = new GenericEvent($share); - $this->eventDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event); + $this->legacyDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event); } public function restoreShare(IShare $share, string $recipientId): IShare { diff --git a/lib/public/Share/Events/ShareCreatedEvent.php b/lib/public/Share/Events/ShareCreatedEvent.php new file mode 100644 index 0000000000000..76e25b7f1667c --- /dev/null +++ b/lib/public/Share/Events/ShareCreatedEvent.php @@ -0,0 +1,53 @@ + + * + * @author Roeland Jago Douma + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\Share\Events; + +use OCP\EventDispatcher\Event; +use OCP\Share\IShare; + +/** + * @since 18.0.0 + */ +class ShareCreatedEvent extends Event { + + /** @var IShare */ + private $share; + + /** + * @since 18.0.0 + */ + public function __construct(IShare $share) { + parent::__construct(); + + $this->share = $share; + } + + /** + * @since 18.0.0 + */ + public function getShare(): IShare { + return $this->share; + } +} diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index 2320e2afa0810..02f779abf51ed 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -28,6 +28,7 @@ use OC\Share20\Manager; use OC\Share20\Share; use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; @@ -94,6 +95,8 @@ class ManagerTest extends \Test\TestCase { protected $rootFolder; /** @var EventDispatcherInterface | MockObject */ protected $eventDispatcher; + /** @var IEventDispatcher|MockObject */ + protected $dispatcher; /** @var IMailer|MockObject */ protected $mailer; /** @var IURLGenerator|MockObject */ @@ -115,6 +118,7 @@ protected function setUp(): void { $this->mailer = $this->createMock(IMailer::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->defaults = $this->createMock(\OC_Defaults::class); + $this->dispatcher = $this->createMock(IEventDispatcher::class); $this->l10nFactory = $this->createMock(IFactory::class); $this->l = $this->createMock(IL10N::class); @@ -140,7 +144,8 @@ protected function setUp(): void { $this->eventDispatcher, $this->mailer, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->dispatcher ); $this->defaultProvider = $this->createMock(DefaultShareProvider::class); @@ -168,11 +173,12 @@ private function createManagerMock() { $this->eventDispatcher, $this->mailer, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->dispatcher ]); } - + public function testDeleteNoShareId() { $this->expectException(\InvalidArgumentException::class); @@ -445,7 +451,7 @@ public function testGetShareById() { $this->assertEquals($share, $this->manager->getShareById('default:42')); } - + public function testGetExpiredShareById() { $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class); @@ -472,7 +478,7 @@ public function testGetExpiredShareById() { $manager->getShareById('default:42'); } - + public function testVerifyPasswordNullButEnforced() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Passwords are enforced for link shares'); @@ -510,7 +516,7 @@ public function testVerifyPasswordHook() { $this->assertNull($result); } - + public function testVerifyPasswordHookFails() { $this->expectException(\Exception::class); $this->expectExceptionMessage('password not accepted'); @@ -719,7 +725,7 @@ public function testGeneralChecks($share, $exceptionMessage, $exception) { $this->assertSame($exception, $thrown); } - + public function testGeneralCheckShareRoot() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('You can’t share your root folder'); @@ -745,7 +751,7 @@ public function testGeneralCheckShareRoot() { self::invokePrivate($this->manager, 'generalCreateChecks', [$share]); } - + public function testvalidateExpirationDateInPast() { $this->expectException(\OCP\Share\Exceptions\GenericShareException::class); $this->expectExceptionMessage('Expiration date is in the past'); @@ -761,7 +767,7 @@ public function testvalidateExpirationDateInPast() { self::invokePrivate($this->manager, 'validateExpirationDate', [$share]); } - + public function testvalidateExpirationDateEnforceButNotSet() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Expiration date is enforced'); @@ -950,7 +956,7 @@ public function testValidateExpirationDateHookModification() { $this->assertEquals($save, $share->getExpirationDate()); } - + public function testValidateExpirationDateHookException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Invalid date!'); @@ -988,7 +994,7 @@ public function testValidateExpirationDateExistingShareNoDefault() { $this->assertEquals(null, $share->getExpirationDate()); } - + public function testUserCreateChecksShareWithGroupMembersOnlyDifferentGroups() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Sharing is only allowed with group members'); @@ -1061,7 +1067,7 @@ public function testUserCreateChecksShareWithGroupMembersOnlySharedGroup() { $this->addToAssertionCount(1); } - + public function testUserCreateChecksIdenticalShareExists() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Path is already shared with this user'); @@ -1086,7 +1092,7 @@ public function testUserCreateChecksIdenticalShareExists() { self::invokePrivate($this->manager, 'userCreateChecks', [$share]); } - + public function testUserCreateChecksIdenticalPathSharedViaGroup() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Path is already shared with this user'); @@ -1197,7 +1203,7 @@ public function testUserCreateChecksIdenticalPathNotSharedWithUser() { $this->addToAssertionCount(1); } - + public function testGroupCreateChecksShareWithGroupMembersGroupSharingNotAllowed() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Group sharing is now allowed'); @@ -1213,7 +1219,7 @@ public function testGroupCreateChecksShareWithGroupMembersGroupSharingNotAllowed self::invokePrivate($this->manager, 'groupCreateChecks', [$share]); } - + public function testGroupCreateChecksShareWithGroupMembersOnlyNotInGroup() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Sharing is only allowed within your own groups'); @@ -1239,7 +1245,7 @@ public function testGroupCreateChecksShareWithGroupMembersOnlyNotInGroup() { self::invokePrivate($this->manager, 'groupCreateChecks', [$share]); } - + public function testGroupCreateChecksShareWithGroupMembersOnlyNullGroup() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Sharing is only allowed within your own groups'); @@ -1292,7 +1298,7 @@ public function testGroupCreateChecksShareWithGroupMembersOnlyInGroup() { $this->addToAssertionCount(1); } - + public function testGroupCreateChecksPathAlreadySharedWithSameGroup() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Path is already shared with this group'); @@ -1348,7 +1354,7 @@ public function testGroupCreateChecksPathAlreadySharedWithDifferentGroup() { $this->addToAssertionCount(1); } - + public function testLinkCreateChecksNoLinkSharesAllowed() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Link sharing is not allowed'); @@ -1364,7 +1370,7 @@ public function testLinkCreateChecksNoLinkSharesAllowed() { self::invokePrivate($this->manager, 'linkCreateChecks', [$share]); } - + public function testLinkCreateChecksSharePermissions() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Link shares can’t have reshare permissions'); @@ -1382,7 +1388,7 @@ public function testLinkCreateChecksSharePermissions() { self::invokePrivate($this->manager, 'linkCreateChecks', [$share]); } - + public function testLinkCreateChecksNoPublicUpload() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Public upload is not allowed'); @@ -1433,7 +1439,7 @@ public function testLinkCreateChecksReadOnly() { $this->addToAssertionCount(1); } - + public function testPathCreateChecksContainsSharedMount() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Path contains files shared with you'); @@ -1925,7 +1931,7 @@ public function testCreateShareMail() { $this->assertEquals('token', $share->getToken()); } - + public function testCreateShareHookError() { $this->expectException(\Exception::class); $this->expectExceptionMessage('I won\'t let you share'); @@ -2192,7 +2198,8 @@ public function testGetShareByToken() { $this->eventDispatcher, $this->mailer, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->dispatcher ); $share = $this->createMock(IShare::class); @@ -2235,7 +2242,8 @@ public function testGetShareByTokenRoom() { $this->eventDispatcher, $this->mailer, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->dispatcher ); $share = $this->createMock(IShare::class); @@ -2285,7 +2293,8 @@ public function testGetShareByTokenWithException() { $this->eventDispatcher, $this->mailer, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->dispatcher ); $share = $this->createMock(IShare::class); @@ -2312,7 +2321,7 @@ public function testGetShareByTokenWithException() { $this->assertSame($share, $ret); } - + public function testGetShareByTokenExpired() { $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class); $this->expectExceptionMessage('The requested share does not exist anymore'); @@ -2371,7 +2380,7 @@ public function testGetShareByTokenNotExpired() { $this->assertSame($share, $res); } - + public function testGetShareByTokenWithPublicLinksDisabled() { $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class); @@ -2467,7 +2476,7 @@ public function testCheckPasswordUpdateShare() { $this->assertTrue($this->manager->checkPassword($share, 'password')); } - + public function testUpdateShareCantChangeShareType() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Can’t change share type'); @@ -2493,7 +2502,7 @@ public function testUpdateShareCantChangeShareType() { $manager->updateShare($share); } - + public function testUpdateShareCantChangeRecipientForGroupShare() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Can only update recipient on user shares'); @@ -2521,7 +2530,7 @@ public function testUpdateShareCantChangeRecipientForGroupShare() { $manager->updateShare($share); } - + public function testUpdateShareCantShareWithOwner() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Can’t share with the share owner'); @@ -2890,7 +2899,7 @@ public function testUpdateShareMailEnableSendPasswordByTalk() { $manager->updateShare($share); } - + public function testUpdateShareMailEnableSendPasswordByTalkWithNoPassword() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password'); @@ -2962,7 +2971,7 @@ public function testUpdateShareMailEnableSendPasswordByTalkWithNoPassword() { $manager->updateShare($share); } - + public function testUpdateShareMailEnableSendPasswordByTalkRemovingPassword() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password'); @@ -3034,7 +3043,7 @@ public function testUpdateShareMailEnableSendPasswordByTalkRemovingPassword() { $manager->updateShare($share); } - + public function testUpdateShareMailEnableSendPasswordByTalkRemovingPasswordWithEmptyString() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password'); @@ -3106,7 +3115,7 @@ public function testUpdateShareMailEnableSendPasswordByTalkRemovingPasswordWithE $manager->updateShare($share); } - + public function testUpdateShareMailEnableSendPasswordByTalkWithPreviousPassword() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password'); @@ -3248,7 +3257,7 @@ public function testUpdateShareMailDisableSendPasswordByTalkWithPreviousPassword $manager->updateShare($share); } - + public function testMoveShareLink() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Can’t change target of link share'); @@ -3261,7 +3270,7 @@ public function testMoveShareLink() { $this->manager->moveShare($share, $recipient); } - + public function testMoveShareUserNotRecipient() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid recipient'); @@ -3288,7 +3297,7 @@ public function testMoveShareUser() { $this->addToAssertionCount(1); } - + public function testMoveShareGroupNotRecipient() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid recipient'); @@ -3308,7 +3317,7 @@ public function testMoveShareGroupNotRecipient() { $this->manager->moveShare($share, 'recipient'); } - + public function testMoveShareGroupNull() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Group "shareWith" does not exist'); @@ -3375,7 +3384,8 @@ public function testShareProviderExists($shareType, $expected) { $this->eventDispatcher, $this->mailer, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->dispatcher ); $this->assertSame($expected, $manager->shareProviderExists($shareType) @@ -3407,7 +3417,8 @@ public function testGetSharesInFolder() { $this->eventDispatcher, $this->mailer, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->dispatcher ); $factory->setProvider($this->defaultProvider); @@ -3470,7 +3481,8 @@ public function testGetAccessList() { $this->eventDispatcher, $this->mailer, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->dispatcher ); $factory->setProvider($this->defaultProvider); @@ -3586,7 +3598,8 @@ public function testGetAccessListWithCurrentAccess() { $this->eventDispatcher, $this->mailer, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->dispatcher ); $factory->setProvider($this->defaultProvider); @@ -3711,7 +3724,8 @@ public function testGetAllShares() { $this->eventDispatcher, $this->mailer, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->dispatcher ); $factory->setProvider($this->defaultProvider);