Skip to content

Commit

Permalink
[full-ci] [tests-only] Backport PR 8046, 8047 (#8078)
Browse files Browse the repository at this point in the history
* Added test for sending share invitation to user with permissions

* Added test for sending share invitation to group with permissions
  • Loading branch information
grgprarup authored Dec 28, 2023
1 parent bf40d9d commit a3f481f
Show file tree
Hide file tree
Showing 3 changed files with 408 additions and 2 deletions.
12 changes: 11 additions & 1 deletion tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,7 @@ public static function getPermissionsList(
*
* @return string
*
* @throws \Exception
*/
public static function getRoleIdByName(
string $role
Expand All @@ -1568,6 +1569,8 @@ public static function getRoleIdByName(
return '1c996275-f1c9-4e71-abdf-a42f6495e960';
case 'Manager':
return '312c0871-5ef7-4b3a-85b6-0e4074c64049';
default:
throw new \Exception('Role ' . $role . ' not found');
}
}

Expand All @@ -1581,9 +1584,11 @@ public static function getRoleIdByName(
* @param string $shareeId
* @param string $shareType
* @param string|null $role
* @param string|null $permission
*
* @return ResponseInterface
* @throws \JsonException
* @throws \Exception
*/
public static function sendSharingInvitation(
string $baseUrl,
Expand All @@ -1594,7 +1599,8 @@ public static function sendSharingInvitation(
string $itemId,
string $shareeId,
string $shareType,
?string $role
?string $role,
?string $permission
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/invite");
$body = [];
Expand All @@ -1609,6 +1615,10 @@ public static function sendSharingInvitation(
$body['roles'] = [$roleId];
}

if ($permission !== null) {
$body['@libre.graph.permissions.actions'] = ['libre.graph/driveItem/' . $permission];
}

return HttpRequestHelper::post(
$url,
$xRequestId,
Expand Down
Loading

0 comments on commit a3f481f

Please sign in to comment.