From 263a3dc4e20e1aa2bbf2e856a853c4eed8f5834c Mon Sep 17 00:00:00 2001 From: prashant-gurung899 Date: Mon, 24 Jun 2024 16:57:36 +0545 Subject: [PATCH] remove unused index paramater Signed-off-by: prashant-gurung899 --- .../features/apiDownloads/download.feature | 7 ++-- tests/acceptance/features/apiOcm/ocm.feature | 3 +- .../changingFilesShare.feature | 2 +- .../bootstrap/FilesVersionsContext.php | 36 +++++++++++-------- .../features/bootstrap/SpacesContext.php | 6 ++-- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/tests/acceptance/features/apiDownloads/download.feature b/tests/acceptance/features/apiDownloads/download.feature index ea88f2f57..dc9438913 100644 --- a/tests/acceptance/features/apiDownloads/download.feature +++ b/tests/acceptance/features/apiDownloads/download.feature @@ -60,7 +60,10 @@ Feature: Download file in project space | Brian | - Scenario: user with role viewer cannot get the old version of the file in the project space + Scenario: user with role viewer cannot get versions of a file in the project space Given user "Alice" has uploaded a file inside space "download file" with content "new content" to "file.txt" - When user "Bob" tries to get version of the file "file.txt" with the index "1" of the space "download file" using the WebDAV API + And user "Alice" has uploaded a file inside space "download file" with content "newest content" to "file.txt" + When user "Bob" tries to get versions of the file "file.txt" from the space "download file" using the WebDAV API + Then the HTTP status code should be "403" + When user "Bob" tries to download version of the file "file.txt" with the index "1" of the space "download file" using the WebDAV API Then the HTTP status code should be "403" diff --git a/tests/acceptance/features/apiOcm/ocm.feature b/tests/acceptance/features/apiOcm/ocm.feature index 42aeaaea7..753dfe4ba 100755 --- a/tests/acceptance/features/apiOcm/ocm.feature +++ b/tests/acceptance/features/apiOcm/ocm.feature @@ -10,11 +10,10 @@ Feature: an user shares resources usin ScienceMesh application And user "Brian" has been created with default attributes and without skeleton files - Scenario: user generates invitation + Scenario: user generates invitation Given using server "LOCAL" When "Alice" generates invitation Then the HTTP status code should be "200" When using server "REMOTE" And "Brian" accepts invitation Then the HTTP status code should be "200" - \ No newline at end of file diff --git a/tests/acceptance/features/apiSpacesShares/changingFilesShare.feature b/tests/acceptance/features/apiSpacesShares/changingFilesShare.feature index 0d3a0b402..79eaaeb29 100644 --- a/tests/acceptance/features/apiSpacesShares/changingFilesShare.feature +++ b/tests/acceptance/features/apiSpacesShares/changingFilesShare.feature @@ -59,7 +59,7 @@ Feature: change shared resource When user "Alice" downloads version of the file "/textfile1.txt" with the index "1" of the space "Personal" using the WebDAV API Then the HTTP status code should be "200" And the downloaded content should be "old content version 2" - When user "Brian" tries to get version of the file "/textfile1.txt" with the index "1" of the space "Shares" using the WebDAV API + When user "Brian" tries to get versions of the file "/textfile1.txt" from the space "Shares" using the WebDAV API Then the HTTP status code should be "403" Examples: | user-role | diff --git a/tests/acceptance/features/bootstrap/FilesVersionsContext.php b/tests/acceptance/features/bootstrap/FilesVersionsContext.php index 52510552f..bf3b89e53 100644 --- a/tests/acceptance/features/bootstrap/FilesVersionsContext.php +++ b/tests/acceptance/features/bootstrap/FilesVersionsContext.php @@ -178,7 +178,11 @@ class FilesVersionsContext implements Context { $user = $this->featureContext->getActualUsername($user); $fileId = $this->featureContext->getFileIdForPath($user, $path); Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)"); - $responseXml = $this->listVersionFolder($user, $fileId, 1); + $response = $this->listVersionFolder($user, $fileId, 1); + $responseXml = HttpRequestHelper::getResponseXml( + $response, + __METHOD__ + ); $xmlPart = $responseXml->xpath("//d:response/d:href"); //restoring the version only works with DAV path v2 $destinationUrl = $this->featureContext->getBaseUrl() . "/" . @@ -236,7 +240,11 @@ class FilesVersionsContext implements Context { * @throws Exception */ public function assertFileVersionsCount(string $user, string $fileId, int $expectedCount):void { - $responseXml = $this->listVersionFolder($user, $fileId, 1); + $response = $this->listVersionFolder($user, $fileId, 1); + $responseXml = HttpRequestHelper::getResponseXml( + $response, + __METHOD__ + ); $actualCount = \count($responseXml->xpath("//d:prop/d:getetag")) - 1; if ($actualCount === -1) { $actualCount = 0; @@ -307,11 +315,10 @@ class FilesVersionsContext implements Context { $user = $this->featureContext->getActualUsername($user); $fileId = $this->featureContext->getFileIdForPath($user, $path); Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)"); - $responseXml = $this->listVersionFolder( - $user, - $fileId, - 1, - ['getcontentlength'] + $response = $this->listVersionFolder($user, $fileId, 1, ['getcontentlength']); + $responseXml = HttpRequestHelper::getResponseXml( + $response, + __METHOD__ ); $xmlPart = $responseXml->xpath("//d:prop/d:getcontentlength"); Assert::assertEquals( @@ -370,7 +377,11 @@ class FilesVersionsContext implements Context { $fileId = $this->featureContext->getFileIdForPath($user, $path); Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)"); $index = (int)$index; - $responseXml = $this->listVersionFolder($user, $fileId, 1); + $response = $this->listVersionFolder($user, $fileId, 1); + if ($response->getStatusCode() === 403) { + return $response; + } + $responseXml = new SimpleXMLElement($response->getBody()->getContents()); $xmlPart = $responseXml->xpath("//d:response/d:href"); if (!isset($xmlPart[$index])) { Assert::fail( @@ -482,7 +493,7 @@ class FilesVersionsContext implements Context { * @param int $folderDepth * @param string[]|null $properties * - * @return SimpleXMLElement + * @return ResponseInterface * @throws Exception */ public function listVersionFolder( @@ -490,7 +501,7 @@ class FilesVersionsContext implements Context { string $fileId, int $folderDepth, ?array $properties = null - ):SimpleXMLElement { + ):ResponseInterface { if (!$properties) { $properties = [ 'getetag' @@ -508,10 +519,7 @@ class FilesVersionsContext implements Context { (string) $folderDepth, "versions" ); - return HttpRequestHelper::getResponseXml( - $response, - __METHOD__ - ); + return $response; } /** diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index f1c2f6443..2f690673d 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -3150,6 +3150,7 @@ class SpacesContext implements Context { /** * @When /^user "([^"]*)" downloads version of the file "([^"]*)" with the index "([^"]*)" of the space "([^"]*)" using the WebDAV API$/ + * @When /^user "([^"]*)" tries to download version of the file "([^"]*)" with the index "([^"]*)" of the space "([^"]*)" using the WebDAV API$/ * * @param string $user * @param string $fileName @@ -3171,17 +3172,16 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" tries to get version of the file "([^"]*)" with the index "([^"]*)" of the space "([^"]*)" using the WebDAV API$/ + * @When user :user tries to get versions of the file :file from the space :space using the WebDAV API * * @param string $user * @param string $file - * @param string $index * @param string $spaceName * * @return void * @throws Exception */ - public function userTriesToDownloadFileVersions(string $user, string $file, string $index, string $spaceName):void { + public function userTriesToDownloadFileVersions(string $user, string $file, string $spaceName):void { $this->setSpaceIDByName($user, $spaceName); $this->featureContext->setResponse( $this->filesVersionsContext->getFileVersions($user, $file)