Skip to content

Commit dfcabbf

Browse files
authored
Merge pull request #11569 from Ashim-Stha/copyFolderWithHeader
[tests-only][full-ci] Add test for copying folder, moving folder and deleting folder with `Transfer-Encoding: chunked` header
2 parents c28455c + fa79fca commit dfcabbf

File tree

4 files changed

+106
-3
lines changed

4 files changed

+106
-3
lines changed

tests/acceptance/bootstrap/WebDav.php

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,16 @@ public function userHasMovedFile(
507507
* @param string $user
508508
* @param string $source
509509
* @param string $destination
510+
* @param array|null $headers
510511
*
511512
* @return ResponseInterface
512513
*/
513-
public function moveResource(string $user, string $source, string $destination): ResponseInterface {
514+
public function moveResource(
515+
string $user,
516+
string $source,
517+
string $destination,
518+
?array $headers = [],
519+
): ResponseInterface {
514520
$user = $this->getActualUsername($user);
515521
$headers['Destination'] = $this->destinationHeaderValue(
516522
$user,
@@ -546,6 +552,33 @@ public function userMovesFileOrFolderUsingTheWebDavAPI(
546552
$this->pushToLastHttpStatusCodesArray();
547553
}
548554

555+
/**
556+
* @When user :user moves file/folder :source to :destination with the following headers using the WebDAV API
557+
*
558+
* @param string $user
559+
* @param string $source
560+
* @param string $destination
561+
* @param TableNode $table
562+
*
563+
* @return void
564+
* @throws JsonException
565+
* @throws GuzzleException
566+
*/
567+
public function userMovesResourceWithTheFollowingHeadersUsingTheWebDavAPI(
568+
string $user,
569+
string $source,
570+
string $destination,
571+
TableNode $table,
572+
): void {
573+
$headers = [];
574+
foreach ($table->getColumnsHash() as $header) {
575+
$headers[$header["header"]] = $header["value"];
576+
}
577+
$response = $this->moveResource($user, $source, $destination, $headers);
578+
$this->setResponse($response);
579+
$this->pushToLastHttpStatusCodesArray();
580+
}
581+
549582
/**
550583
* @When user :user moves the following file using the WebDAV API
551584
*
@@ -2543,13 +2576,14 @@ public function theUserShouldNotBeAbleToDeleteEntry(string $user, string $entry,
25432576
/**
25442577
* @param string $user
25452578
* @param string $resource
2579+
* @param array|null $headers
25462580
*
25472581
* @return void
25482582
*/
2549-
public function deleteFile(string $user, string $resource): ResponseInterface {
2583+
public function deleteFile(string $user, string $resource, ?array $headers = []): ResponseInterface {
25502584
$user = $this->getActualUsername($user);
25512585
$this->pauseUploadDelete();
2552-
$response = $this->makeDavRequest($user, 'DELETE', $resource, []);
2586+
$response = $this->makeDavRequest($user, 'DELETE', $resource, $headers);
25532587
$this->lastUploadDeleteTime = \time();
25542588
return $response;
25552589
}
@@ -2568,6 +2602,29 @@ public function userDeletesFile(string $user, string $resource): void {
25682602
$this->pushToLastStatusCodesArrays();
25692603
}
25702604

2605+
/**
2606+
* @When user :user deletes file/folder :resource with the following headers using the WebDAV API
2607+
*
2608+
* @param string $user
2609+
* @param string $resource
2610+
* @param TableNode $table
2611+
*
2612+
* @return void
2613+
*/
2614+
public function userDeletesFileOrFolderWithTheFollowingHeadersUsingTheWebDAVAPI(
2615+
string $user,
2616+
string $resource,
2617+
TableNode $table,
2618+
): void {
2619+
$headers = [];
2620+
foreach ($table->getColumnsHash() as $header) {
2621+
$headers[$header["header"]] = $header["value"];
2622+
}
2623+
$response = $this->deleteFile($user, $resource, $headers);
2624+
$this->setResponse($response);
2625+
$this->pushToLastStatusCodesArrays();
2626+
}
2627+
25712628
/**
25722629
* @When user :user deletes file :filename from space :space using file-id :fileId
25732630
*

tests/acceptance/features/apiContract/copy.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,14 @@ Feature: Copy test
2525
| Access-Control-Allow-Origin | /^%base_url%$/ |
2626
| X-Request-Id | %request_id_pattern% |
2727

28+
@issue-10809
29+
Scenario: copy a folder with Transfer-Encoding: chunked header
30+
Given user "Alice" has created a folder "folder1" in space "new-space"
31+
And user "Alice" has created a folder "folder2" in space "new-space"
32+
When user "Alice" copies folder "folder2" from space "new-space" to "folder1/folder2" inside space "new-space" with following headers using the WebDAV API
33+
| header | value |
34+
# NOTE: requires system curl version >= 8.12.0
35+
| Transfer-Encoding | chunked |
36+
Then the HTTP status code should be "201"
37+
And for user "Alice" folder "folder1" of the space "new-space" should contain these entries:
38+
| folder2 |

tests/acceptance/features/coreApiWebdavDelete/deleteFolder.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,18 @@ Feature: delete folder
7979
| spaces | /..fo |
8080
| spaces | /fo.xyz |
8181
| spaces | /fo.exe |
82+
83+
@issue-10809
84+
Scenario Outline: delete a folder with Transfer-Encoding: chunked header
85+
Given using <dav-path-version> DAV path
86+
When user "Alice" deletes folder "PARENT" with the following headers using the WebDAV API
87+
| header | value |
88+
# NOTE: requires system curl version >= 8.12.0
89+
| Transfer-Encoding | chunked |
90+
Then the HTTP status code should be "204"
91+
And as "Alice" folder "PARENT" should not exist
92+
Examples:
93+
| dav-path-version |
94+
| old |
95+
| new |
96+
| spaces |

tests/acceptance/features/coreApiWebdavMove1/moveFolder.feature

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,23 @@ Feature: move (rename) folder
264264
| old |
265265
| new |
266266
| spaces |
267+
268+
@issue-10809
269+
Scenario Outline: move a folder with Transfer-Encoding: chunked header
270+
Given using <dav-path-version> DAV path
271+
And user "Alice" has created folder "folder1"
272+
And user "Alice" has created folder "folder2"
273+
When user "Alice" moves folder "folder2" to "folder1/folder2" with the following headers using the WebDAV API
274+
| header | value |
275+
# NOTE: requires system curl version >= 8.12.0
276+
| Transfer-Encoding | chunked |
277+
Then the HTTP status code should be "201"
278+
And user "Alice" should not see the following elements
279+
| folder2 |
280+
And user "Alice" should see the following elements
281+
| folder1/folder2 |
282+
Examples:
283+
| dav-path-version |
284+
| old |
285+
| new |
286+
| spaces |

0 commit comments

Comments
 (0)