From dd1284428243a8adc762e7d5acf34f29f2fba2cf Mon Sep 17 00:00:00 2001 From: nirajacharya2 <122071597+nirajacharya2@users.noreply.github.com> Date: Thu, 14 Dec 2023 14:44:27 +0545 Subject: [PATCH] adding test for file version of a share in a projectspace (#7829) --- tests/acceptance/config/behat.yml | 1 + .../fileVersionByFileID.feature | 32 +++++++++++++++++++ .../bootstrap/FilesVersionsContext.php | 23 +++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 tests/acceptance/features/apiSpacesDavOperation/fileVersionByFileID.feature diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index e955d84748f..e09ee589736 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -242,6 +242,7 @@ default: contexts: - FeatureContext: *common_feature_context_params - WebDavPropertiesContext: + - FilesVersionsContext: apiLocks: paths: diff --git a/tests/acceptance/features/apiSpacesDavOperation/fileVersionByFileID.feature b/tests/acceptance/features/apiSpacesDavOperation/fileVersionByFileID.feature new file mode 100644 index 00000000000..ca9cfa02ecf --- /dev/null +++ b/tests/acceptance/features/apiSpacesDavOperation/fileVersionByFileID.feature @@ -0,0 +1,32 @@ +Feature: checking file versions using file id + As a user + I want to share file outside of the space + So that other users can access the file + + + Scenario Outline: check the file versions of a shared file + Given these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + And using spaces DAV path + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "Project1" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "Project1" with content "hello world version 1" to "text.txt" + And we save it into "FILEID" + And user "Alice" has uploaded a file inside space "Project1" with content "hello world version 1.1" to "text.txt" + And user "Alice" has created a share inside of space "Project1" with settings: + | path | text.txt | + | shareWith | Brian | + | role | | + And using new DAV path + When user "Alice" gets the number of versions of file "/text.txt" using file-id path "/meta/<>/v" + Then the HTTP status code should be "207" + And the number of versions should be "1" + When user "Brian" tries to get the number of versions of file "/text.txt" using file-id path "/meta/<>/v" + Then the HTTP status code should be "403" + Examples: + | role | + | editor | + | viewer | + | all | diff --git a/tests/acceptance/features/bootstrap/FilesVersionsContext.php b/tests/acceptance/features/bootstrap/FilesVersionsContext.php index 9959515c061..ff1914b04ec 100644 --- a/tests/acceptance/features/bootstrap/FilesVersionsContext.php +++ b/tests/acceptance/features/bootstrap/FilesVersionsContext.php @@ -101,6 +101,29 @@ public function getFileVersions( ); } + /** + * @When user :user gets the number of versions of file :resource using file-id path :endpoint + * @When user :user tries to get the number of versions of file :resource using file-id path :endpoint + * + * @param string $user + * @param string $endpoint + * + * @return void + */ + public function userGetsTheNumberOfVersionsOfFileOfTheSpace(string $user, string $endpoint):void { + $this->featureContext->setResponse( + $this->featureContext->makeDavRequest( + $user, + "PROPFIND", + $endpoint, + null, + null, + null, + (string)$this->featureContext->getDavPathVersion() + ) + ); + } + /** * @When user :user gets the version metadata of file :file *