adding test for listing permission of a project space (#8551)

This commit is contained in:
nirajacharya2
2024-03-04 16:54:01 +05:45
committed by GitHub
parent 3b79c1c40a
commit 28d53fee78
2 changed files with 191 additions and 16 deletions
@@ -91,6 +91,34 @@ class SharingNgContext implements Context {
);
}
/**
* @param string $user
* @param string $fileOrFolder (file|folder)
* @param string $space
* @param string $resource
*
* @return ResponseInterface
* @throws Exception
*/
public function getPermissionsList(string $user, string $fileOrFolder, string $space, ?string $resource = ''):ResponseInterface {
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
if ($fileOrFolder === 'folder') {
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);
} else {
$itemId = $this->spacesContext->getFileId($user, $space, $resource);
}
return GraphHelper::getPermissionsList(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId,
$itemId
);
}
/**
* @When /^user "([^"]*)" gets permissions list for (folder|file) "([^"]*)" of the space "([^"]*)" using the Graph API$/
*
@@ -102,23 +130,24 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception
*/
public function theUserPermissionsListOfResource(string $user, string $fileOrFolder, string $resource, string $space):void {
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
if ($fileOrFolder === 'folder') {
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);
} else {
$itemId = $this->spacesContext->getFileId($user, $space, $resource);
}
public function userGetsPermissionsListForResourceOfTheSpaceUsingTheGraphiAPI(string $user, string $fileOrFolder, string $resource, string $space):void {
$this->featureContext->setResponse(
GraphHelper::getPermissionsList(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId,
$itemId
)
$this->getPermissionsList($user, $fileOrFolder, $space, $resource)
);
}
/**
* @When /^user "([^"]*)" lists the permissions of space "([^"]*)" using the Graph API$/
*
* @param string $user
* @param string $space
*
* @return void
* @throws Exception
*/
public function userListsThePermissionsOfSpaceUsingTheGraphApi($user, $space):void {
$this->featureContext->setResponse(
$this->getPermissionsList($user, 'folder', $space)
);
}