[tests-only]tests: add tests for removing share permission (#8098)

* tests: add tests for removing share permission

* tests: add cases for project space share

* tests: update test step to use the sharingNg invite endpoint

* tests: address reviews

* tests: address reviews
This commit is contained in:
Swikriti Tripathi
2024-01-04 12:28:07 +05:45
committed by GitHub
parent 7eeb61bcb7
commit 672a38bf98
3 changed files with 221 additions and 17 deletions
+68
View File
@@ -1540,6 +1540,42 @@ class GraphHelper {
);
}
/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $userIdOfShareeUser
* @param string $password
* @param string $spaceId
* @param string $itemId
*
* @return string
*
* @throws GuzzleException
* @throws \JsonException
*/
public static function getSharePermissionId(
string $baseUrl,
string $xRequestId,
string $user,
string $userIdOfShareeUser,
string $password,
string $spaceId,
string $itemId
): string {
$response = self::getPermissionsList($baseUrl, $xRequestId, $user, $password, $spaceId, $itemId);
$permissionList = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
foreach ($permissionList["value"] as $value) {
if ($value["grantedToV2"]["user"]["id"] === $userIdOfShareeUser) {
return $value["id"];
}
}
throw new \Exception(
__METHOD__
. " Cannot find share permission id for user '$user'"
);
}
/**
* Get the role id by name
*
@@ -1701,4 +1737,36 @@ class GraphHelper {
$body
);
}
/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
* @param string $spaceId
* @param string $itemId
* @param string $permissionId
*
* @return ResponseInterface
*
* @throws GuzzleException
*/
public static function deleteSharePermission(
string $baseUrl,
string $xRequestId,
string $user,
string $password,
string $spaceId,
string $itemId,
string $permissionId
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/permissions/$permissionId");
return HttpRequestHelper::delete(
$url,
$xRequestId,
$user,
$password,
self::getRequestHeaders()
);
}
}