mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-22 12:59:23 -05:00
added test to send share invitation to multiple groups at once
This commit is contained in:
@@ -1581,8 +1581,8 @@ class GraphHelper {
|
||||
* @param string $password
|
||||
* @param string $spaceId
|
||||
* @param string $itemId
|
||||
* @param string $shareeId
|
||||
* @param string $shareType
|
||||
* @param array $shareeIds
|
||||
* @param array $shareTypes
|
||||
* @param string|null $permissionsRole
|
||||
* @param string|null $permissionsAction
|
||||
* @param string|null $expireDate
|
||||
@@ -1598,8 +1598,8 @@ class GraphHelper {
|
||||
string $password,
|
||||
string $spaceId,
|
||||
string $itemId,
|
||||
string $shareeId,
|
||||
string $shareType,
|
||||
array $shareeIds,
|
||||
array $shareTypes,
|
||||
?string $permissionsRole,
|
||||
?string $permissionsAction,
|
||||
?string $expireDate
|
||||
@@ -1607,10 +1607,13 @@ class GraphHelper {
|
||||
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/invite");
|
||||
$body = [];
|
||||
|
||||
$recipients['objectId'] = $shareeId;
|
||||
$recipients['@libre.graph.recipient.type'] = $shareType;
|
||||
|
||||
$body['recipients'] = [$recipients];
|
||||
foreach ($shareeIds as $index => $shareeId) {
|
||||
$shareType = $shareTypes[$index];
|
||||
$body['recipients'][] = [
|
||||
"@libre.graph.recipient.type" => $shareType,
|
||||
"objectId" => $shareeId
|
||||
];
|
||||
}
|
||||
|
||||
if ($permissionsRole !== null) {
|
||||
$roleId = self::getPermissionsRoleIdByName($permissionsRole);
|
||||
|
||||
@@ -979,3 +979,70 @@ Feature: Send a sharing invitations
|
||||
| Co Owner | folder | FolderToShare |
|
||||
| Uploader | folder | FolderToShare |
|
||||
| Manager | folder | FolderToShare |
|
||||
|
||||
|
||||
Scenario Outline: try to send sharing invitation to multiple groups
|
||||
Given these users have been created with default attributes and without skeleton files:
|
||||
| username |
|
||||
| Carol |
|
||||
| Bob |
|
||||
And group "grp1" has been created
|
||||
And group "grp2" has been created
|
||||
And the following users have been added to the following groups
|
||||
| username | groupname |
|
||||
| Brian | grp1 |
|
||||
| Carol | grp2 |
|
||||
| Bob | grp2 |
|
||||
And user "Alice" has uploaded file with content "to share" to "/textfile1.txt"
|
||||
And user "Alice" has created folder "FolderToShare"
|
||||
When user "Alice" sends the following share invitation using the Graph API:
|
||||
| resourceType | <resource-type> |
|
||||
| resource | <path> |
|
||||
| space | Personal |
|
||||
| sharee | grp1, grp2 |
|
||||
| shareType | group, group |
|
||||
| permissionsRole | <permissions-role> |
|
||||
Then the HTTP status code should be "400"
|
||||
And the JSON data of the response should match
|
||||
"""
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"error"
|
||||
],
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"code",
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"invalidRequest"
|
||||
]
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Key: 'DriveItemInvite.Recipients' Error:Field validation for 'Recipients' failed on the 'len' tag"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
Examples:
|
||||
| permissions-role | resource-type | path |
|
||||
| Viewer | file | /textfile1.txt |
|
||||
| File Editor | file | /textfile1.txt |
|
||||
| Co Owner | file | /textfile1.txt |
|
||||
| Manager | file | /textfile1.txt |
|
||||
| Viewer | folder | FolderToShare |
|
||||
| Editor | folder | FolderToShare |
|
||||
| Co Owner | folder | FolderToShare |
|
||||
| Uploader | folder | FolderToShare |
|
||||
| Manager | folder | FolderToShare |
|
||||
|
||||
@@ -143,9 +143,16 @@ class SharingNgContext implements Context {
|
||||
? $this->spacesContext->getResourceId($user, $rows['space'], $rows['resource'])
|
||||
: $this->spacesContext->getFileId($user, $rows['space'], $rows['resource']);
|
||||
|
||||
$shareeId = ($rows['shareType'] === 'user')
|
||||
? $this->featureContext->getAttributeOfCreatedUser($rows['sharee'], 'id')
|
||||
: $this->featureContext->getAttributeOfCreatedGroup($rows['sharee'], 'id');
|
||||
$sharees = array_map('trim', explode(',', $rows['sharee']));
|
||||
$shareTypes = array_map('trim', explode(',', $rows['shareType']));
|
||||
|
||||
$shareeIds = [];
|
||||
foreach ($sharees as $index => $sharee) {
|
||||
$shareType = $shareTypes[$index];
|
||||
$shareeIds[] = ($shareType === 'user')
|
||||
? $this->featureContext->getAttributeOfCreatedUser($sharee, 'id')
|
||||
: $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id');
|
||||
}
|
||||
|
||||
$permissionsRole = $rows['permissionsRole'] ?? null;
|
||||
$permissionsAction = $rows['permissionsAction'] ?? null;
|
||||
@@ -158,8 +165,8 @@ class SharingNgContext implements Context {
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$spaceId,
|
||||
$itemId,
|
||||
$shareeId,
|
||||
$rows['shareType'],
|
||||
$shareeIds,
|
||||
$shareTypes,
|
||||
$permissionsRole,
|
||||
$permissionsAction,
|
||||
$expireDate
|
||||
|
||||
Reference in New Issue
Block a user