From 95c93f63b70bcb92696563a6ac401dfded567f2b Mon Sep 17 00:00:00 2001 From: Sabin Panta <64484313+S-Panta@users.noreply.github.com> Date: Wed, 15 May 2024 12:58:22 +0545 Subject: [PATCH] [tests-only][full-ci]adding tests for enable disable sync when sharer is deleted (#9130) * adding tests for enable disable sync when sharer is deleted * addhressing reviews --- .../enableDisableShareSync.feature | 229 ++++++++++++++++++ .../features/bootstrap/Provisioning.php | 3 +- .../features/bootstrap/SharingNgContext.php | 4 + 3 files changed, 235 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/features/apiSharingNg/enableDisableShareSync.feature b/tests/acceptance/features/apiSharingNg/enableDisableShareSync.feature index a05a6f29d6..5aed5dcf33 100644 --- a/tests/acceptance/features/apiSharingNg/enableDisableShareSync.feature +++ b/tests/acceptance/features/apiSharingNg/enableDisableShareSync.feature @@ -413,3 +413,232 @@ Feature: enable or disable sync of incoming shares } } """ + + + Scenario: try to enable sync of shared resource from Personal Space when sharer is deleted + Given user "Brian" has disabled the auto-sync share + And user "Alice" has uploaded file with content "hello world" to "/textfile0.txt" + And we save it into "FILEID" + And user "Alice" has sent the following resource share invitation: + | resource | textfile0.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And the user "Admin" has deleted a user "Alice" + 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": "converting to drive items failed" + } + } + } + } + } + """ + + + Scenario: try to disable sync of shared resource from Personal Space when sharer is deleted + Given user "Brian" has disabled the auto-sync share + And user "Alice" has uploaded file with content "hello world" to "/textfile0.txt" + And we save it into "FILEID" + And user "Alice" has sent the following resource share invitation: + | resource | textfile0.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And the user "Admin" has deleted a user "Alice" + When user "Brian" tries to disable sync of share "textfile0.txt" 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": "unmounting share failed" + } + } + } + } + } + """ + + + Scenario: enable sync of shared resource from Project Space when sharer is deleted + Given user "Brian" has disabled the auto-sync share + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "NewSpace" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "NewSpace" with content "hello world" to "/textfile0.txt" + And we save it into "FILEID" + And user "Alice" has sent the following resource share invitation: + | resource | textfile0.txt | + | space | NewSpace | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And the user "Admin" has deleted a user "Alice" + When user "Brian" enables share sync of a resource "<>" using the Graph API + Then the HTTP status code should be "201" + And user "Brian" should have sync enabled for share "textfile0.txt" + + + Scenario: disable sync of shared resource from Project Space when sharer is deleted + Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "NewSpace" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "NewSpace" with content "hello world" to "/textfile0.txt" + And we save it into "FILEID" + And user "Alice" has sent the following resource share invitation: + | resource | textfile0.txt | + | space | NewSpace | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And the user "Admin" has deleted a user "Alice" + When user "Brian" disables sync of share "textfile0.txt" using the Graph API + Then the HTTP status code should be "204" + And user "Brian" should have sync disabled for share "textfile0.txt" + + + Scenario: try to enable sync of group shared resource when sharer is deleted + Given user "Brian" has disabled the auto-sync share + And group "grp1" has been created + And user "Alice" has been added to group "grp1" + And user "Brian" has been added to group "grp1" + And user "Alice" has uploaded file with content "hello world" to "/textfile0.txt" + And we save it into "FILEID" + And user "Alice" has sent the following resource share invitation: + | resource | textfile0.txt | + | space | Personal | + | sharee | grp1 | + | shareType | group | + | permissionsRole | Viewer | + And group "grp1" has been deleted + 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": "mounting share failed" + } + } + } + } + } + """ + + + Scenario: try to disable sync of group shared resource when sharer is deleted + Given user "Brian" has disabled the auto-sync share + And group "grp1" has been created + And user "Alice" has been added to group "grp1" + And user "Brian" has been added to group "grp1" + And user "Alice" has uploaded file with content "hello world" to "/textfile0.txt" + And we save it into "FILEID" + And user "Alice" has sent the following resource share invitation: + | resource | textfile0.txt | + | space | Personal | + | sharee | grp1 | + | shareType | group | + | permissionsRole | Viewer | + And group "grp1" has been deleted + When user "Brian" tries to disable sync of share "textfile0.txt" 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": "unmounting share failed" + } + } + } + } + } + """ diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 21eace93a4..2c0a6301d5 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -1881,6 +1881,7 @@ trait Provisioning { $response = $this->graphContext->deleteGroupWithName($group); $this->theHTTPStatusCodeShouldBe(204, "", $response); } + $this->rememberThatGroupIsNotExpectedToExist($group); Assert::assertFalse( $this->groupExists($group), "Group '$group' should not exist but does exist" @@ -1937,7 +1938,7 @@ trait Provisioning { $response = $this->graphContext->removeUserFromGroup($group, $user); $this->TheHTTPStatusCodeShouldBe(204, '', $response); } - + if (OcisHelper::isTestingOnReva()) { $fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/users/$user/groups"; $response = HttpRequestHelper::get( diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index a419687917..1d091ffdcf 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -1001,6 +1001,7 @@ class SharingNgContext implements Context { /** * @When user :user disables sync of share :share using the Graph API + * @When user :user tries to disable sync of share :share using the Graph API * * @param string $user * @@ -1080,7 +1081,10 @@ class SharingNgContext implements Context { } /** + * step definition for enabling sync for items for non-existing group|user|space sharer + * * @When user :user tries to enable share sync of a resource :resource using the Graph API + * @When user :user enables share sync of a resource :resource using the Graph API * * @param string $user * @param string $resource