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 1 commit
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,37 @@ Feature: moving/renaming file using file id
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |

@issue-6739
Scenario Outline: try to move a file to space 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 a file "textfile.txt" 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: move a file to folder 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"
And user "Alice" has created folder "docs"
And user "Alice" has uploaded file with content "readme file" to "docs/readme.txt"
When user "Alice" moves a file "textfile.txt" 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 |
40 changes: 40 additions & 0 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,46 @@ public function userCopiesOrMovesFileWithFileIdFromAndToSpaceBetweenSpaces(strin
}
}

/**
* @When /^user "([^"]*)" tries to move a (?:file|folder) "([^"]*)" to (space|folder) "([^"]*)" using its id in destination path "([^"]*)"$/
* @When /^user "([^"]*)" moves a (?:file|folder) "([^"]*)" to (folder) "([^"]*)" using its id in destination path "([^"]*)"$/
*
* @param string $user
* @param string $source
* @param string $destinationType
* @param string $destinationName
* @param string $destinationPath
*
* @throws GuzzleException
* @return void
*/
public function userMovesFileToResourceUsingItsIdAsDestinationPath(
string $user,
string $source,
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, "Personal") . "/";
saw-jan marked this conversation as resolved.
Show resolved Hide resolved
}
$fullUrl = $baseUrl . \rtrim($destinationPath, "/") . "/{$suffix}{$source}";

$destinationId = "";
if ($destinationType === "space") {
$destinationId = $this->getSpaceIdByName($user, $destinationName);
} else {
$destinationId = $this->getResourceId($user, "Personal", $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