diff --git a/src/Drive.php b/src/Drive.php index 43f75312..3f24653a 100644 --- a/src/Drive.php +++ b/src/Drive.php @@ -12,10 +12,15 @@ use OpenAPI\Client\Model\Drive as ApiDrive; use OpenAPI\Client\Model\DriveUpdate; use OpenAPI\Client\Model\DriveItem; +use OpenAPI\Client\Model\DriveItemCreateLink; +use OpenAPI\Client\Model\SharingLinkType; +use OpenAPI\Client\Model\DriveRecipient; use OpenAPI\Client\Model\DriveItemInvite; use OpenAPI\Client\Model\DriveRecipient; use OpenAPI\Client\Model\OdataError; use OpenAPI\Client\Model\Permission; +use OpenAPI\Client\Model\SharingLink as ApiSharingLink; +use OpenAPI\Client\Model\Permission; use OpenAPI\Client\Model\Quota; use Owncloud\OcisPhpSdk\Exception\BadRequestException; use Owncloud\OcisPhpSdk\Exception\ConflictException; @@ -920,6 +925,132 @@ public function setPermissionExpiration(string $permissionId, ?\DateTimeImmutabl return $this->updatePermission($permissionId, $apiPermission); } + /** + * @param User $recipient + * @param string $role + * @param string|null $password + * @param string|null $displayName + * @param boolean|null $quickLink + * @param \DateTimeImmutable|null $expiration + * @return ShareLink + */ + public function createLink($recipient, string $role, ?string $password = null, ?string $displayName = null, ?bool $quickLink = false, ?\DateTimeImmutable $expiration = null): ShareLink + { + $driveItemCreateLink = []; + $recipientData = []; + + $driveItemCreateLink['type'] = SharingLinkType::from($role); // get from enum + if ($expiration !== null) { + $expirationMutable = \DateTime::createFromImmutable($expiration); + $driveItemCreateLink['expiration_date_time'] = $expirationMutable; + } + if(isset($password)) { + $driveItemCreateLink['password'] = $password; + } + if(isset($displayName)) { + $driveItemCreateLink['display_name'] = $displayName; + } + $driveItemCreateLink['at_libre_graph_quick_link'] = $quickLink; + + $recipientData['object_id'] = $recipient->getId(); + $driveItemCreateLink['recipients'][] = new DriveRecipient($recipientData); + + if (array_key_exists('drivesRootApi', $this->connectionConfig)) { + $apiInstance = $this->connectionConfig['drivesRootApi']; + } else { + $guzzle = new Client( + Ocis::createGuzzleConfig($this->connectionConfig, $this->accessToken) + ); + $apiInstance = new DrivesRootApi( + $guzzle, + $this->graphApiConfig + ); + } + + $inviteData = new DriveItemCreateLink($driveItemCreateLink); + try { + $permissions = $apiInstance->createLinkSpaceRoot($this->getId(), $inviteData); + } catch (ApiException $e) { + throw ExceptionHelper::getHttpErrorException($e); + } + if ($permissions instanceof OdataError) { + throw new InvalidResponseException( + "invite returned an OdataError - " . $permissions->getError() + ); + } + if(isset($password)) { + $permissions->setHasPassword(true); + } else { + $permissions->setHasPassword(false); + } + + return new ShareLink( + $permissions, + $this->getId(), + $this->getId(), + $this->connectionConfig, + $this->serviceUrl, + $this->accessToken + ); + } + + /** + * @param ShareLink $recipient + * @param string $role + * @param string|null $password + * @param string|null $displayName + * @param boolean|null $quickLink + * @param \DateTimeImmutable|null $expiration + * @return ShareLink + */ + public function updateLink($share, string $type, ?string $displayName = null, ?bool $quickLink = false, ?\DateTimeImmutable $expiration = null): ShareLink + { + $shareLink=new ApiSharingLink(); + $permissions=new Permission(); + + // $permissions->set; + $shareLink->setType(SharingLinkType::EDIT); + + $permissions->setLink($shareLink); + + if (array_key_exists('drivesRootApi', $this->connectionConfig)) { + $apiInstance = $this->connectionConfig['drivesRootApi']; + } else { + $guzzle = new Client( + Ocis::createGuzzleConfig($this->connectionConfig, $this->accessToken) + ); + $apiInstance = new DrivesRootApi( + $guzzle, + $this->graphApiConfig + ); + } + + var_dump($this->accessToken); + try { + $permissions = $apiInstance->updatePermissionSpaceRoot($this->getId(), $share->getPermissionId(),$permissions); + } catch (ApiException $e) { + throw ExceptionHelper::getHttpErrorException($e); + } + if ($permissions instanceof OdataError) { + throw new InvalidResponseException( + "invite returned an OdataError - " . $permissions->getError() + ); + } + if(isset($password)) { + $permissions->setHasPassword(true); + } else { + $permissions->setHasPassword(false); + } + return new ShareLink( + $permissions, + $this->getId(), + $this->getId(), + $this->connectionConfig, + $this->serviceUrl, + $this->accessToken + ); + } + /** * @param array $tags * @todo This function is not implemented yet! Place, name and signature of the function might change! diff --git a/src/OcisResource.php b/src/OcisResource.php index cf377edb..50db2cd4 100644 --- a/src/OcisResource.php +++ b/src/OcisResource.php @@ -7,6 +7,7 @@ use OpenAPI\Client\Api\DrivesApi; // @phan-suppress-current-line PhanUnreferencedUseNormal it's used in a comment use OpenAPI\Client\Api\DrivesPermissionsApi; use OpenAPI\Client\Api\TagsApi; +use OpenAPI\Client\Api\DrivesRootApi; use OpenAPI\Client\ApiException; use OpenAPI\Client\Configuration; use OpenAPI\Client\Model\DriveItemCreateLink; diff --git a/src/Share.php b/src/Share.php index e982ef3f..088d0399 100644 --- a/src/Share.php +++ b/src/Share.php @@ -176,4 +176,8 @@ public function setExpiration(?\DateTimeImmutable $expiration): bool $this->apiPermission = $apiPermission; return true; } + + function getPermission() : ApiPermission { + return $this->apiPermission; + } } diff --git a/tests/integration/Owncloud/OcisPhpSdk/DriveTest.php b/tests/integration/Owncloud/OcisPhpSdk/DriveTest.php index 24a352e3..2573c22c 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/DriveTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/DriveTest.php @@ -14,6 +14,8 @@ use Owncloud\OcisPhpSdk\Exception\NotFoundException; use Owncloud\OcisPhpSdk\Exception\UnauthorizedException; use Owncloud\OcisPhpSdk\Ocis; +use Owncloud\OcisPhpSdk\ShareCreated; +use Owncloud\OcisPhpSdk\ShareLink; use Owncloud\OcisPhpSdk\SharingRole; require_once __DIR__ . '/OcisPhpSdkTestCase.php'; @@ -89,545 +91,20 @@ public function testGetDriveRole(): void ); } - public function testSetValidName(): void + public function testbesta(): void { - $name = 'test name'; - $this->assertEquals($this->drive->getName(), $this->driveName); - $this->drive->setName($name); - $this->assertEquals($this->drive->getName(), $name, "Failed to set name $name"); + $einsteinOcis = $this->initUser('einstein', 'relativity'); + $einstein = $einsteinOcis->getUsers('einstein')[0]; + $share = $this->drive->createLink($einstein, 'view', 'P@$$w0rd', 'user'); + $this->assertInstanceOf(ShareLink::class, $share); } - public function testSetInvalidName(): void + public function testbestb(): void { - $this->expectException(BadRequestException::class); - $this->expectExceptionMessage('spacename must not be empty'); - - $this->drive->setName(''); - } - /** - * @dataProvider descriptionStrings - */ - public function testSetDescription(string $description): void - { - $this->drive->setDescription($description); - $this->assertEquals($this->drive->getDescription(), $description, "Failed to set description $description"); - } - - /** - * @return array> - */ - public static function descriptionStrings(): array - { - return [ - [''], - ['test string'], - ]; - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testCreateDriveInvite(): void - { - $marieOcis = $this->initUser('marie', 'radioactivity'); - - $marie = $this->ocis->getUsers('marie')[0]; - - $managerRole = null; - - $shareRoles = $this->drive->getRoles(); - foreach ($shareRoles as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Manager')) { - $managerRole = $role; - break; - } - } - - $this->assertInstanceOf(SharingRole::class, $managerRole, "manager role not found"); - - $driveInvitation = $this->drive->invite($marie, $managerRole); - - $this->assertInstanceOf( - Permission::class, - $driveInvitation, - "Expected class to be 'Permission' but found " - . get_class($driveInvitation), - ); - $this->assertNull($driveInvitation->getExpirationDateTime(), "Expiration date for sharing drive wasn't found to be null"); - $receivedInvitationDrive = $marieOcis->getDriveById($this->drive->getId()); - $this->assertSame( - $this->drive->getId(), - $receivedInvitationDrive->getId(), - "Expected driveId to be " . $this->drive->getId() - . " but found " . $receivedInvitationDrive->getId(), - ); - $this->assertSame( - $this->drive->getName(), - $receivedInvitationDrive->getName(), - "Expected shared drive name to be " . $this->drive->getName() . " but found " . $receivedInvitationDrive->getName(), - ); - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testDeleteDriveInvite(): void - { - $this->initUser('marie', 'radioactivity'); - - $marie = $this->ocis->getUsers('marie')[0]; - - $managerRole = null; - - foreach ($this->drive->getRoles() as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Manager')) { - $managerRole = $role; - break; - } - } - - $this->assertInstanceOf(SharingRole::class, $managerRole, "manager role not found"); - - $this->drive->invite($marie, $managerRole); - $permissions = $this->drive->getPermissions(); - $permissionId = null; - foreach ($permissions as $permission) { - $grantedToV2 = $permission->getGrantedToV2(); - if ($grantedToV2 && $grantedToV2->getUser() && $grantedToV2->getUser()->getDisplayName() === 'Marie Curie') { - $permissionId = $permission->getId(); - } - } - - $this->assertIsString($permissionId, "Permission not found of user Marie Curie"); - - $isDriveShareDeleted = $this->drive->deletePermission($permissionId); - $this->assertTrue($isDriveShareDeleted); - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testSetRole(): void - { - $this->initUser('marie', 'radioactivity'); - - $marie = $this->ocis->getUsers('marie')[0]; - - $managerRole = null; - - $driveRoles = $this->drive->getRoles(); - foreach ($driveRoles as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Manager')) { - $managerRole = $role; - break; - } - } - $this->assertInstanceOf(SharingRole::class, $managerRole, "manager role not found"); - $this->drive->invite($marie, $managerRole); - $nonManagerRoleFound = false; - foreach ($driveRoles as $role) { - if ($role->getId() !== self::getPermissionsRoleIdByName('Manager')) { - $nonManagerRoleFound = true; - $permissions = $this->drive->getPermissions(); - $permissionId = null; - foreach ($permissions as $permission) { - $grantedToV2 = $permission->getGrantedToV2(); - if ($grantedToV2 && $grantedToV2->getUser() && $grantedToV2->getUser()->getDisplayName() === 'Marie Curie') { - $permissionId = $permission->getId(); - } - } - - $this->assertIsString($permissionId, "Permission not found of user Marie Curie"); - $isRoleSet = $this->drive->setPermissionRole($permissionId, $role); - - $this->assertTrue($isRoleSet, "Failed to set role"); - } - } - $this->assertTrue($nonManagerRoleFound, "Only the Manager role exists. setPermissionRole was never called"); - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testSetExpirationDate(): void - { - $this->initUser('marie', 'radioactivity'); - - $marie = $this->ocis->getUsers('marie')[0]; - - $managerRole = null; - - foreach ($this->drive->getRoles() as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Manager')) { - $managerRole = $role; - break; - } - } - $this->assertInstanceOf(SharingRole::class, $managerRole, "manager role not found"); - $tomorrow = new \DateTimeImmutable('tomorrow'); - - $oneYearTime = new \DateTimeImmutable(date('Y-m-d', strtotime('+1 year'))); - - $this->drive->invite($marie, $managerRole, $tomorrow); - $permissions = $this->drive->getPermissions(); - $permissionId = null; - foreach ($permissions as $permission) { - $grantedToV2 = $permission->getGrantedToV2(); - if ($grantedToV2 && $grantedToV2->getUser() && $grantedToV2->getUser()->getDisplayName() === 'Marie Curie') { - $permissionId = $permission->getId(); - } - } - - $this->assertIsString($permissionId, "Permission not found of user Marie Curie"); - - $isExpirationDateUpdated = $this->drive->setPermissionExpiration($permissionId, $oneYearTime); - $this->assertTrue($isExpirationDateUpdated, "Expected expiration date to be updated"); - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testDriveInviteToGroup(): void - { - $marieOcis = $this->initUser('marie', 'radioactivity'); - - $marie = $this->ocis->getUsers('marie')[0]; - - $philosophyHatersGroup = $this->ocis->createGroup( - 'philosophyhaters', - 'philosophy haters group', - ); - $this->createdGroups = [$philosophyHatersGroup]; - $philosophyHatersGroup->addUser($marie); - - $managerRole = null; - - $shareRoles = $this->drive->getRoles(); - foreach ($shareRoles as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Manager')) { - $managerRole = $role; - break; - } - } - - $this->assertInstanceOf(SharingRole::class, $managerRole, "manager role not found"); - - $this->drive->invite($philosophyHatersGroup, $managerRole); - $receivedInvitationDrive = $marieOcis->getDriveById($this->drive->getId()); - - $this->assertSame( - $this->drive->getId(), - $receivedInvitationDrive->getId(), - "Expected driveId to be " . $this->drive->getId() - . " but found " . $receivedInvitationDrive->getId(), - ); - $this->assertSame( - $this->drive->getName(), - $receivedInvitationDrive->getName(), - "Expected shared drive name to be " . $this->drive->getName() . " but found " . $receivedInvitationDrive->getName(), - ); - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testGetDriveShareResourceByReceiver(): void - { - $marieOcis = $this->initUser('marie', 'radioactivity'); - - $marie = $this->ocis->getUsers('marie')[0]; - $this->drive->createFolder('myfolder'); - - $managerRole = null; - - $shareRoles = $this->drive->getRoles(); - foreach ($shareRoles as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Manager')) { - $managerRole = $role; - break; - } - } - - $this->assertInstanceOf(SharingRole::class, $managerRole, "manager role not found"); - - $this->drive->invite($marie, $managerRole); - $receivedInvitationDrive = $marieOcis->getDriveById($this->drive->getId()); - - $this->assertSame( - $this->drive->getName(), - $receivedInvitationDrive->getName(), - "Expected shared drive name to be " . $this->drive->getName() . " but found " . $receivedInvitationDrive->getName(), - ); - $this->assertSame( - 'myfolder', - $receivedInvitationDrive->getResources()[0]->getName(), - "Expected resource name to be myfolder" - . " but found " . $receivedInvitationDrive->getResources()[0]->getName(), - ); - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testGetMyDriveForDriveShareReceiver(): void - { - $katherineOcis = $this->getOcis('katherine', 'gemini'); - $katherineDrive = $katherineOcis->createDrive('katherine Project Drive'); - $this->createdDrives[] = $katherineDrive->getId(); - $katherine = $this->ocis->getUsers('katherine')[0]; - - $managerRole = null; - - $shareRoles = $this->drive->getRoles(); - foreach ($shareRoles as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Manager')) { - $managerRole = $role; - break; - } - } - - $this->assertInstanceOf(SharingRole::class, $managerRole, "manager role not found"); - - $this->drive->invite($katherine, $managerRole); - - $katherineDrives = $katherineOcis->getMyDrives(); - $projectDriveFound = false; - - foreach ($katherineDrives as $drive) { - if ($drive->getType() === DriveType::PROJECT) { - $projectDriveFound = true; - $this->assertThat( - $drive->getName(), - $this->logicalOr( - $this->equalTo('katherine Project Drive'), - $this->equalTo('test drive'), - ), - "Expected drivename to be either:" - . "'katherine Project Drive' or 'test drive' but found " - . $drive->getName(), - ); - } - } - - $this->assertTrue($projectDriveFound, "No project drive was found for Katherine"); - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testReceiverInviteOtherUserToDriveShare(): void - { - $marieOcis = $this->initUser('marie', 'radioactivity'); - $katherineOcis = $this->getOcis('katherine', 'gemini'); - $katherine = $this->ocis->getUsers('katherine')[0]; - $marie = $this->ocis->getUsers('marie')[0]; - $managerRole = null; - $shareRoles = $this->drive->getRoles(); - foreach ($shareRoles as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Manager')) { - $managerRole = $role; - break; - } - } - $this->assertInstanceOf(SharingRole::class, $managerRole, "manager role not found"); - - $this->drive->invite($marie, $managerRole); - $marieReceivedProjectDrive = $marieOcis->getDriveById($this->drive->getId()); - $this->assertSame( - $this->drive->getId(), - $marieReceivedProjectDrive->getId(), - "Expected driveId to be " . $this->drive->getId() - . " but found " . $marieReceivedProjectDrive->getId(), - ); - $marieReceivedProjectDrive->invite($katherine, $managerRole); - $katherineReceivedProjectDrive = $katherineOcis->getDriveById($this->drive->getId()); - $this->assertSame( - $this->drive->getName(), - $katherineReceivedProjectDrive->getName(), - "Expected shared drive name to be " . $this->drive->getName() . " but found " . $katherineReceivedProjectDrive->getName(), - ); - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testReceiverInviteOtherUserToDriveShareWithNoInvitePermission(): void - { - $marieOcis = $this->initUser('marie', 'radioactivity'); - $this->initUser('katherine', 'gemini'); - $katherine = $this->ocis->getUsers('katherine')[0]; - $marie = $this->ocis->getUsers('marie')[0]; - $shareRoles = $this->drive->getRoles(); - $viewerRole = null; - foreach ($shareRoles as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Space Viewer')) { - $viewerRole = $role; - break; - } - } - $this->assertInstanceOf(SharingRole::class, $viewerRole, "Space viewer role not found"); - $this->drive->invite($marie, $viewerRole); - $marieReceivedProjectDrive = $marieOcis->getDriveById($this->drive->getId()); - $this->expectException(ForbiddenException::class); - $this->expectExceptionMessage("accessDenied - add grant: error: permission denied:"); - $marieReceivedProjectDrive->invite($katherine, $viewerRole); - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testReceiverUpdatesDriveShareRole(): void - { - $marieOcis = $this->initUser('marie', 'radioactivity'); - $marie = $this->ocis->getUsers('marie')[0]; - - $shareRoles = $this->drive->getRoles(); - $managerRole = null; - foreach ($shareRoles as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Manager')) { - $managerRole = $role; - break; - } - } - $this->assertInstanceOf(SharingRole::class, $managerRole, "manager role not found"); - - $driveInvitation = $this->drive->invite($marie, $managerRole); - $permissionId = $driveInvitation->getId(); - $this->assertIsString($permissionId, "Permission not found of user Marie Curie"); - $receivedInvitationDrive = $marieOcis->getDriveById($this->drive->getId()); - $shareRoles = $receivedInvitationDrive->getRoles(); - $spaceViewerRole = null; - foreach ($shareRoles as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Space Viewer')) { - $spaceViewerRole = $role; - break; - } - } - $this->assertInstanceOf(SharingRole::class, $spaceViewerRole, "Space viewer role not found"); - $isRoleSet = $receivedInvitationDrive->setPermissionRole($permissionId, $spaceViewerRole); - $this->assertTrue($isRoleSet, "Failed to set role id"); - } - - /** - * @throws ForbiddenException - * @throws InvalidResponseException - * @throws BadRequestException - * @throws EndPointNotImplementedException - * @throws UnauthorizedException - * @throws HttpException - * @throws NotFoundException - * @throws InternalServerErrorException - * @throws \Exception - */ - public function testReceiverUpdatesDriveShareRoleNotEnoughPermission(): void - { - $marieOcis = $this->initUser('marie', 'radioactivity'); - $marie = $this->ocis->getUsers('marie')[0]; - $shareRoles = $this->drive->getRoles(); - $spaceViewerRole = null; - foreach ($shareRoles as $role) { - if ($role->getId() === self::getPermissionsRoleIdByName('Space Viewer')) { - $spaceViewerRole = $role; - break; - } - } - $this->assertInstanceOf(SharingRole::class, $spaceViewerRole, "Space viewer role not found"); - - $driveInvitation = $this->drive->invite($marie, $spaceViewerRole); - $permissionId = $driveInvitation->getId(); - $this->assertIsString($permissionId, "Permission not found of user Marie Curie"); - $receivedInvitationDrive = $marieOcis->getDriveById($this->drive->getId()); - $shareRoles = $receivedInvitationDrive->getRoles(); - $this->assertNotEmpty($shareRoles, "no roles found for the drive that was shared with Marie Curie"); - - foreach ($shareRoles as $role) { - if (getenv('OCIS_VERSION') === "stable") { - $this->expectException(InternalServerErrorException::class); - } else { - $this->expectException(ForbiddenException::class); - } - $this->expectExceptionMessage("error committing share to storage grant"); - $receivedInvitationDrive->setPermissionRole($permissionId, $role); - } + $einsteinOcis = $this->initUser('einstein', 'relativity'); + $einstein = $einsteinOcis->getUsers('einstein')[0]; + $share = $this->drive->createLink($einstein, 'view', 'P@$$w0rd', 'user'); + $shareU = $this->drive->updateLink($share, 'edit'); + $this->assertInstanceOf(ShareLink::class, $shareU); } } diff --git a/tests/integration/Owncloud/OcisPhpSdk/OcisPhpSdkTestCase.php b/tests/integration/Owncloud/OcisPhpSdk/OcisPhpSdkTestCase.php index c6bd6595..ae629f9c 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/OcisPhpSdkTestCase.php +++ b/tests/integration/Owncloud/OcisPhpSdk/OcisPhpSdkTestCase.php @@ -53,35 +53,35 @@ public function setUp(): void $this->tokenUrl = $openIdConfiguration['token_endpoint']; } - public function tearDown(): void - { - $ocis = $this->getOcis('admin', 'admin'); - foreach ($this->createdDrives as $driveId) { - try { - $drive = $ocis->getDriveById($driveId); - $drive->disable(); - $drive->delete(); - } catch (NotFoundException) { - // ignore, we don't care if the drive was already deleted - } + // public function tearDown(): void + // { + // $ocis = $this->getOcis('admin', 'admin'); + // foreach ($this->createdDrives as $driveId) { + // try { + // $drive = $ocis->getDriveById($driveId); + // $drive->disable(); + // $drive->delete(); + // } catch (NotFoundException) { + // // ignore, we don't care if the drive was already deleted + // } - } - foreach ($this->createdGroups as $group) { - $group->delete(); - } - $this->createdGroups = []; + // } + // foreach ($this->createdGroups as $group) { + // $group->delete(); + // } + // $this->createdGroups = []; - foreach ($this->createdResources as $driveId => $resources) { - $drive = $ocis->getDriveById($driveId); - foreach ($resources as $resource) { - try { - $drive->deleteResource($resource); - } catch (NotFoundException) { - // ignore, we don't care if the resource was already deleted - } - } - } - } + // foreach ($this->createdResources as $driveId => $resources) { + // $drive = $ocis->getDriveById($driveId); + // foreach ($resources as $resource) { + // try { + // $drive->deleteResource($resource); + // } catch (NotFoundException) { + // // ignore, we don't care if the resource was already deleted + // } + // } + // } + // } protected function getGuzzleClient(): Client {