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][full-ci] Added webdav spaces in apiTrashbin suite #39982

Merged
merged 6 commits into from
Apr 28, 2022
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
48 changes: 43 additions & 5 deletions tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ class WebDavHelper {
*/
public static $spacesIdRef = [];

/**
* clear space id reference for user
*
* @param string|null $user
*
* @return void
* @throws Exception
*/
public static function removeSpaceIdReferenceForUser(
?string $user
):void {
if (\array_key_exists($user, self::$spacesIdRef)) {
unset(self::$spacesIdRef[$user]);
}
}

/**
* returns the id of a file
*
Expand Down Expand Up @@ -118,6 +134,7 @@ public static function getFileIdForPath(
* @param string|null $folderDepth
* @param string|null $type
* @param int|null $davPathVersionToUse
* @param string|null $doDavRequestAsUser
*
* @return ResponseInterface
*/
Expand All @@ -130,7 +147,8 @@ public static function propfind(
?string $xRequestId = '',
?string $folderDepth = '0',
?string $type = "files",
?int $davPathVersionToUse = self::DAV_VERSION_NEW
?int $davPathVersionToUse = self::DAV_VERSION_NEW,
?string $doDavRequestAsUser = null
):ResponseInterface {
$propertyBody = "";
$extraNamespaces = "";
Expand Down Expand Up @@ -178,7 +196,14 @@ public static function propfind(
$xRequestId,
$body,
$davPathVersionToUse,
$type
$type,
null,
null,
false,
null,
null,
[],
$doDavRequestAsUser
);
}

Expand Down Expand Up @@ -534,7 +559,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 @@ -615,6 +644,7 @@ public static function getDavPath(
?string $type = "files",
?string $spaceId = null
):string {
$newTrashbinDavPath = "remote.php/dav/trash-bin/$user/";
if ($type === "public-files" || $type === "public-files-old") {
return "public.php/webdav/";
}
Expand All @@ -633,15 +663,23 @@ 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;
if ($type === "trash-bin") {
// Since there is no trash bin endpoint for old dav version, new dav version's endpoint is used here.
return $newTrashbinDavPath;
}
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 $newTrashbinDavPath;
} 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 |
grgprarup marked this conversation as resolved.
Show resolved Hide resolved
| 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
@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 |
Loading