From f976386ee2e7c9ce8aee06817d655ad565876d37 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 30 Jul 2024 17:10:35 +0545 Subject: [PATCH] test: fix tests and issue tags test: fix properties namespace --- tests/TestHelpers/WebDavHelper.php | 6 +-- .../expected-failures-API-on-OCIS-storage.md | 24 ++++----- .../features/bootstrap/FavoritesContext.php | 27 ---------- .../bootstrap/FilesVersionsContext.php | 4 +- .../bootstrap/WebDavPropertiesContext.php | 49 ++++++++++--------- .../setFileProperties.feature | 14 ++++-- 6 files changed, 54 insertions(+), 70 deletions(-) diff --git a/tests/TestHelpers/WebDavHelper.php b/tests/TestHelpers/WebDavHelper.php index 29e2c7f2e8..55064e7fb0 100644 --- a/tests/TestHelpers/WebDavHelper.php +++ b/tests/TestHelpers/WebDavHelper.php @@ -146,7 +146,7 @@ class WebDavHelper { $property = $propertyParts[1]; } - if ($namespacePrefix){ + if ($namespacePrefix) { $propertyBody .= "<$namespacePrefix:$property/>"; } else { $propertyBody .= "<$property/>"; @@ -418,7 +418,7 @@ class WebDavHelper { ):ResponseInterface { if (!$properties) { $properties = [ - 'getetag', 'resourcetype' + 'd:getetag', 'd:resourcetype' ]; } return self::propfind( @@ -940,7 +940,7 @@ class WebDavHelper { $user, $password, $resource, - ["getlastmodified"], + ["d:getlastmodified"], $xRequestId, "0", "files", diff --git a/tests/acceptance/expected-failures-API-on-OCIS-storage.md b/tests/acceptance/expected-failures-API-on-OCIS-storage.md index c5a65ee552..c67e3062c8 100644 --- a/tests/acceptance/expected-failures-API-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-API-on-OCIS-storage.md @@ -8,16 +8,21 @@ Basic file management like up and download, move, copy, properties, trash, versi #### [COPY a folder to received share file/folder seems to work but no change in shares](https://github.com/owncloud/ocis/issues/6999) -- [coreApiWebdavProperties/copyFile.feature:261](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L261) -- [coreApiWebdavProperties/copyFile.feature:262](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L262) +- [coreApiWebdavProperties/copyFile.feature:284](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L284) +- [coreApiWebdavProperties/copyFile.feature:285](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L285) +- [coreApiWebdavProperties/copyFile.feature:308](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L308) +- [coreApiWebdavProperties/copyFile.feature:309](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L309) +- [coreApiWebdavProperties/copyFile.feature:482](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L482) +- [coreApiWebdavProperties/copyFile.feature:483](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L483) +- [coreApiWebdavProperties/copyFile.feature:484](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L484) #### [Custom dav properties with namespaces are rendered incorrectly](https://github.com/owncloud/ocis/issues/2140) _ocdav: double-check the webdav property parsing when custom namespaces are used_ -- [coreApiWebdavProperties/setFileProperties.feature:120](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/setFileProperties.feature#L120) -- [coreApiWebdavProperties/setFileProperties.feature:121](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/setFileProperties.feature#L121) -- [coreApiWebdavProperties/setFileProperties.feature:122](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/setFileProperties.feature#L122) +- [coreApiWebdavProperties/setFileProperties.feature:128](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/setFileProperties.feature#L128) +- [coreApiWebdavProperties/setFileProperties.feature:129](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/setFileProperties.feature#L129) +- [coreApiWebdavProperties/setFileProperties.feature:130](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/setFileProperties.feature#L130) #### [Cannot set custom webDav properties](https://github.com/owncloud/product/issues/264) @@ -187,14 +192,11 @@ And other missing implementation of favorites #### [copying the file inside Shares folder returns 412](https://github.com/owncloud/ocis/issues/3874) -- [coreApiWebdavProperties/copyFile.feature:408](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L408) -- [coreApiWebdavProperties/copyFile.feature:409](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L409) -- [coreApiWebdavProperties/copyFile.feature:410](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L410) -- [coreApiWebdavProperties/copyFile.feature:435](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L435) -- [coreApiWebdavProperties/copyFile.feature:436](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L436) -- [coreApiWebdavProperties/copyFile.feature:437](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L437) - [coreApiWebdavProperties/copyFile.feature:238](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L238) - [coreApiWebdavProperties/copyFile.feature:239](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L239) +- [coreApiWebdavProperties/copyFile.feature:455](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L455) +- [coreApiWebdavProperties/copyFile.feature:456](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L456) +- [coreApiWebdavProperties/copyFile.feature:457](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L457) ### Won't fix diff --git a/tests/acceptance/features/bootstrap/FavoritesContext.php b/tests/acceptance/features/bootstrap/FavoritesContext.php index c6af207eb4..0cf927acb5 100644 --- a/tests/acceptance/features/bootstrap/FavoritesContext.php +++ b/tests/acceptance/features/bootstrap/FavoritesContext.php @@ -192,33 +192,6 @@ class FavoritesContext implements Context { $this->asUserFileOrFolderShouldBeFavorited($user, $path, 0); } - /** - * @Then /^as the user (?:file|folder|entry) "([^"]*)" should be favorited$/ - * - * @param string $path - * @param integer $expectedValue 0|1 - * - * @return void - */ - public function asTheUserFileOrFolderShouldBeFavorited(string $path, int $expectedValue = 1):void { - $this->asUserFileOrFolderShouldBeFavorited( - $this->featureContext->getCurrentUser(), - $path, - $expectedValue - ); - } - - /** - * @Then /^as the user (?:file|folder|entry) "([^"]*)" should not be favorited$/ - * - * @param string $path - * - * @return void - */ - public function asTheUserFileOrFolderShouldNotBeFavorited(string $path):void { - $this->asTheUserFileOrFolderShouldBeFavorited($path, 0); - } - /** * Set the elements of a proppatch * diff --git a/tests/acceptance/features/bootstrap/FilesVersionsContext.php b/tests/acceptance/features/bootstrap/FilesVersionsContext.php index bf3b89e53b..fb8401fded 100644 --- a/tests/acceptance/features/bootstrap/FilesVersionsContext.php +++ b/tests/acceptance/features/bootstrap/FilesVersionsContext.php @@ -315,7 +315,7 @@ class FilesVersionsContext implements Context { $user = $this->featureContext->getActualUsername($user); $fileId = $this->featureContext->getFileIdForPath($user, $path); Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)"); - $response = $this->listVersionFolder($user, $fileId, 1, ['getcontentlength']); + $response = $this->listVersionFolder($user, $fileId, 1, ['d:getcontentlength']); $responseXml = HttpRequestHelper::getResponseXml( $response, __METHOD__ @@ -504,7 +504,7 @@ class FilesVersionsContext implements Context { ):ResponseInterface { if (!$properties) { $properties = [ - 'getetag' + 'd:getetag' ]; } $user = $this->featureContext->getActualUsername($user); diff --git a/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php b/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php index 87b4e5fa6b..b89c23b962 100644 --- a/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php +++ b/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php @@ -213,15 +213,15 @@ class WebDavPropertiesContext implements Context { $user = $this->featureContext->getActualUsername($user); $properties = [$propertyName]; $response = WebDavHelper::propfind( - $this->featureContext->getBaseUrl(), - $this->featureContext->getActualUsername($user), - $this->featureContext->getUserPassword($user), - $path, - $properties, - $this->featureContext->getStepLineRef(), - "0", - "files", - $this->featureContext->getDavPathVersion() + $this->featureContext->getBaseUrl(), + $this->featureContext->getActualUsername($user), + $this->featureContext->getUserPassword($user), + $path, + $properties, + $this->featureContext->getStepLineRef(), + "0", + "files", + $this->featureContext->getDavPathVersion() ); $this->featureContext->setResponse($response); } @@ -248,15 +248,15 @@ class WebDavPropertiesContext implements Context { $namespace => $propertyName ]; $response = WebDavHelper::propfind( - $this->featureContext->getBaseUrl(), - $this->featureContext->getActualUsername($user), - $this->featureContext->getUserPassword($user), - $path, - $properties, - $this->featureContext->getStepLineRef(), - "0", - "files", - $this->featureContext->getDavPathVersion() + $this->featureContext->getBaseUrl(), + $this->featureContext->getActualUsername($user), + $this->featureContext->getUserPassword($user), + $path, + $properties, + $this->featureContext->getStepLineRef(), + "0", + "files", + $this->featureContext->getDavPathVersion() ); $this->featureContext->setResponse($response); } @@ -645,14 +645,12 @@ class WebDavPropertiesContext implements Context { public function checkResponseContainsProperty(ResponseInterface $response, string $key, string $namespaceString = null): SimpleXMLElement { $xmlPart = $this->featureContext->getResponseXml($response); - $nsPrefix = ""; if ($namespaceString !== null) { $ns = $this->parseNamespace($namespaceString); $xmlPart->registerXPathNamespace( $ns->prefix, $ns->namespace ); - $nsPrefix = $ns->prefix . ":"; } $match = $xmlPart->xpath("//d:prop/$key"); @@ -661,9 +659,12 @@ class WebDavPropertiesContext implements Context { isset($match[0]), "Cannot find property \"$key\"" ); + + $property = \explode(":", $key); + $propertyName = $property[\count($property) - 1]; Assert::assertEquals( - $nsPrefix.$match[0]->getName(), - $key + $match[0]->getName(), + $propertyName ); return $match[0]; } @@ -1176,7 +1177,7 @@ class WebDavPropertiesContext implements Context { $storePath = $path; } $user = $this->featureContext->getActualUsername($user); - $propertiesTable = new TableNode([['propertyName'],['getetag']]); + $propertiesTable = new TableNode([['propertyName'],['d:getetag']]); $response = $this->getPropertiesOfFolder( $user, $path, @@ -1322,7 +1323,7 @@ class WebDavPropertiesContext implements Context { */ public function getCurrentEtagOfElement(string $path, string $user):string { $user = $this->featureContext->getActualUsername($user); - $propertiesTable = new TableNode([['propertyName'],['getetag']]); + $propertiesTable = new TableNode([['propertyName'],['d:getetag']]); $response = $this->getPropertiesOfFolder( $user, $path, diff --git a/tests/acceptance/features/coreApiWebdavProperties/setFileProperties.feature b/tests/acceptance/features/coreApiWebdavProperties/setFileProperties.feature index d395a43345..26e68c65c4 100644 --- a/tests/acceptance/features/coreApiWebdavProperties/setFileProperties.feature +++ b/tests/acceptance/features/coreApiWebdavProperties/setFileProperties.feature @@ -14,9 +14,17 @@ Feature: set file properties When user "Alice" sets property "very-custom-prop" of file "testcustomprop.txt" to "veryCustomPropValue" Then the HTTP status code should be "207" And the xml response should contain a property "very-custom-prop" + And the content in the response should include the following content: + """ + + """ When user "Alice" gets a custom property "very-custom-prop" of file "testcustomprop.txt" Then the HTTP status code should be "207" And the response should contain a custom "very-custom-prop" property with value "veryCustomPropValue" + And the content in the response should include the following content: + """ + veryCustomPropValue + """ Examples: | dav-path-version | | old | @@ -101,7 +109,7 @@ Feature: set file properties Scenario Outline: setting custom DAV property with custom namespace and reading it Given using DAV path And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "testcustomprop.txt" - When user "Alice" sets property "very-custom-prop" with namespace "x1='http://whatever.org/ns'" of file "testcustomprop.txt" to "customPropValue" using the WebDAV API + When user "Alice" sets property "very-custom-prop" with namespace "x1='http://whatever.org/ns'" of file "testcustomprop.txt" to "veryCustomPropValue" using the WebDAV API Then the HTTP status code should be "207" And the xml response should contain a property "x1:very-custom-prop" with namespace "x1='http://whatever.org/ns'" And the content in the response should include the following content: @@ -110,10 +118,10 @@ Feature: set file properties """ When user "Alice" gets a custom property "x1:very-custom-prop" with namespace "x1='http://whatever.org/ns'" of file "testcustomprop.txt" Then the HTTP status code should be "207" - And the response should contain a custom "x1:very-custom-prop" property with namespace "x1='http://whatever.org/ns'" and value "customPropValue" + And the response should contain a custom "x1:very-custom-prop" property with namespace "x1='http://whatever.org/ns'" and value "veryCustomPropValue" And the content in the response should include the following content: """ - customPropValue + veryCustomPropValue """ Examples: | dav-path-version |