Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only] add API test coverage for file MOVE to space-id as destination #8459

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -706,3 +706,67 @@ Feature: moving/renaming file using file id
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |

@issue-6739
Scenario Outline: try to move personal file to other spaces using its id as the destination
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "myspace" with the default quota using the Graph API
And user "Alice" has uploaded file with content "some data" to "textfile.txt"
When user "Alice" tries to move file "textfile.txt" of space "Personal" to space "<space>" using its id in destination path "<dav-path>"
Then the HTTP status code should be "400"
And for user "Alice" the space "Personal" should contain these entries:
| textfile.txt |
Examples:
| dav-path | space |
| /remote.php/dav/spaces | Personal |
| /dav/spaces | Personal |
| /remote.php/dav/spaces | myspace |
| /dav/spaces | myspace |

@issue-6739
Scenario Outline: try to move project file to other spaces using its id as the destination
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "myspace" with the default quota using the Graph API
And user "Alice" has uploaded a file inside space "myspace" with content "some data" to "textfile.txt"
When user "Alice" tries to move file "textfile.txt" of space "myspace" to space "<space>" using its id in destination path "<dav-path>"
Then the HTTP status code should be "400"
And for user "Alice" the space "myspace" should contain these entries:
| textfile.txt |
Examples:
| dav-path | space |
| /remote.php/dav/spaces | Personal |
| /dav/spaces | Personal |
| /remote.php/dav/spaces | myspace |
| /dav/spaces | myspace |

@issue-6739
Scenario Outline: move a file to folder using its id as the destination (Personal space)
Given user "Alice" has uploaded file with content "some data" to "textfile.txt"
And user "Alice" has created folder "docs"
When user "Alice" moves file "textfile.txt" of space "Personal" to folder "docs" using its id in destination path "<dav-path>"
Then the HTTP status code should be "204"
And the content of file "docs" for user "Alice" should be "some data"
And as "Alice" file "textfile.txt" should not exist
And as "Alice" folder "docs" should not exist
And as "Alice" folder "docs" should exist in the trashbin of the space "Personal"
Examples:
| dav-path |
| /remote.php/dav/spaces |
| /dav/spaces |

@issue-6739
Scenario Outline: move a file to folder using its id as the destination (Project space)
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "myspace" with the default quota using the Graph API
And user "Alice" has uploaded a file inside space "myspace" with content "some data" to "textfile.txt"
And user "Alice" has created a folder "docs" in space "myspace"
When user "Alice" moves file "textfile.txt" of space "myspace" to folder "docs" using its id in destination path "<dav-path>"
Then the HTTP status code should be "204"
And for user "Alice" the content of the file "docs" of the space "myspace" should be "some data"
And as "Alice" folder "docs" should exist in the trashbin of the space "myspace"
And for user "Alice" folder "/" of the space "myspace" should not contain these files:
| textfile.txt |
Examples:
| dav-path |
| /remote.php/dav/spaces |
| /dav/spaces |
42 changes: 42 additions & 0 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,48 @@ public function userCopiesOrMovesFileWithFileIdFromAndToSpaceBetweenSpaces(strin
}
}

/**
* @When /^user "([^"]*)" tries to move (?:file|folder) "([^"]*)" of space "([^"]*)" to (space|folder) "([^"]*)" using its id in destination path "([^"]*)"$/
* @When /^user "([^"]*)" moves (?:file|folder) "([^"]*)" of space "([^"]*)" to (folder) "([^"]*)" using its id in destination path "([^"]*)"$/
*
* @param string $user
* @param string $source
* @param string $sourceSpace
* @param string $destinationType
* @param string $destinationName
* @param string $destinationPath
*
* @throws GuzzleException
* @return void
*/
public function userMovesFileToResourceUsingItsIdAsDestinationPath(
string $user,
string $source,
string $sourceSpace,
string $destinationType,
string $destinationName,
string $destinationPath
): void {
$source = \trim($source, "/");
$baseUrl = $this->featureContext->getBaseUrl();
$suffix = "";
if ($this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
$suffix = $this->getSpaceIdByName($user, $sourceSpace) . "/";
}
$fullUrl = $baseUrl . \rtrim($destinationPath, "/") . "/{$suffix}{$source}";

$destinationId = "";
if ($destinationType === "space") {
$destinationId = $this->getSpaceIdByName($user, $destinationName);
} else {
$destinationId = $this->getResourceId($user, $sourceSpace, $destinationName);
}
$headers['Destination'] = $baseUrl . \rtrim($destinationPath, "/") . "/$destinationId";

$response = $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
$this->featureContext->setResponse($response);
}

/**
* @Given /^user "([^"]*)" has uploaded a file inside space "([^"]*)" with content "([^"]*)" to "([^"]*)"$/
*
Expand Down
9 changes: 6 additions & 3 deletions tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -1752,9 +1752,12 @@ public function asFileOrFolderShouldNotExist(
} else {
$actualResourceType = "folder";
}
Assert::fail(
"$entry '$path' should not exist. But it does exist and is a $actualResourceType"
);

if ($entry === $actualResourceType) {
Assert::fail(
"$entry '$path' should not exist. But it does."
);
}
}
}

Expand Down