diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index cdf370c82fd35..cab989aeb4330 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -550,7 +550,8 @@ public function deleteShare(string $id): DataResponse { * @param string $publicUpload If public uploading is allowed * @param string $password Password for the share * @param string|null $sendPasswordByTalk Send the password for the share over Talk - * @param string $expireDate Expiry date of the share using user timezone at 00:00. It means date in UTC timezone will be used. + * @param ?string $expireDate The expiry date of the share in the user's timezone at 00:00. + * If $expireDate is not supplied or set to `null`, the system default will be used. * @param string $note Note for the share * @param string $label Label for the share (only used in link and email) * @param string|null $attributes Additional attributes for the share @@ -571,8 +572,8 @@ public function createShare( string $shareWith = null, string $publicUpload = 'false', string $password = '', - string $sendPasswordByTalk = null, - string $expireDate = '', + ?string $sendPasswordByTalk = null, + ?string $expireDate = null, string $note = '', string $label = '', string $attributes = null @@ -647,12 +648,18 @@ public function createShare( } //Expire date - if ($expireDate !== '') { - try { - $expireDateTime = $this->parseDate($expireDate); - $share->setExpirationDate($expireDateTime); - } catch (\Exception $e) { - throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD')); + if ($expireDate !== null) { + if ($expireDate !== '') { + try { + $expireDateTime = $this->parseDate($expireDate); + $share->setExpirationDate($expireDateTime); + } catch (\Exception $e) { + throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD')); + } + } else { + // Client sent empty string for expire date. + // Set noExpirationDate to true so overwrite is prevented. + $share->setNoExpirationDate(true); } } @@ -769,19 +776,19 @@ public function createShare( $share->setPermissions($permissions); } elseif ($shareType === IShare::TYPE_ROOM) { try { - $this->getRoomShareHelper()->createShare($share, $shareWith, $permissions, $expireDate); + $this->getRoomShareHelper()->createShare($share, $shareWith, $permissions, $expireDate ?? ''); } catch (QueryException $e) { throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$node->getPath()])); } } elseif ($shareType === IShare::TYPE_DECK) { try { - $this->getDeckShareHelper()->createShare($share, $shareWith, $permissions, $expireDate); + $this->getDeckShareHelper()->createShare($share, $shareWith, $permissions, $expireDate ?? ''); } catch (QueryException $e) { throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$node->getPath()])); } } elseif ($shareType === IShare::TYPE_SCIENCEMESH) { try { - $this->getSciencemeshShareHelper()->createShare($share, $shareWith, $permissions, $expireDate); + $this->getSciencemeshShareHelper()->createShare($share, $shareWith, $permissions, $expireDate ?? ''); } catch (QueryException $e) { throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support ScienceMesh shares', [$node->getPath()])); } diff --git a/apps/files_sharing/openapi.json b/apps/files_sharing/openapi.json index 9a869feb3b2ce..661134126d3b8 100644 --- a/apps/files_sharing/openapi.json +++ b/apps/files_sharing/openapi.json @@ -1755,10 +1755,10 @@ { "name": "expireDate", "in": "query", - "description": "Expiry date of the share using user timezone at 00:00. It means date in UTC timezone will be used.", + "description": "The expiry date of the share in the user's timezone at 00:00. If $expireDate is not supplied or set to `null`, the system default will be used.", "schema": { "type": "string", - "default": "" + "nullable": true } }, { diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php index d7c3f218d9fa4..100c77599002d 100644 --- a/apps/files_sharing/tests/CapabilitiesTest.php +++ b/apps/files_sharing/tests/CapabilitiesTest.php @@ -38,7 +38,6 @@ use OCP\IConfig; use OCP\IDateTimeZone; use OCP\IGroupManager; -use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\IUserSession; @@ -86,7 +85,6 @@ private function getResults(array $map) { $this->createMock(IHasher::class), $this->createMock(IMountManager::class), $this->createMock(IGroupManager::class), - $this->createMock(IL10N::class), $this->createMock(IFactory::class), $this->createMock(IProviderFactory::class), $this->createMock(IUserManager::class), diff --git a/build/integration/features/bootstrap/Sharing.php b/build/integration/features/bootstrap/Sharing.php index a38ef392e61f0..0f1b221563952 100644 --- a/build/integration/features/bootstrap/Sharing.php +++ b/build/integration/features/bootstrap/Sharing.php @@ -81,7 +81,9 @@ public function asCreatingAShareWith($user, $body) { $fd = $body->getRowsHash(); if (array_key_exists('expireDate', $fd)) { $dateModification = $fd['expireDate']; - $fd['expireDate'] = date('Y-m-d', strtotime($dateModification)); + if (!empty($dateModification)) { + $fd['expireDate'] = date('Y-m-d', strtotime($dateModification)); + } } $options['form_params'] = $fd; } @@ -328,7 +330,9 @@ public function createShare($user, public function isFieldInResponse($field, $contentExpected) { $data = simplexml_load_string($this->response->getBody())->data[0]; if ((string)$field == 'expiration') { - $contentExpected = date('Y-m-d', strtotime($contentExpected)) . " 00:00:00"; + if (!empty($contentExpected)) { + $contentExpected = date('Y-m-d', strtotime($contentExpected)) . " 00:00:00"; + } } if (count($data->element) > 0) { foreach ($data as $element) { diff --git a/build/integration/sharing_features/sharing-v1.feature b/build/integration/sharing_features/sharing-v1.feature index ca030bd3a31fa..2b5d4e8933184 100644 --- a/build/integration/sharing_features/sharing-v1.feature +++ b/build/integration/sharing_features/sharing-v1.feature @@ -229,6 +229,24 @@ Feature: sharing | url | AN_URL | | mimetype | httpd/unix-directory | + Scenario: Creating a new share with expiration date removed, when default expiration is set + Given user "user0" exists + And user "user1" exists + And parameter "shareapi_default_expire_date" of app "core" is set to "yes" + And As an "user0" + When creating a share with + | path | welcome.txt | + | shareWith | user1 | + | shareType | 0 | + | expireDate | | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And Getting info of last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And Share fields of last share match with + | expiration || + Scenario: Creating a new public share, updating its password and getting its info Given user "user0" exists And As an "user0" diff --git a/lib/private/Server.php b/lib/private/Server.php index 419d6344a30a8..a43742d69c7a7 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -151,7 +151,6 @@ use OC\Session\CryptoWrapper; use OC\SetupCheck\SetupCheckManager; use OC\Share20\ProviderFactory; -use OC\Share20\ShareDisableChecker; use OC\Share20\ShareHelper; use OC\SpeechToText\SpeechToTextManager; use OC\SystemTag\ManagerFactory as SystemTagManagerFactory; @@ -259,6 +258,7 @@ use OCP\Security\RateLimiting\ILimiter; use OCP\Security\VerificationToken\IVerificationToken; use OCP\SetupCheck\ISetupCheckManager; +use OCP\Share\IProviderFactory; use OCP\Share\IShareHelper; use OCP\SpeechToText\ISpeechToTextManager; use OCP\SystemTag\ISystemTagManager; @@ -1241,36 +1241,14 @@ public function __construct($webRoot, \OC\Config $config) { /** @deprecated 19.0.0 */ $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class); - $this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) { + $this->registerService(IProviderFactory::class, function (ContainerInterface $c) { $config = $c->get(\OCP\IConfig::class); $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); /** @var \OCP\Share\IProviderFactory $factory */ - $factory = new $factoryClass($this); - - $manager = new \OC\Share20\Manager( - $c->get(LoggerInterface::class), - $c->get(\OCP\IConfig::class), - $c->get(ISecureRandom::class), - $c->get(IHasher::class), - $c->get(IMountManager::class), - $c->get(IGroupManager::class), - $c->getL10N('lib'), - $c->get(IFactory::class), - $factory, - $c->get(IUserManager::class), - $c->get(IRootFolder::class), - $c->get(IMailer::class), - $c->get(IURLGenerator::class), - $c->get('ThemingDefaults'), - $c->get(IEventDispatcher::class), - $c->get(IUserSession::class), - $c->get(KnownUserService::class), - $c->get(ShareDisableChecker::class), - $c->get(IDateTimeZone::class), - ); - - return $manager; + return new $factoryClass($this); }); + + $this->registerAlias(\OCP\Share\IManager::class, \OC\Share20\Manager::class); /** @deprecated 19.0.0 */ $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class); diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 76d696eb97990..b797b0b56988c 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -84,87 +84,34 @@ * This class is the communication hub for all sharing related operations. */ class Manager implements IManager { - /** @var IProviderFactory */ - private $factory; - private LoggerInterface $logger; - /** @var IConfig */ - private $config; - /** @var ISecureRandom */ - private $secureRandom; - /** @var IHasher */ - private $hasher; - /** @var IMountManager */ - private $mountManager; - /** @var IGroupManager */ - private $groupManager; - /** @var IL10N */ - private $l; - /** @var IFactory */ - private $l10nFactory; - /** @var IUserManager */ - private $userManager; - /** @var IRootFolder */ - private $rootFolder; - /** @var LegacyHooks */ - private $legacyHooks; - /** @var IMailer */ - private $mailer; - /** @var IURLGenerator */ - private $urlGenerator; - /** @var \OC_Defaults */ - private $defaults; - /** @var IEventDispatcher */ - private $dispatcher; - /** @var IUserSession */ - private $userSession; - /** @var KnownUserService */ - private $knownUserService; - private ShareDisableChecker $shareDisableChecker; - private IDateTimeZone $dateTimeZone; + + private IL10N|null $l; + private LegacyHooks $legacyHooks; public function __construct( - LoggerInterface $logger, - IConfig $config, - ISecureRandom $secureRandom, - IHasher $hasher, - IMountManager $mountManager, - IGroupManager $groupManager, - IL10N $l, - IFactory $l10nFactory, - IProviderFactory $factory, - IUserManager $userManager, - IRootFolder $rootFolder, - IMailer $mailer, - IURLGenerator $urlGenerator, - \OC_Defaults $defaults, - IEventDispatcher $dispatcher, - IUserSession $userSession, - KnownUserService $knownUserService, - ShareDisableChecker $shareDisableChecker, - IDateTimeZone $dateTimeZone, + private LoggerInterface $logger, + private IConfig $config, + private ISecureRandom $secureRandom, + private IHasher $hasher, + private IMountManager $mountManager, + private IGroupManager $groupManager, + private IFactory $l10nFactory, + private IProviderFactory $factory, + private IUserManager $userManager, + private IRootFolder $rootFolder, + private IMailer $mailer, + private IURLGenerator $urlGenerator, + private \OC_Defaults $defaults, + private IEventDispatcher $dispatcher, + private IUserSession $userSession, + private KnownUserService $knownUserService, + private ShareDisableChecker $shareDisableChecker, + private IDateTimeZone $dateTimeZone ) { - $this->logger = $logger; - $this->config = $config; - $this->secureRandom = $secureRandom; - $this->hasher = $hasher; - $this->mountManager = $mountManager; - $this->groupManager = $groupManager; - $this->l = $l; - $this->l10nFactory = $l10nFactory; - $this->factory = $factory; - $this->userManager = $userManager; - $this->rootFolder = $rootFolder; + $this->l = $this->l10nFactory->get('lib'); // The constructor of LegacyHooks registers the listeners of share events // do not remove if those are not properly migrated - $this->legacyHooks = new LegacyHooks($dispatcher); - $this->mailer = $mailer; - $this->urlGenerator = $urlGenerator; - $this->defaults = $defaults; - $this->dispatcher = $dispatcher; - $this->userSession = $userSession; - $this->knownUserService = $knownUserService; - $this->shareDisableChecker = $shareDisableChecker; - $this->dateTimeZone = $dateTimeZone; + $this->legacyHooks = new LegacyHooks($this->dispatcher); } /** @@ -349,26 +296,6 @@ protected function validateExpirationDateInternal(IShare $share) { $expirationDate = $share->getExpirationDate(); - if ($expirationDate !== null) { - $expirationDate->setTimezone($this->dateTimeZone->getTimeZone()); - $expirationDate->setTime(0, 0, 0); - - $date = new \DateTime('now', $this->dateTimeZone->getTimeZone()); - $date->setTime(0, 0, 0); - if ($date >= $expirationDate) { - $message = $this->l->t('Expiration date is in the past'); - throw new GenericShareException($message, $message, 404); - } - } - - // If expiredate is empty set a default one if there is a default - $fullId = null; - try { - $fullId = $share->getFullId(); - } catch (\UnexpectedValueException $e) { - // This is a new share - } - if ($isRemote) { $defaultExpireDate = $this->shareApiRemoteDefaultExpireDate(); $defaultExpireDays = $this->shareApiRemoteDefaultExpireDays(); @@ -380,28 +307,53 @@ protected function validateExpirationDateInternal(IShare $share) { $configProp = 'internal_defaultExpDays'; $isEnforced = $this->shareApiInternalDefaultExpireDateEnforced(); } - if ($fullId === null && $expirationDate === null && $defaultExpireDate) { - $expirationDate = new \DateTime('now', $this->dateTimeZone->getTimeZone()); - $expirationDate->setTime(0, 0, 0); - $days = (int)$this->config->getAppValue('core', $configProp, (string)$defaultExpireDays); - if ($days > $defaultExpireDays) { - $days = $defaultExpireDays; + + // If $expirationDate is falsy, noExpirationDate is true and expiration not enforced + // Then skip expiration date validation as null is accepted + if (!($share->getNoExpirationDate() && !$isEnforced)) { + if ($expirationDate != null) { + $expirationDate->setTimezone($this->dateTimeZone->getTimeZone()); + $expirationDate->setTime(0, 0, 0); + + $date = new \DateTime('now', $this->dateTimeZone->getTimeZone()); + $date->setTime(0, 0, 0); + if ($date >= $expirationDate) { + $message = $this->l->t('Expiration date is in the past'); + throw new GenericShareException($message, $message, 404); + } } - $expirationDate->add(new \DateInterval('P' . $days . 'D')); - } - // If we enforce the expiration date check that is does not exceed - if ($isEnforced) { - if ($expirationDate === null) { - throw new \InvalidArgumentException('Expiration date is enforced'); + // If expiredate is empty set a default one if there is a default + $fullId = null; + try { + $fullId = $share->getFullId(); + } catch (\UnexpectedValueException $e) { + // This is a new share } - $date = new \DateTime('now', $this->dateTimeZone->getTimeZone()); - $date->setTime(0, 0, 0); - $date->add(new \DateInterval('P' . $defaultExpireDays . 'D')); - if ($date < $expirationDate) { - $message = $this->l->n('Cannot set expiration date more than %n day in the future', 'Cannot set expiration date more than %n days in the future', $defaultExpireDays); - throw new GenericShareException($message, $message, 404); + if ($fullId === null && $expirationDate === null && $defaultExpireDate) { + $expirationDate = new \DateTime('now', $this->dateTimeZone->getTimeZone()); + $expirationDate->setTime(0, 0, 0); + $days = (int)$this->config->getAppValue('core', $configProp, (string)$defaultExpireDays); + if ($days > $defaultExpireDays) { + $days = $defaultExpireDays; + } + $expirationDate->add(new \DateInterval('P' . $days . 'D')); + } + + // If we enforce the expiration date check that is does not exceed + if ($isEnforced) { + if (empty($expirationDate)) { + throw new \InvalidArgumentException('Expiration date is enforced'); + } + + $date = new \DateTime('now', $this->dateTimeZone->getTimeZone()); + $date->setTime(0, 0, 0); + $date->add(new \DateInterval('P' . $defaultExpireDays . 'D')); + if ($date < $expirationDate) { + $message = $this->l->n('Cannot set expiration date more than %n day in the future', 'Cannot set expiration date more than %n days in the future', $defaultExpireDays); + throw new GenericShareException($message, $message, 404); + } } } @@ -434,51 +386,57 @@ protected function validateExpirationDateInternal(IShare $share) { */ protected function validateExpirationDateLink(IShare $share) { $expirationDate = $share->getExpirationDate(); - - if ($expirationDate !== null) { - $expirationDate->setTimezone($this->dateTimeZone->getTimeZone()); - $expirationDate->setTime(0, 0, 0); - - $date = new \DateTime('now', $this->dateTimeZone->getTimeZone()); - $date->setTime(0, 0, 0); - if ($date >= $expirationDate) { - $message = $this->l->t('Expiration date is in the past'); - throw new GenericShareException($message, $message, 404); + $isEnforced = $this->shareApiLinkDefaultExpireDateEnforced(); + + // If $expirationDate is falsy, noExpirationDate is true and expiration not enforced + // Then skip expiration date validation as null is accepted + if (!($share->getNoExpirationDate() && !$isEnforced)) { + if ($expirationDate !== null) { + $expirationDate->setTimezone($this->dateTimeZone->getTimeZone()); + $expirationDate->setTime(0, 0, 0); + + $date = new \DateTime('now', $this->dateTimeZone->getTimeZone()); + $date->setTime(0, 0, 0); + if ($date >= $expirationDate) { + $message = $this->l->t('Expiration date is in the past'); + throw new GenericShareException($message, $message, 404); + } } - } - - // If expiredate is empty set a default one if there is a default - $fullId = null; - try { - $fullId = $share->getFullId(); - } catch (\UnexpectedValueException $e) { - // This is a new share - } - if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) { - $expirationDate = new \DateTime('now', $this->dateTimeZone->getTimeZone()); - $expirationDate->setTime(0, 0, 0); - - $days = (int)$this->config->getAppValue('core', 'link_defaultExpDays', (string)$this->shareApiLinkDefaultExpireDays()); - if ($days > $this->shareApiLinkDefaultExpireDays()) { - $days = $this->shareApiLinkDefaultExpireDays(); + // If expiredate is empty set a default one if there is a default + $fullId = null; + try { + $fullId = $share->getFullId(); + } catch (\UnexpectedValueException $e) { + // This is a new share + } + + if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) { + $expirationDate = new \DateTime('now', $this->dateTimeZone->getTimeZone()); + $expirationDate->setTime(0, 0, 0); + + $days = (int)$this->config->getAppValue('core', 'link_defaultExpDays', (string)$this->shareApiLinkDefaultExpireDays()); + if ($days > $this->shareApiLinkDefaultExpireDays()) { + $days = $this->shareApiLinkDefaultExpireDays(); + } + $expirationDate->add(new \DateInterval('P' . $days . 'D')); } - $expirationDate->add(new \DateInterval('P' . $days . 'D')); - } - - // If we enforce the expiration date check that is does not exceed - if ($this->shareApiLinkDefaultExpireDateEnforced()) { - if ($expirationDate === null) { - throw new \InvalidArgumentException('Expiration date is enforced'); + + // If we enforce the expiration date check that is does not exceed + if ($isEnforced) { + if (empty($expirationDate)) { + throw new \InvalidArgumentException('Expiration date is enforced'); + } + + $date = new \DateTime('now', $this->dateTimeZone->getTimeZone()); + $date->setTime(0, 0, 0); + $date->add(new \DateInterval('P' . $this->shareApiLinkDefaultExpireDays() . 'D')); + if ($date < $expirationDate) { + $message = $this->l->n('Cannot set expiration date more than %n day in the future', 'Cannot set expiration date more than %n days in the future', $this->shareApiLinkDefaultExpireDays()); + throw new GenericShareException($message, $message, 404); + } } - $date = new \DateTime('now', $this->dateTimeZone->getTimeZone()); - $date->setTime(0, 0, 0); - $date->add(new \DateInterval('P' . $this->shareApiLinkDefaultExpireDays() . 'D')); - if ($date < $expirationDate) { - $message = $this->l->n('Cannot set expiration date more than %n day in the future', 'Cannot set expiration date more than %n days in the future', $this->shareApiLinkDefaultExpireDays()); - throw new GenericShareException($message, $message, 404); - } } $accepted = true; diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php index c80d332e9dba2..b911a3b462357 100644 --- a/lib/private/Share20/Share.php +++ b/lib/private/Share20/Share.php @@ -99,10 +99,11 @@ class Share implements IShare { /** @var ICacheEntry|null */ private $nodeCacheEntry; - /** @var bool */ private $hideDownload = false; + private bool $noExpirationDate = false; + public function __construct(IRootFolder $rootFolder, IUserManager $userManager) { $this->rootFolder = $rootFolder; $this->userManager = $userManager; @@ -421,6 +422,21 @@ public function getExpirationDate() { return $this->expireDate; } + /** + * @inheritdoc + */ + public function setNoExpirationDate(bool $noExpirationDate) { + $this->noExpirationDate = $noExpirationDate; + return $this; + } + + /** + * @inheritdoc + */ + public function getNoExpirationDate(): bool { + return $this->noExpirationDate; + } + /** * @inheritdoc */ diff --git a/lib/public/Share/IShare.php b/lib/public/Share/IShare.php index e5a943b0bac89..e3b6349bbfa98 100644 --- a/lib/public/Share/IShare.php +++ b/lib/public/Share/IShare.php @@ -385,20 +385,38 @@ public function getNote(); /** * Set the expiration date * - * @param null|\DateTime $expireDate + * @param \DateTime|null $expireDate * @return \OCP\Share\IShare The modified object * @since 9.0.0 */ - public function setExpirationDate($expireDate); + public function setExpirationDate(\DateTime|null $expireDate); /** * Get the expiration date * - * @return null|\DateTime + * @return \DateTime|null * @since 9.0.0 */ public function getExpirationDate(); + /** + * Set overwrite flag for falsy expiry date vavlues + * + * @param bool $noExpirationDate + * @return \OCP\Share\IShare The modified object + * @since 28.0.7 + */ + public function setNoExpirationDate(bool $noExpirationDate); + + + /** + * Get value of overwrite falsy expiry date flag + * + * @return bool + * @since 28.0.7 + */ + public function getNoExpirationDate(); + /** * Is the share expired ? * diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index aeea1b5b863e4..e352c088d514e 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -151,19 +151,27 @@ protected function setUp(): void { ->willReturnCallback(function ($singular, $plural, $count, $parameters = []) { return vsprintf(str_replace('%n', $count, ($count === 1) ? $singular : $plural), $parameters); }); + $this->l10nFactory->method('get')->willReturn($this->l); $this->factory = new DummyFactory(\OC::$server); - $this->manager = new Manager( + $this->manager = $this->createManager($this->factory); + + $this->defaultProvider = $this->createMock(DefaultShareProvider::class); + $this->defaultProvider->method('identifier')->willReturn('default'); + $this->factory->setProvider($this->defaultProvider); + } + + private function createManager(IProviderFactory $factory): Manager { + return new Manager( $this->logger, $this->config, $this->secureRandom, $this->hasher, $this->mountManager, $this->groupManager, - $this->l, $this->l10nFactory, - $this->factory, + $factory, $this->userManager, $this->rootFolder, $this->mailer, @@ -175,10 +183,6 @@ protected function setUp(): void { $this->shareDisabledChecker, $this->dateTimeZone, ); - - $this->defaultProvider = $this->createMock(DefaultShareProvider::class); - $this->defaultProvider->method('identifier')->willReturn('default'); - $this->factory->setProvider($this->defaultProvider); } /** @@ -193,7 +197,6 @@ private function createManagerMock() { $this->hasher, $this->mountManager, $this->groupManager, - $this->l, $this->l10nFactory, $this->factory, $this->userManager, @@ -2802,27 +2805,7 @@ public function testGetShareByToken() { $factory = $this->createMock(IProviderFactory::class); - $manager = new Manager( - $this->logger, - $this->config, - $this->secureRandom, - $this->hasher, - $this->mountManager, - $this->groupManager, - $this->l, - $this->l10nFactory, - $factory, - $this->userManager, - $this->rootFolder, - $this->mailer, - $this->urlGenerator, - $this->defaults, - $this->dispatcher, - $this->userSession, - $this->knownUserService, - $this->shareDisabledChecker, - $this->dateTimeZone, - ); + $manager = $this->createManager($factory); $share = $this->createMock(IShare::class); @@ -2851,27 +2834,7 @@ public function testGetShareByTokenRoom() { $factory = $this->createMock(IProviderFactory::class); - $manager = new Manager( - $this->logger, - $this->config, - $this->secureRandom, - $this->hasher, - $this->mountManager, - $this->groupManager, - $this->l, - $this->l10nFactory, - $factory, - $this->userManager, - $this->rootFolder, - $this->mailer, - $this->urlGenerator, - $this->defaults, - $this->dispatcher, - $this->userSession, - $this->knownUserService, - $this->shareDisabledChecker, - $this->dateTimeZone, - ); + $manager = $this->createManager($factory); $share = $this->createMock(IShare::class); @@ -2907,27 +2870,7 @@ public function testGetShareByTokenWithException() { $factory = $this->createMock(IProviderFactory::class); - $manager = new Manager( - $this->logger, - $this->config, - $this->secureRandom, - $this->hasher, - $this->mountManager, - $this->groupManager, - $this->l, - $this->l10nFactory, - $factory, - $this->userManager, - $this->rootFolder, - $this->mailer, - $this->urlGenerator, - $this->defaults, - $this->dispatcher, - $this->userSession, - $this->knownUserService, - $this->shareDisabledChecker, - $this->dateTimeZone, - ); + $manager = $this->createManager($factory); $share = $this->createMock(IShare::class); @@ -4308,27 +4251,7 @@ public function testShareProviderExists($shareType, $expected) { throw new Exception\ProviderException(); }); - $manager = new Manager( - $this->logger, - $this->config, - $this->secureRandom, - $this->hasher, - $this->mountManager, - $this->groupManager, - $this->l, - $this->l10nFactory, - $factory, - $this->userManager, - $this->rootFolder, - $this->mailer, - $this->urlGenerator, - $this->defaults, - $this->dispatcher, - $this->userSession, - $this->knownUserService, - $this->shareDisabledChecker, - $this->dateTimeZone, - ); + $manager = $this->createManager($factory); $this->assertSame($expected, $manager->shareProviderExists($shareType) ); @@ -4344,27 +4267,7 @@ public function dataTestShareProviderExists() { public function testGetSharesInFolder() { $factory = new DummyFactory2($this->createMock(IServerContainer::class)); - $manager = new Manager( - $this->logger, - $this->config, - $this->secureRandom, - $this->hasher, - $this->mountManager, - $this->groupManager, - $this->l, - $this->l10nFactory, - $factory, - $this->userManager, - $this->rootFolder, - $this->mailer, - $this->urlGenerator, - $this->defaults, - $this->dispatcher, - $this->userSession, - $this->knownUserService, - $this->shareDisabledChecker, - $this->dateTimeZone, - ); + $manager = $this->createManager($factory); $factory->setProvider($this->defaultProvider); $extraProvider = $this->createMock(IShareProvider::class); @@ -4411,27 +4314,7 @@ public function testGetSharesInFolder() { public function testGetAccessList() { $factory = new DummyFactory2($this->createMock(IServerContainer::class)); - $manager = new Manager( - $this->logger, - $this->config, - $this->secureRandom, - $this->hasher, - $this->mountManager, - $this->groupManager, - $this->l, - $this->l10nFactory, - $factory, - $this->userManager, - $this->rootFolder, - $this->mailer, - $this->urlGenerator, - $this->defaults, - $this->dispatcher, - $this->userSession, - $this->knownUserService, - $this->shareDisabledChecker, - $this->dateTimeZone, - ); + $manager = $this->createManager($factory); $factory->setProvider($this->defaultProvider); $extraProvider = $this->createMock(IShareProvider::class); @@ -4530,27 +4413,7 @@ public function testGetAccessList() { public function testGetAccessListWithCurrentAccess() { $factory = new DummyFactory2($this->createMock(IServerContainer::class)); - $manager = new Manager( - $this->logger, - $this->config, - $this->secureRandom, - $this->hasher, - $this->mountManager, - $this->groupManager, - $this->l, - $this->l10nFactory, - $factory, - $this->userManager, - $this->rootFolder, - $this->mailer, - $this->urlGenerator, - $this->defaults, - $this->dispatcher, - $this->userSession, - $this->knownUserService, - $this->shareDisabledChecker, - $this->dateTimeZone, - ); + $manager = $this->createManager($factory); $factory->setProvider($this->defaultProvider); $extraProvider = $this->createMock(IShareProvider::class); @@ -4658,27 +4521,7 @@ public function testGetAccessListWithCurrentAccess() { public function testGetAllShares() { $factory = new DummyFactory2($this->createMock(IServerContainer::class)); - $manager = new Manager( - $this->logger, - $this->config, - $this->secureRandom, - $this->hasher, - $this->mountManager, - $this->groupManager, - $this->l, - $this->l10nFactory, - $factory, - $this->userManager, - $this->rootFolder, - $this->mailer, - $this->urlGenerator, - $this->defaults, - $this->dispatcher, - $this->userSession, - $this->knownUserService, - $this->shareDisabledChecker, - $this->dateTimeZone, - ); + $manager = $this->createManager($factory); $factory->setProvider($this->defaultProvider); $extraProvider = $this->createMock(IShareProvider::class);