add tests for new role space editor withour versions
Signed-off-by: prashant-gurung899 <prasantgrg777@gmail.com>
This commit is contained in:
@@ -16,6 +16,21 @@ use Psr\Http\Message\ResponseInterface;
|
|||||||
* A helper class for managing Graph API requests
|
* A helper class for managing Graph API requests
|
||||||
*/
|
*/
|
||||||
class GraphHelper {
|
class GraphHelper {
|
||||||
|
public const DEFAULT_PERMISSIONS_ROLES = [
|
||||||
|
'Viewer' => 'b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5',
|
||||||
|
'Editor' => 'fb6c3e19-e378-47e5-b277-9732f9de6e21',
|
||||||
|
'File Editor' => '2d00ce52-1fc2-4dbc-8b95-a73b73395f5a',
|
||||||
|
'Uploader' => '1c996275-f1c9-4e71-abdf-a42f6495e960',
|
||||||
|
'Space Viewer' => 'a8d5fe5e-96e3-418d-825b-534dbdf22b99',
|
||||||
|
'Space Editor' => '58c63c02-1d89-4572-916a-870abc5a1b7d',
|
||||||
|
'Manager' => '312c0871-5ef7-4b3a-85b6-0e4074c64049',
|
||||||
|
];
|
||||||
|
|
||||||
|
public const ADDITIONAL_PERMISSIONS_ROLES = [
|
||||||
|
'Secure viewer' => 'aa97fe03-7980-45ac-9e50-b325749fd7e6',
|
||||||
|
'Space Editor Without Versions' => '3284f2d5-0070-4ad8-ac40-c247f7c1fb27',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
@@ -1657,31 +1672,13 @@ class GraphHelper {
|
|||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getPermissionsRoleIdByName(
|
public static function getPermissionsRoleIdByName(string $permissionsRole): string {
|
||||||
string $permissionsRole
|
$allPermissionsRoles = array_merge(self::DEFAULT_PERMISSIONS_ROLES, self::ADDITIONAL_PERMISSIONS_ROLES);
|
||||||
): string {
|
if (\array_key_exists($permissionsRole, $allPermissionsRoles)) {
|
||||||
switch ($permissionsRole) {
|
return $allPermissionsRoles[$permissionsRole];
|
||||||
case 'Viewer':
|
|
||||||
return 'b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5';
|
|
||||||
case 'Space Viewer':
|
|
||||||
return 'a8d5fe5e-96e3-418d-825b-534dbdf22b99';
|
|
||||||
case 'Editor':
|
|
||||||
return 'fb6c3e19-e378-47e5-b277-9732f9de6e21';
|
|
||||||
case 'Space Editor':
|
|
||||||
return '58c63c02-1d89-4572-916a-870abc5a1b7d';
|
|
||||||
case 'File Editor':
|
|
||||||
return '2d00ce52-1fc2-4dbc-8b95-a73b73395f5a';
|
|
||||||
case 'Co Owner':
|
|
||||||
return '3a4ba8e9-6a0d-4235-9140-0e7a34007abe';
|
|
||||||
case 'Uploader':
|
|
||||||
return '1c996275-f1c9-4e71-abdf-a42f6495e960';
|
|
||||||
case 'Manager':
|
|
||||||
return '312c0871-5ef7-4b3a-85b6-0e4074c64049';
|
|
||||||
case 'Secure viewer':
|
|
||||||
return 'aa97fe03-7980-45ac-9e50-b325749fd7e6';
|
|
||||||
default:
|
|
||||||
throw new \Exception('Role ' . $permissionsRole . ' not found');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new \Exception("Role '$permissionsRole' not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1693,29 +1690,13 @@ class GraphHelper {
|
|||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getPermissionNameByPermissionRoleId(
|
public static function getPermissionNameByPermissionRoleId(string $permissionsRoleId): string {
|
||||||
string $permissionsRoleId
|
$allPermissionsRoles = array_merge(self::DEFAULT_PERMISSIONS_ROLES, self::ADDITIONAL_PERMISSIONS_ROLES);
|
||||||
): string {
|
$roleName = array_search($permissionsRoleId, $allPermissionsRoles);
|
||||||
switch ($permissionsRoleId) {
|
if ($roleName) {
|
||||||
case 'b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5':
|
return $roleName;
|
||||||
return 'Viewer';
|
|
||||||
case 'fb6c3e19-e378-47e5-b277-9732f9de6e21':
|
|
||||||
return 'Editor';
|
|
||||||
case '2d00ce52-1fc2-4dbc-8b95-a73b73395f5a':
|
|
||||||
return 'File Editor';
|
|
||||||
case '1c996275-f1c9-4e71-abdf-a42f6495e960':
|
|
||||||
return 'Uploader';
|
|
||||||
case 'a8d5fe5e-96e3-418d-825b-534dbdf22b99':
|
|
||||||
return 'Space Viewer';
|
|
||||||
case '58c63c02-1d89-4572-916a-870abc5a1b7d':
|
|
||||||
return 'Space Editor';
|
|
||||||
case '312c0871-5ef7-4b3a-85b6-0e4074c64049':
|
|
||||||
return 'Manager';
|
|
||||||
case 'aa97fe03-7980-45ac-9e50-b325749fd7e6':
|
|
||||||
return 'Secure viewer';
|
|
||||||
default:
|
|
||||||
throw new \Exception('Permission role id: ' . $permissionsRoleId . ' not found');
|
|
||||||
}
|
}
|
||||||
|
throw new \Exception("Permission role id: '$permissionsRoleId' not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ use Behat\Behat\Context\Context;
|
|||||||
use Behat\Gherkin\Node\TableNode;
|
use Behat\Gherkin\Node\TableNode;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use TestHelpers\OcisConfigHelper;
|
use TestHelpers\OcisConfigHelper;
|
||||||
|
use TestHelpers\GraphHelper;
|
||||||
use PHPUnit\Framework\Assert;
|
use PHPUnit\Framework\Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,6 +76,31 @@ class OcisConfigContext implements Context {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given the administrator has enabled the permissions role :role
|
||||||
|
*
|
||||||
|
* @param string $role
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function theAdministratorHasEnabledTheRole(string $role): void {
|
||||||
|
$roleId = GraphHelper::getPermissionsRoleIdByName($role);
|
||||||
|
$defaultRoles = array_values(GraphHelper::DEFAULT_PERMISSIONS_ROLES);
|
||||||
|
|
||||||
|
if (!\in_array($role, $defaultRoles)) {
|
||||||
|
$defaultRoles[] = $roleId;
|
||||||
|
}
|
||||||
|
$envs = [
|
||||||
|
"GRAPH_AVAILABLE_ROLES" => implode(',', $defaultRoles),
|
||||||
|
];
|
||||||
|
$response = OcisConfigHelper::reConfigureOcis($envs);
|
||||||
|
Assert::assertEquals(
|
||||||
|
200,
|
||||||
|
$response->getStatusCode(),
|
||||||
|
"Failed to enable role $role"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given the config :configVariable has been set to path :path
|
* @Given the config :configVariable has been set to path :path
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -315,6 +315,7 @@ default:
|
|||||||
- FilesVersionsContext:
|
- FilesVersionsContext:
|
||||||
- SharingNgContext:
|
- SharingNgContext:
|
||||||
- SettingsContext:
|
- SettingsContext:
|
||||||
|
- OcisConfigContext:
|
||||||
|
|
||||||
apiLocks:
|
apiLocks:
|
||||||
paths:
|
paths:
|
||||||
|
|||||||
@@ -2248,7 +2248,6 @@ Feature: Send a sharing invitations
|
|||||||
| Space Viewer | role not applicable to this resource |
|
| Space Viewer | role not applicable to this resource |
|
||||||
| Space Editor | role not applicable to this resource |
|
| Space Editor | role not applicable to this resource |
|
||||||
| Manager | role not applicable to this resource |
|
| Manager | role not applicable to this resource |
|
||||||
| Co Owner | Key: 'DriveItemInvite.Roles' Error:Field validation for 'Roles' failed on the 'available_role' tag |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: try to send share invitation with different re-sharing permissions
|
Scenario Outline: try to send share invitation with different re-sharing permissions
|
||||||
|
|||||||
@@ -164,3 +164,14 @@ Feature: checking file versions using file id
|
|||||||
| source | destination |
|
| source | destination |
|
||||||
| / | folder/ |
|
| / | folder/ |
|
||||||
| folder/ | / |
|
| folder/ | / |
|
||||||
|
|
||||||
|
@env-config
|
||||||
|
Scenario: check the versions of a file in a shared space as editor without versions role
|
||||||
|
Given the administrator has enabled the permissions role "Space Editor Without Versions"
|
||||||
|
And user "Alice" has sent the following space share invitation:
|
||||||
|
| space | Project1 |
|
||||||
|
| sharee | Brian |
|
||||||
|
| shareType | user |
|
||||||
|
| permissionsRole | Space Editor Without Versions |
|
||||||
|
When user "Brian" gets the number of versions of file "/text.txt" using file-id path "/meta/<<FILEID>>/v"
|
||||||
|
Then the HTTP status code should be "403"
|
||||||
|
|||||||
Reference in New Issue
Block a user