Skip to content

Commit

Permalink
[tests-only] restore the removed scenarios for the core repository
Browse files Browse the repository at this point in the history
Signed-off-by: Kiran Parajuli <kiranparajuli589@gmail.com>
  • Loading branch information
kiranparajuli589 committed Aug 29, 2022
1 parent b79de5f commit 5eee569
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiGraph/createGroupCaseSensitive.feature:19](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L19)
- [apiGraph/createGroupCaseSensitive.feature:20](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L20)
- [apiGraph/createGroupCaseSensitive.feature:21](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L21)

### [PROPFIND on accepted shares with identical names containing brackets exit with 404](https://github.com/owncloud/ocis/issues/4421)

- [apiSpaces/changingFilesShare.feature:12](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changingFilesShare.feature#L12)
39 changes: 39 additions & 0 deletions tests/acceptance/features/apiSpaces/changingFilesShare.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@api @skipOnOcV10
Feature:

Background:
Given using spaces DAV path
And these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |

@issue-4421
Scenario: Move files between shares by different users
Given user "Carol" has been created with default attributes and without skeleton files
And user "Alice" has uploaded file with content "some data" to "/textfile0.txt"
And user "Alice" has created folder "/PARENT"
And user "Brian" has created folder "/PARENT"
And user "Alice" has moved file "textfile0.txt" to "PARENT/from_alice.txt" in space "Personal"
And user "Alice" has shared folder "/PARENT" with user "Carol"
And user "Brian" has shared folder "/PARENT" with user "Carol"
And user "Carol" has accepted share "/PARENT" offered by user "Alice"
And user "Carol" has accepted share "/PARENT" offered by user "Brian"
When user "Carol" moves file "PARENT/from_alice.txt" to "PARENT (1)/from_alice.txt" in space "Shares Jail" using the WebDAV API
Then the HTTP status code should be "201"
And for user "Carol" folder "PARENT" of the space "Shares Jail" should not contain these entries:
| from_alice.txt |
And for user "Carol" folder "PARENT (1)" of the space "Shares Jail" should contain these entries:
| from_alice.txt |


Scenario: overwrite a received file share
Given user "Alice" has uploaded file with content "this is the old content" to "/textfile1.txt"
And user "Alice" has shared file "/textfile1.txt" with user "Brian"
And user "Brian" has accepted share "/textfile1.txt" offered by user "Alice"
When user "Brian" uploads a file inside space "Shares Jail" with content "this is a new content" to "textfile1.txt" using the WebDAV API
Then the HTTP status code should be "204"
And for user "Brian" the space "Shares Jail" should contain these entries:
| textfile1.txt |
And for user "Brian" the content of the file "/textfile1.txt" of the space "Shares Jail" should be "this is a new content"
And for user "Alice" the content of the file "/textfile1.txt" of the space "Personal" should be "this is a new content"
2 changes: 2 additions & 0 deletions tests/acceptance/features/apiSpaces/moveSpaces.feature
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ Feature: move (rename) file
Then the HTTP status code should be "201"
And for user "Alice" folder "testshare2" of the space "Shares Jail" should contain these entries:
| testshare1.txt |
And for user "Alice" folder "testshare1" of the space "Shares Jail" should not contain these entries:
| testshare1.txt |
And for user "Brian" the space "Personal" should contain these entries:
| /testshare2/testshare1.txt |

Expand Down
60 changes: 58 additions & 2 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,20 @@ public function verifyTableNodeColumnsCount(
}
}

/**
* Escapes the given string for
* 1. Space --> %20
* 2. Opening Small Bracket --> %28
* 3. Closing Small Bracket --> %29
*
* @param string $path - File path to parse
*
* @return string
*/
public function escapePath(string $path): string {
return \str_replace([" ", "(", ")"], ["%20", "%28", "%29"], $path);
}

/**
* parses a PROPFIND response from $this->response into xml
* and returns found search results if found else returns false
Expand Down Expand Up @@ -1375,6 +1389,9 @@ public function findEntryFromPropfindResponse(
// trim any leading "/" passed by the caller, we can just match the "raw" name
$trimmedEntryNameToSearch = \trim($entryNameToSearch, "/");

// url encode for spaces and brackets that may appear in the filePath
$folderPath = $this->escapePath($folderPath);

// topWebDavPath should be something like /remote.php/webdav/ or
// /remote.php/dav/files/alice/
$topWebDavPath = "/" . "dav/spaces/" . $spaceId . "/" . $folderPath;
Expand Down Expand Up @@ -1850,6 +1867,7 @@ public function userCopiesFileWithinSpaceUsingTheWebDAVAPI(
* @param string $spaceName
*
* @return void
* @throws GuzzleException
*/
public function userMovesFileWithinSpaceUsingTheWebDAVAPI(
string $user,
Expand All @@ -1864,10 +1882,42 @@ public function userMovesFileWithinSpaceUsingTheWebDAVAPI(
$spaceName
);

$fullUrl = $space["root"]["webDavUrl"] . '/' . \trim($fileSource, "/");
$fileSource = $this->escapePath(\trim($fileSource, "/"));
$fullUrl = $space["root"]["webDavUrl"] . '/' . $fileSource;
$this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
}

/**
* @Given /^user "([^"]*)" has moved (?:file|folder) "([^"]*)" to "([^"]*)" in space "([^"]*)"$/
*
* @param string $user
* @param string $fileSource
* @param string $fileDestination
* @param string $spaceName
*
* @return void
* @throws GuzzleException
*/
public function userHasMovedFileWithinSpaceUsingTheWebDAVAPI(
string $user,
string $fileSource,
string $fileDestination,
string $spaceName
):void {
$this->userMovesFileWithinSpaceUsingTheWebDAVAPI(
$user,
$fileSource,
$fileDestination,
$spaceName
);
$this->featureContext->theHTTPStatusCodeShouldBe(
201,
__METHOD__ . "Expected response status code should be 201 (Created)\n" .
"Actual response status code was: " . $this->featureContext->getResponse()->getStatusCode() . "\n" .
"Actual response body was: " . $this->featureContext->getResponse()->getBody()
);
}

/**
* MOVE request for files|folders
*
Expand All @@ -1889,6 +1939,9 @@ public function moveFilesAndFoldersRequest(string $user, string $fullUrl, array
$headers,
)
);
$this->featureContext->pushToLastHttpStatusCodesArray(
(string)$this->featureContext->getResponse()->getStatusCode()
);
}

/**
Expand Down Expand Up @@ -1953,7 +2006,10 @@ public function userMovesFileFromAndToSpaceBetweenSpaces(
*/
public function destinationHeaderValueWithSpaceName(string $user, string $fileDestination, string $spaceName):string {
$space = $this->getSpaceByName($user, $spaceName);
return $space["root"]["webDavUrl"] . '/' . \ltrim($fileDestination, '/');

$fileDestination = $this->escapePath(\ltrim($fileDestination, "/"));

return $space["root"]["webDavUrl"] . '/' . $fileDestination;
}

/**
Expand Down

0 comments on commit 5eee569

Please sign in to comment.