From 9e287925315181a4e4ebfd9d1a3020cf6ea16029 Mon Sep 17 00:00:00 2001 From: prajwol Date: Wed, 27 Dec 2023 16:37:29 +0545 Subject: [PATCH] added test to check group members have received shares using me/drive/sharedWithMe --- .../apiSharingNg/shareInvitations.feature | 761 ++++++++++++++++++ .../features/bootstrap/SharingNgContext.php | 61 +- 2 files changed, 804 insertions(+), 18 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/shareInvitations.feature b/tests/acceptance/features/apiSharingNg/shareInvitations.feature index 35888e53380..690fa0718a0 100644 --- a/tests/acceptance/features/apiSharingNg/shareInvitations.feature +++ b/tests/acceptance/features/apiSharingNg/shareInvitations.feature @@ -580,3 +580,764 @@ Feature: Send a sharing invitations | permissions/delete | | deleted/delete | | permissions/deny | + + + Scenario Outline: send share invitation for file to group with different roles + Given user "Carol" has been created with default attributes and without skeleton files + And group "grp1" has been created + And the following users have been added to the following groups + | username | groupname | + | Brian | grp1 | + | Carol | grp1 | + And user "Alice" has uploaded file with content "to share" to "/textfile1.txt" + And user "Alice" has sent the following share invitation using the Graph API: + | resourceType | file | + | resource | /textfile1.txt | + | space | Personal | + | sharee | grp1 | + | shareType | group | + | role | | + When user "Brian" lists the resources shared with him using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "name", + "parentReference", + "remoteItem" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "name": { + "type": "string", + "enum": [ + "textfile1.txt" + ] + }, + "parentReference": { + "type": "object", + "required": [ + "driveId", + "driveType" + ], + "properties": { + "driveId": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "driveType": { + "type": "string", + "enum": ["personal"] + } + } + }, + "remoteItem": { + "type": "object", + "required": [ + "createdBy", + "file", + "id", + "name", + "shared", + "size" + ], + "properties": { + "createdBy": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + }, + "file": { + "type": "object", + "required": [ + "mimeType" + ], + "properties": { + "mimeType": { + "type": "string", + "pattern": "text/plain" + } + } + }, + "id": { + "type": "string", + "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + }, + "name": { + "type": "string", + "enum": [ + "textfile1.txt" + ] + }, + "shared": { + "type": "object", + "required": [ + "sharedBy", + "owner" + ], + "properties": { + "owner": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + }, + "sharedBy": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + } + } + }, + "size": { + "type": "number", + "enum": [ + 8 + ] + } + } + } + } + } + } + } + } + """ + When user "Carol" lists the resources shared with her using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "name", + "parentReference", + "remoteItem" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "name": { + "type": "string", + "enum": [ + "textfile1.txt" + ] + }, + "parentReference": { + "type": "object", + "required": [ + "driveId", + "driveType" + ], + "properties": { + "driveId": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "driveType": { + "type": "string", + "enum": ["personal"] + } + } + }, + "remoteItem": { + "type": "object", + "required": [ + "createdBy", + "file", + "id", + "name", + "shared", + "size" + ], + "properties": { + "createdBy": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + }, + "file": { + "type": "object", + "required": [ + "mimeType" + ], + "properties": { + "mimeType": { + "type": "string", + "pattern": "text/plain" + } + } + }, + "id": { + "type": "string", + "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + }, + "name": { + "type": "string", + "enum": [ + "textfile1.txt" + ] + }, + "shared": { + "type": "object", + "required": [ + "sharedBy", + "owner" + ], + "properties": { + "owner": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + }, + "sharedBy": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + } + } + }, + "size": { + "type": "number", + "enum": [ + 8 + ] + } + } + } + } + } + } + } + } + """ + Examples: + | role | + | Viewer | + | File Editor | + | Co Owner | + | Manager | + + + Scenario Outline: send share invitation for folder to group with different roles + Given user "Carol" has been created with default attributes and without skeleton files + And group "grp1" has been created + And the following users have been added to the following groups + | username | groupname | + | Brian | grp1 | + | Carol | grp1 | + And user "Alice" has created folder "FolderToShare" + And user "Alice" has sent the following share invitation using the Graph API: + | resourceType | folder | + | resource | FolderToShare | + | space | Personal | + | sharee | grp1 | + | shareType | group | + | role | | + When user "Brian" lists the resources shared with him using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "id", + "remoteItem" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "name": { + "type": "string", + "enum": [ + "FolderToShare" + ] + }, + "parentReference": { + "type": "object", + "required": [ + "driveId", + "driveType" + ], + "properties": { + "driveId": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "driveType": { + "type": "string", + "enum": ["personal"] + } + } + }, + "remoteItem": { + "type": "object", + "required": [ + "createdBy", + "folder", + "id", + "name", + "shared", + "size" + ], + "properties": { + "createdBy": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + }, + "id": { + "type": "string", + "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + }, + "name": { + "type": "string", + "enum": [ + "FolderToShare" + ] + }, + "shared": { + "type": "object", + "required": [ + "sharedBy", + "owner" + ], + "properties": { + "owner": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + }, + "sharedBy": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + } + } + }, + "size": { + "type": "number", + "enum": [ + 0 + ] + } + } + } + } + } + } + } + } + """ + When user "Carol" lists the resources shared with her using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "id", + "remoteItem" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "name": { + "type": "string", + "enum": [ + "FolderToShare" + ] + }, + "parentReference": { + "type": "object", + "required": [ + "driveId", + "driveType" + ], + "properties": { + "driveId": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "driveType": { + "type": "string", + "enum": ["personal"] + } + } + }, + "remoteItem": { + "type": "object", + "required": [ + "createdBy", + "folder", + "id", + "name", + "shared", + "size" + ], + "properties": { + "createdBy": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + }, + "id": { + "type": "string", + "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + }, + "name": { + "type": "string", + "enum": [ + "FolderToShare" + ] + }, + "shared": { + "type": "object", + "required": [ + "sharedBy", + "owner" + ], + "properties": { + "owner": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + }, + "sharedBy": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + } + } + } + } + } + } + }, + "size": { + "type": "number", + "enum": [ + 0 + ] + } + } + } + } + } + } + } + } + """ + Examples: + | role | + | Viewer | + | Editor | + | Co Owner | + | Uploader | + | Manager | diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 9828ffbb6ac..5b3ae18561d 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -24,6 +24,8 @@ use PHPUnit\Framework\Assert; use TestHelpers\GraphHelper; use Behat\Gherkin\Node\TableNode; +use Psr\Http\Message\ResponseInterface; +use GuzzleHttp\Exception\GuzzleException; require_once 'bootstrap.php'; @@ -84,15 +86,14 @@ public function theUserPermissionsListOfResource(string $user, string $fileOrFol } /** - * @When /^user "([^"]*)" sends the following share invitation using the Graph API:$/ - * * @param string $user * @param TableNode $table * - * @return void - * @throws Exception + * @return ResponseInterface + * @throws JsonException + * @throws GuzzleException */ - public function userSendsTheFollowingShareInvitationUsingTheGraphApi(string $user, TableNode $table): void { + public function sendShareInvitation(string $user, TableNode $table): ResponseInterface { $rows = $table->getRowsHash(); $spaceId = ($this->spacesContext->getSpaceByName($user, $rows['space']))["id"]; @@ -107,22 +108,46 @@ public function userSendsTheFollowingShareInvitationUsingTheGraphApi(string $use $role = $rows['role'] ?? null; $permission = $rows['permission'] ?? null; - $this->featureContext->setResponse( - GraphHelper::sendSharingInvitation( - $this->featureContext->getBaseUrl(), - $this->featureContext->getStepLineRef(), - $user, - $this->featureContext->getPasswordForUser($user), - $spaceId, - $itemId, - $shareeId, - $rows['shareType'], - $role, - $permission - ) + return GraphHelper::sendSharingInvitation( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $spaceId, + $itemId, + $shareeId, + $rows['shareType'], + $role, + $permission ); } + /** + * @Given user :user has sent the following share invitation using the Graph API: + * + * @param string $user + * @param TableNode $table + * + * @return void + */ + public function userHasSentTheFollowingShareInvitationUsingTheGraphApi(string $user, TableNode $table): void { + $response = $this->sendShareInvitation($user, $table); + $this->featureContext->theHttpStatusCodeShouldBe(200, "", $response); + } + + /** + * @When /^user "([^"]*)" sends the following share invitation using the Graph API:$/ + * + * @param string $user + * @param TableNode $table + * + * @return void + * @throws Exception + */ + public function userSendsTheFollowingShareInvitationUsingTheGraphApi(string $user, TableNode $table): void { + $this->featureContext->setResponse($this->sendShareInvitation($user, $table)); + } + /** * @When /^user "([^"]*)" creates the following link share using the Graph API:$/ *