From 08922584bca996e32900055e1c454e8f1476e98b Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 1 Oct 2024 12:58:30 +0545 Subject: [PATCH 1/3] test: fix PROPFIND shares space tests --- tests/acceptance/TestHelpers/GraphHelper.php | 14 ++ tests/acceptance/bootstrap/SpacesContext.php | 144 +++++++++--------- .../features/apiContract/propfind.feature | 64 ++++---- .../features/apiContract/sharesReport.feature | 36 ++--- .../features/apiContract/spacesReport.feature | 54 +++---- .../apiContract/spacesSharesReport.feature | 28 ++-- .../features/apiLocks/lockFiles.feature | 18 +-- .../apiSearchContent/extractedProps.feature | 12 +- .../apiSharingNg1/propfindShares.feature | 89 +++-------- .../acceptance/features/apiSpaces/tag.feature | 18 +-- .../propfindByFileId.feature | 12 +- 11 files changed, 229 insertions(+), 260 deletions(-) diff --git a/tests/acceptance/TestHelpers/GraphHelper.php b/tests/acceptance/TestHelpers/GraphHelper.php index e02e8e6344..1024481c4c 100644 --- a/tests/acceptance/TestHelpers/GraphHelper.php +++ b/tests/acceptance/TestHelpers/GraphHelper.php @@ -116,6 +116,7 @@ class GraphHelper { public static function getEtagRegex(): string { return "^\\\"[a-f0-9:.]{1,32}\\\"$"; } + /** * Federated users have a base64 encoded string of {remoteid}@{provider} as their id * This regex matches only non empty base64 encoded strings @@ -126,6 +127,19 @@ class GraphHelper { return '^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$'; } + /** + * @param string $pattern + * + * @return string regex pattern + */ + public static function sanitizeRegexPattern(string $pattern): string { + $pattern = \str_replace("\\\\", "\\", $pattern); + $pattern = \str_replace("/", "\/", $pattern); + $pattern = \preg_replace('/^\^/', '', $pattern); + $pattern = \preg_replace('/\$$/', '', $pattern); + return "/^$pattern$/"; + } + /** * Key name can consist of @@@ * This function separate such key and return its actual value from actual drive response which can be used for assertion diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index 9cf94d8608..3cbf0b3967 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -355,9 +355,11 @@ class SpacesContext implements Context { $this->featureContext->getPasswordForUser($user), ['Depth' => '0'], ); - $responseArray = json_decode(json_encode($this->featureContext->getResponseXml($response)->xpath("//d:response/d:propstat/d:prop/oc:fileid")), true, 512, JSON_THROW_ON_ERROR); - Assert::assertNotEmpty($responseArray, "the PROPFIND response for $folderName is empty"); - return $responseArray[0][0]; + + $this->featureContext->theHttpStatusCodeShouldBe(207, '', $response); + $xmlResponse = $this->featureContext->getResponseXml($response); + $fileId = $xmlResponse->xpath("//d:response/d:propstat/d:prop/oc:fileid")[0]; + return $fileId->__toString(); } /** @@ -3701,9 +3703,8 @@ class SpacesContext implements Context { * @throws GuzzleException */ public function userSendsPropfindRequestFromTheSpaceToTheResourceWithDepthUsingTheWebdavApi(string $user, string $spaceName, string $resource, ?string $folderDepth = "1"): void { - $this->featureContext->setResponse( - $this->sendPropfindRequestToSpace($user, $spaceName, $resource, null, $folderDepth) - ); + $response = $this->sendPropfindRequestToSpace($user, $spaceName, $resource, null, $folderDepth); + $this->featureContext->setResponse($response); } /** @@ -3768,6 +3769,16 @@ class SpacesContext implements Context { 'd:lockdiscovery', 'd:activelock' ]; + + $davPathVersion = $this->featureContext->getDavPathVersion(); + if ($spaceName === 'Shares' && $davPathVersion !== WebDavHelper::DAV_VERSION_SPACES) { + if ($resource === '' || $resource === '/') { + $resource = $spaceName; + } else { + $resource = $spaceName . '/' . $resource; + } + } + return WebDavHelper::propfind( $this->featureContext->getBaseUrl(), $this->featureContext->getActualUsername($user), @@ -3777,34 +3788,18 @@ class SpacesContext implements Context { $this->featureContext->getStepLineRef(), $folderDepth, "files", - $this->featureContext->getDavPathVersion(), + $davPathVersion, null, $headers ); } /** - * @Then /^the "([^"]*)" response should contain a space "([^"]*)" with these key and value pairs:$/ + * @Then /^as user "([^"]*)" the (PROPFIND|REPORT) response should contain a (mountpoint|space) "([^"]*)" with these key and value pairs:$/ * - * @param string $method # method should be either PROPFIND or REPORT - * @param string $space - * @param TableNode $table - * - * @return void - * @throws GuzzleException - * @throws JsonException - */ - public function theResponseShouldContainSpace(string $method, string $space, TableNode $table): void { - $this->featureContext->verifyTableNodeColumns($table, ['key', 'value']); - $this->theResponseShouldContain($method, $this->getSpaceCreator($space), $space, $table); - } - - /** - * @Then /^the "([^"]*)" response to user "([^"]*)" should contain a mountpoint "([^"]*)" with these key and value pairs:$/ - * @Then /^the "([^"]*)" response to user "([^"]*)" should contain a space "([^"]*)" with these key and value pairs:$/ - * - * @param string $method # method should be either PROPFIND or REPORT * @param string $user + * @param string $method # method should be either PROPFIND or REPORT + * @param string $type # type should be either mountpoint or space * @param string $mountPoint * @param TableNode $table * @@ -3812,14 +3807,18 @@ class SpacesContext implements Context { * @throws GuzzleException * @throws JsonException */ - public function theResponseShouldContainMountPoint(string $method, string $user, string $mountPoint, TableNode $table): void { + public function asUsertheXMLResponseShouldContainMountpointWithTheseKeyAndValuePair(string $user, string $method, string $type, string $mountPoint, TableNode $table): void { $this->featureContext->verifyTableNodeColumns($table, ['key', 'value']); - $this->theResponseShouldContain($method, $user, $mountPoint, $table); + if ($this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES && $type === 'space') { + $space = $this->getSpaceByName($user, $mountPoint); + $mountPoint = $space['id']; + } else { + $mountPoint = \rawurlencode($mountPoint); + } + $this->theXMLResponseShouldContain($mountPoint, $table); } /** - * @param string $method # method should be either PROPFIND or REPORT - * @param string $user * @param string $spaceNameOrMountPoint # an entity inside a space, or the space name itself * @param TableNode $table * @@ -3827,77 +3826,72 @@ class SpacesContext implements Context { * @throws GuzzleException * @throws JsonException */ - public function theResponseShouldContain(string $method, string $user, string $spaceNameOrMountPoint, TableNode $table): void { - $xmlRes = $this->featureContext->getResponseXml(); + public function theXMLResponseShouldContain(string $spaceNameOrMountPoint, TableNode $table): void { + $xmlResponse = $this->featureContext->getResponseXml(); + $hrefs = array_map(fn($href) => $href->__toString(), $xmlResponse->xpath("//d:response/d:href")); + + $currentHref = ''; + foreach ($hrefs as $href) { + if (\str_ends_with(\rtrim($href, "/"), "/$spaceNameOrMountPoint")) { + $currentHref = $href; + break; + } + } + foreach ($table->getHash() as $row) { - $findItem = $row['key']; - $xmlResponses = $xmlRes->xpath("//d:response/d:propstat/d:prop/$findItem"); + $itemToFind = $row['key']; + $foundXmlItem = $xmlResponse->xpath("//d:href[text()='$currentHref']/following-sibling::d:propstat//$itemToFind"); Assert::assertNotEmpty( - $xmlResponses, - 'The xml response "' . $xmlRes->asXML() . '" did not contain "<' . $findItem . '>" element' + $foundXmlItem, + 'The xml response "' . $xmlResponse->asXML() . '" did not contain "<' . $itemToFind . '>" element' ); - $responseValues = []; - foreach ($xmlResponses as $xmlResponse) { - $responseValues[] = $xmlResponse[0]->__toString(); - } + $actualValue = $foundXmlItem[0]->__toString(); + $expectedValue = $this->featureContext->substituteInLineCodes($row['value']); - $value = str_replace('UUIDof:', '', $row['value']); - switch ($findItem) { + switch ($itemToFind) { case "oc:fileid": - $resourceType = $xmlRes->xpath("//d:response/d:propstat/d:prop/d:getcontenttype")[0]->__toString(); - if ($method === 'PROPFIND') { - if (!$resourceType) { - Assert::assertContainsEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response'); - } else { - Assert::assertContainsEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response'); - } - } else { - if ($resourceType === 'httpd/unix-directory') { - Assert::assertContainsEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response'); - } else { - Assert::assertContainsEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response'); - } - } + $expectedValue = GraphHelper::sanitizeRegexPattern($expectedValue); + Assert::assertRegExp($expectedValue, $actualValue, 'wrong "fileid" in the response'); break; case "oc:file-parent": - Assert::assertContainsEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong file-parentId in the response'); + $expectedValue = GraphHelper::sanitizeRegexPattern($expectedValue); + Assert::assertRegExp($expectedValue, $actualValue, 'wrong "file-parent" in the response'); break; case "oc:privatelink": - Assert::assertContainsEquals($this->getPrivateLink($user, $spaceNameOrMountPoint), $responseValues, 'cannot find private link for space or resource in the response'); + $expectedValue = GraphHelper::sanitizeRegexPattern($expectedValue); + Assert::assertRegExp($expectedValue, $actualValue, 'wrong "privatelink" 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 = \explode(",", $expectedValue); \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"); + + $actualTags = \explode(",", $actualValue); + \sort($actualTags); + $actualTags = \implode(",", $actualValue); + Assert::assertEquals($expectedTags, $actualTags, "wrong '$itemToFind' in the response"); break; case "d:lockdiscovery/d:activelock/d:timeout": - if ($value === "Infinity") { - Assert::assertContainsEquals($value, $responseValues, "wrong $findItem in the response"); + if ($expectedValue === "Infinity") { + Assert::assertEquals($expectedValue, $actualValue, "wrong '$itemToFind' in the response"); } else { // some time may be required between a lock and propfind request. - $responseValue = explode('-', $responseValues[0]); + $responseValue = explode('-', $actualValue); $responseValue = \intval($responseValue[1]); - $value = explode('-', $value); - $value = \intval($value[1]); - Assert::assertTrue($responseValue >= ($value - 3)); + $expectedValue = explode('-', $expectedValue); + $expectedValue = \intval($expectedValue[1]); + Assert::assertTrue($responseValue >= ($expectedValue - 3)); } break; case "oc:remote-item-id": - Assert::assertContainsEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong remoteItemId in the response'); + $expectedValue = GraphHelper::sanitizeRegexPattern($expectedValue); + Assert::assertRegExp($expectedValue, $actualValue, 'wrong "remote-item-id" in the response'); break; default: - Assert::assertContainsEquals($value, $responseValues, "wrong $findItem in the response"); + Assert::assertEquals($expectedValue, $actualValue, "wrong '$itemToFind' in the response"); break; } } diff --git a/tests/acceptance/features/apiContract/propfind.feature b/tests/acceptance/features/apiContract/propfind.feature index 61c8698854..4c2240d2bf 100644 --- a/tests/acceptance/features/apiContract/propfind.feature +++ b/tests/acceptance/features/apiContract/propfind.feature @@ -19,13 +19,13 @@ Feature: Propfind test 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+)?$/ | - And the "PROPFIND" response should contain a space "new-space" with these key and value pairs: - | key | value | - | oc:fileid | UUIDof:new-space | - | oc:name | new-space | - | oc:permissions | RDNVCKZP | - | oc:privatelink | | - | oc:size | 12 | + And as user "Alice" the PROPFIND response should contain a space "new-space" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:name | new-space | + | oc:permissions | RDNVCKZP | + | oc:privatelink | %base_url%/f/[0-9a-z-$%]+ | + | oc:size | 12 | Scenario Outline: space member with a different role checks the PROPFIND request of a space @@ -39,14 +39,14 @@ Feature: Propfind test 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+)?$/ | - And the "PROPFIND" response should contain a space "new-space" with these key and value pairs: - | key | value | - | oc:fileid | UUIDof:new-space | - | oc:name | new-space | - | oc:permissions | | - | oc:privatelink | | - | oc:size | 12 | - Examples: + And as user "Brian" the PROPFIND response should contain a space "new-space" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:name | new-space | + | oc:permissions | | + | oc:privatelink | %base_url%/f/[0-9a-z-$%]+ | + | oc:size | 12 | + Examples: | space-role | oc-permission | | Manager | RDNVCKZP | | Space Editor | DNVCK | @@ -62,10 +62,10 @@ Feature: Propfind test | permissionsRole | | 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: + And as user "Brian" the PROPFIND response should contain a mountpoint "folderMain" with these key and value pairs: | key | value | - | oc:fileid | UUIDof:folderMain | - | oc:file-parent | UUIDof:new-space | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | | oc:name | folderMain | | oc:permissions | | | oc:size | 0 | @@ -85,13 +85,13 @@ Feature: Propfind test | permissionsRole | | 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 | - | oc:fileid | UUIDof:folderMain/subFolder1/subFolder2 | - | oc:file-parent | UUIDof:folderMain/subFolder1 | - | oc:name | subFolder2 | - | oc:permissions | | - | oc:size | 0 | + And as user "Brian" the PROPFIND response should contain a mountpoint "subFolder2" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | + | oc:name | subFolder2 | + | oc:permissions | | + | oc:size | 0 | Examples: | space-role | oc-permission | | Manager | RDNVCKZP | @@ -108,13 +108,13 @@ Feature: Propfind test | permissionsRole | | 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 | - | oc:fileid | UUIDof:testfile.txt | - | oc:file-parent | UUIDof:new-space | - | oc:name | testfile.txt | - | oc:permissions | | - | oc:size | 12 | + And as user "Brian" the PROPFIND response should contain a mountpoint "testfile.txt" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | + | oc:name | testfile.txt | + | oc:permissions | | + | oc:size | 12 | Examples: | space-role | oc-permission | | Manager | RDNVWZP | diff --git a/tests/acceptance/features/apiContract/sharesReport.feature b/tests/acceptance/features/apiContract/sharesReport.feature index d7c8d16603..b115d0a1ee 100644 --- a/tests/acceptance/features/apiContract/sharesReport.feature +++ b/tests/acceptance/features/apiContract/sharesReport.feature @@ -26,15 +26,15 @@ Feature: REPORT request to Shares space 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+)?$/ | - And the "REPORT" response to user "Brian" should contain a mountpoint "folderMain" with these key and value pairs: + And as user "Brian" the REPORT response should contain a mountpoint "SubFolder1" with these key and value pairs: | key | value | - | oc:fileid | UUIDof:SubFolder1 | - | oc:file-parent | UUIDof:folderMain | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | | oc:shareroot | /folderMain | | oc:name | SubFolder1 | | d:getcontenttype | httpd/unix-directory | | oc:permissions | S | - | oc:remote-item-id | UUIDof:folderMain | + | oc:remote-item-id | %file_id_pattern% | Examples: | dav-path-version | | old | @@ -48,16 +48,16 @@ Feature: REPORT request to Shares space 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+)?$/ | - And the "REPORT" response to user "Brian" should contain a mountpoint "folderMain" with these key and value pairs: - | key | value | - | oc:fileid | UUIDof:SubFolder1/subFOLDER2/frodo.txt | - | oc:file-parent | UUIDof:SubFolder1/subFOLDER2 | - | oc:shareroot | /folderMain | - | oc:name | frodo.txt | - | d:getcontenttype | text/plain | - | oc:permissions | S | - | d:getcontentlength | 34 | - | oc:remote-item-id | UUIDof:folderMain | + And as user "Brian" the REPORT response should contain a mountpoint "frodo.txt" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | + | oc:shareroot | /folderMain | + | oc:name | frodo.txt | + | d:getcontenttype | text/plain | + | oc:permissions | S | + | d:getcontentlength | 34 | + | oc:remote-item-id | %file_id_pattern% | Examples: | dav-path-version | | old | @@ -100,19 +100,19 @@ Feature: REPORT request to Shares space 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+)?$/ | - And the "REPORT" response to user "Brian" should contain a mountpoint "secureFolder" with these key and value pairs: + And as user "Brian" the REPORT response should contain a mountpoint "secureFolder" with these key and value pairs: | key | value | | oc:shareroot | /secureFolder | | oc:name | secureFolder | | d:getcontenttype | httpd/unix-directory | | oc:permissions | SMX | | oc:size | 14 | - | oc:remote-item-id | UUIDof:secureFolder | + | oc:remote-item-id | %file_id_pattern% | When user "Brian" searches for "secure.txt" using the WebDAV API And the following headers should match these regular expressions | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | Then the HTTP status code should be "207" - And the "REPORT" response to user "Brian" should contain a mountpoint "secureFolder" with these key and value pairs: + And as user "Brian" the REPORT response should contain a mountpoint "secure.txt" with these key and value pairs: | key | value | | oc:shareroot | /secureFolder | | oc:name | secure.txt | @@ -140,7 +140,7 @@ Feature: REPORT request to Shares space 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+)?$/ | - And the "REPORT" response to user "Brian" should contain a mountpoint "secure.txt" with these key and value pairs: + And as user "Brian" the REPORT response should contain a mountpoint "secure.txt" with these key and value pairs: | key | value | | oc:shareroot | /secure.txt | | oc:name | secure.txt | diff --git a/tests/acceptance/features/apiContract/spacesReport.feature b/tests/acceptance/features/apiContract/spacesReport.feature index bf84872d43..93c4493782 100644 --- a/tests/acceptance/features/apiContract/spacesReport.feature +++ b/tests/acceptance/features/apiContract/spacesReport.feature @@ -22,14 +22,14 @@ Feature: REPORT request to project space | /testFile.txt | And the following headers should match these regular expressions | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | - And the "REPORT" response to user "Alice" should contain a mountpoint "findData" with these key and value pairs: - | key | value | - | oc:fileid | UUIDof:testFile.txt | - | oc:file-parent | UUIDof:findData | - | oc:name | testFile.txt | - | d:getcontenttype | text/plain | - | oc:permissions | RDNVW | - | d:getcontentlength | 12 | + And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | + | oc:name | testFile.txt | + | d:getcontenttype | text/plain | + | oc:permissions | RDNVW | + | d:getcontentlength | 12 | Scenario: check the response of the searched sub-file @@ -42,14 +42,14 @@ Feature: REPORT request to project space | /folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt | And the following headers should match these regular expressions | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | - And the "REPORT" response to user "Alice" should contain a mountpoint "findData" with these key and value pairs: - | key | value | - | oc:fileid | UUIDof:folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt | - | oc:file-parent | UUIDof:folderMain/SubFolder1/subFOLDER2 | - | oc:name | insideTheFolder.txt | - | d:getcontenttype | text/plain | - | oc:permissions | RDNVW | - | d:getcontentlength | 12 | + And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | + | oc:name | insideTheFolder.txt | + | d:getcontenttype | text/plain | + | oc:permissions | RDNVW | + | d:getcontentlength | 12 | Scenario: check the response of the searched folder @@ -61,10 +61,10 @@ Feature: REPORT request to project space | /folderMain | And the following headers should match these regular expressions | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | - And the "REPORT" response to user "Alice" should contain a mountpoint "findData" with these key and value pairs: + And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs: | key | value | - | oc:fileid | UUIDof:folderMain | - | oc:file-parent | UUIDof:findData | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | | oc:name | folderMain | | d:getcontenttype | httpd/unix-directory | | oc:permissions | RDNVCK | @@ -81,11 +81,11 @@ Feature: REPORT request to project space And the following headers should match these regular expressions | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | And the HTTP status code should be "207" - And the "REPORT" response to user "Alice" should contain a mountpoint "findData" with these key and value pairs: - | key | value | - | oc:fileid | UUIDof:folderMain/sub-folder | - | oc:file-parent | UUIDof:folderMain | - | oc:name | sub-folder | - | d:getcontenttype | httpd/unix-directory | - | oc:permissions | RDNVCK | - | oc:size | 0 | + And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | + | oc:name | sub-folder | + | d:getcontenttype | httpd/unix-directory | + | oc:permissions | RDNVCK | + | oc:size | 0 | diff --git a/tests/acceptance/features/apiContract/spacesSharesReport.feature b/tests/acceptance/features/apiContract/spacesSharesReport.feature index 7962a5af22..f3d3af5f3a 100644 --- a/tests/acceptance/features/apiContract/spacesSharesReport.feature +++ b/tests/acceptance/features/apiContract/spacesSharesReport.feature @@ -31,16 +31,16 @@ Feature: Report test 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+)?$/ | - And the "REPORT" response to user "Brian" should contain a mountpoint "folderMain" with these key and value pairs: + And as user "Brian" the REPORT response should contain a mountpoint "folderMain" with these key and value pairs: | key | value | - | oc:fileid | UUIDof:SubFolder1 | - | oc:file-parent | UUIDof:folderMain | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | | oc:shareroot | /folderMain | | oc:name | SubFolder1 | | d:getcontenttype | httpd/unix-directory | | oc:permissions | S | | oc:size | 12 | - | oc:remote-item-id | UUIDof:folderMain | + | oc:remote-item-id | %file_id_pattern% | Scenario: check the response of the found file @@ -55,16 +55,16 @@ Feature: Report test 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+)?$/ | - And the "REPORT" response to user "Brian" should contain a mountpoint "folderMain" with these key and value pairs: - | key | value | - | oc:fileid | UUIDof:SubFolder1/subFOLDER2/insideTheFolder.txt | - | oc:file-parent | UUIDof:SubFolder1/subFOLDER2 | - | oc:shareroot | /folderMain | - | oc:name | insideTheFolder.txt | - | d:getcontenttype | text/plain | - | oc:permissions | SD | - | d:getcontentlength | 12 | - | oc:remote-item-id | UUIDof:folderMain | + And as user "Brian" the REPORT response should contain a mountpoint "insideTheFolder.txt" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:file-parent | %file_id_pattern% | + | oc:shareroot | /folderMain | + | oc:name | insideTheFolder.txt | + | d:getcontenttype | text/plain | + | oc:permissions | SD | + | d:getcontentlength | 12 | + | oc:remote-item-id | %file_id_pattern% | Scenario: search for the shared folder when the share is not accepted diff --git a/tests/acceptance/features/apiLocks/lockFiles.feature b/tests/acceptance/features/apiLocks/lockFiles.feature index dcb1bab4e9..0612858581 100644 --- a/tests/acceptance/features/apiLocks/lockFiles.feature +++ b/tests/acceptance/features/apiLocks/lockFiles.feature @@ -17,7 +17,7 @@ Feature: lock files Then the HTTP status code should be "200" 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: + And as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/d:depth | Infinity | @@ -39,7 +39,7 @@ Feature: lock files Then the HTTP status code should be "200" 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: + And as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/d:depth | Infinity | @@ -61,7 +61,7 @@ Feature: lock files Then the HTTP status code should be "200" 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: + And as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/d:depth | Infinity | @@ -104,7 +104,7 @@ Feature: lock files Then the HTTP status code should be "200" 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: + And as user "Brian" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/d:depth | Infinity | @@ -133,7 +133,7 @@ Feature: lock files Then the HTTP status code should be "200" 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: + And as user "Brian" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/d:depth | Infinity | @@ -179,7 +179,7 @@ Feature: lock files Then the HTTP status code should be "200" 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: + And as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/oc:ownername | Brian Murphy | @@ -206,7 +206,7 @@ Feature: lock files Then the HTTP status code should be "200" 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: + And as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/oc:ownername | Brian Murphy | @@ -253,7 +253,7 @@ Feature: lock files Then the HTTP status code should be "423" 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: + And as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/oc:ownername | Alice Hansen | @@ -277,7 +277,7 @@ Feature: lock files Then the HTTP status code should be "423" 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: + And as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/oc:ownername | Brian Murphy | diff --git a/tests/acceptance/features/apiSearchContent/extractedProps.feature b/tests/acceptance/features/apiSearchContent/extractedProps.feature index f2b464e476..3d881be2d6 100644 --- a/tests/acceptance/features/apiSearchContent/extractedProps.feature +++ b/tests/acceptance/features/apiSearchContent/extractedProps.feature @@ -18,7 +18,7 @@ Feature: propfind extracted props | propertyName | | oc:audio | Then the HTTP status code should be "207" - And the "PROPFIND" response should contain a space "new-space" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a space "new-space" with these key and value pairs: | key | value | | oc:audio/oc:album | ALBUM1234567890123456789012345 | | oc:audio/oc:artist | ARTIST123456789012345678901234 | @@ -32,7 +32,7 @@ Feature: propfind extracted props | oc:location | | oc:photo | Then the HTTP status code should be "207" - And the "PROPFIND" response should contain a space "new-space" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a space "new-space" with these key and value pairs: | key | value | | oc:image/oc:width | 640 | | oc:image/oc:height | 480 | @@ -51,7 +51,7 @@ Feature: propfind extracted props | propertyName | | oc:audio | Then the HTTP status code should be "207" - And the "PROPFIND" response to user "Alice" should contain a mountpoint "testaudio.mp3" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a mountpoint "testaudio.mp3" with these key and value pairs: | key | value | | oc:audio/oc:album | ALBUM1234567890123456789012345 | | oc:audio/oc:artist | ARTIST123456789012345678901234 | @@ -65,7 +65,7 @@ Feature: propfind extracted props | oc:location | | oc:photo | Then the HTTP status code should be "207" - And the "PROPFIND" response to user "Alice" should contain a mountpoint "testavatar.jpg" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a mountpoint "testavatar.jpg" with these key and value pairs: | key | value | | oc:image/oc:width | 640 | | oc:image/oc:height | 480 | @@ -101,7 +101,7 @@ Feature: propfind extracted props | propertyName | | oc:audio | 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: + And as user "Brian" the PROPFIND response should contain a space "Shares" with these key and value pairs: | key | value | | oc:audio/oc:album | ALBUM1234567890123456789012345 | | oc:audio/oc:artist | ARTIST123456789012345678901234 | @@ -115,7 +115,7 @@ Feature: propfind extracted props | oc:location | | oc:photo | 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: + And as user "Brian" the PROPFIND response should contain a space "Shares" with these key and value pairs: | key | value | | oc:image/oc:width | 640 | | oc:image/oc:height | 480 | diff --git a/tests/acceptance/features/apiSharingNg1/propfindShares.feature b/tests/acceptance/features/apiSharingNg1/propfindShares.feature index 93d893e88e..eda789dd52 100644 --- a/tests/acceptance/features/apiSharingNg1/propfindShares.feature +++ b/tests/acceptance/features/apiSharingNg1/propfindShares.feature @@ -10,47 +10,8 @@ Feature: propfind a shares | Brian | | Carol | - @issue-4421 + @issue-4421 @issue-9933 Scenario Outline: sharee PROPFIND same name shares shared by multiple users - Given using spaces DAV path - And user "Alice" has uploaded file with content "to share" to "textfile.txt" - And user "Alice" has created folder "folderToShare" - And user "Carol" has uploaded file with content "to share" to "textfile.txt" - And user "Carol" has created folder "folderToShare" - And user "Alice" has sent the following resource share invitation: - | resource | | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | Viewer | - And user "Brian" has a share "" synced - And user "Carol" has sent the following resource share invitation: - | resource | | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | Viewer | - And user "Brian" has a share "" synced - 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 | - | 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 | | - | oc:permissions | S | - And the "PROPFIND" response to user "Brian" should contain a mountpoint "Shares" with these key and value pairs: - | key | value | - | oc:name | | - | oc:permissions | S | - Examples: - | resource | resource-2 | - | textfile.txt | textfile (1).txt | - | folderToShare | folderToShare (1) | - - @issue-4421 @issue-9933 @skip - Scenario Outline: sharee PROPFIND same name shares shared by multiple users using new dav path Given using DAV path And user "Alice" has uploaded file with content "to share" to "textfile.txt" And user "Alice" has created folder "folderToShare" @@ -70,22 +31,22 @@ Feature: propfind a shares | shareType | user | | permissionsRole | Viewer | And user "Brian" has a share "" synced - When user "Brian" sends PROPFIND request from the space "Shares" to the resource "Shares" using the WebDAV API + When user "Brian" sends PROPFIND request from the space "Shares" to the resource "/" 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 | - | oc:name | Shares | - And the "PROPFIND" response to user "Brian" should contain a mountpoint "Shares" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a space "Shares" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:name | Shares | + And as user "Brian" the PROPFIND response should contain a mountpoint "" with these key and value pairs: | key | value | - | oc:fileid | UUIDof: | + | oc:fileid | %file_id_pattern% | | oc:name | | | oc:permissions | S | - And the "PROPFIND" response to user "Brian" should contain a mountpoint "Shares" with these key and value pairs: - | key | value | - | oc:fileid | UUIDof: | - | oc:name | | - | oc:permissions | S | + And as user "Brian" the PROPFIND response should contain a mountpoint "" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:name | | + | oc:permissions | S | Examples: | dav-path-version | resource | resource-2 | | old | textfile.txt | textfile (1).txt | @@ -93,8 +54,8 @@ Feature: propfind a shares | new | textfile.txt | textfile (1).txt | | new | folderToShare | folderToShare (1) | - @issue-4421 @issue-9933 @skip - Scenario: sharee PROPFIND shares with bracket in the name + @issue-4421 @issue-9933 + Scenario: sharee PROPFIND a share having bracket in the name Given using spaces DAV path And user "Alice" has created folder "folderToShare" And user "Alice" has uploaded file with content "to share" to "folderToShare/textfile.txt" @@ -116,16 +77,16 @@ Feature: propfind a shares And user "Brian" has a share "folderToShare (1)" synced When user "Brian" sends PROPFIND request from the space "Shares" to the resource "folderToShare (1)" using the WebDAV API Then the HTTP status code should be "207" - And the "PROPFIND" response to user "Brian" should contain a mountpoint "folderToShare (1)" with these key and value pairs: - | key | value | - | oc:fileid | UUIDof:folderToShare (1) | - | oc:name | folderToShare | - | oc:permissions | S | - And the "PROPFIND" response to user "Brian" should contain a mountpoint "folderToShare (1)" with these key and value pairs: - | key | value | - | oc:fileid | UUIDof:textfile.txt | - | oc:name | textfile.txt | - | oc:permissions | S | + And as user "Brian" the PROPFIND response should contain a mountpoint "folderToShare (1)" with these key and value pairs: + | key | value | + | oc:fileid | %share_id_pattern% | + | oc:name | folderToShare | + | oc:permissions | S | + And as user "Brian" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: + | key | value | + | oc:fileid | %file_id_pattern% | + | oc:name | textfile.txt | + | oc:permissions | | Scenario Outline: check file-id from PROPFIND with shared-with-me drive-item-id diff --git a/tests/acceptance/features/apiSpaces/tag.feature b/tests/acceptance/features/apiSpaces/tag.feature index 57a64210ff..e6c104c423 100644 --- a/tests/acceptance/features/apiSpaces/tag.feature +++ b/tests/acceptance/features/apiSpaces/tag.feature @@ -30,7 +30,7 @@ Feature: Tag Then the HTTP status code should be "200" 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: + And as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: | key | value | | oc:tags | tag level#1,tag with symbols @^$#^%$@%!_+) | When user "Alice" creates the following tags for file "folderMain/insideTheFolder.txt" of space "use-tag": @@ -38,7 +38,7 @@ Feature: 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" 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: + And as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: | key | value | | oc:tags | fileTag | When user "Alice" lists all available tags via the Graph API @@ -68,12 +68,12 @@ Feature: Tag Then the HTTP status code should be "200" 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: + And as user "Alice" the PROPFIND response should contain a mountpoint "folderMain" 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" 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: + And as user "Alice" the PROPFIND response should contain a mountpoint "file.txt" with these key and value pairs: | key | value | | oc:tags | fileTag,tag with symbol @^$#^%$@%!_+) | When user "Alice" lists all available tags via the Graph API @@ -188,7 +188,7 @@ Feature: Tag | marketing | 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: + And as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: | key | value | | oc:tags | development | @@ -268,7 +268,7 @@ Feature: Tag Then the HTTP status code should be "200" 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: + And as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: | key | value | | oc:tags | finance,नेपाल | When user "Alice" creates the following tags for file "folderMain/insideTheFolder.txt" of space "use-tag": @@ -276,7 +276,7 @@ Feature: 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" 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: + And as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: | key | value | | oc:tags | file,नेपाल,Tag | When user "Alice" lists all available tags via the Graph API @@ -295,8 +295,8 @@ Feature: 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" 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: + Then the HTTP status code should be "207": + And as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: | key | value | | oc:tags | engineering,finance,hr,qa | When user "Alice" lists all available tags via the Graph API diff --git a/tests/acceptance/features/apiSpacesDavOperation/propfindByFileId.feature b/tests/acceptance/features/apiSpacesDavOperation/propfindByFileId.feature index 4ed42c17d9..c2e0f33479 100644 --- a/tests/acceptance/features/apiSpacesDavOperation/propfindByFileId.feature +++ b/tests/acceptance/features/apiSpacesDavOperation/propfindByFileId.feature @@ -13,7 +13,7 @@ Feature: propfind a file using file id And we save it into "FILEID" When user "Alice" sends HTTP method "PROPFIND" to URL "" 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: + And as user "Alice" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | RDNVWZP | @@ -29,7 +29,7 @@ Feature: propfind a file using file id And we save it into "FILEID" When user "Alice" sends HTTP method "PROPFIND" to URL "" 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: + And as user "Alice" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | RDNVWZP | @@ -58,7 +58,7 @@ Feature: propfind a file using file id And we save it into "FILEID" When user "Alice" sends HTTP method "PROPFIND" to URL "" Then the HTTP status code should be "207" - And the "PROPFIND" response should contain a space "new-space" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | RDNVWZP | @@ -76,7 +76,7 @@ Feature: propfind a file using file id And we save it into "FILEID" When user "Alice" sends HTTP method "PROPFIND" to URL "" Then the HTTP status code should be "207" - And the "PROPFIND" response should contain a space "new-space" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | RDNVWZP | @@ -113,7 +113,7 @@ Feature: propfind a file using file id And user "Brian" has a share "textfile.txt" synced When user "Brian" sends HTTP method "PROPFIND" to URL "" Then the HTTP status code should be "207" - And the "PROPFIND" response to user "Alice" should contain a mountpoint "Brian Murphy" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | SNVW | @@ -137,7 +137,7 @@ Feature: propfind a file using file id And we save it into "FILEID" When user "Brian" sends HTTP method "PROPFIND" to URL "" Then the HTTP status code should be "207" - And the "PROPFIND" response to user "Alice" should contain a mountpoint "Brian Murphy" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | DNVW | From 732f2b241eb6eb95b07e8c8a713c6347103487fc Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 1 Oct 2024 18:07:47 +0545 Subject: [PATCH 2/3] test: rename PROPFIND response check steps test: fix tests --- .../TestHelpers/CollaborationHelper.php | 1 - tests/acceptance/TestHelpers/GraphHelper.php | 2 +- .../TestHelpers/HttpRequestHelper.php | 18 ++++++++ tests/acceptance/bootstrap/FeatureContext.php | 41 +++++++++---------- tests/acceptance/bootstrap/SpacesContext.php | 36 ++++++++-------- .../features/apiContract/copy.feature | 6 +-- .../features/apiContract/propfind.feature | 12 +++--- .../features/apiContract/sharesReport.feature | 22 +++++----- .../features/apiContract/spacesReport.feature | 16 ++++---- .../apiContract/spacesSharesReport.feature | 10 ++--- .../features/apiLocks/lockFiles.feature | 18 ++++---- .../apiSearchContent/extractedProps.feature | 12 +++--- .../apiSharingNg1/propfindShares.feature | 8 ++-- .../acceptance/features/apiSpaces/tag.feature | 18 ++++---- .../propfindByFileId.feature | 12 +++--- 15 files changed, 124 insertions(+), 108 deletions(-) diff --git a/tests/acceptance/TestHelpers/CollaborationHelper.php b/tests/acceptance/TestHelpers/CollaborationHelper.php index 758666e8ec..60404c8e4b 100644 --- a/tests/acceptance/TestHelpers/CollaborationHelper.php +++ b/tests/acceptance/TestHelpers/CollaborationHelper.php @@ -29,7 +29,6 @@ use Psr\Http\Message\ResponseInterface; * A helper class for managing wopi requests */ class CollaborationHelper { - /** * @param string $fileId * @param string $app diff --git a/tests/acceptance/TestHelpers/GraphHelper.php b/tests/acceptance/TestHelpers/GraphHelper.php index 1024481c4c..a080ab94d0 100644 --- a/tests/acceptance/TestHelpers/GraphHelper.php +++ b/tests/acceptance/TestHelpers/GraphHelper.php @@ -132,7 +132,7 @@ class GraphHelper { * * @return string regex pattern */ - public static function sanitizeRegexPattern(string $pattern): string { + public static function jsonSchemaRegexToPureRegex(string $pattern): string { $pattern = \str_replace("\\\\", "\\", $pattern); $pattern = \str_replace("/", "\/", $pattern); $pattern = \preg_replace('/^\^/', '', $pattern); diff --git a/tests/acceptance/TestHelpers/HttpRequestHelper.php b/tests/acceptance/TestHelpers/HttpRequestHelper.php index c532691cad..b7b693ccff 100644 --- a/tests/acceptance/TestHelpers/HttpRequestHelper.php +++ b/tests/acceptance/TestHelpers/HttpRequestHelper.php @@ -665,4 +665,22 @@ class HttpRequestHelper { public static function getJsonDecodedResponseBodyContent(ResponseInterface $response): mixed { return json_decode($response->getBody()->getContents(), null, 512, JSON_THROW_ON_ERROR); } + + /** + * @return bool + */ + public static function sendScenarioLineReferencesInXRequestId(): bool { + return (\getenv("SEND_SCENARIO_LINE_REFERENCES") === "true"); + } + + /** + * @return bool + */ + public static function getXRequestIdRegex(): string { + if (self::sendScenarioLineReferencesInXRequestId()) { + return '/^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/'; + } + $host = gethostname(); + return "/^$host\/.*$/"; + } } diff --git a/tests/acceptance/bootstrap/FeatureContext.php b/tests/acceptance/bootstrap/FeatureContext.php index bce949a068..1013cd4deb 100644 --- a/tests/acceptance/bootstrap/FeatureContext.php +++ b/tests/acceptance/bootstrap/FeatureContext.php @@ -145,8 +145,6 @@ class FeatureContext extends BehatVariablesContext { * in the apiComments suite. */ private string $stepLineRef = ''; - private bool $sendStepLineRef = false; - private bool $sendStepLineRefHasBeenChecked = false; /** * @var boolean true if TEST_SERVER_FED_URL is defined @@ -416,17 +414,6 @@ class FeatureContext extends BehatVariablesContext { return (\getenv("TEST_WITH_LDAP") === "true"); } - /** - * @return bool - */ - public function sendScenarioLineReferencesInXRequestId(): ?bool { - if ($this->sendStepLineRefHasBeenChecked === false) { - $this->sendStepLineRef = (\getenv("SEND_SCENARIO_LINE_REFERENCES") === "true"); - $this->sendStepLineRefHasBeenChecked = true; - } - return $this->sendStepLineRef; - } - /** * @return bool */ @@ -880,7 +867,7 @@ class FeatureContext extends BehatVariablesContext { * @return string */ public function getStepLineRef(): string { - if (!$this->sendStepLineRef) { + if (!HttpRequestHelper::sendScenarioLineReferencesInXRequestId()) { return ''; } @@ -2435,6 +2422,14 @@ class FeatureContext extends BehatVariablesContext { "getUUIDv4Regex" ], "parameter" => [] + ], + [ + "code" => "%request_id_pattern%", + "function" => [ + __NAMESPACE__ . '\TestHelpers\HttpRequestHelper', + "getXRequestIdRegex" + ], + "parameter" => [] ] ]; if ($user !== null) { @@ -2522,11 +2517,15 @@ class FeatureContext extends BehatVariablesContext { $substitution["function"], $substitution["parameter"] ); - foreach ($functions as $function => $parameters) { - $replacement = \call_user_func_array( - $function, - \array_merge([$replacement], $parameters) - ); + + // do not run functions on regex patterns + if (!\str_ends_with($value, "_pattern%")) { + foreach ($functions as $function => $parameters) { + $replacement = \call_user_func_array( + $function, + \array_merge([$replacement], $parameters) + ); + } } $value = \str_replace( $substitution["code"], @@ -2644,7 +2643,7 @@ class FeatureContext extends BehatVariablesContext { $environment->registerContext($this->spacesContext); } - if ($this->sendScenarioLineReferencesInXRequestId()) { + if (HttpRequestHelper::sendScenarioLineReferencesInXRequestId()) { $this->scenarioString = $suiteName . '/' . $featureFileName . ':' . $scenarioLine; } else { $this->scenarioString = ''; @@ -2678,7 +2677,7 @@ class FeatureContext extends BehatVariablesContext { * @return void */ public function beforeEachStep(BeforeStepScope $scope): void { - if ($this->sendScenarioLineReferencesInXRequestId()) { + if (HttpRequestHelper::sendScenarioLineReferencesInXRequestId()) { $this->stepLineRef = $this->scenarioString . '-' . $scope->getStep()->getLine(); } else { $this->stepLineRef = ''; diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index 3cbf0b3967..52f0c8017e 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -3775,7 +3775,7 @@ class SpacesContext implements Context { if ($resource === '' || $resource === '/') { $resource = $spaceName; } else { - $resource = $spaceName . '/' . $resource; + $resource = "$spaceName/$resource"; } } @@ -3795,44 +3795,44 @@ class SpacesContext implements Context { } /** - * @Then /^as user "([^"]*)" the (PROPFIND|REPORT) response should contain a (mountpoint|space) "([^"]*)" with these key and value pairs:$/ + * @Then /^as user "([^"]*)" the (PROPFIND|REPORT) response should contain a (resource|space) "([^"]*)" with these key and value pairs:$/ * * @param string $user * @param string $method # method should be either PROPFIND or REPORT - * @param string $type # type should be either mountpoint or space - * @param string $mountPoint + * @param string $type # type should be either resource or space + * @param string $resource * @param TableNode $table * * @return void * @throws GuzzleException * @throws JsonException */ - public function asUsertheXMLResponseShouldContainMountpointWithTheseKeyAndValuePair(string $user, string $method, string $type, string $mountPoint, TableNode $table): void { + public function asUsertheXMLResponseShouldContainMountpointWithTheseKeyAndValuePair(string $user, string $method, string $type, string $resource, TableNode $table): void { $this->featureContext->verifyTableNodeColumns($table, ['key', 'value']); if ($this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES && $type === 'space') { - $space = $this->getSpaceByName($user, $mountPoint); - $mountPoint = $space['id']; + $space = $this->getSpaceByName($user, $resource); + $resource = $space['id']; } else { - $mountPoint = \rawurlencode($mountPoint); + $resource = \rawurlencode($resource); } - $this->theXMLResponseShouldContain($mountPoint, $table); + $this->theXMLResponseShouldContain($resource, $table); } /** - * @param string $spaceNameOrMountPoint # an entity inside a space, or the space name itself + * @param string $resource * @param TableNode $table * * @return void * @throws GuzzleException * @throws JsonException */ - public function theXMLResponseShouldContain(string $spaceNameOrMountPoint, TableNode $table): void { + public function theXMLResponseShouldContain(string $resource, TableNode $table): void { $xmlResponse = $this->featureContext->getResponseXml(); - $hrefs = array_map(fn($href) => $href->__toString(), $xmlResponse->xpath("//d:response/d:href")); + $hrefs = array_map(fn ($href) => $href->__toString(), $xmlResponse->xpath("//d:response/d:href")); $currentHref = ''; foreach ($hrefs as $href) { - if (\str_ends_with(\rtrim($href, "/"), "/$spaceNameOrMountPoint")) { + if (\str_ends_with(\rtrim($href, "/"), "/$resource")) { $currentHref = $href; break; } @@ -3851,15 +3851,15 @@ class SpacesContext implements Context { switch ($itemToFind) { case "oc:fileid": - $expectedValue = GraphHelper::sanitizeRegexPattern($expectedValue); + $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); Assert::assertRegExp($expectedValue, $actualValue, 'wrong "fileid" in the response'); break; case "oc:file-parent": - $expectedValue = GraphHelper::sanitizeRegexPattern($expectedValue); + $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); Assert::assertRegExp($expectedValue, $actualValue, 'wrong "file-parent" in the response'); break; case "oc:privatelink": - $expectedValue = GraphHelper::sanitizeRegexPattern($expectedValue); + $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); Assert::assertRegExp($expectedValue, $actualValue, 'wrong "privatelink" in the response'); break; case "oc:tags": @@ -3871,7 +3871,7 @@ class SpacesContext implements Context { $actualTags = \explode(",", $actualValue); \sort($actualTags); - $actualTags = \implode(",", $actualValue); + $actualTags = \implode(",", $actualTags); Assert::assertEquals($expectedTags, $actualTags, "wrong '$itemToFind' in the response"); break; case "d:lockdiscovery/d:activelock/d:timeout": @@ -3887,7 +3887,7 @@ class SpacesContext implements Context { } break; case "oc:remote-item-id": - $expectedValue = GraphHelper::sanitizeRegexPattern($expectedValue); + $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); Assert::assertRegExp($expectedValue, $actualValue, 'wrong "remote-item-id" in the response'); break; default: diff --git a/tests/acceptance/features/apiContract/copy.feature b/tests/acceptance/features/apiContract/copy.feature index 8a9c8e1903..ae1a49914d 100644 --- a/tests/acceptance/features/apiContract/copy.feature +++ b/tests/acceptance/features/apiContract/copy.feature @@ -21,7 +21,7 @@ Feature: Copy test | Origin | %base_url% | Then the HTTP status code should be "201" And the following headers should match these regular expressions - | Oc-Fileid | /^[a-f0-9!\$\-]{110}$/ | - | Access-Control-Allow-Origin | /^%base_url%$/ | - | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | + | Oc-Fileid | /^[a-f0-9!\$\-]{110}$/ | + | Access-Control-Allow-Origin | /^%base_url%$/ | + | X-Request-Id | %request_id_pattern% | diff --git a/tests/acceptance/features/apiContract/propfind.feature b/tests/acceptance/features/apiContract/propfind.feature index 4c2240d2bf..42b0b3ab81 100644 --- a/tests/acceptance/features/apiContract/propfind.feature +++ b/tests/acceptance/features/apiContract/propfind.feature @@ -18,7 +18,7 @@ Feature: Propfind test 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+)?$/ | + | X-Request-Id | %request_id_pattern% | And as user "Alice" the PROPFIND response should contain a space "new-space" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | @@ -38,7 +38,7 @@ Feature: Propfind test 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+)?$/ | + | X-Request-Id | %request_id_pattern% | And as user "Brian" the PROPFIND response should contain a space "new-space" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | @@ -46,7 +46,7 @@ Feature: Propfind test | oc:permissions | | | oc:privatelink | %base_url%/f/[0-9a-z-$%]+ | | oc:size | 12 | - Examples: + Examples: | space-role | oc-permission | | Manager | RDNVCKZP | | Space Editor | DNVCK | @@ -62,7 +62,7 @@ Feature: Propfind test | permissionsRole | | 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 as user "Brian" the PROPFIND response should contain a mountpoint "folderMain" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "folderMain" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | @@ -85,7 +85,7 @@ Feature: Propfind test | permissionsRole | | 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 as user "Brian" the PROPFIND response should contain a mountpoint "subFolder2" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "subFolder2" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | @@ -108,7 +108,7 @@ Feature: Propfind test | permissionsRole | | 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 as user "Brian" the PROPFIND response should contain a mountpoint "testfile.txt" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "testfile.txt" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | diff --git a/tests/acceptance/features/apiContract/sharesReport.feature b/tests/acceptance/features/apiContract/sharesReport.feature index b115d0a1ee..a1d85d84e0 100644 --- a/tests/acceptance/features/apiContract/sharesReport.feature +++ b/tests/acceptance/features/apiContract/sharesReport.feature @@ -25,8 +25,8 @@ Feature: REPORT request to Shares space When user "Brian" searches for "SubFolder1" 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+)?$/ | - And as user "Brian" the REPORT response should contain a mountpoint "SubFolder1" with these key and value pairs: + | X-Request-Id | %request_id_pattern% | + And as user "Brian" the REPORT response should contain a resource "SubFolder1" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | @@ -47,8 +47,8 @@ Feature: REPORT request to Shares space When user "Brian" searches for "frodo.txt" 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+)?$/ | - And as user "Brian" the REPORT response should contain a mountpoint "frodo.txt" with these key and value pairs: + | X-Request-Id | %request_id_pattern% | + And as user "Brian" the REPORT response should contain a resource "frodo.txt" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | @@ -77,7 +77,7 @@ Feature: REPORT request to Shares space When user "Brian" searches for "folderToBrian" 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+)?$/ | + | X-Request-Id | %request_id_pattern% | And the search result should contain "0" entries Examples: | dav-path-version | @@ -99,8 +99,8 @@ Feature: REPORT request to Shares space When user "Brian" searches for "secureFolder" 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+)?$/ | - And as user "Brian" the REPORT response should contain a mountpoint "secureFolder" with these key and value pairs: + | X-Request-Id | %request_id_pattern% | + And as user "Brian" the REPORT response should contain a resource "secureFolder" with these key and value pairs: | key | value | | oc:shareroot | /secureFolder | | oc:name | secureFolder | @@ -110,9 +110,9 @@ Feature: REPORT request to Shares space | oc:remote-item-id | %file_id_pattern% | When user "Brian" searches for "secure.txt" using the WebDAV API And the following headers should match these regular expressions - | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | + | X-Request-Id | %request_id_pattern% | Then the HTTP status code should be "207" - And as user "Brian" the REPORT response should contain a mountpoint "secure.txt" with these key and value pairs: + And as user "Brian" the REPORT response should contain a resource "secure.txt" with these key and value pairs: | key | value | | oc:shareroot | /secureFolder | | oc:name | secure.txt | @@ -139,8 +139,8 @@ Feature: REPORT request to Shares space When user "Brian" searches for "secure.txt" 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+)?$/ | - And as user "Brian" the REPORT response should contain a mountpoint "secure.txt" with these key and value pairs: + | X-Request-Id | %request_id_pattern% | + And as user "Brian" the REPORT response should contain a resource "secure.txt" with these key and value pairs: | key | value | | oc:shareroot | /secure.txt | | oc:name | secure.txt | diff --git a/tests/acceptance/features/apiContract/spacesReport.feature b/tests/acceptance/features/apiContract/spacesReport.feature index 93c4493782..dce427d705 100644 --- a/tests/acceptance/features/apiContract/spacesReport.feature +++ b/tests/acceptance/features/apiContract/spacesReport.feature @@ -21,8 +21,8 @@ Feature: REPORT request to project space And the search result of user "Alice" should contain only these entries: | /testFile.txt | And the following headers should match these regular expressions - | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | - And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs: + | X-Request-Id | %request_id_pattern% | + And as user "Alice" the REPORT response should contain a resource "testFile.txt" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | @@ -41,8 +41,8 @@ Feature: REPORT request to project space And the search result of user "Alice" should contain only these entries: | /folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt | And the following headers should match these regular expressions - | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | - And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs: + | X-Request-Id | %request_id_pattern% | + And as user "Alice" the REPORT response should contain a resource "insideTheFolder.txt" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | @@ -60,8 +60,8 @@ Feature: REPORT request to project space And the search result of user "Alice" should contain only these entries: | /folderMain | And the following headers should match these regular expressions - | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | - And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs: + | X-Request-Id | %request_id_pattern% | + And as user "Alice" the REPORT response should contain a resource "folderMain" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | @@ -79,9 +79,9 @@ Feature: REPORT request to project space And the search result of user "Alice" should contain only these entries: | /folderMain/sub-folder | And the following headers should match these regular expressions - | X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ | + | X-Request-Id | %request_id_pattern% | And the HTTP status code should be "207" - And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs: + And as user "Alice" the REPORT response should contain a resource "sub-folder" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | diff --git a/tests/acceptance/features/apiContract/spacesSharesReport.feature b/tests/acceptance/features/apiContract/spacesSharesReport.feature index f3d3af5f3a..fc05b63e21 100644 --- a/tests/acceptance/features/apiContract/spacesSharesReport.feature +++ b/tests/acceptance/features/apiContract/spacesSharesReport.feature @@ -30,8 +30,8 @@ Feature: Report test When user "Brian" searches for "SubFolder1" 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+)?$/ | - And as user "Brian" the REPORT response should contain a mountpoint "folderMain" with these key and value pairs: + | X-Request-Id | %request_id_pattern% | + And as user "Brian" the REPORT response should contain a resource "SubFolder1" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | @@ -54,8 +54,8 @@ Feature: Report test When user "Brian" searches for "insideTheFolder.txt" 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+)?$/ | - And as user "Brian" the REPORT response should contain a mountpoint "insideTheFolder.txt" with these key and value pairs: + | X-Request-Id | %request_id_pattern% | + And as user "Brian" the REPORT response should contain a resource "insideTheFolder.txt" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:file-parent | %file_id_pattern% | @@ -78,5 +78,5 @@ Feature: Report test When user "Brian" searches for "folderMain" 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+)?$/ | + | X-Request-Id | %request_id_pattern% | And the search result should contain "0" entries diff --git a/tests/acceptance/features/apiLocks/lockFiles.feature b/tests/acceptance/features/apiLocks/lockFiles.feature index 0612858581..3f4b4c8783 100644 --- a/tests/acceptance/features/apiLocks/lockFiles.feature +++ b/tests/acceptance/features/apiLocks/lockFiles.feature @@ -17,7 +17,7 @@ Feature: lock files Then the HTTP status code should be "200" 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 as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "textfile.txt" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/d:depth | Infinity | @@ -39,7 +39,7 @@ Feature: lock files Then the HTTP status code should be "200" 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 as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "textfile.txt" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/d:depth | Infinity | @@ -61,7 +61,7 @@ Feature: lock files Then the HTTP status code should be "200" 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 as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "textfile.txt" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/d:depth | Infinity | @@ -104,7 +104,7 @@ Feature: lock files Then the HTTP status code should be "200" 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 as user "Brian" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "textfile.txt" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/d:depth | Infinity | @@ -133,7 +133,7 @@ Feature: lock files Then the HTTP status code should be "200" 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 as user "Brian" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "textfile.txt" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/d:depth | Infinity | @@ -179,7 +179,7 @@ Feature: lock files Then the HTTP status code should be "200" 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 as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "textfile.txt" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/oc:ownername | Brian Murphy | @@ -206,7 +206,7 @@ Feature: lock files Then the HTTP status code should be "200" 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 as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "textfile.txt" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/oc:ownername | Brian Murphy | @@ -253,7 +253,7 @@ Feature: lock files Then the HTTP status code should be "423" 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 as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "textfile.txt" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/oc:ownername | Alice Hansen | @@ -277,7 +277,7 @@ Feature: lock files Then the HTTP status code should be "423" 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 as user "Alice" the PROPFIND response should contain a space "Alice Hansen" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "textfile.txt" with these key and value pairs: | key | value | | d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | | | d:lockdiscovery/d:activelock/oc:ownername | Brian Murphy | diff --git a/tests/acceptance/features/apiSearchContent/extractedProps.feature b/tests/acceptance/features/apiSearchContent/extractedProps.feature index 3d881be2d6..7d5d606188 100644 --- a/tests/acceptance/features/apiSearchContent/extractedProps.feature +++ b/tests/acceptance/features/apiSearchContent/extractedProps.feature @@ -18,7 +18,7 @@ Feature: propfind extracted props | propertyName | | oc:audio | Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a space "new-space" with these key and value pairs: + And as user "Alice" the REPORT response should contain a resource "testaudio.mp3" with these key and value pairs: | key | value | | oc:audio/oc:album | ALBUM1234567890123456789012345 | | oc:audio/oc:artist | ARTIST123456789012345678901234 | @@ -32,7 +32,7 @@ Feature: propfind extracted props | oc:location | | oc:photo | Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a space "new-space" with these key and value pairs: + And as user "Alice" the REPORT response should contain a resource "testavatar.jpg" with these key and value pairs: | key | value | | oc:image/oc:width | 640 | | oc:image/oc:height | 480 | @@ -51,7 +51,7 @@ Feature: propfind extracted props | propertyName | | oc:audio | Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a mountpoint "testaudio.mp3" with these key and value pairs: + And as user "Alice" the REPORT response should contain a resource "testaudio.mp3" with these key and value pairs: | key | value | | oc:audio/oc:album | ALBUM1234567890123456789012345 | | oc:audio/oc:artist | ARTIST123456789012345678901234 | @@ -65,7 +65,7 @@ Feature: propfind extracted props | oc:location | | oc:photo | Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a mountpoint "testavatar.jpg" with these key and value pairs: + And as user "Alice" the REPORT response should contain a resource "testavatar.jpg" with these key and value pairs: | key | value | | oc:image/oc:width | 640 | | oc:image/oc:height | 480 | @@ -101,7 +101,7 @@ Feature: propfind extracted props | propertyName | | oc:audio | Then the HTTP status code should be "207" - And as user "Brian" the PROPFIND response should contain a space "Shares" with these key and value pairs: + And as user "Brian" the REPORT response should contain a resource "testaudio.mp3" with these key and value pairs: | key | value | | oc:audio/oc:album | ALBUM1234567890123456789012345 | | oc:audio/oc:artist | ARTIST123456789012345678901234 | @@ -115,7 +115,7 @@ Feature: propfind extracted props | oc:location | | oc:photo | Then the HTTP status code should be "207" - And as user "Brian" the PROPFIND response should contain a space "Shares" with these key and value pairs: + And as user "Brian" the REPORT response should contain a resource "testavatar.jpg" with these key and value pairs: | key | value | | oc:image/oc:width | 640 | | oc:image/oc:height | 480 | diff --git a/tests/acceptance/features/apiSharingNg1/propfindShares.feature b/tests/acceptance/features/apiSharingNg1/propfindShares.feature index eda789dd52..1cf8041836 100644 --- a/tests/acceptance/features/apiSharingNg1/propfindShares.feature +++ b/tests/acceptance/features/apiSharingNg1/propfindShares.feature @@ -37,12 +37,12 @@ Feature: propfind a shares | key | value | | oc:fileid | %file_id_pattern% | | oc:name | Shares | - And as user "Brian" the PROPFIND response should contain a mountpoint "" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:name | | | oc:permissions | S | - And as user "Brian" the PROPFIND response should contain a mountpoint "" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:name | | @@ -77,12 +77,12 @@ Feature: propfind a shares And user "Brian" has a share "folderToShare (1)" synced When user "Brian" sends PROPFIND request from the space "Shares" to the resource "folderToShare (1)" using the WebDAV API Then the HTTP status code should be "207" - And as user "Brian" the PROPFIND response should contain a mountpoint "folderToShare (1)" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "folderToShare (1)" with these key and value pairs: | key | value | | oc:fileid | %share_id_pattern% | | oc:name | folderToShare | | oc:permissions | S | - And as user "Brian" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "textfile.txt" with these key and value pairs: | key | value | | oc:fileid | %file_id_pattern% | | oc:name | textfile.txt | diff --git a/tests/acceptance/features/apiSpaces/tag.feature b/tests/acceptance/features/apiSpaces/tag.feature index e6c104c423..1267273049 100644 --- a/tests/acceptance/features/apiSpaces/tag.feature +++ b/tests/acceptance/features/apiSpaces/tag.feature @@ -30,7 +30,7 @@ Feature: Tag Then the HTTP status code should be "200" 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 as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "folderMain" with these key and value pairs: | key | value | | oc:tags | tag level#1,tag with symbols @^$#^%$@%!_+) | When user "Alice" creates the following tags for file "folderMain/insideTheFolder.txt" of space "use-tag": @@ -38,7 +38,7 @@ Feature: 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" with depth "0" using the WebDAV API Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "insideTheFolder.txt" with these key and value pairs: | key | value | | oc:tags | fileTag | When user "Alice" lists all available tags via the Graph API @@ -68,12 +68,12 @@ Feature: Tag Then the HTTP status code should be "200" 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 as user "Alice" the PROPFIND response should contain a mountpoint "folderMain" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "folderMain" 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" with depth "0" using the WebDAV API Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a mountpoint "file.txt" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "file.txt" with these key and value pairs: | key | value | | oc:tags | fileTag,tag with symbol @^$#^%$@%!_+) | When user "Alice" lists all available tags via the Graph API @@ -188,7 +188,7 @@ Feature: Tag | marketing | 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 as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "folderMain" with these key and value pairs: | key | value | | oc:tags | development | @@ -268,7 +268,7 @@ Feature: Tag Then the HTTP status code should be "200" 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 as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "folderMain" with these key and value pairs: | key | value | | oc:tags | finance,नेपाल | When user "Alice" creates the following tags for file "folderMain/insideTheFolder.txt" of space "use-tag": @@ -276,7 +276,7 @@ Feature: 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" with depth "0" using the WebDAV API Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "insideTheFolder.txt" with these key and value pairs: | key | value | | oc:tags | file,नेपाल,Tag | When user "Alice" lists all available tags via the Graph API @@ -295,8 +295,8 @@ Feature: 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" with depth "0" using the WebDAV API - Then the HTTP status code should be "207": - And as user "Alice" the PROPFIND response should contain a space "use-tag" with these key and value pairs: + Then the HTTP status code should be "207" + And as user "Alice" the PROPFIND response should contain a resource "folderMain" with these key and value pairs: | key | value | | oc:tags | engineering,finance,hr,qa | When user "Alice" lists all available tags via the Graph API diff --git a/tests/acceptance/features/apiSpacesDavOperation/propfindByFileId.feature b/tests/acceptance/features/apiSpacesDavOperation/propfindByFileId.feature index c2e0f33479..6ef92020c2 100644 --- a/tests/acceptance/features/apiSpacesDavOperation/propfindByFileId.feature +++ b/tests/acceptance/features/apiSpacesDavOperation/propfindByFileId.feature @@ -13,7 +13,7 @@ Feature: propfind a file using file id And we save it into "FILEID" When user "Alice" sends HTTP method "PROPFIND" to URL "" Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "<>" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | RDNVWZP | @@ -29,7 +29,7 @@ Feature: propfind a file using file id And we save it into "FILEID" When user "Alice" sends HTTP method "PROPFIND" to URL "" Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "<>" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | RDNVWZP | @@ -58,7 +58,7 @@ Feature: propfind a file using file id And we save it into "FILEID" When user "Alice" sends HTTP method "PROPFIND" to URL "" Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "<>" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | RDNVWZP | @@ -76,7 +76,7 @@ Feature: propfind a file using file id And we save it into "FILEID" When user "Alice" sends HTTP method "PROPFIND" to URL "" Then the HTTP status code should be "207" - And as user "Alice" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: + And as user "Alice" the PROPFIND response should contain a resource "<>" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | RDNVWZP | @@ -113,7 +113,7 @@ Feature: propfind a file using file id And user "Brian" has a share "textfile.txt" synced When user "Brian" sends HTTP method "PROPFIND" to URL "" Then the HTTP status code should be "207" - And as user "Brian" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "<>" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | SNVW | @@ -137,7 +137,7 @@ Feature: propfind a file using file id And we save it into "FILEID" When user "Brian" sends HTTP method "PROPFIND" to URL "" Then the HTTP status code should be "207" - And as user "Brian" the PROPFIND response should contain a mountpoint "textfile.txt" with these key and value pairs: + And as user "Brian" the PROPFIND response should contain a resource "<>" with these key and value pairs: | key | value | | oc:name | textfile.txt | | oc:permissions | DNVW | From ca82ac03fc8242c725d0769855143e756d70afa3 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Wed, 2 Oct 2024 12:35:19 +0545 Subject: [PATCH 3/3] test: allow multiple xpaths checks --- .../TestHelpers/HttpRequestHelper.php | 2 +- tests/acceptance/bootstrap/SpacesContext.php | 73 +++++++++++++++---- 2 files changed, 58 insertions(+), 17 deletions(-) diff --git a/tests/acceptance/TestHelpers/HttpRequestHelper.php b/tests/acceptance/TestHelpers/HttpRequestHelper.php index b7b693ccff..66bb859d62 100644 --- a/tests/acceptance/TestHelpers/HttpRequestHelper.php +++ b/tests/acceptance/TestHelpers/HttpRequestHelper.php @@ -674,7 +674,7 @@ class HttpRequestHelper { } /** - * @return bool + * @return string */ public static function getXRequestIdRegex(): string { if (self::sendScenarioLineReferencesInXRequestId()) { diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index 52f0c8017e..282187aea4 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -3772,6 +3772,7 @@ class SpacesContext implements Context { $davPathVersion = $this->featureContext->getDavPathVersion(); if ($spaceName === 'Shares' && $davPathVersion !== WebDavHelper::DAV_VERSION_SPACES) { + // for old/new dav paths, append the Shares space path if ($resource === '' || $resource === '/') { $resource = $spaceName; } else { @@ -3795,10 +3796,9 @@ class SpacesContext implements Context { } /** - * @Then /^as user "([^"]*)" the (PROPFIND|REPORT) response should contain a (resource|space) "([^"]*)" with these key and value pairs:$/ + * @Then /^as user "([^"]*)" the (?:PROPFIND|REPORT) response should contain a (resource|space) "([^"]*)" with these key and value pairs:$/ * * @param string $user - * @param string $method # method should be either PROPFIND or REPORT * @param string $type # type should be either resource or space * @param string $resource * @param TableNode $table @@ -3807,26 +3807,29 @@ class SpacesContext implements Context { * @throws GuzzleException * @throws JsonException */ - public function asUsertheXMLResponseShouldContainMountpointWithTheseKeyAndValuePair(string $user, string $method, string $type, string $resource, TableNode $table): void { + public function asUsertheXMLResponseShouldContainMountpointWithTheseKeyAndValuePair(string $user, string $type, string $resource, TableNode $table): void { $this->featureContext->verifyTableNodeColumns($table, ['key', 'value']); if ($this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES && $type === 'space') { $space = $this->getSpaceByName($user, $resource); $resource = $space['id']; + } elseif (\preg_match(GraphHelper::jsonSchemaRegexToPureRegex(GraphHelper::getFileIdRegex()), $resource)) { + // When using file-id, some characters need to be encoded + $resource = \str_replace("!", "%21", $resource); } else { $resource = \rawurlencode($resource); } - $this->theXMLResponseShouldContain($resource, $table); + $this->theXMLResponseShouldContain($resource, $table->getHash()); } /** - * @param string $resource - * @param TableNode $table + * @param string $resource // can be resource name, space id or file id + * @param array $properties // ["key" => "value"] * * @return void * @throws GuzzleException * @throws JsonException */ - public function theXMLResponseShouldContain(string $resource, TableNode $table): void { + public function theXMLResponseShouldContain(string $resource, array $properties): void { $xmlResponse = $this->featureContext->getResponseXml(); $hrefs = array_map(fn ($href) => $href->__toString(), $xmlResponse->xpath("//d:response/d:href")); @@ -3838,29 +3841,67 @@ class SpacesContext implements Context { } } - foreach ($table->getHash() as $row) { - $itemToFind = $row['key']; - $foundXmlItem = $xmlResponse->xpath("//d:href[text()='$currentHref']/following-sibling::d:propstat//$itemToFind"); + foreach ($properties as $property) { + $itemToFind = $property['key']; + + // if href is not found, build xpath using oc:name + $xpaths = []; + if (!$currentHref) { + $decodedResource = \urldecode($resource); + if ($property['key'] === 'oc:name') { + $xpath = "//oc:name[text()='$decodedResource']"; + } elseif (\array_key_exists('oc:shareroot', $properties)) { + $xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/preceding-sibling::/"; + $xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/following-sibling::/"; + $xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/preceding-sibling::/"; + $xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/following-sibling::/"; + } else { + $xpaths[] = "//oc:name[text()='$decodedResource']/preceding-sibling::"; + $xpaths[] = "//oc:name[text()='$decodedResource']/following-sibling::"; + } + } else { + $xpath = "//d:href[text()='$currentHref']/following-sibling::d:propstat//$itemToFind"; + } + + if (\count($xpaths)) { + // check every xpath + foreach ($xpaths as $key => $path) { + $xpath = "{$path}{$itemToFind}"; + $foundXmlItem = $xmlResponse->xpath($xpath); + $xpaths[$key] = $xpath; + if (\count($foundXmlItem)) { + break; + } + } + } else { + $foundXmlItem = $xmlResponse->xpath($xpath); + $xpaths[] = $xpath; + } + Assert::assertNotEmpty( $foundXmlItem, - 'The xml response "' . $xmlResponse->asXML() . '" did not contain "<' . $itemToFind . '>" element' + // all these for the sake of a nice error message + "Using xpaths:\n\t- " . \join("\n\t- ", $xpaths) + . "\n" + . "Could not find '<$itemToFind>' element in the XML response\n\t" + . "'" . \trim($xmlResponse->asXML()) . "'" ); $actualValue = $foundXmlItem[0]->__toString(); - $expectedValue = $this->featureContext->substituteInLineCodes($row['value']); + $expectedValue = $this->featureContext->substituteInLineCodes($property['value']); switch ($itemToFind) { case "oc:fileid": $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); - Assert::assertRegExp($expectedValue, $actualValue, 'wrong "fileid" in the response'); + Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "fileid" in the response'); break; case "oc:file-parent": $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); - Assert::assertRegExp($expectedValue, $actualValue, 'wrong "file-parent" in the response'); + Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "file-parent" in the response'); break; case "oc:privatelink": $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); - Assert::assertRegExp($expectedValue, $actualValue, 'wrong "privatelink" in the response'); + Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "privatelink" in the response'); break; case "oc:tags": // The value should be a comma-separated string of tag names. @@ -3888,7 +3929,7 @@ class SpacesContext implements Context { break; case "oc:remote-item-id": $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); - Assert::assertRegExp($expectedValue, $actualValue, 'wrong "remote-item-id" in the response'); + Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "remote-item-id" in the response'); break; default: Assert::assertEquals($expectedValue, $actualValue, "wrong '$itemToFind' in the response");