From 8f0b536ef75c552703d84e5e541d99727e6a5c31 Mon Sep 17 00:00:00 2001 From: Sabin Panta <64484313+S-Panta@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:35:09 +0545 Subject: [PATCH] [tests-only][full-ci]added test with step definition for mounting share when auto accept env set to false (#8623) * added test with step definition for accepting pending share * addressing review --- tests/TestHelpers/GraphHelper.php | 35 +++++++++++++++++++ .../apiSharingNg/mountOrUnmountShare.feature | 32 +++++++++++++++++ .../features/bootstrap/SharingNgContext.php | 26 ++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/tests/TestHelpers/GraphHelper.php b/tests/TestHelpers/GraphHelper.php index 53e0a272e..8e6ee0d59 100644 --- a/tests/TestHelpers/GraphHelper.php +++ b/tests/TestHelpers/GraphHelper.php @@ -1922,4 +1922,39 @@ class GraphHelper { self::getRequestHeaders() ); } + + /** + * @param string $baseUrl + * @param string $xRequestId + * @param string $user + * @param string $password + * @param string $itemId + * @param string $shareSpaceId + * + * @return ResponseInterface + * @throws GuzzleException + */ + public static function mountShare( + string $baseUrl, + string $xRequestId, + string $user, + string $password, + string $itemId, + string $shareSpaceId + ): ResponseInterface { + $body = [ + "remoteItem" => [ + "id" => $itemId + ] + ]; + $url = self::getBetaFullUrl($baseUrl, "drives/$shareSpaceId/root/children"); + return HttpRequestHelper::post( + $url, + $xRequestId, + $user, + $password, + self::getRequestHeaders(), + \json_encode($body) + ); + } } diff --git a/tests/acceptance/features/apiSharingNg/mountOrUnmountShare.feature b/tests/acceptance/features/apiSharingNg/mountOrUnmountShare.feature index 106eb027a..72b860deb 100644 --- a/tests/acceptance/features/apiSharingNg/mountOrUnmountShare.feature +++ b/tests/acceptance/features/apiSharingNg/mountOrUnmountShare.feature @@ -54,3 +54,35 @@ Feature: mount or unmount incoming share | resource | | textfile0.txt | | FolderToShare | + + + Scenario Outline: mount shared resource when auto-sync is disabled + Given user "Brian" has disabled the auto-sync share + And user "Alice" has uploaded file with content "hello world" to "/textfile0.txt" + And user "Alice" has created folder "folder" + And user "Alice" has sent the following share invitation: + | resource | | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When user "Brian" mounts share "" offered by "Alice" from "Personal" space using the Graph API + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "@client.synchronize" + ], + "properties": { + "@client.synchronize": { + "const": true + } + } + } + """ + Examples: + | resource | + | textfile0.txt | + | folder | diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 9b7f64d59..a972082ff 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -594,4 +594,30 @@ class SharingNgContext implements Context { $this->featureContext->setResponse($this->unmountShare($user, $itemId, $shareSpaceId)); $this->featureContext->pushToLastStatusCodesArrays(); } + + /** + * @When user :user mounts share :share offered by :offeredBy from :space space using the Graph API + * + * @param string $user + * @param string $share + * @param string $offeredBy + * @param string $space + * + * @return void + * @throws Exception + */ + public function userMountsShareOfferedByFromSpaceUsingTheGraphApi(string $user, string $share, string $offeredBy, string $space):void { + $share = ltrim($share, '/'); + $itemId = $this->spacesContext->getResourceId($offeredBy, $space, $share); + $shareSpaceId = FeatureContext::SHARES_SPACE_ID; + $response = GraphHelper::mountShare( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $this->featureContext->getActualUsername($user), + $this->featureContext->getPasswordForUser($user), + $itemId, + $shareSpaceId + ); + $this->featureContext->setResponse($response); + } }