diff --git a/apps/sharing/tests/Command/CommandTest.php b/apps/sharing/tests/Command/CommandTest.php index b10dfef40c31e..934dfdcf7a6cc 100644 --- a/apps/sharing/tests/Command/CommandTest.php +++ b/apps/sharing/tests/Command/CommandTest.php @@ -33,6 +33,7 @@ use OCP\Sharing\Permission\SharePermission; use OCP\Sharing\Property\ShareProperty; use OCP\Sharing\Recipient\ShareRecipient; +use OCP\Sharing\Share; use OCP\Sharing\ShareAccessContext; use OCP\Sharing\ShareState; use OCP\Sharing\Source\ShareSource; @@ -42,6 +43,9 @@ use Symfony\Component\Console\Output\Output; use Test\Sharing\AbstractSharingManagerTests; +/** + * @psalm-import-type SharingShare from Share + */ #[Group(name: 'DB')] final class CommandTest extends AbstractSharingManagerTests { /** @var list> */ @@ -363,7 +367,7 @@ protected function deleteShare(ShareAccessContext $accessContext, string $id): v } /** - * @return array + * @return SharingShare */ #[Override] protected function getShare(ShareAccessContext $accessContext, string $id): array { @@ -380,7 +384,7 @@ protected function getShare(ShareAccessContext $accessContext, string $id): arra } /** - * @return array + * @return SharingShare[] */ #[Override] protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array { diff --git a/apps/sharing/tests/Controller/ApiV1ControllerTest.php b/apps/sharing/tests/Controller/ApiV1ControllerTest.php index bfee7b020155f..2424aba18d1cf 100644 --- a/apps/sharing/tests/Controller/ApiV1ControllerTest.php +++ b/apps/sharing/tests/Controller/ApiV1ControllerTest.php @@ -22,6 +22,7 @@ use OCP\Sharing\Permission\SharePermission; use OCP\Sharing\Property\ShareProperty; use OCP\Sharing\Recipient\ShareRecipient; +use OCP\Sharing\Share; use OCP\Sharing\ShareAccessContext; use OCP\Sharing\ShareState; use OCP\Sharing\Source\ShareSource; @@ -29,6 +30,10 @@ use Test\Sharing\AbstractSharingManagerTests; // TODO: Use Dispatcher + +/** + * @psalm-import-type SharingShare from Share + */ #[Group(name: 'DB')] final class ApiV1ControllerTest extends AbstractSharingManagerTests { public function testDefaultShareAccessContext(): void { @@ -146,11 +151,17 @@ protected function deleteShare(ShareAccessContext $accessContext, string $id): v $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->deleteShare($id)); } + /** + * @psalm-suppress MixedReturnTypeCoercion + */ #[Override] protected function getShare(ShareAccessContext $accessContext, string $id): array { return $this->executeRequest(new ShareAccessContext($accessContext->currentUser, null, [], $accessContext->overrideChecks), fn (ApiV1Controller $controller): DataResponse => $controller->getShare($id, $accessContext->secret, $accessContext->arguments)); } + /** + * @psalm-suppress MixedReturnTypeCoercion + */ #[Override] protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array { return $this->executeRequest($accessContext, function (ApiV1Controller $controller) use ($filterSourceTypeClass, $filterSourceTypeValue, $lastShareID, $limit): DataResponse { diff --git a/core/Sharing/Property/ExpirationDateSharePropertyType.php b/core/Sharing/Property/ExpirationDateSharePropertyType.php index 7def2d4b7eae5..67f83bbaa67dd 100644 --- a/core/Sharing/Property/ExpirationDateSharePropertyType.php +++ b/core/Sharing/Property/ExpirationDateSharePropertyType.php @@ -62,6 +62,7 @@ public function isRequired(Share $share): bool { if ($this->hasRemoteRecipient($share) && $this->legacyManager->shareApiRemoteDefaultExpireDateEnforced()) { return true; } + return $this->hasLocalNonTokenAndEmailRecipient($share) && $this->legacyManager->shareApiInternalDefaultExpireDateEnforced(); } diff --git a/tests/lib/Sharing/AbstractSharingManagerTests.php b/tests/lib/Sharing/AbstractSharingManagerTests.php index 96238de0aecca..b3420efc829f7 100644 --- a/tests/lib/Sharing/AbstractSharingManagerTests.php +++ b/tests/lib/Sharing/AbstractSharingManagerTests.php @@ -35,6 +35,9 @@ /** * @psalm-import-type SharingShare from Share * @psalm-import-type SharingRecipient from Share + * + * @psalm-suppress RedundantConditionGivenDocblockType + * @psalm-suppress PossiblyUndefinedArrayOffset */ abstract class AbstractSharingManagerTests extends TestCase { abstract protected function searchRecipients(ShareAccessContext $accessContext, ?array $filterRecipientTypeClasses, string $query, int $limit, int $offset, ?string $id = null): array; @@ -61,8 +64,14 @@ abstract protected function selectSharePermissionPreset(ShareAccessContext $acce abstract protected function deleteShare(ShareAccessContext $accessContext, string $id): void; + /** + * @return SharingShare + */ abstract protected function getShare(ShareAccessContext $accessContext, string $id): array; + /** + * @return SharingShare[] + */ abstract protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array; protected IDBConnection $dbConnection; @@ -3097,6 +3106,7 @@ public function testGetShareWithSecret(): void { $this->assertGreaterThanOrEqual($before, $share['last_updated']); $this->assertLessThanOrEqual($after, $share['last_updated']); + usort($share['recipients'], fn (array $a, array $b): int => $a['value'] <=> $b['value']); $this->assertArrayHasKey('recipients', $share); $this->assertIsArray($share['recipients']); $this->assertCount(4, $share['recipients']); diff --git a/tests/lib/Sharing/SharingManagerTest.php b/tests/lib/Sharing/SharingManagerTest.php index 117cb18c54d7b..519b60e1b6cc4 100644 --- a/tests/lib/Sharing/SharingManagerTest.php +++ b/tests/lib/Sharing/SharingManagerTest.php @@ -207,9 +207,6 @@ protected function getShare(ShareAccessContext $accessContext, string $id): arra } } - /** - * @return mixed[][] - */ #[\Override] protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array { try {