diff --git a/tests/TestHelpers/GraphHelper.php b/tests/TestHelpers/GraphHelper.php index b24f46516..253e582a2 100644 --- a/tests/TestHelpers/GraphHelper.php +++ b/tests/TestHelpers/GraphHelper.php @@ -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); diff --git a/tests/acceptance/features/apiSharingNg/shareInvitations.feature b/tests/acceptance/features/apiSharingNg/shareInvitations.feature index 827c86299..9fdc189dd 100644 --- a/tests/acceptance/features/apiSharingNg/shareInvitations.feature +++ b/tests/acceptance/features/apiSharingNg/shareInvitations.feature @@ -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 | | + | space | Personal | + | sharee | grp1, grp2 | + | shareType | group, group | + | permissionsRole | | + 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 | diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 281f2def3..eb016d95b 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -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