From e1101940dcb211d6a720a8f0933cc7feaccece83 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 23 Jan 2024 12:40:13 +0545 Subject: [PATCH] fix cors tests --- ...xpected-failures-localAPI-on-OCIS-storage.md | 4 ---- .../features/apiContract/copy.feature | 4 +++- .../features/bootstrap/SpacesContext.php | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index acd221bf2..d9b6da351 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -359,9 +359,5 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiSpacesDavOperation/moveByFileId.feature:464](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L464) - [apiSpacesDavOperation/moveByFileId.feature:465](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L465) -### [CORS headers are only set when origin is sent by the client](https://github.com/owncloud/ocis/issues/5195) - -- [apiContract/copy.feature:16](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiContract/copy.feature#L16) - - Note: always have an empty line at the end of this file. The bash script that processes this file requires that the last line has a newline on the end. diff --git a/tests/acceptance/features/apiContract/copy.feature b/tests/acceptance/features/apiContract/copy.feature index 5bf61391e..08a1fc195 100644 --- a/tests/acceptance/features/apiContract/copy.feature +++ b/tests/acceptance/features/apiContract/copy.feature @@ -16,7 +16,9 @@ Feature: Copy test Scenario: check the COPY response headers Given user "Alice" has uploaded a file inside space "new-space" with content "some content" to "testfile.txt" And user "Alice" has created a folder "new" in space "new-space" - When user "Alice" copies file "testfile.txt" from space "new-space" to "/new/testfile.txt" inside space "new-space" using the WebDAV API + When user "Alice" copies file "testfile.txt" from space "new-space" to "/new/testfile.txt" inside space "new-space" with following headers using the WebDAV API + | header | value | + | 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}$/ | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index f4672f187..acc293c08 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1807,12 +1807,15 @@ class SpacesContext implements Context { /** * @When /^user "([^"]*)" copies (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)" using the WebDAV API$/ + * @When /^user "([^"]*)" copies (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)"(?: with following headers) using the WebDAV API$/ * * @param string $user * @param string $fileSource * @param string $fromSpaceName * @param string $fileDestination * @param string $toSpaceName + * @param string $toSpaceName + * @param TableNode|null $table * * @return void * @throws GuzzleException @@ -1822,10 +1825,22 @@ class SpacesContext implements Context { string $fileSource, string $fromSpaceName, string $fileDestination, - string $toSpaceName + string $toSpaceName, + TableNode $table = null ):void { $space = $this->getSpaceByName($user, $fromSpaceName); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName); + + if ($table !== null) { + $this->featureContext->verifyTableNodeColumns( + $table, + ['header', 'value'] + ); + foreach ($table as $row) { + $headers[$row['header']] = $this->featureContext->substituteInLineCodes($row['value']); + } + } + $fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($fileSource, "/"); $this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers)); }