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 23, 2022
1 parent cb2822b commit 9f6267e
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .drone.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The test runner source for API tests
CORE_COMMITID=f79fbff0a0d129df7b6ec20bc202665c4fda5fad
CORE_COMMITID=809f7256bdea4cd3dee45dfd5cd078542f4c55cf
CORE_BRANCH=master

# The test runner source for UI tests
Expand Down
2 changes: 2 additions & 0 deletions tests/acceptance/expected-failures-API-on-OCIS-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ File and sync features in a shared scenario
#### [not possible to move file into a received folder](https://github.com/owncloud/ocis/issues/764)

- [apiShareManagementBasicToShares/createShareToSharesFolder.feature:500](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/createShareToSharesFolder.feature#L500)
- [apiSpaces/changingFilesShare.feature:12](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSpaces/changingFilesShare.feature#L12)
- [apiSpaces/changingFilesShare.feature:67](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSpaces/changingFilesShare.feature#L67)

#### [File deletion using dav gives unique string in filename in the trashbin](https://github.com/owncloud/product/issues/178)

Expand Down
97 changes: 97 additions & 0 deletions tests/acceptance/features/apiSpaces/changingFilesShare.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
@api @skipOnOcV10
Feature:

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

@issue-764
Scenario: Moving a file into a share as recipient
Given user "Alice" has created folder "/shared"
And user "Alice" has shared folder "/shared" with user "Brian"
And user "Brian" has accepted share "/shared" offered by user "Alice"
And user "Brian" has uploaded file with content "some data" to "/textfile0.txt"
When user "Brian" moves file "textfile0.txt" from space "Personal" to "shared/shared_file.txt" inside space "Shares Jail" using the WebDAV API
Then the HTTP status code should be "201"
And for user "Brian" folder "shared" of the space "Shares Jail" should contain these entries:
| shared_file.txt |
And for user "Alice" the space "Personal" should contain these entries:
| shared_file.txt |


Scenario: Moving files between shares by same user
And user "Alice" has created folder "share1"
And user "Alice" has created folder "share2"
And user "Alice" has uploaded file with content "some data" to "/textfile0.txt"
And user "Alice" has moved file "textfile0.txt" to "share1/textfile0.txt"
And user "Alice" has shared folder "/share1" with user "Brian"
And user "Alice" has shared folder "/share2" with user "Brian"
And user "Brian" has accepted share "/share1" offered by user "Alice"
And user "Brian" has accepted share "/share2" offered by user "Alice"
When user "Brian" moves file "share1/textfile0.txt" to "share2/textfile0.txt" in space "Shares Jail" using the WebDAV API
Then the HTTP status code should be "201"
And for user "Brian" folder "share1" of the space "Shares Jail" should not contain these entries:
| textfile0.txt |
And for user "Brian" folder "share2" of the space "Shares Jail" should contain these entries:
| textfile0.txt |
And for user "Alice" the space "Personal" should not contain these entries:
| share1/textfile0.txt |
And for user "Alice" the space "Personal" should contain these entries:
| share2/textfile0.txt |

@issue-764
Scenario: Moving files added by sharee between shares by same user
And user "Alice" has created folder "share1"
And user "Alice" has created folder "share2"
And user "Brian" has uploaded file with content "some data" to "/textfile0.txt"
And user "Alice" has shared folder "/share1" with user "Brian"
And user "Alice" has shared folder "/share2" with user "Brian"
And user "Brian" has accepted share "/share1" offered by user "Alice"
And user "Brian" has accepted share "/share2" offered by user "Alice"
When user "Brian" moves file "textfile0.txt" from space "Personal" to "share1/shared_file.txt" inside space "Shares Jail" using the WebDAV API
And user "Brian" moves file "share1/shared_file.txt" to "share2/shared_file.txt" in space "Shares Jail" using the WebDAV API
Then the HTTP status code of responses on all endpoints should be "201"
And for user "Brian" folder "share1" of the space "Shares Jail" should not contain these entries:
| shared_file.txt |
And for user "Alice" the space "Personal" should contain these entries:
| share1/shared_file.txt |
And for user "Brian" folder "share2" of the space "Shares Jail" should contain these entries:
| shared_file.txt |
And for user "Alice" the space "Personal" should contain these entries:
| share2/shared_file.txt |

@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/shared_file.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/shared_file.txt" to "PARENT (1)/shared_file.txt" in space "Shares Jail" using the WebDAV API
Then the HTTP status code should be "201"
And as "Carol" file "/Shares/PARENT (1)/shared_file.txt" should exist
And for user "Brian" folder "PARENT (1)" of the space "Shares Jail" should contain these entries:
| shared_file.txt |
And for user "Brian" the space "Personal" should contain these entries:
| PARENT/shared_file.txt |
And for user "Alice" the space "Personal" should not contain these entries:
| PARENT/shared_file.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 the content of file "textfile1.txt" inside space "Shares Jail" for user "Brian" should be "this is a new content"
And the content of file "textfile1.txt" inside space "Personal" for user "Alice" should be "this is a new content"
77 changes: 74 additions & 3 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,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 = \str_replace([" ", "(", ")"], ["%20", "%28", "%29"], $folderPath);

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

$fullUrl = $space["root"]["webDavUrl"] . '/' . \trim($fileSource, "/");
$fileSource = \trim($fileSource, "/");
$fileSource = \str_replace([" ", "(", ")"], ["%20", "%28", "%29"], $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 @@ -1885,6 +1922,9 @@ public function moveFilesAndFoldersRequest(string $user, string $fullUrl, array
$headers,
)
);
$this->featureContext->pushToLastHttpStatusCodesArray(
(string)$this->featureContext->getResponse()->getStatusCode()
);
}

/**
Expand Down Expand Up @@ -1949,7 +1989,11 @@ 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 = \ltrim($fileDestination, "/");
$fileDestination = \str_replace([" ", "(", ")"], ["%20", "%28", "%29"], $fileDestination);

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

/**
Expand Down Expand Up @@ -3027,7 +3071,7 @@ public function forUserSpaceShouldContainLinks(
string $fileName = ''
): void {
$body = '';
if (!empty ($fileName)) {
if (!empty($fileName)) {
$body = $this->getFileId($user, $spaceName, $fileName);
} else {
$space = $this->getSpaceByName($user, $spaceName);
Expand Down Expand Up @@ -3142,4 +3186,31 @@ public function asUserFileInsideSpaceShouldContainAPropertyWithValue(
$expectedValue
);
}

/**
* @Given /^the content of file "([^"]*)" inside space "([^"]*)" for user "([^"]*)" should be "([^"]*)"$/
* @throws GuzzleException
*/
public function theContentOfFileInsideSpaceForUserShouldBe($fileSource, $spaceName, $user, $expectedContent) {
$user = $this->featureContext->getActualUsername($user);
$space = $this->getSpaceByName($user, $spaceName);
$fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($fileSource, "/");
$this->featureContext->setResponse(
HttpRequestHelper::get(
$fullUrl,
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
)
);
$this->featureContext->theHttpStatusCodeShouldBe(200);
$actualContent = (string) $this->featureContext->getResponse()->getBody();
Assert::assertEquals(
$expectedContent,
$actualContent,
__METHOD__ . " Downloaded content mis-match for resource at '$fileSource' inside space '$spaceName'" .
"\n- Expected content: $expectedContent" .
"\n+ Actual content: $actualContent"
);
}
}

0 comments on commit 9f6267e

Please sign in to comment.