From bc2410900a61552d743531abe29d096d703d4d94 Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Tue, 12 Mar 2024 15:35:53 +0545 Subject: [PATCH 1/5] Added tests for PROPFIND as sharee --- .../apiSharingNg/propfindShares.feature | 45 +++++++++++ .../features/bootstrap/SpacesContext.php | 77 ++++++++++++++----- 2 files changed, 101 insertions(+), 21 deletions(-) create mode 100644 tests/acceptance/features/apiSharingNg/propfindShares.feature diff --git a/tests/acceptance/features/apiSharingNg/propfindShares.feature b/tests/acceptance/features/apiSharingNg/propfindShares.feature new file mode 100644 index 000000000..7fb15876e --- /dev/null +++ b/tests/acceptance/features/apiSharingNg/propfindShares.feature @@ -0,0 +1,45 @@ +Feature: propfind a shares + As a user + I want to check the PROPFIND response + So that I can make sure that the response contains all the relevant values + + Background: + Given these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + | Carol | + + + Scenario: sharee PROPFIND a shares when multiple user shares resources with same name + Given user "Alice" has uploaded file with content "to share" to "textfile.txt" + And user "Carol" has uploaded file with content "to share" to "textfile.txt" + And user "Alice" has sent the following share invitation: + | resource | textfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And user "Carol" has sent the following share invitation: + | resource | textfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When user "Brian" sends PROPFIND request from the space "Shares" to the resource "/" with depth "1" using the WebDAV API + Then the HTTP status code should be "207" + And the "PROPFIND" response to user "Brian" should contain a space "Shares" with these key and value pairs: + | key | value | + | oc:fileid | UUIDof:Shares | + And the "PROPFIND" response to user "Brian" should contain a mountpoint "Shares" with these key and value pairs: + | key | value | + | oc:name | textfile.txt | + | oc:permissions | SR | + | oc:size | 8 | + | d:getcontenttype | text/plain | + And the "PROPFIND" response to user "Brian" should contain a mountpoint "Shares" with these key and value pairs: + | key | value | + | oc:name | textfile (1).txt | + | oc:permissions | SR | + | oc:size | 8 | + | d:getcontenttype | text/plain | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 6ce5bd0b2..8622fee5d 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -3598,10 +3598,12 @@ class SpacesContext implements Context { /** * @When /^user "([^"]*)" sends PROPFIND request to space "([^"]*)" using the WebDAV API$/ * @When /^user "([^"]*)" sends PROPFIND request from the space "([^"]*)" to the resource "([^"]*)" using the WebDAV API$/ + * @When /^user "([^"]*)" sends PROPFIND request from the space "([^"]*)" to the resource "([^"]*)" with depth "([^"]*)" using the WebDAV API$/ * * @param string $user * @param string $spaceName * @param ?string $resource + * @param ?string $folderDepth * * @return void * @@ -3609,9 +3611,9 @@ class SpacesContext implements Context { * * @throws GuzzleException */ - public function userSendsPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = ""): void { + public function userSendsPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?string $folderDepth = "0"): void { $this->featureContext->setResponse( - $this->sendPropfindRequestToSpace($user, $spaceName, $resource) + $this->sendPropfindRequestToSpace($user, $spaceName, $resource, null, $folderDepth) ); } @@ -3646,15 +3648,36 @@ class SpacesContext implements Context { * @param string $spaceName * @param string|null $resource * @param array|null $headers + * @param string|null $folderDepth * * @return ResponseInterface * @throws GuzzleException * * @throws JsonException */ - public function sendPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?array $headers = []): ResponseInterface { + public function sendPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?array $headers = [], ?string $folderDepth = "0"): ResponseInterface { $this->setSpaceIDByName($user, $spaceName); - $properties = ['oc:permissions','oc:file-parent','oc:fileid','oc:share-types','oc:privatelink','d:resourcetype','oc:size','oc:name','d:getcontenttype','oc:tags','d:lockdiscovery','d:activelock']; + $properties = [ + 'oc:id', + 'oc:fileid', + 'oc:spaceid', + 'oc:file-parent', + 'oc:shareid', + 'oc:name', + 'd:displayname', + 'd:getetag', + 'oc:permissions', + 'd:resourcetype', + 'oc:size', + 'd:getlastmodified', + 'oc:tags', + 'oc:favorite', + 'oc:share-types', + 'oc:privatelink', + 'd:getcontenttype', + 'd:lockdiscovery', + 'd:activelock' + ]; return WebDavHelper::propfind( $this->featureContext->getBaseUrl(), $this->featureContext->getActualUsername($user), @@ -3662,10 +3685,10 @@ class SpacesContext implements Context { $resource, $properties, $this->featureContext->getStepLineRef(), - "0", + $folderDepth, "files", WebDavHelper::DAV_VERSION_SPACES, - "", + null, $headers ); } @@ -3718,50 +3741,62 @@ class SpacesContext implements Context { $xmlRes = $this->featureContext->getResponseXml(); foreach ($table->getHash() as $row) { $findItem = $row['key']; + $xmlResponses = $xmlRes->xpath("//d:response/d:propstat/d:prop/$findItem"); Assert::assertNotEmpty( - $xmlRes->xpath("//d:response/d:propstat/d:prop/$findItem"), + $xmlResponses, 'The xml response "' . $xmlRes->asXML() . '" did not contain "<' . $findItem . '>" element' ); - $responseValue = $xmlRes->xpath("//d:response/d:propstat/d:prop/$findItem")[0]->__toString(); + + $responseValues = []; + foreach ($xmlResponses as $xmlResponse) { + $responseValues[] = $xmlResponse[0]->__toString(); + } + $value = str_replace('UUIDof:', '', $row['value']); switch ($findItem) { case "oc:fileid": $resourceType = $xmlRes->xpath("//d:response/d:propstat/d:prop/d:getcontenttype")[0]->__toString(); if ($method === 'PROPFIND') { if (!$resourceType) { - Assert::assertEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response'); + Assert::assertContainsEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response'); } else { - Assert::assertEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response'); + Assert::assertContainsEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response'); } } else { if ($resourceType === 'httpd/unix-directory') { - Assert::assertEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response'); + Assert::assertContainsEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response'); } else { - Assert::assertEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response'); + Assert::assertContainsEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response'); } } break; case "oc:file-parent": - Assert::assertEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong file-parentId in the response'); + Assert::assertContainsEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong file-parentId in the response'); break; case "oc:privatelink": - Assert::assertEquals($this->getPrivateLink($user, $spaceNameOrMountPoint), $responseValue, 'cannot find private link for space or resource in the response'); + Assert::assertContainsEquals($this->getPrivateLink($user, $spaceNameOrMountPoint), $responseValues, 'cannot find private link for space or resource in the response'); break; case "oc:tags": // The value should be a comma-separated string of tag names. // We do not care what order they happen to be in, so compare as sorted lists. $expectedTags = \explode(",", $value); - $expectedTags = \sort($expectedTags); - $actualTags = \explode(",", $responseValue); - $actualTags = \sort($actualTags); - Assert::assertEquals($expectedTags, $actualTags, "wrong $findItem in the response"); + \sort($expectedTags); + $expectedTags = \implode(",", $expectedTags); + $actualTags = []; + foreach ($responseValues as $responseValue) { + $responseValue = \explode(",", $responseValue); + \sort($responseValue); + $responseValue = \implode(",", $responseValue); + $actualTags[] = $responseValue; + } + Assert::assertContainsEquals($expectedTags, $actualTags, "wrong $findItem in the response"); break; case "d:lockdiscovery/d:activelock/d:timeout": if ($value === "Infinity") { - Assert::assertEquals($value, $responseValue, "wrong $findItem in the response"); + Assert::assertContainsEquals($value, $responseValues, "wrong $findItem in the response"); } else { // some time may be required between a lock and propfind request. - $responseValue = explode('-', $responseValue); + $responseValue = explode('-', $responseValues[0]); $responseValue = \intval($responseValue[1]); $value = explode('-', $value); $value = \intval($value[1]); @@ -3769,7 +3804,7 @@ class SpacesContext implements Context { } break; default: - Assert::assertEquals($value, $responseValue, "wrong $findItem in the response"); + Assert::assertContainsEquals($value, $responseValues, "wrong $findItem in the response"); break; } } From d48ea766ea41943c9e3b1030f31cee8e398d5b29 Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Wed, 13 Mar 2024 14:26:37 +0545 Subject: [PATCH 2/5] Refactored step to use depth for propfind --- .../features/apiContract/propfind.feature | 10 +++++----- .../features/apiLocks/lockFiles.feature | 18 +++++++++--------- .../acceptance/features/apiSpaces/tag.feature | 16 ++++++++-------- .../features/bootstrap/SpacesContext.php | 9 ++++----- .../bootstrap/WebDavLockingContext.php | 2 +- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/tests/acceptance/features/apiContract/propfind.feature b/tests/acceptance/features/apiContract/propfind.feature index 200ea281c..1e7bf9661 100644 --- a/tests/acceptance/features/apiContract/propfind.feature +++ b/tests/acceptance/features/apiContract/propfind.feature @@ -15,7 +15,7 @@ Feature: Propfind test Scenario: space-admin checks the PROPFIND request of a space Given user "Alice" has uploaded a file inside space "new-space" with content "some content" to "testfile.txt" - When user "Alice" sends PROPFIND request to space "new-space" using the WebDAV API + When user "Alice" sends PROPFIND request to space "new-space" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the following headers should match these regular expressions | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | @@ -33,7 +33,7 @@ Feature: Propfind test And user "Alice" has shared a space "new-space" with settings: | shareWith | Brian | | role | | - When user "Brian" sends PROPFIND request to space "new-space" using the WebDAV API + When user "Brian" sends PROPFIND request to space "new-space" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the following headers should match these regular expressions | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | @@ -56,7 +56,7 @@ Feature: Propfind test And user "Alice" has shared a space "new-space" with settings: | shareWith | Brian | | role | | - When user "Brian" sends PROPFIND request from the space "new-space" to the resource "folderMain" using the WebDAV API + When user "Brian" sends PROPFIND request from the space "new-space" to the resource "folderMain" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response should contain a space "new-space" with these key and value pairs: | key | value | @@ -77,7 +77,7 @@ Feature: Propfind test And user "Alice" has shared a space "new-space" with settings: | shareWith | Brian | | role | | - When user "Brian" sends PROPFIND request from the space "new-space" to the resource "folderMain/subFolder1/subFolder2" using the WebDAV API + When user "Brian" sends PROPFIND request from the space "new-space" to the resource "folderMain/subFolder1/subFolder2" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response should contain a space "new-space" with these key and value pairs: | key | value | @@ -98,7 +98,7 @@ Feature: Propfind test And user "Alice" has shared a space "new-space" with settings: | shareWith | Brian | | role | | - When user "Brian" sends PROPFIND request from the space "new-space" to the resource "testfile.txt" using the WebDAV API + When user "Brian" sends PROPFIND request from the space "new-space" to the resource "testfile.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response should contain a space "new-space" with these key and value pairs: | key | value | diff --git a/tests/acceptance/features/apiLocks/lockFiles.feature b/tests/acceptance/features/apiLocks/lockFiles.feature index dece6da8b..65c181e1e 100644 --- a/tests/acceptance/features/apiLocks/lockFiles.feature +++ b/tests/acceptance/features/apiLocks/lockFiles.feature @@ -15,7 +15,7 @@ Feature: lock files When user "Alice" locks file "textfile.txt" using the WebDAV API setting the following properties | lockscope | exclusive | Then the HTTP status code should be "200" - When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs: | key | value | @@ -37,7 +37,7 @@ Feature: lock files | lockscope | exclusive | | timeout | Second-5000 | Then the HTTP status code should be "200" - When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs: | key | value | @@ -59,7 +59,7 @@ Feature: lock files | lockscope | exclusive | | timeout | Second-3600 | Then the HTTP status code should be "200" - When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs: | key | value | @@ -100,7 +100,7 @@ Feature: lock files | lockscope | exclusive | | timeout | Second-3600 | Then the HTTP status code should be "200" - When user "Brian" sends PROPFIND request from the space "Project" to the resource "textfile.txt" using the WebDAV API + When user "Brian" sends PROPFIND request from the space "Project" to the resource "textfile.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Brian" should contain a space "Project" with these key and value pairs: | key | value | @@ -127,7 +127,7 @@ Feature: lock files | lockscope | exclusive | | timeout | Second-3600 | Then the HTTP status code should be "200" - When user "Brian" sends PROPFIND request from the space "Project" to the resource "textfile.txt" using the WebDAV API + When user "Brian" sends PROPFIND request from the space "Project" to the resource "textfile.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Brian" should contain a space "Project" with these key and value pairs: | key | value | @@ -168,7 +168,7 @@ Feature: lock files When user "Brian" locks file "/Shares/textfile.txt" using the WebDAV API setting the following properties | lockscope | exclusive | Then the HTTP status code should be "200" - When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs: | key | value | @@ -192,7 +192,7 @@ Feature: lock files | lockscope | exclusive | | timeout | Second-3600 | Then the HTTP status code should be "200" - When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs: | key | value | @@ -229,7 +229,7 @@ Feature: lock files | lockscope | exclusive | | timeout | Second-3600 | Then the HTTP status code should be "423" - When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs: | key | value | @@ -250,7 +250,7 @@ Feature: lock files | lockscope | exclusive | | timeout | Second-3600 | Then the HTTP status code should be "423" - When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs: | key | value | diff --git a/tests/acceptance/features/apiSpaces/tag.feature b/tests/acceptance/features/apiSpaces/tag.feature index 652a2380a..8d847e501 100644 --- a/tests/acceptance/features/apiSpaces/tag.feature +++ b/tests/acceptance/features/apiSpaces/tag.feature @@ -26,7 +26,7 @@ Feature: Tag | tag level#1 | | tag with symbols @^$#^%$@%!_+) | Then the HTTP status code should be "200" - When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs: | key | value | @@ -34,7 +34,7 @@ Feature: Tag When user "Alice" creates the following tags for file "folderMain/insideTheFolder.txt" of space "use-tag": | fileTag | Then the HTTP status code should be "200" - When user "Brian" sends PROPFIND request from the space "use-tag" to the resource "folderMain/insideTheFolder.txt" using the WebDAV API + When user "Brian" sends PROPFIND request from the space "use-tag" to the resource "folderMain/insideTheFolder.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs: | key | value | @@ -64,12 +64,12 @@ Feature: Tag | fileTag | | tag with symbol @^$#^%$@%!_+) | Then the HTTP status code should be "200" - When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "folderMain" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "folderMain" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Alice" should contain a mountpoint "Alice Hansen" with these key and value pairs: | key | value | | oc:tags | my tag,important | - When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "file.txt" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "file.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Alice" should contain a mountpoint "Alice Hansen" with these key and value pairs: | key | value | @@ -177,7 +177,7 @@ Feature: Tag When user "Alice" removes the following tags for folder "folderMain" of space "use-tag": | folderTag | | marketing | - And user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" using the WebDAV API + And user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs: | key | value | @@ -255,7 +255,7 @@ Feature: Tag When user "Alice" creates the following tags for folder "folderMain" of space "use-tag": | finance,नेपाल | Then the HTTP status code should be "200" - When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs: | key | value | @@ -263,7 +263,7 @@ Feature: Tag When user "Alice" creates the following tags for file "folderMain/insideTheFolder.txt" of space "use-tag": | file,नेपाल,Tag | Then the HTTP status code should be "200" - When user "Brian" sends PROPFIND request from the space "use-tag" to the resource "folderMain/insideTheFolder.txt" using the WebDAV API + When user "Brian" sends PROPFIND request from the space "use-tag" to the resource "folderMain/insideTheFolder.txt" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs: | key | value | @@ -283,7 +283,7 @@ Feature: Tag When user "Alice" creates the following tags for folder "folderMain" of space "use-tag": | engineering,finance,qa | Then the HTTP status code should be "200" - When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" using the WebDAV API + When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" with depth "0" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs: | key | value | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 8622fee5d..484b05269 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -3596,8 +3596,7 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" sends PROPFIND request to space "([^"]*)" using the WebDAV API$/ - * @When /^user "([^"]*)" sends PROPFIND request from the space "([^"]*)" to the resource "([^"]*)" using the WebDAV API$/ + * @When /^user "([^"]*)" sends PROPFIND request to space "([^"]*)" with depth "([^"]*)" using the WebDAV API$/ * @When /^user "([^"]*)" sends PROPFIND request from the space "([^"]*)" to the resource "([^"]*)" with depth "([^"]*)" using the WebDAV API$/ * * @param string $user @@ -3611,7 +3610,7 @@ class SpacesContext implements Context { * * @throws GuzzleException */ - public function userSendsPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?string $folderDepth = "0"): void { + public function userSendsPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?string $folderDepth = "1"): void { $this->featureContext->setResponse( $this->sendPropfindRequestToSpace($user, $spaceName, $resource, null, $folderDepth) ); @@ -3639,7 +3638,7 @@ class SpacesContext implements Context { $headers[$row['header']] = $row ['value']; } $this->featureContext->setResponse( - $this->sendPropfindRequestToSpace($user, $spaceName, '', $headers) + $this->sendPropfindRequestToSpace($user, $spaceName, '', $headers, '0') ); } @@ -3655,7 +3654,7 @@ class SpacesContext implements Context { * * @throws JsonException */ - public function sendPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?array $headers = [], ?string $folderDepth = "0"): ResponseInterface { + public function sendPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?array $headers = [], ?string $folderDepth = "1"): ResponseInterface { $this->setSpaceIDByName($user, $spaceName); $properties = [ 'oc:id', diff --git a/tests/acceptance/features/bootstrap/WebDavLockingContext.php b/tests/acceptance/features/bootstrap/WebDavLockingContext.php index 3fc79a939..a74135f98 100644 --- a/tests/acceptance/features/bootstrap/WebDavLockingContext.php +++ b/tests/acceptance/features/bootstrap/WebDavLockingContext.php @@ -914,7 +914,7 @@ class WebDavLockingContext implements Context { * @throws GuzzleException */ public function numberOfLockShouldBeReportedInProjectSpace(int $count, string $file, string $spaceName, string $user) { - $response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file); + $response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file, null, '0'); $this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response); $responseXml = $this->featureContext->getResponseXml($response); $xmlPart = $responseXml->xpath("//d:response//d:lockdiscovery/d:activelock"); From 18f156c8803e534100b5342e048b2f2888da77e2 Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Thu, 14 Mar 2024 09:53:43 +0545 Subject: [PATCH 3/5] Separated step implementation --- .../features/bootstrap/SpacesContext.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 484b05269..cc2a02e7b 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -3596,7 +3596,26 @@ class SpacesContext implements Context { } /** + * @When /^user "([^"]*)" sends PROPFIND request to space "([^"]*)" using the WebDAV API$/ * @When /^user "([^"]*)" sends PROPFIND request to space "([^"]*)" with depth "([^"]*)" using the WebDAV API$/ + * + * @param string $user + * @param string $spaceName + * @param ?string $folderDepth + * + * @return void + * + * @throws JsonException + * + * @throws GuzzleException + */ + public function userSendsPropfindRequestToSpaceUsingTheWebdavApi(string $user, string $spaceName, ?string $folderDepth = "1"): void { + $this->featureContext->setResponse( + $this->sendPropfindRequestToSpace($user, $spaceName, "", null, $folderDepth) + ); + } + + /** * @When /^user "([^"]*)" sends PROPFIND request from the space "([^"]*)" to the resource "([^"]*)" with depth "([^"]*)" using the WebDAV API$/ * * @param string $user @@ -3610,7 +3629,7 @@ class SpacesContext implements Context { * * @throws GuzzleException */ - public function userSendsPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?string $folderDepth = "1"): void { + public function userSendsPropfindRequestFromTheSpaceToTheResourceWithDepthUsingTheWebdavApi(string $user, string $spaceName, ?string $resource = "", ?string $folderDepth = "1"): void { $this->featureContext->setResponse( $this->sendPropfindRequestToSpace($user, $spaceName, $resource, null, $folderDepth) ); From c52c3e9db7214eca09732b930757be721ca5b35c Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Fri, 15 Mar 2024 14:18:33 +0545 Subject: [PATCH 4/5] Addressed reviews --- .../acceptance/features/apiSharingNg/propfindShares.feature | 2 +- tests/acceptance/features/bootstrap/SpacesContext.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/propfindShares.feature b/tests/acceptance/features/apiSharingNg/propfindShares.feature index 7fb15876e..6dae19ec0 100644 --- a/tests/acceptance/features/apiSharingNg/propfindShares.feature +++ b/tests/acceptance/features/apiSharingNg/propfindShares.feature @@ -26,7 +26,7 @@ Feature: propfind a shares | sharee | Brian | | shareType | user | | permissionsRole | Viewer | - When user "Brian" sends PROPFIND request from the space "Shares" to the resource "/" with depth "1" using the WebDAV API + When user "Brian" sends PROPFIND request to space "Shares" using the WebDAV API Then the HTTP status code should be "207" And the "PROPFIND" response to user "Brian" should contain a space "Shares" with these key and value pairs: | key | value | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index cc2a02e7b..4ec063d2d 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -3620,8 +3620,8 @@ class SpacesContext implements Context { * * @param string $user * @param string $spaceName - * @param ?string $resource - * @param ?string $folderDepth + * @param string $resource + * @param string $folderDepth * * @return void * @@ -3629,7 +3629,7 @@ class SpacesContext implements Context { * * @throws GuzzleException */ - public function userSendsPropfindRequestFromTheSpaceToTheResourceWithDepthUsingTheWebdavApi(string $user, string $spaceName, ?string $resource = "", ?string $folderDepth = "1"): void { + public function userSendsPropfindRequestFromTheSpaceToTheResourceWithDepthUsingTheWebdavApi(string $user, string $spaceName, string $resource, string $folderDepth): void { $this->featureContext->setResponse( $this->sendPropfindRequestToSpace($user, $spaceName, $resource, null, $folderDepth) ); From 275b10060a8c7fcb7ac8152b0b24012a1be1bc82 Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Fri, 15 Mar 2024 17:18:45 +0545 Subject: [PATCH 5/5] Added issue tag --- tests/acceptance/features/apiSharingNg/propfindShares.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/features/apiSharingNg/propfindShares.feature b/tests/acceptance/features/apiSharingNg/propfindShares.feature index 6dae19ec0..13938fdcf 100644 --- a/tests/acceptance/features/apiSharingNg/propfindShares.feature +++ b/tests/acceptance/features/apiSharingNg/propfindShares.feature @@ -10,7 +10,7 @@ Feature: propfind a shares | Brian | | Carol | - + @issue-4421 Scenario: sharee PROPFIND a shares when multiple user shares resources with same name Given user "Alice" has uploaded file with content "to share" to "textfile.txt" And user "Carol" has uploaded file with content "to share" to "textfile.txt"