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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/sharing/tests/Command/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<class-string<SharingBase>> */
Expand Down Expand Up @@ -363,7 +367,7 @@ protected function deleteShare(ShareAccessContext $accessContext, string $id): v
}

/**
* @return array<string, mixed>
* @return SharingShare
*/
#[Override]
protected function getShare(ShareAccessContext $accessContext, string $id): array {
Expand All @@ -380,7 +384,7 @@ protected function getShare(ShareAccessContext $accessContext, string $id): arra
}

/**
* @return array<string, mixed>
* @return SharingShare[]
*/
#[Override]
protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array {
Expand Down
11 changes: 11 additions & 0 deletions apps/sharing/tests/Controller/ApiV1ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@
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;
use PHPUnit\Framework\Attributes\Group;
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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
10 changes: 10 additions & 0 deletions tests/lib/Sharing/AbstractSharingManagerTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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']);
Expand Down
3 changes: 0 additions & 3 deletions tests/lib/Sharing/SharingManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading