fix cors tests

This commit is contained in:
Saw-jan
2024-01-23 12:40:13 +05:45
parent ca2b5744a1
commit e1101940dc
3 changed files with 19 additions and 6 deletions
@@ -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: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) - [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. - 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. The bash script that processes this file requires that the last line has a newline on the end.
@@ -16,7 +16,9 @@ Feature: Copy test
Scenario: check the COPY response headers Scenario: check the COPY response headers
Given user "Alice" has uploaded a file inside space "new-space" with content "some content" to "testfile.txt" 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" 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" Then the HTTP status code should be "201"
And the following headers should match these regular expressions And the following headers should match these regular expressions
| Oc-Fileid | /^[a-f0-9!\$\-]{110}$/ | | Oc-Fileid | /^[a-f0-9!\$\-]{110}$/ |
@@ -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 "([^"]*)" 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 $user
* @param string $fileSource * @param string $fileSource
* @param string $fromSpaceName * @param string $fromSpaceName
* @param string $fileDestination * @param string $fileDestination
* @param string $toSpaceName * @param string $toSpaceName
* @param string $toSpaceName
* @param TableNode|null $table
* *
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
@@ -1822,10 +1825,22 @@ class SpacesContext implements Context {
string $fileSource, string $fileSource,
string $fromSpaceName, string $fromSpaceName,
string $fileDestination, string $fileDestination,
string $toSpaceName string $toSpaceName,
TableNode $table = null
):void { ):void {
$space = $this->getSpaceByName($user, $fromSpaceName); $space = $this->getSpaceByName($user, $fromSpaceName);
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName); $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, "/"); $fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($fileSource, "/");
$this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers)); $this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers));
} }