mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(files_sharing): Respect permissions passed when creating link shares
Given: User creates a link or email share with permissions=4 (create only = file drop). Problem: Currently the permissions are automatically extended to permissions = 5 (READ + CREATE). Work around was to create the share and directly update it. Solution: Respect what the user is requesting, create a file drop share. Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de> Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com> Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
2a8ec35f44
commit
55b764b64b
3 changed files with 361 additions and 316 deletions
|
|
@ -45,7 +45,6 @@ declare(strict_types=1);
|
|||
namespace OCA\Files_Sharing\Controller;
|
||||
|
||||
use Exception;
|
||||
use OC\Files\FileInfo;
|
||||
use OC\Files\Storage\Wrapper\Wrapper;
|
||||
use OCA\Files\Helper;
|
||||
use OCA\Files_Sharing\Exceptions\SharingRightsException;
|
||||
|
|
@ -60,6 +59,7 @@ use OCP\AppFramework\OCS\OCSNotFoundException;
|
|||
use OCP\AppFramework\OCSController;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\Constants;
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\Files\InvalidPathException;
|
||||
use OCP\Files\IRootFolder;
|
||||
|
|
@ -549,20 +549,21 @@ class ShareAPIController extends OCSController {
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $permissions
|
||||
* @param int $shareType
|
||||
* @param string $shareWith
|
||||
* @param string $publicUpload
|
||||
* @param string $password
|
||||
* @param string $sendPasswordByTalk
|
||||
* @param string $expireDate
|
||||
* @param string $label
|
||||
* @param string $attributes
|
||||
* @param string|null $path Path of the share
|
||||
* @param int|null $permissions Permissions for the share
|
||||
* @param int $shareType Type of the share
|
||||
* @param string|null $shareWith The entity this should be shared with
|
||||
* @param 'true'|'false'|null $publicUpload If public uploading is allowed (deprecated)
|
||||
* @param string $password Password for the share
|
||||
* @param string|null $sendPasswordByTalk Send the password for the share over Talk
|
||||
* @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
|
||||
*
|
||||
* @return DataResponse
|
||||
* @throws NotFoundException
|
||||
* @throws OCSBadRequestException
|
||||
* @throws OCSBadRequestException Unknown share type
|
||||
* @throws OCSException
|
||||
* @throws OCSForbiddenException
|
||||
* @throws OCSNotFoundException
|
||||
|
|
@ -573,8 +574,8 @@ class ShareAPIController extends OCSController {
|
|||
string $path = null,
|
||||
int $permissions = null,
|
||||
int $shareType = -1,
|
||||
string $shareWith = null,
|
||||
string $publicUpload = 'false',
|
||||
?string $shareWith = null,
|
||||
?string $publicUpload = null,
|
||||
string $password = '',
|
||||
string $sendPasswordByTalk = null,
|
||||
string $expireDate = '',
|
||||
|
|
@ -583,16 +584,7 @@ class ShareAPIController extends OCSController {
|
|||
string $attributes = null
|
||||
): DataResponse {
|
||||
$share = $this->shareManager->newShare();
|
||||
|
||||
if ($permissions === null) {
|
||||
if ($shareType === IShare::TYPE_LINK
|
||||
|| $shareType === IShare::TYPE_EMAIL) {
|
||||
// to keep legacy default behaviour, we ignore the setting below for link shares
|
||||
$permissions = Constants::PERMISSION_READ;
|
||||
} else {
|
||||
$permissions = (int)$this->config->getAppValue('core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL);
|
||||
}
|
||||
}
|
||||
$hasPublicUpload = $this->getLegacyPublicUpload($publicUpload, $permissions);
|
||||
|
||||
// Verify path
|
||||
if ($path === null) {
|
||||
|
|
@ -611,7 +603,7 @@ class ShareAPIController extends OCSController {
|
|||
// combine all permissions to determine if the user can share this file
|
||||
$nodes = $userFolder->getById($node->getId());
|
||||
foreach ($nodes as $nodeById) {
|
||||
/** @var FileInfo $fileInfo */
|
||||
/** @var \OC\Files\FileInfo $fileInfo */
|
||||
$fileInfo = $node->getFileInfo();
|
||||
$fileInfo['permissions'] |= $nodeById->getPermissions();
|
||||
}
|
||||
|
|
@ -624,17 +616,23 @@ class ShareAPIController extends OCSController {
|
|||
throw new OCSNotFoundException($this->l->t('Could not create share'));
|
||||
}
|
||||
|
||||
if ($permissions < 0 || $permissions > Constants::PERMISSION_ALL) {
|
||||
throw new OCSNotFoundException($this->l->t('Invalid permissions'));
|
||||
// Set permissions
|
||||
if ($shareType === IShare::TYPE_LINK || $shareType === IShare::TYPE_EMAIL) {
|
||||
$permissions = $this->getLinkSharePermissions($permissions, $hasPublicUpload);
|
||||
$this->validateLinkSharePermissions($node, $permissions, $hasPublicUpload);
|
||||
} else {
|
||||
// Use default permissions only for non-link shares to keep legacy behavior
|
||||
if ($permissions === null) {
|
||||
$permissions = (int)$this->config->getAppValue('core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL);
|
||||
}
|
||||
// Non-link shares always require read permissions (link shares could be file drop)
|
||||
$permissions |= Constants::PERMISSION_READ;
|
||||
}
|
||||
|
||||
// Shares always require read permissions
|
||||
$permissions |= Constants::PERMISSION_READ;
|
||||
|
||||
if ($node instanceof \OCP\Files\File) {
|
||||
// Single file shares should never have delete or create permissions
|
||||
$permissions &= ~Constants::PERMISSION_DELETE;
|
||||
$permissions &= ~Constants::PERMISSION_CREATE;
|
||||
// For legacy reasons the API allows to pass PERMISSIONS_ALL even for single file shares (I look at you Talk)
|
||||
if ($node instanceof File) {
|
||||
// if this is a single file share we remove the DELETE and CREATE permissions
|
||||
$permissions = $permissions & ~(Constants::PERMISSION_DELETE | Constants::PERMISSION_CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -678,28 +676,7 @@ class ShareAPIController extends OCSController {
|
|||
throw new OCSNotFoundException($this->l->t('Public link sharing is disabled by the administrator'));
|
||||
}
|
||||
|
||||
if ($publicUpload === 'true') {
|
||||
// Check if public upload is allowed
|
||||
if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
|
||||
throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
|
||||
}
|
||||
|
||||
// Public upload can only be set for folders
|
||||
if ($node instanceof \OCP\Files\File) {
|
||||
throw new OCSNotFoundException($this->l->t('Public upload is only possible for publicly shared folders'));
|
||||
}
|
||||
|
||||
$permissions = Constants::PERMISSION_READ |
|
||||
Constants::PERMISSION_CREATE |
|
||||
Constants::PERMISSION_UPDATE |
|
||||
Constants::PERMISSION_DELETE;
|
||||
}
|
||||
|
||||
// TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones
|
||||
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
|
||||
$permissions |= Constants::PERMISSION_SHARE;
|
||||
}
|
||||
|
||||
$this->validateLinkSharePermissions($node, $permissions, $hasPublicUpload);
|
||||
$share->setPermissions($permissions);
|
||||
|
||||
// Set password
|
||||
|
|
@ -980,6 +957,73 @@ class ShareAPIController extends OCSController {
|
|||
return new DataResponse($shares);
|
||||
}
|
||||
|
||||
private function getLinkSharePermissions(?int $permissions, ?bool $legacyPublicUpload): int {
|
||||
$permissions = $permissions ?? Constants::PERMISSION_READ;
|
||||
|
||||
// Legacy option handling
|
||||
if ($legacyPublicUpload !== null) {
|
||||
$permissions = $legacyPublicUpload
|
||||
? (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE)
|
||||
: Constants::PERMISSION_READ;
|
||||
}
|
||||
|
||||
// TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones
|
||||
if ($this->hasPermission($permissions, Constants::PERMISSION_READ)
|
||||
&& $this->shareManager->outgoingServer2ServerSharesAllowed()) {
|
||||
$permissions |= Constants::PERMISSION_SHARE;
|
||||
}
|
||||
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to check for legacy "publicUpload" handling.
|
||||
* If the value is set to `true` or `false` then true or false are returned.
|
||||
* Otherwise null is returned to indicate that the option was not (or wrong) set.
|
||||
*
|
||||
* @param null|string $legacyPublicUpload The value of `publicUpload`
|
||||
*/
|
||||
private function getLegacyPublicUpload(?string $legacyPublicUpload, ?int $permissions): ?bool {
|
||||
if ($legacyPublicUpload === 'true') {
|
||||
return true;
|
||||
} elseif ($legacyPublicUpload === 'false') {
|
||||
return false;
|
||||
} elseif ($legacyPublicUpload === null && $permissions === null) {
|
||||
return false;
|
||||
}
|
||||
// Not set at all
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* For link and email shares validate that only allowed combinations are set.
|
||||
*
|
||||
* @throw OCSBadRequestException If permission combination is invalid.
|
||||
* @throw OCSForbiddenException If public upload was forbidden by the administrator.
|
||||
*/
|
||||
private function validateLinkSharePermissions(Node $node, int $permissions, ?bool $legacyPublicUpload): void {
|
||||
if ($legacyPublicUpload && ($node instanceof File)) {
|
||||
throw new OCSBadRequestException($this->l->t('Public upload is only possible for publicly shared folders'));
|
||||
}
|
||||
|
||||
// We need at least READ or CREATE (file drop)
|
||||
if (!$this->hasPermission($permissions, Constants::PERMISSION_READ)
|
||||
&& !$this->hasPermission($permissions, Constants::PERMISSION_CREATE)) {
|
||||
throw new OCSBadRequestException($this->l->t('Share must at least have READ or CREATE permissions'));
|
||||
}
|
||||
|
||||
// UPDATE and DELETE require a READ permission
|
||||
if (!$this->hasPermission($permissions, Constants::PERMISSION_READ)
|
||||
&& ($this->hasPermission($permissions, Constants::PERMISSION_UPDATE) || $this->hasPermission($permissions, Constants::PERMISSION_DELETE))) {
|
||||
throw new OCSBadRequestException($this->l->t('Share must have READ permission if UPDATE or DELETE permission is set'));
|
||||
}
|
||||
|
||||
// Check if public uploading was disabled
|
||||
if ($this->hasPermission($permissions, Constants::PERMISSION_CREATE)
|
||||
&& !$this->shareManager->shareApiLinkAllowPublicUpload()) {
|
||||
throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $viewer
|
||||
|
|
@ -1165,7 +1209,6 @@ class ShareAPIController extends OCSController {
|
|||
return ($permissionsSet & $permissionsToCheck) === $permissionsToCheck;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
|
|
@ -1238,7 +1281,7 @@ class ShareAPIController extends OCSController {
|
|||
$this->checkInheritedAttributes($share);
|
||||
|
||||
/**
|
||||
* expirationdate, password and publicUpload only make sense for link shares
|
||||
* expiration date, password and publicUpload only make sense for link shares
|
||||
*/
|
||||
if ($share->getShareType() === IShare::TYPE_LINK
|
||||
|| $share->getShareType() === IShare::TYPE_EMAIL) {
|
||||
|
|
@ -1261,58 +1304,13 @@ class ShareAPIController extends OCSController {
|
|||
$share->setHideDownload(false);
|
||||
}
|
||||
|
||||
$newPermissions = null;
|
||||
if ($publicUpload === 'true') {
|
||||
$newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE;
|
||||
} elseif ($publicUpload === 'false') {
|
||||
$newPermissions = Constants::PERMISSION_READ;
|
||||
}
|
||||
|
||||
if ($permissions !== null) {
|
||||
$newPermissions = $permissions;
|
||||
$newPermissions = $newPermissions & ~Constants::PERMISSION_SHARE;
|
||||
}
|
||||
|
||||
if ($newPermissions !== null) {
|
||||
if (!$this->hasPermission($newPermissions, Constants::PERMISSION_READ) && !$this->hasPermission($newPermissions, Constants::PERMISSION_CREATE)) {
|
||||
throw new OCSBadRequestException($this->l->t('Share must at least have READ or CREATE permissions'));
|
||||
}
|
||||
|
||||
if (!$this->hasPermission($newPermissions, Constants::PERMISSION_READ) && (
|
||||
$this->hasPermission($newPermissions, Constants::PERMISSION_UPDATE) || $this->hasPermission($newPermissions, Constants::PERMISSION_DELETE)
|
||||
)) {
|
||||
throw new OCSBadRequestException($this->l->t('Share must have READ permission if UPDATE or DELETE permission is set'));
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
// legacy
|
||||
$newPermissions === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE) ||
|
||||
// correct
|
||||
$newPermissions === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE)
|
||||
) {
|
||||
if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
|
||||
throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
|
||||
}
|
||||
|
||||
if (!($share->getNode() instanceof \OCP\Files\Folder)) {
|
||||
throw new OCSBadRequestException($this->l->t('Public upload is only possible for publicly shared folders'));
|
||||
}
|
||||
|
||||
// normalize to correct public upload permissions
|
||||
if ($publicUpload === 'true') {
|
||||
$newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newPermissions !== null) {
|
||||
// TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones
|
||||
if (($newPermissions & Constants::PERMISSION_READ) && $this->shareManager->outgoingServer2ServerSharesAllowed()) {
|
||||
$newPermissions |= Constants::PERMISSION_SHARE;
|
||||
}
|
||||
|
||||
$share->setPermissions($newPermissions);
|
||||
$permissions = $newPermissions;
|
||||
// If either manual permissions are specified or publicUpload
|
||||
// then we need to also update the permissions of the share
|
||||
if ($permissions !== null || $publicUpload !== null) {
|
||||
$hasPublicUpload = $this->getLegacyPublicUpload($publicUpload, $permissions);
|
||||
$permissions = $this->getLinkSharePermissions($permissions ?? Constants::PERMISSION_READ, $hasPublicUpload);
|
||||
$this->validateLinkSharePermissions($share->getNode(), $permissions, $hasPublicUpload);
|
||||
$share->setPermissions($permissions);
|
||||
}
|
||||
|
||||
if ($password === '') {
|
||||
|
|
|
|||
|
|
@ -35,11 +35,14 @@
|
|||
*/
|
||||
namespace OCA\Files_Sharing\Tests\Controller;
|
||||
|
||||
use OCA\Files_Sharing\AppInfo\Application;
|
||||
use OCA\Files_Sharing\Controller\ShareAPIController;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\OCS\OCSBadRequestException;
|
||||
use OCP\AppFramework\OCS\OCSException;
|
||||
use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||
use OCP\Constants;
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\Files\IRootFolder;
|
||||
|
|
@ -62,8 +65,10 @@ use OCP\Share\Exceptions\GenericShareException;
|
|||
use OCP\Share\IAttributes as IShareAttributes;
|
||||
use OCP\Share\IManager;
|
||||
use OCP\Share\IShare;
|
||||
use Test\TestCase;
|
||||
use OCP\UserStatus\IManager as IUserStatusManager;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
* Class ShareAPIControllerTest
|
||||
|
|
@ -72,55 +77,26 @@ use OCP\UserStatus\IManager as IUserStatusManager;
|
|||
* @group DB
|
||||
*/
|
||||
class ShareAPIControllerTest extends TestCase {
|
||||
/** @var string */
|
||||
private $appName = 'files_sharing';
|
||||
|
||||
/** @var \OC\Share20\Manager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $shareManager;
|
||||
private ShareAPIController $ocs;
|
||||
private string $currentUser;
|
||||
|
||||
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $groupManager;
|
||||
|
||||
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $userManager;
|
||||
|
||||
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $request;
|
||||
|
||||
/** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $rootFolder;
|
||||
|
||||
/** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $urlGenerator;
|
||||
|
||||
/** @var string|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $currentUser;
|
||||
|
||||
/** @var ShareAPIController */
|
||||
private $ocs;
|
||||
|
||||
/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $l;
|
||||
|
||||
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $appManager;
|
||||
|
||||
/** @var IServerContainer|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $serverContainer;
|
||||
|
||||
/** @var IUserStatusManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $userStatusManager;
|
||||
|
||||
/** @var IPreview|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $previewManager;
|
||||
|
||||
/** @var IDateTimeZone|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $dateTimeZone;
|
||||
private \OC\Share20\Manager|MockObject $shareManager;
|
||||
private IGroupManager|MockObject $groupManager;
|
||||
private IUserManager|MockObject $userManager;
|
||||
private IRequest|MockObject $request;
|
||||
private IRootFolder|MockObject $rootFolder;
|
||||
private IURLGenerator|MockObject $urlGenerator;
|
||||
private IL10N|MockObject $l;
|
||||
private IConfig|MockObject $config;
|
||||
private IAppManager|MockObject $appManager;
|
||||
private ContainerInterface|MockObject $serverContainer;
|
||||
private IUserStatusManager|MockObject $userStatusManager;
|
||||
private IPreview|MockObject $previewManager;
|
||||
private IDateTimeZone|MockObject $dateTimeZone;
|
||||
|
||||
protected function setUp(): void {
|
||||
/** @var IManager|MockObject */
|
||||
$this->shareManager = $this->createMock(IManager::class);
|
||||
$this->shareManager
|
||||
->expects($this->any())
|
||||
|
|
@ -153,7 +129,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->dateTimeZone = $this->createMock(IDateTimeZone::class);
|
||||
|
||||
$this->ocs = new ShareAPIController(
|
||||
$this->appName,
|
||||
Application::APP_ID,
|
||||
$this->request,
|
||||
$this->shareManager,
|
||||
$this->groupManager,
|
||||
|
|
@ -172,12 +148,12 @@ class ShareAPIControllerTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return ShareAPIController|\PHPUnit\Framework\MockObject\MockObject
|
||||
* @return ShareAPIController&MockObject
|
||||
*/
|
||||
private function mockFormatShare() {
|
||||
return $this->getMockBuilder(ShareAPIController::class)
|
||||
->setConstructorArgs([
|
||||
$this->appName,
|
||||
Application::APP_ID,
|
||||
$this->request,
|
||||
$this->shareManager,
|
||||
$this->groupManager,
|
||||
|
|
@ -197,7 +173,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
}
|
||||
|
||||
private function newShare() {
|
||||
return \OC::$server->getShareManager()->newShare();
|
||||
return \OCP\Server::get(IManager::class)->newShare();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -762,11 +738,11 @@ class ShareAPIControllerTest extends TestCase {
|
|||
/**
|
||||
* @dataProvider dataGetShare
|
||||
*/
|
||||
public function testGetShare(\OCP\Share\IShare $share, array $result) {
|
||||
/** @var ShareAPIController|\PHPUnit\Framework\MockObject\MockObject $ocs */
|
||||
public function testGetShare(IShare $share, array $result): void {
|
||||
/** @var ShareAPIController&MockObject $ocs */
|
||||
$ocs = $this->getMockBuilder(ShareAPIController::class)
|
||||
->setConstructorArgs([
|
||||
$this->appName,
|
||||
Application::APP_ID,
|
||||
$this->request,
|
||||
$this->shareManager,
|
||||
$this->groupManager,
|
||||
|
|
@ -847,7 +823,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
|
||||
$this->expectExceptionMessage('Wrong share ID, share does not exist');
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setSharedBy('initiator')
|
||||
->setSharedWith('recipient')
|
||||
->setShareOwner('owner');
|
||||
|
|
@ -878,7 +854,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$folder->method('getDirectoryListing')
|
||||
->willReturn([$file1, $file2]);
|
||||
|
||||
$file1UserShareOwner = \OC::$server->getShareManager()->newShare();
|
||||
$file1UserShareOwner = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1UserShareOwner->setShareType(IShare::TYPE_USER)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -892,7 +868,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_USER,
|
||||
];
|
||||
|
||||
$file1UserShareInitiator = \OC::$server->getShareManager()->newShare();
|
||||
$file1UserShareInitiator = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1UserShareInitiator->setShareType(IShare::TYPE_USER)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('currentUser')
|
||||
|
|
@ -906,7 +882,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_USER,
|
||||
];
|
||||
|
||||
$file1UserShareRecipient = \OC::$server->getShareManager()->newShare();
|
||||
$file1UserShareRecipient = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1UserShareRecipient->setShareType(IShare::TYPE_USER)
|
||||
->setSharedWith('currentUser')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -920,7 +896,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_USER,
|
||||
];
|
||||
|
||||
$file1UserShareOther = \OC::$server->getShareManager()->newShare();
|
||||
$file1UserShareOther = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1UserShareOther->setShareType(IShare::TYPE_USER)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -934,7 +910,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_USER,
|
||||
];
|
||||
|
||||
$file1GroupShareOwner = \OC::$server->getShareManager()->newShare();
|
||||
$file1GroupShareOwner = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1GroupShareOwner->setShareType(IShare::TYPE_GROUP)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -948,7 +924,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_GROUP,
|
||||
];
|
||||
|
||||
$file1GroupShareRecipient = \OC::$server->getShareManager()->newShare();
|
||||
$file1GroupShareRecipient = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1GroupShareRecipient->setShareType(IShare::TYPE_GROUP)
|
||||
->setSharedWith('currentUserGroup')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -962,7 +938,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_GROUP,
|
||||
];
|
||||
|
||||
$file1GroupShareOther = \OC::$server->getShareManager()->newShare();
|
||||
$file1GroupShareOther = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1GroupShareOther->setShareType(IShare::TYPE_GROUP)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -971,7 +947,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
->setNode($file1)
|
||||
->setId(108);
|
||||
|
||||
$file1LinkShareOwner = \OC::$server->getShareManager()->newShare();
|
||||
$file1LinkShareOwner = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1LinkShareOwner->setShareType(IShare::TYPE_LINK)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -985,7 +961,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_LINK,
|
||||
];
|
||||
|
||||
$file1EmailShareOwner = \OC::$server->getShareManager()->newShare();
|
||||
$file1EmailShareOwner = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1EmailShareOwner->setShareType(IShare::TYPE_EMAIL)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -999,7 +975,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_EMAIL,
|
||||
];
|
||||
|
||||
$file1CircleShareOwner = \OC::$server->getShareManager()->newShare();
|
||||
$file1CircleShareOwner = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1CircleShareOwner->setShareType(IShare::TYPE_CIRCLE)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -1013,7 +989,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_CIRCLE,
|
||||
];
|
||||
|
||||
$file1RoomShareOwner = \OC::$server->getShareManager()->newShare();
|
||||
$file1RoomShareOwner = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1RoomShareOwner->setShareType(IShare::TYPE_ROOM)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -1027,7 +1003,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_ROOM,
|
||||
];
|
||||
|
||||
$file1RemoteShareOwner = \OC::$server->getShareManager()->newShare();
|
||||
$file1RemoteShareOwner = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1RemoteShareOwner->setShareType(IShare::TYPE_REMOTE)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -1042,7 +1018,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_REMOTE,
|
||||
];
|
||||
|
||||
$file1RemoteGroupShareOwner = \OC::$server->getShareManager()->newShare();
|
||||
$file1RemoteGroupShareOwner = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file1RemoteGroupShareOwner->setShareType(IShare::TYPE_REMOTE_GROUP)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -1057,7 +1033,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
'share_type' => IShare::TYPE_REMOTE_GROUP,
|
||||
];
|
||||
|
||||
$file2UserShareOwner = \OC::$server->getShareManager()->newShare();
|
||||
$file2UserShareOwner = \OCP\Server::get(IManager::class)->newShare();
|
||||
$file2UserShareOwner->setShareType(IShare::TYPE_USER)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -1388,11 +1364,11 @@ class ShareAPIControllerTest extends TestCase {
|
|||
/**
|
||||
* @dataProvider dataGetShares
|
||||
*/
|
||||
public function testGetShares(array $getSharesParameters, array $shares, array $extraShareTypes, array $expected) {
|
||||
/** @var \OCA\Files_Sharing\Controller\ShareAPIController $ocs */
|
||||
public function testGetShares(array $getSharesParameters, array $shares, array $extraShareTypes, array $expected): void {
|
||||
/** @var ShareAPIController|MockObject $ocs */
|
||||
$ocs = $this->getMockBuilder(ShareAPIController::class)
|
||||
->setConstructorArgs([
|
||||
$this->appName,
|
||||
Application::APP_ID,
|
||||
$this->request,
|
||||
$this->shareManager,
|
||||
$this->groupManager,
|
||||
|
|
@ -1638,38 +1614,35 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->ocs->createShare('invalid-path');
|
||||
}
|
||||
|
||||
|
||||
public function testCreateShareInvalidPermissions() {
|
||||
$this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
|
||||
$this->expectExceptionMessage('Invalid permissions');
|
||||
public function testCreateShareInvalidShareType(): void {
|
||||
$this->expectException(OCSBadRequestException::class);
|
||||
$this->expectExceptionMessage('Unknown share type');
|
||||
|
||||
$share = $this->newShare();
|
||||
$this->shareManager->method('newShare')->willReturn($share);
|
||||
|
||||
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
|
||||
$this->rootFolder->expects($this->once())
|
||||
->method('getUserFolder')
|
||||
->with('currentUser')
|
||||
->willReturn($userFolder);
|
||||
[$userFolder, $file] = $this->getNonSharedUserFile();
|
||||
$this->rootFolder->expects($this->atLeastOnce())
|
||||
->method('getUserFolder')
|
||||
->with('currentUser')
|
||||
->willReturn($userFolder);
|
||||
|
||||
$path = $this->getMockBuilder(File::class)->getMock();
|
||||
$userFolder->expects($this->once())
|
||||
->method('get')
|
||||
->with('valid-path')
|
||||
->willReturn($path);
|
||||
$userFolder->expects($this->atLeastOnce())
|
||||
->method('get')
|
||||
->with('valid-path')
|
||||
->willReturn($file);
|
||||
$userFolder->method('getById')
|
||||
->willReturn([]);
|
||||
|
||||
$path->expects($this->once())
|
||||
$file->expects($this->once())
|
||||
->method('lock')
|
||||
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
|
||||
|
||||
$this->ocs->createShare('valid-path', 32);
|
||||
$this->ocs->createShare('valid-path', 31);
|
||||
}
|
||||
|
||||
|
||||
public function testCreateShareUserNoShareWith() {
|
||||
$this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
|
||||
public function testCreateShareUserNoShareWith(): void {
|
||||
$this->expectException(OCSNotFoundException::class);
|
||||
$this->expectExceptionMessage('Please specify a valid user');
|
||||
|
||||
$share = $this->newShare();
|
||||
|
|
@ -1732,7 +1705,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
/** @var \OCA\Files_Sharing\Controller\ShareAPIController $ocs */
|
||||
$ocs = $this->getMockBuilder(ShareAPIController::class)
|
||||
->setConstructorArgs([
|
||||
$this->appName,
|
||||
Application::APP_ID,
|
||||
$this->request,
|
||||
$this->shareManager,
|
||||
$this->groupManager,
|
||||
|
|
@ -1824,10 +1797,10 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$share = $this->newShare();
|
||||
$this->shareManager->method('newShare')->willReturn($share);
|
||||
|
||||
/** @var ShareAPIController|\PHPUnit\Framework\MockObject\MockObject $ocs */
|
||||
/** @var ShareAPIController&MockObject $ocs */
|
||||
$ocs = $this->getMockBuilder(ShareAPIController::class)
|
||||
->setConstructorArgs([
|
||||
$this->appName,
|
||||
Application::APP_ID,
|
||||
$this->request,
|
||||
$this->shareManager,
|
||||
$this->groupManager,
|
||||
|
|
@ -1949,7 +1922,9 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->rootFolder->method('getById')
|
||||
->willReturn([]);
|
||||
|
||||
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
|
||||
$this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare());
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
$this->shareManager->method('shareApiAllowLinks')->willReturn(false);
|
||||
|
||||
$this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
|
||||
}
|
||||
|
|
@ -1972,31 +1947,34 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->rootFolder->method('getById')
|
||||
->willReturn([]);
|
||||
|
||||
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
|
||||
$this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare());
|
||||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
|
||||
$this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true');
|
||||
}
|
||||
|
||||
|
||||
public function testCreateShareLinkPublicUploadFile() {
|
||||
$this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
|
||||
public function testCreateShareLinkPublicUploadFile(): void {
|
||||
$this->expectException(OCSBadRequestException::class);
|
||||
$this->expectExceptionMessage('Public upload is only possible for publicly shared folders');
|
||||
|
||||
$path = $this->getMockBuilder(File::class)->getMock();
|
||||
$storage = $this->createMock(Storage::class);
|
||||
$storage->method('instanceOfStorage')
|
||||
->willReturnMap([
|
||||
['OCA\Files_Sharing\External\Storage', false],
|
||||
['OCA\Files_Sharing\SharedStorage', false],
|
||||
]);
|
||||
$path->method('getStorage')->willReturn($storage);
|
||||
|
||||
$file = $this->createMock(File::class);
|
||||
$file->method('getId')->willReturn(42);
|
||||
$file->method('getStorage')->willReturn($storage);
|
||||
|
||||
$this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
|
||||
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
|
||||
$this->rootFolder->method('get')->with('valid-path')->willReturn($file);
|
||||
$this->rootFolder->method('getById')
|
||||
->willReturn([]);
|
||||
|
||||
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
|
||||
$this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare());
|
||||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
|
|
@ -2019,7 +1997,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->rootFolder->method('getById')
|
||||
->willReturn([]);
|
||||
|
||||
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
|
||||
$this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare());
|
||||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
|
|
@ -2057,23 +2035,23 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->rootFolder->method('getById')
|
||||
->willReturn([]);
|
||||
|
||||
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
|
||||
$this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare());
|
||||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
$this->shareManager->expects($this->once())->method('createShare')->with(
|
||||
$this->callback(function (\OCP\Share\IShare $share) use ($path) {
|
||||
return $share->getNode() === $path &&
|
||||
$share->getShareType() === IShare::TYPE_LINK &&
|
||||
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
|
||||
$share->getSharedBy() === 'currentUser' &&
|
||||
$share->getPassword() === 'password' &&
|
||||
$share->getExpirationDate() === null;
|
||||
$this->callback(function (IShare $share) use ($path) {
|
||||
return $share->getNode() === $path
|
||||
&& $share->getShareType() === IShare::TYPE_LINK
|
||||
&& $share->getPermissions() === Constants::PERMISSION_READ // publicUpload was set to false
|
||||
&& $share->getSharedBy() === 'currentUser'
|
||||
&& $share->getPassword() === 'password'
|
||||
&& $share->getExpirationDate() === null;
|
||||
})
|
||||
)->willReturnArgument(0);
|
||||
|
||||
$expected = new DataResponse([]);
|
||||
$result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', null, '');
|
||||
$result = $ocs->createShare('valid-path', Constants::PERMISSION_READ, IShare::TYPE_LINK, null, 'false', 'password', null, '');
|
||||
|
||||
$this->assertInstanceOf(get_class($expected), $result);
|
||||
$this->assertEquals($expected->getData(), $result->getData());
|
||||
|
|
@ -2095,7 +2073,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->rootFolder->method('getById')
|
||||
->willReturn([]);
|
||||
|
||||
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
|
||||
$this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare());
|
||||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
|
|
@ -2105,7 +2083,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->callback(function (\OCP\Share\IShare $share) use ($path) {
|
||||
return $share->getNode() === $path &&
|
||||
$share->getShareType() === IShare::TYPE_LINK &&
|
||||
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
|
||||
$share->getPermissions() === (Constants::PERMISSION_ALL & ~(Constants::PERMISSION_SHARE)) &&
|
||||
$share->getSharedBy() === 'currentUser' &&
|
||||
$share->getPassword() === 'password' &&
|
||||
$share->getSendPasswordByTalk() === true &&
|
||||
|
|
@ -2114,7 +2092,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
)->willReturnArgument(0);
|
||||
|
||||
$expected = new DataResponse([]);
|
||||
$result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', '');
|
||||
$result = $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true', 'password', 'true', '');
|
||||
|
||||
$this->assertInstanceOf(get_class($expected), $result);
|
||||
$this->assertEquals($expected->getData(), $result->getData());
|
||||
|
|
@ -2141,7 +2119,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->rootFolder->method('getById')
|
||||
->willReturn([]);
|
||||
|
||||
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
|
||||
$this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare());
|
||||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
|
|
@ -2178,7 +2156,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->rootFolder->method('getById')
|
||||
->willReturn([]);
|
||||
|
||||
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
|
||||
$this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare());
|
||||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
|
|
@ -2223,7 +2201,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->rootFolder->method('getById')
|
||||
->willReturn([]);
|
||||
|
||||
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
|
||||
$this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare());
|
||||
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
|
|
@ -2237,7 +2215,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
/** @var \OCA\Files_Sharing\Controller\ShareAPIController $ocs */
|
||||
$ocs = $this->getMockBuilder(ShareAPIController::class)
|
||||
->setConstructorArgs([
|
||||
$this->appName,
|
||||
Application::APP_ID,
|
||||
$this->request,
|
||||
$this->shareManager,
|
||||
$this->groupManager,
|
||||
|
|
@ -2304,7 +2282,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
/** @var \OCA\Files_Sharing\Controller\ShareAPIController $ocs */
|
||||
$ocs = $this->getMockBuilder(ShareAPIController::class)
|
||||
->setConstructorArgs([
|
||||
$this->appName,
|
||||
Application::APP_ID,
|
||||
$this->request,
|
||||
$this->shareManager,
|
||||
$this->groupManager,
|
||||
|
|
@ -2405,11 +2383,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
)->willReturnCallback(
|
||||
function ($share) {
|
||||
$share->setSharedWith('recipientRoom');
|
||||
$share->setPermissions(
|
||||
\OCP\Constants::PERMISSION_ALL &
|
||||
~\OCP\Constants::PERMISSION_DELETE &
|
||||
~\OCP\Constants::PERMISSION_CREATE
|
||||
);
|
||||
$share->setPermissions(Constants::PERMISSION_ALL);
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -2418,16 +2392,12 @@ class ShareAPIControllerTest extends TestCase {
|
|||
->willReturn($helper);
|
||||
|
||||
$this->shareManager->method('createShare')
|
||||
->with($this->callback(function (\OCP\Share\IShare $share) use ($path) {
|
||||
return $share->getNode() === $path &&
|
||||
$share->getPermissions() === (
|
||||
\OCP\Constants::PERMISSION_ALL &
|
||||
~\OCP\Constants::PERMISSION_DELETE &
|
||||
~\OCP\Constants::PERMISSION_CREATE
|
||||
) &&
|
||||
$share->getShareType() === IShare::TYPE_ROOM &&
|
||||
$share->getSharedWith() === 'recipientRoom' &&
|
||||
$share->getSharedBy() === 'currentUser';
|
||||
->with($this->callback(function (IShare $share) use ($path) {
|
||||
return $share->getNode() === $path
|
||||
&& $share->getPermissions() === Constants::PERMISSION_ALL
|
||||
&& $share->getShareType() === IShare::TYPE_ROOM
|
||||
&& $share->getSharedWith() === 'recipientRoom'
|
||||
&& $share->getSharedBy() === 'currentUser';
|
||||
}))
|
||||
->willReturnArgument(0);
|
||||
|
||||
|
|
@ -2508,15 +2478,13 @@ class ShareAPIControllerTest extends TestCase {
|
|||
->willReturn(true);
|
||||
|
||||
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
|
||||
->setMethods(['createShare'])
|
||||
->addMethods(['createShare'])
|
||||
->getMock();
|
||||
$helper->method('createShare')
|
||||
->with(
|
||||
$share,
|
||||
'recipientRoom',
|
||||
\OCP\Constants::PERMISSION_ALL &
|
||||
~\OCP\Constants::PERMISSION_DELETE &
|
||||
~\OCP\Constants::PERMISSION_CREATE,
|
||||
Constants::PERMISSION_ALL & ~(Constants::PERMISSION_CREATE | Constants::PERMISSION_DELETE),
|
||||
''
|
||||
)->willReturnCallback(
|
||||
function ($share) {
|
||||
|
|
@ -2537,14 +2505,14 @@ class ShareAPIControllerTest extends TestCase {
|
|||
* Test for https://github.com/owncloud/core/issues/22587
|
||||
* TODO: Remove once proper solution is in place
|
||||
*/
|
||||
public function testCreateReshareOfFederatedMountNoDeletePermissions() {
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
public function testCreateReshareOfFederatedMountNoDeletePermissions(): void {
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$this->shareManager->method('newShare')->willReturn($share);
|
||||
|
||||
/** @var ShareAPIController|\PHPUnit\Framework\MockObject\MockObject $ocs */
|
||||
/** @var ShareAPIController&MockObject $ocs */
|
||||
$ocs = $this->getMockBuilder(ShareAPIController::class)
|
||||
->setConstructorArgs([
|
||||
$this->appName,
|
||||
Application::APP_ID,
|
||||
$this->request,
|
||||
$this->shareManager,
|
||||
$this->groupManager,
|
||||
|
|
@ -2735,8 +2703,8 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$folder->method('getId')
|
||||
->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setPermissions(Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setShareType(IShare::TYPE_LINK)
|
||||
->setNode($folder);
|
||||
|
|
@ -2792,8 +2760,8 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$folder->method('getId')
|
||||
->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setPermissions(Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setShareType(IShare::TYPE_LINK)
|
||||
->setPassword('password')
|
||||
|
|
@ -2853,8 +2821,8 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$folder->method('getId')
|
||||
->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setPermissions(Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setShareType(IShare::TYPE_LINK)
|
||||
->setPassword('password')
|
||||
|
|
@ -2884,7 +2852,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
->willReturn(42);
|
||||
|
||||
$expected = new DataResponse([]);
|
||||
$result = $ocs->updateShare(42, $permissions, 'password', null, 'true', null);
|
||||
$result = $ocs->updateShare(42, $permissions, 'password', null, null, null);
|
||||
|
||||
$this->assertInstanceOf(get_class($expected), $result);
|
||||
$this->assertEquals($expected->getData(), $result->getData());
|
||||
|
|
@ -2905,7 +2873,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
|
||||
$this->expectExceptionMessage('Share must at least have READ or CREATE permissions');
|
||||
|
||||
$this->testUpdateLinkShareSetCRUDPermissions($permissions);
|
||||
$this->testUpdateLinkShareSetCRUDPermissions($permissions, null);
|
||||
}
|
||||
|
||||
public function publicLinkInvalidPermissionsProvider2() {
|
||||
|
|
@ -2941,8 +2909,8 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$folder->method('getId')
|
||||
->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setPermissions(Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setShareType(IShare::TYPE_LINK)
|
||||
->setNode($folder);
|
||||
|
|
@ -2987,8 +2955,8 @@ class ShareAPIControllerTest extends TestCase {
|
|||
|
||||
$folder->method('getId')->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setPermissions(Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setShareType(IShare::TYPE_LINK)
|
||||
->setNode($folder);
|
||||
|
|
@ -3006,25 +2974,32 @@ class ShareAPIControllerTest extends TestCase {
|
|||
|
||||
$ocs = $this->mockFormatShare();
|
||||
|
||||
$file = $this->getMockBuilder(File::class)->getMock();
|
||||
$file->method('getId')
|
||||
->willReturn(42);
|
||||
[$userFolder, $folder] = $this->getNonSharedUserFolder();
|
||||
[$userFolder, $file] = $this->getNonSharedUserFile();
|
||||
$file->method('getId')->willReturn(42);
|
||||
$userFolder->method('getById')
|
||||
->with(42)
|
||||
->willReturn([$folder]);
|
||||
->willReturn([$file]);
|
||||
$this->rootFolder->method('getUserFolder')
|
||||
->with($this->currentUser)
|
||||
->willReturn($userFolder);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setPermissions(Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setShareType(IShare::TYPE_LINK)
|
||||
->setNode($file);
|
||||
|
||||
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
$this->shareManager
|
||||
->method('getShareById')
|
||||
->with('ocinternal:42')
|
||||
->willReturn($share);
|
||||
$this->shareManager
|
||||
->method('shareApiLinkAllowPublicUpload')
|
||||
->willReturn(true);
|
||||
$this->shareManager
|
||||
->method('updateShare')
|
||||
->with($share)
|
||||
->willThrowException(new \InvalidArgumentException('File shares cannot have create or delete permissions'));
|
||||
|
||||
$ocs->updateShare(42, null, 'password', null, 'true', '');
|
||||
}
|
||||
|
|
@ -3374,8 +3349,8 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$folder->method('getId')
|
||||
->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setPermissions(Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setShareType(IShare::TYPE_LINK)
|
||||
->setPassword('password')
|
||||
|
|
@ -3435,8 +3410,8 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$folder->method('getId')
|
||||
->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setPermissions(Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setShareType(IShare::TYPE_LINK)
|
||||
->setPassword('password')
|
||||
|
|
@ -3495,8 +3470,8 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$folder->method('getId')
|
||||
->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setPermissions(Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setShareType(IShare::TYPE_LINK)
|
||||
->setPassword('password')
|
||||
|
|
@ -3511,17 +3486,19 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
|
||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||
|
||||
$this->shareManager->expects($this->once())->method('updateShare')->with(
|
||||
$this->callback(function (\OCP\Share\IShare $share) use ($date) {
|
||||
return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
|
||||
$share->getPassword() === 'password' &&
|
||||
$share->getSendPasswordByTalk() === true &&
|
||||
$share->getExpirationDate() === $date &&
|
||||
$share->getNote() === 'note' &&
|
||||
$share->getLabel() === 'label' &&
|
||||
$share->getHideDownload() === true;
|
||||
})
|
||||
)->willReturnArgument(0);
|
||||
$this->shareManager->expects($this->once())
|
||||
->method('updateShare')
|
||||
->with(
|
||||
$this->callback(function (IShare $share) use ($date) {
|
||||
return $share->getPermissions() === Constants::PERMISSION_ALL &&
|
||||
$share->getPassword() === 'password' &&
|
||||
$share->getSendPasswordByTalk() === true &&
|
||||
$share->getExpirationDate() === $date &&
|
||||
$share->getNote() === 'note' &&
|
||||
$share->getLabel() === 'label' &&
|
||||
$share->getHideDownload() === true;
|
||||
})
|
||||
)->willReturnArgument(0);
|
||||
|
||||
$this->rootFolder->method('getUserFolder')
|
||||
->with($this->currentUser)
|
||||
|
|
@ -3540,7 +3517,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->shareManager->method('getSharedWith')->willReturn([]);
|
||||
|
||||
$expected = new DataResponse([]);
|
||||
$result = $ocs->updateShare(42, 31, null, null, null, null, null, null, null);
|
||||
$result = $ocs->updateShare(42, Constants::PERMISSION_ALL, null, null, null, null, null, null, null);
|
||||
|
||||
$this->assertInstanceOf(get_class($expected), $result);
|
||||
$this->assertEquals($expected->getData(), $result->getData());
|
||||
|
|
@ -3553,8 +3530,8 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$file->method('getId')
|
||||
->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setPermissions(Constants::PERMISSION_ALL)
|
||||
->setSharedBy($this->currentUser)
|
||||
->setShareType(IShare::TYPE_USER)
|
||||
->setNode($file);
|
||||
|
|
@ -3599,7 +3576,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$folder->method('getId')
|
||||
->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share
|
||||
->setId(42)
|
||||
->setSharedBy($this->currentUser)
|
||||
|
|
@ -3611,7 +3588,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
|
||||
// note: updateShare will modify the received instance but getSharedWith will reread from the database,
|
||||
// so their values will be different
|
||||
$incomingShare = \OC::$server->getShareManager()->newShare();
|
||||
$incomingShare = \OCP\Server::get(IManager::class)->newShare();
|
||||
$incomingShare
|
||||
->setId(42)
|
||||
->setSharedBy($this->currentUser)
|
||||
|
|
@ -3671,7 +3648,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$folder->method('getId')
|
||||
->willReturn(42);
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share
|
||||
->setId(42)
|
||||
->setSharedBy($this->currentUser)
|
||||
|
|
@ -3683,7 +3660,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
|
||||
// note: updateShare will modify the received instance but getSharedWith will reread from the database,
|
||||
// so their values will be different
|
||||
$incomingShare = \OC::$server->getShareManager()->newShare();
|
||||
$incomingShare = \OCP\Server::get(IManager::class)->newShare();
|
||||
$incomingShare
|
||||
->setId(42)
|
||||
->setSharedBy($this->currentUser)
|
||||
|
|
@ -3769,7 +3746,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
|
||||
$result = [];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_USER)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -3863,7 +3840,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
], false
|
||||
];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_USER)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -3913,7 +3890,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
], $share, [], false
|
||||
];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_USER)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -3965,7 +3942,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
|
||||
// with existing group
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_GROUP)
|
||||
->setSharedWith('recipientGroup')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -4014,7 +3991,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
];
|
||||
|
||||
// with unknown group / no group backend
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_GROUP)
|
||||
->setSharedWith('recipientGroup2')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -4060,7 +4037,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
], $share, [], false
|
||||
];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_LINK)
|
||||
->setSharedBy('initiator')
|
||||
->setShareOwner('owner')
|
||||
|
|
@ -4114,7 +4091,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
], $share, [], false
|
||||
];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_LINK)
|
||||
->setSharedBy('initiator')
|
||||
->setShareOwner('owner')
|
||||
|
|
@ -4168,7 +4145,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
], $share, [], false
|
||||
];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_REMOTE)
|
||||
->setSharedBy('initiator')
|
||||
->setSharedWith('user@server.com')
|
||||
|
|
@ -4216,7 +4193,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
], $share, [], false
|
||||
];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_REMOTE_GROUP)
|
||||
->setSharedBy('initiator')
|
||||
->setSharedWith('user@server.com')
|
||||
|
|
@ -4265,7 +4242,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
];
|
||||
|
||||
// Circle with id, display name and avatar set by the Circles app
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_CIRCLE)
|
||||
->setSharedBy('initiator')
|
||||
->setSharedWith('Circle (Public circle, circleOwner) [4815162342]')
|
||||
|
|
@ -4316,7 +4293,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
];
|
||||
|
||||
// Circle with id set by the Circles app
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_CIRCLE)
|
||||
->setSharedBy('initiator')
|
||||
->setSharedWith('Circle (Public circle, circleOwner) [4815162342]')
|
||||
|
|
@ -4364,7 +4341,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
];
|
||||
|
||||
// Circle with id not set by the Circles app
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_CIRCLE)
|
||||
->setSharedBy('initiator')
|
||||
->setSharedWith('Circle (Public circle, circleOwner)')
|
||||
|
|
@ -4411,7 +4388,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
], $share, [], false
|
||||
];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_USER)
|
||||
->setSharedBy('initiator')
|
||||
->setSharedWith('recipient')
|
||||
|
|
@ -4426,7 +4403,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
[], $share, [], true
|
||||
];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_EMAIL)
|
||||
->setSharedBy('initiator')
|
||||
->setSharedWith('user@server.com')
|
||||
|
|
@ -4476,7 +4453,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
], $share, [], false
|
||||
];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_EMAIL)
|
||||
->setSharedBy('initiator')
|
||||
->setSharedWith('user@server.com')
|
||||
|
|
@ -4528,7 +4505,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
];
|
||||
|
||||
// Preview is available
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_USER)
|
||||
->setSharedWith('recipient')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -4683,7 +4660,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
|
||||
$result = [];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_ROOM)
|
||||
->setSharedWith('recipientRoom')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -4730,7 +4707,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
], $share, false, []
|
||||
];
|
||||
|
||||
$share = \OC::$server->getShareManager()->newShare();
|
||||
$share = \OCP\Server::get(IManager::class)->newShare();
|
||||
$share->setShareType(IShare::TYPE_ROOM)
|
||||
->setSharedWith('recipientRoom')
|
||||
->setSharedBy('initiator')
|
||||
|
|
@ -4828,6 +4805,9 @@ class ShareAPIControllerTest extends TestCase {
|
|||
$this->assertEquals($expects, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list{Folder, Folder}
|
||||
*/
|
||||
private function getNonSharedUserFolder(): array {
|
||||
$node = $this->getMockBuilder(Folder::class)->getMock();
|
||||
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
|
||||
|
|
@ -4842,6 +4822,9 @@ class ShareAPIControllerTest extends TestCase {
|
|||
return [$userFolder, $node];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list{Folder, File}
|
||||
*/
|
||||
private function getNonSharedUserFile(): array {
|
||||
$node = $this->getMockBuilder(File::class)->getMock();
|
||||
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
|
||||
|
|
|
|||
64
build/integration/sharing_features/sharing-v1-part4.feature
Normal file
64
build/integration/sharing_features/sharing-v1-part4.feature
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
Feature: sharing
|
||||
Background:
|
||||
Given using api version "1"
|
||||
Given using new dav path
|
||||
|
||||
# See sharing-v1-part3.feature
|
||||
|
||||
# This is a regression test as in the past creating a file drop required creating with permissions=5
|
||||
# and then afterwards update the share to permissions=4
|
||||
Scenario: Directly create link share with CREATE only permissions (file drop)
|
||||
Given user "user0" exists
|
||||
And As an "user0"
|
||||
And user "user0" created a folder "/TMP"
|
||||
When creating a share with
|
||||
| path | TMP |
|
||||
| shareType | 3 |
|
||||
| permissions | 4 |
|
||||
And Getting info of last share
|
||||
Then Share fields of last share match with
|
||||
| uid_file_owner | user0 |
|
||||
| share_type | 3 |
|
||||
| permissions | 4 |
|
||||
|
||||
Scenario: Directly create email share with CREATE only permissions (file drop)
|
||||
Given user "user0" exists
|
||||
And As an "user0"
|
||||
And user "user0" created a folder "/TMP"
|
||||
When creating a share with
|
||||
| path | TMP |
|
||||
| shareType | 4 |
|
||||
| shareWith | j.doe@example.com |
|
||||
| permissions | 4 |
|
||||
And Getting info of last share
|
||||
Then Share fields of last share match with
|
||||
| uid_file_owner | user0 |
|
||||
| share_type | 4 |
|
||||
| permissions | 4 |
|
||||
|
||||
# This ensures the legacy behavior of sharing v1 is kept
|
||||
Scenario: publicUpload overrides permissions
|
||||
Given user "user0" exists
|
||||
And As an "user0"
|
||||
And parameter "outgoing_server2server_share_enabled" of app "files_sharing" is set to "no"
|
||||
And user "user0" created a folder "/TMP"
|
||||
When creating a share with
|
||||
| path | TMP |
|
||||
| shareType | 3 |
|
||||
| permissions | 4 |
|
||||
| publicUpload | true |
|
||||
And Getting info of last share
|
||||
Then Share fields of last share match with
|
||||
| uid_file_owner | user0 |
|
||||
| share_type | 3 |
|
||||
| permissions | 15 |
|
||||
When creating a share with
|
||||
| path | TMP |
|
||||
| shareType | 3 |
|
||||
| permissions | 4 |
|
||||
| publicUpload | false |
|
||||
And Getting info of last share
|
||||
Then Share fields of last share match with
|
||||
| uid_file_owner | user0 |
|
||||
| share_type | 3 |
|
||||
| permissions | 1 |
|
||||
Loading…
Reference in a new issue