From f7fb0bc591268e9bfe195c19c56fb1c489baefa5 Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Fri, 26 Apr 2024 14:20:59 +0545 Subject: [PATCH] [full-ci] [tests-only] Added tests for enabling share sync with empty resource id (#8963) * Added tests for enabling share sync with empty resource id * Addressed reviews --- .../enableDisableShareSync.feature | 41 ++++++++++++++++++- .../features/bootstrap/SharingNgContext.php | 12 ++++-- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/enableDisableShareSync.feature b/tests/acceptance/features/apiSharingNg/enableDisableShareSync.feature index 05918466d..76e82e078 100644 --- a/tests/acceptance/features/apiSharingNg/enableDisableShareSync.feature +++ b/tests/acceptance/features/apiSharingNg/enableDisableShareSync.feature @@ -300,7 +300,8 @@ Feature: enable or disable sync of incoming shares @issue-8724 Scenario: try to enable share sync of a non-existent resource - When user "Brian" tries to enable share sync of a non-existent resource using the Graph API + Given user "Brian" has disabled the auto-sync share + When user "Brian" tries to enable share sync of a resource "nonexistent" using the Graph API Then the HTTP status code should be "400" And the JSON data of the response should match """ @@ -334,3 +335,41 @@ Feature: enable or disable sync of incoming shares } } """ + + + Scenario: try to enable share sync with empty resource id + Given user "Brian" has disabled the auto-sync share + When user "Brian" tries to enable share sync of a resource "" using the Graph API + 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", + "innererror", + "message" + ], + "properties": { + "code" : { + "const": "invalidRequest" + }, + "innererror" : { + "type": "object", + "required": [ + "date", + "request-id" + ] + }, + "message" : { + "const": "invalid id" + } + } + } + } + } + """ diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 80fa52c96..c6bfad345 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -165,7 +165,7 @@ class SharingNgContext implements Context { public function userTriesToListThePermissionsOfSpaceUsingPermissionsEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner):void { $spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"]; $itemId = $this->spacesContext->getResourceId($spaceOwner, $space, ''); - + $this->featureContext->setResponse( GraphHelper::getPermissionsList( $this->featureContext->getBaseUrl(), @@ -741,20 +741,24 @@ class SharingNgContext implements Context { } /** - * @When user :user tries to enable share sync of a non-existent resource using the Graph API + * @When user :user tries to enable share sync of a resource :resource using the Graph API * * @param string $user + * @param string $resource * * @return void + * @throws Exception|GuzzleException */ - public function userTriesToEnablsShareSyncOfNonExistentResourceUsingTheGraphApi(string $user):void { + public function userTriesToEnableShareSyncOfResourceUsingTheGraphApi(string $user, string $resource):void { $shareSpaceId = FeatureContext::SHARES_SPACE_ID; + $itemId = ($resource === 'nonexistent') ? WebDavHelper::generateUUIDv4() : ''; + $response = GraphHelper::enableShareSync( $this->featureContext->getBaseUrl(), $this->featureContext->getStepLineRef(), $this->featureContext->getActualUsername($user), $this->featureContext->getPasswordForUser($user), - WebDavHelper::generateUUIDv4(), + $itemId, $shareSpaceId ); $this->featureContext->setResponse($response);