Skip to content

Commit

Permalink
Added webdav spaces in apiTrashbin/trashbinDelete.feature
Browse files Browse the repository at this point in the history
  • Loading branch information
grgprarup committed Apr 19, 2022
1 parent e98e41f commit b6e7379
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 36 deletions.
14 changes: 11 additions & 3 deletions tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,11 @@ public static function makeDavRequest(
$spaceId = null;
// get space id if testing with spaces dav
if ($davPathVersionToUse === self::DAV_VERSION_SPACES) {
$spaceId = self::getPersonalSpaceIdForUser($baseUrl, $user, $password, $xRequestId);
if ($doDavRequestAsUser === null) {
$spaceId = self::getPersonalSpaceIdForUser($baseUrl, $user, $password, $xRequestId);
} else {
$spaceId = self::getPersonalSpaceIdForUser($baseUrl, $doDavRequestAsUser, $password, $xRequestId);
}
}

if ($doDavRequestAsUser === null) {
Expand Down Expand Up @@ -633,15 +637,19 @@ public static function getDavPath(
__METHOD__ . " A spaceId must be passed when using DAV path version 3 (spaces)"
);
}
if ($type === "trash-bin") {
return "/remote.php/dav/spaces/trash-bin/" . $spaceId . '/';
}
return "dav/spaces/" . $spaceId . '/';
} else {
if ($davPathVersionToUse === self::DAV_VERSION_OLD) {
$path = "remote.php/webdav/";
return $path;
return "remote.php/webdav/";
} elseif ($davPathVersionToUse === self::DAV_VERSION_NEW) {
if ($type === "files") {
$path = 'remote.php/dav/files/';
return $path . $user . '/';
} elseif ($type === "trash-bin") {
return "remote.php/dav/trash-bin/" . $user . '/';
} else {
return "remote.php/dav";
}
Expand Down
130 changes: 107 additions & 23 deletions tests/acceptance/features/apiTrashbin/trashbinDelete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Feature: files and folders can be deleted from the trashbin

@smokeTest
Scenario Outline: Trashbin can be emptied
Given user "Alice" has uploaded file with content "file with comma" to "sample,0.txt"
Given using <dav-path> DAV path
And user "Alice" has uploaded file with content "file with comma" to "sample,0.txt"
And user "Alice" has uploaded file with content "file with comma" to "sample,1.txt"
And using <dav-path> DAV path
And user "Alice" has deleted file "<filename1>"
And user "Alice" has deleted file "<filename2>"
When user "Alice" empties the trashbin using the trashbin API
Expand All @@ -26,14 +26,19 @@ Feature: files and folders can be deleted from the trashbin
And as "Alice" the file with original path "<filename2>" should not exist in the trashbin
Examples:
| dav-path | filename1 | filename2 |
| old | textfile0.txt | textfile1.txt |
| new | textfile0.txt | textfile1.txt |
| old | sample,0.txt | sample,1.txt |
| new | sample,0.txt | sample,1.txt |

@skipOnOcV10 @personalSpace
Examples:
| dav-path | filename1 | filename2 |
| spaces | textfile0.txt | textfile1.txt |
| spaces | sample,0.txt | sample,1.txt |

@smokeTest
Scenario: delete a single file from the trashbin
Given user "Alice" has deleted file "/textfile0.txt"
Scenario Outline: delete a single file from the trashbin
Given using <dav-path> DAV path
And user "Alice" has deleted file "/textfile0.txt"
And user "Alice" has deleted file "/textfile1.txt"
And user "Alice" has deleted file "/PARENT/parent.txt"
And user "Alice" has deleted file "/PARENT/CHILD/child.txt"
Expand All @@ -43,10 +48,19 @@ Feature: files and folders can be deleted from the trashbin
But as "Alice" the file with original path "/textfile0.txt" should exist in the trashbin
And as "Alice" the file with original path "/PARENT/parent.txt" should exist in the trashbin
And as "Alice" the file with original path "/PARENT/CHILD/child.txt" should exist in the trashbin
Examples:
| dav-path |
| new |

@skipOnOcV10 @personalSpace
Examples:
| dav-path |
| spaces |

@smokeTest
Scenario: delete multiple files from the trashbin and make sure the correct ones are gone
Given user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/PARENT/textfile0.txt"
Scenario Outline: delete multiple files from the trashbin and make sure the correct ones are gone
Given using <dav-path> DAV path
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/PARENT/textfile0.txt"
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/PARENT/child.txt"
And user "Alice" has deleted file "/textfile0.txt"
And user "Alice" has deleted file "/textfile1.txt"
Expand All @@ -61,10 +75,19 @@ Feature: files and folders can be deleted from the trashbin
And as "Alice" the file with original path "/PARENT/CHILD/child.txt" should not exist in the trashbin
But as "Alice" the file with original path "/textfile0.txt" should exist in the trashbin
And as "Alice" the file with original path "/PARENT/child.txt" should exist in the trashbin
Examples:
| dav-path |
| new |

@skipOnOcV10 @personalSpace
Examples:
| dav-path |
| spaces |

@skipOnOcV10.3
Scenario: User tries to delete another user's trashbin
Given user "Brian" has been created with default attributes and without skeleton files
Scenario Outline: User tries to delete another user's trashbin
Given using <dav-path> DAV path
And user "Brian" has been created with default attributes and without skeleton files
And user "Alice" has deleted file "/textfile0.txt"
And user "Alice" has deleted file "/textfile1.txt"
And user "Alice" has deleted file "/PARENT/parent.txt"
Expand All @@ -75,9 +98,18 @@ Feature: files and folders can be deleted from the trashbin
And as "Alice" the file with original path "/textfile0.txt" should exist in the trashbin
And as "Alice" the file with original path "/PARENT/parent.txt" should exist in the trashbin
And as "Alice" the file with original path "/PARENT/CHILD/child.txt" should exist in the trashbin
Examples:
| dav-path |
| new |

Scenario: User tries to delete trashbin file using invalid password
Given user "Brian" has been created with default attributes and without skeleton files
@issue-ocis-3544 @skipOnOcV10 @personalSpace
Examples:
| dav-path |
| spaces |

Scenario Outline: User tries to delete trashbin file using invalid password
Given using <dav-path> DAV path
And user "Brian" has been created with default attributes and without skeleton files
And user "Alice" has deleted file "/textfile0.txt"
And user "Alice" has deleted file "/textfile1.txt"
And user "Alice" has deleted file "/PARENT/parent.txt"
Expand All @@ -88,9 +120,18 @@ Feature: files and folders can be deleted from the trashbin
And as "Alice" the file with original path "/textfile0.txt" should exist in the trashbin
And as "Alice" the file with original path "/PARENT/parent.txt" should exist in the trashbin
And as "Alice" the file with original path "/PARENT/CHILD/child.txt" should exist in the trashbin
Examples:
| dav-path |
| new |

@skipOnOcV10 @personalSpace
Examples:
| dav-path |
| spaces |

Scenario: User tries to delete trashbin file using no password
Given user "Brian" has been created with default attributes and without skeleton files
Scenario Outline: User tries to delete trashbin file using no password
Given using <dav-path> DAV path
And user "Brian" has been created with default attributes and without skeleton files
And user "Alice" has deleted file "/textfile0.txt"
And user "Alice" has deleted file "/textfile1.txt"
And user "Alice" has deleted file "/PARENT/parent.txt"
Expand All @@ -101,10 +142,19 @@ Feature: files and folders can be deleted from the trashbin
And as "Alice" the file with original path "/textfile0.txt" should exist in the trashbin
And as "Alice" the file with original path "/PARENT/parent.txt" should exist in the trashbin
And as "Alice" the file with original path "/PARENT/CHILD/child.txt" should exist in the trashbin
Examples:
| dav-path |
| new |

@skipOnOcV10 @personalSpace
Examples:
| dav-path |
| spaces |


Scenario: delete a folder that contains a file from the trashbin
Given user "Alice" has created folder "FOLDER"
Scenario Outline: delete a folder that contains a file from the trashbin
Given using <dav-path> DAV path
And user "Alice" has created folder "FOLDER"
And user "Alice" has created folder "FOLDER/CHILD"
And user "Alice" has uploaded file with content "to delete" to "/FOLDER/parent.txt"
And user "Alice" has uploaded file with content "to delete" to "/FOLDER/CHILD/child.txt"
Expand All @@ -117,10 +167,19 @@ Feature: files and folders can be deleted from the trashbin
And as "Alice" the folder with original path "/PARENT/CHILD/" should not exist in the trashbin
But as "Alice" the file with original path "/FOLDER/parent.txt" should exist in the trashbin
And as "Alice" the file with original path "/FOLDER/CHILD/child.txt" should exist in the trashbin
Examples:
| dav-path |
| new |

@skipOnOcV10 @personalSpace
Examples:
| dav-path |
| spaces |

Scenario: delete a subfolder from a deleted folder from the trashbin
Given user "Alice" has created folder "FOLDER"

Scenario Outline: delete a subfolder from a deleted folder from the trashbin
Given using <dav-path> DAV path
And user "Alice" has created folder "FOLDER"
And user "Alice" has created folder "FOLDER/CHILD"
And user "Alice" has uploaded file with content "to delete" to "/FOLDER/parent.txt"
And user "Alice" has uploaded file with content "to delete" to "/FOLDER/CHILD/child.txt"
Expand All @@ -133,6 +192,14 @@ Feature: files and folders can be deleted from the trashbin
But as "Alice" the file with original path "/PARENT/parent.txt" should exist in the trashbin
But as "Alice" the file with original path "/FOLDER/parent.txt" should exist in the trashbin
And as "Alice" the file with original path "/FOLDER/CHILD/child.txt" should exist in the trashbin
Examples:
| dav-path |
| new |

@skipOnOcV10 @personalSpace
Examples:
| dav-path |
| spaces |


Scenario Outline: delete files with special characters from the trashbin
Expand Down Expand Up @@ -164,9 +231,13 @@ Feature: files and folders can be deleted from the trashbin
| # %ab ab?=ed.txt |
Examples:
| dav-path |
| old |
| new |

@skipOnOcV10 @personalSpace
Examples:
| dav-path |
| spaces |


Scenario Outline: delete folders with special characters from the trashbin
Given using <dav-path> DAV path
Expand Down Expand Up @@ -197,11 +268,16 @@ Feature: files and folders can be deleted from the trashbin
| # %ab ab?=ed |
Examples:
| dav-path |
| old |
| new |

Scenario: delete folders with dot in the name from the trashbin
Given user "Alice" has created the following folders
@skipOnOcV10 @personalSpace
Examples:
| dav-path |
| spaces |

Scenario Outline: delete folders with dot in the name from the trashbin
Given using <dav-path> DAV path
And user "Alice" has created the following folders
| path |
| /fo. |
| /fo.1 |
Expand Down Expand Up @@ -237,4 +313,12 @@ Feature: files and folders can be deleted from the trashbin
| /... |
| /..fo |
| /fo.xyz |
| /fo.exe |
| /fo.exe |
Examples:
| dav-path |
| new |

@skipOnOcV10 @personalSpace
Examples:
| dav-path |
| spaces |
23 changes: 13 additions & 10 deletions tests/acceptance/features/bootstrap/TrashbinContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ class TrashbinContext implements Context {
*/
public function emptyTrashbin(?string $user):ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$davPathVersion = $this->featureContext->getDavPathVersion();
$response = WebDavHelper::makeDavRequest(
$this->featureContext->getBaseUrl(),
$user,
$this->featureContext->getPasswordForUser($user),
'DELETE',
"/trash-bin/$user/",
null,
[],
$this->featureContext->getStepLineRef(),
null,
2,
$davPathVersion,
'trash-bin'
);

Expand Down Expand Up @@ -152,11 +153,12 @@ public function listTrashbinFolder(?string $user, ?string $path, ?string $asUser
$path = $path ?? '/';
$password = $password ?? $this->featureContext->getPasswordForUser($asUser);
$depth = (string) $depth;
$davPathVersion = $this->featureContext->getDavPathVersion();
$response = WebDavHelper::listFolder(
$this->featureContext->getBaseUrl(),
$asUser,
$password,
"/trash-bin/$user/$path",
$path,
$depth,
$this->featureContext->getStepLineRef(),
[
Expand All @@ -165,7 +167,8 @@ public function listTrashbinFolder(?string $user, ?string $path, ?string $asUser
'oc:trashbin-delete-timestamp',
'd:getlastmodified'
],
'trash-bin'
'trash-bin',
$davPathVersion
);
$this->featureContext->setResponse($response);
$responseXml = HttpRequestHelper::getResponseXml(
Expand Down Expand Up @@ -486,11 +489,9 @@ public function userTriesToRestoreFromTrashbinOfUserUsingPassword(?string $asUse
private function convertTrashbinHref(string $href):string {
$trashItemHRef = \trim($href, '/');
$trashItemHRef = \strstr($trashItemHRef, '/trash-bin');
$trashItemHRef = \trim($trashItemHRef, '/');
$parts = \explode('/', $trashItemHRef);
$decodedParts = [];
foreach ($parts as $part) {
$decodedParts[] = urldecode($part);
}
$decodedParts = \array_slice($parts, 2);
return '/' . \join('/', $decodedParts);
}

Expand Down Expand Up @@ -523,9 +524,11 @@ public function tryToDeleteFileFromTrashbin(?string $user, ?string $originalPath
[],
null,
'trash-bin',
'2',
null,
false,
$password
$password,
[],
$user
);
$this->featureContext->setResponse($response);
$numItemsDeleted++;
Expand Down

0 comments on commit b6e7379

Please sign in to comment.