mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-16 05:17:55 -04:00
test: fix MOVE within Shares tests
This commit is contained in:
@@ -443,6 +443,35 @@ class WebDavHelper {
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $baseUrl
|
||||
* @param string $user
|
||||
* @param string $password
|
||||
* @param string $xRequestId
|
||||
*
|
||||
* @return string
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getSharesSpaceIdForUser(string $baseUrl, string $user, string $password, string $xRequestId): string {
|
||||
if (\array_key_exists($user, self::$spacesIdRef) && \array_key_exists("virtual", self::$spacesIdRef[$user])) {
|
||||
return self::$spacesIdRef[$user]["virtual"];
|
||||
}
|
||||
|
||||
$response = GraphHelper::getMySpaces($baseUrl, $user, $password, '', $xRequestId);
|
||||
$body = HttpRequestHelper::getJsonDecodedResponseBodyContent($response);
|
||||
|
||||
$spaceId = null;
|
||||
foreach ($body->value as $spaces) {
|
||||
if ($spaces->driveType === "virtual") {
|
||||
$spaceId = $spaces->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $spaceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches personal space id for provided user
|
||||
*
|
||||
@@ -641,12 +670,23 @@ class WebDavHelper {
|
||||
|
||||
// get space id if testing with spaces dav
|
||||
if (self::$SPACE_ID_FROM_OCIS === '' && $davPathVersionToUse === self::DAV_VERSION_SPACES) {
|
||||
$spaceId = self::getPersonalSpaceIdForUserOrFakeIfNotFound(
|
||||
$baseUrl,
|
||||
$doDavRequestAsUser ?? $user,
|
||||
$password,
|
||||
$xRequestId
|
||||
);
|
||||
$path = \ltrim($path, "/");
|
||||
if (\str_starts_with($path, "Shares/")) {
|
||||
$spaceId = self::getSharesSpaceIdForUser(
|
||||
$baseUrl,
|
||||
$doDavRequestAsUser ?? $user,
|
||||
$password,
|
||||
$xRequestId
|
||||
);
|
||||
$path = "/" . preg_replace("/^Shares\//", "", $path);
|
||||
} else {
|
||||
$spaceId = self::getPersonalSpaceIdForUserOrFakeIfNotFound(
|
||||
$baseUrl,
|
||||
$doDavRequestAsUser ?? $user,
|
||||
$password,
|
||||
$xRequestId
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$spaceId = self::$SPACE_ID_FROM_OCIS;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,6 @@ Synchronization features like etag propagation, setting mtime and locking files
|
||||
|
||||
#### [deleting a file inside a received shared folder is moved to the trash-bin of the sharer not the receiver](https://github.com/owncloud/ocis/issues/1124)
|
||||
|
||||
- [coreApiTrashbin/trashbinSharingToShares.feature:30](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L30)
|
||||
- [coreApiTrashbin/trashbinSharingToShares.feature:53](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L53)
|
||||
- [coreApiTrashbin/trashbinSharingToShares.feature:54](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L54)
|
||||
- [coreApiTrashbin/trashbinSharingToShares.feature:81](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L81)
|
||||
@@ -85,8 +84,6 @@ Synchronization features like etag propagation, setting mtime and locking files
|
||||
- [coreApiTrashbin/trashbinSharingToShares.feature:139](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L139)
|
||||
- [coreApiTrashbin/trashbinSharingToShares.feature:196](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L196)
|
||||
- [coreApiTrashbin/trashbinSharingToShares.feature:197](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L197)
|
||||
- [coreApiTrashbin/trashbinSharingToShares.feature:220](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L220)
|
||||
- [coreApiTrashbin/trashbinSharingToShares.feature:245](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L245)
|
||||
|
||||
### Other
|
||||
|
||||
|
||||
@@ -560,10 +560,18 @@ trait WebDav {
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function destinationHeaderValue(string $user, string $fileDestination):string {
|
||||
$fileDestination = \ltrim($fileDestination, "/");
|
||||
$spaceId = $this->getPersonalSpaceIdForUser($user);
|
||||
// If the destination is a share, we need to get the space ID for the Shares space
|
||||
if (\str_starts_with($fileDestination, "Shares/")) {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($user, "Shares");
|
||||
if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
|
||||
$fileDestination = \preg_replace("/^Shares\//", "", $fileDestination);
|
||||
}
|
||||
}
|
||||
$fullUrl = $this->getBaseUrl() . '/' .
|
||||
WebDavHelper::getDavPath($user, $this->getDavPathVersion(), "files", $spaceId);
|
||||
return \rtrim($fullUrl, '/') . '/' . \ltrim($fileDestination, '/');
|
||||
return \rtrim($fullUrl, '/') . '/' . $fileDestination;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -580,17 +588,7 @@ trait WebDav {
|
||||
?string $fileSource,
|
||||
?string $fileDestination
|
||||
):void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$headers['Destination'] = $this->destinationHeaderValue(
|
||||
$user,
|
||||
$fileDestination
|
||||
);
|
||||
$response = $this->makeDavRequest(
|
||||
$user,
|
||||
"MOVE",
|
||||
$fileSource,
|
||||
$headers
|
||||
);
|
||||
$response = $this->moveResource($user, $fileSource, $fileDestination);
|
||||
$actualStatusCode = $response->getStatusCode();
|
||||
$this->theHTTPStatusCodeShouldBe(
|
||||
201,
|
||||
|
||||
@@ -378,7 +378,7 @@ Feature: share resources where the sharee receives the share in multiple ways
|
||||
| shareType | group |
|
||||
| permissionsRole | Viewer |
|
||||
And user "Alice" has a share "parent" synced
|
||||
And user "Brian" has a share "child1" synced
|
||||
And user "Brian" has a share "parent" synced
|
||||
And user "Carol" has sent the following resource share invitation:
|
||||
| resource | parent/child1 |
|
||||
| space | Personal |
|
||||
|
||||
@@ -155,7 +155,7 @@ Feature: using trashbin together with sharing
|
||||
| sharee | grp1 |
|
||||
| shareType | group |
|
||||
| permissionsRole | Editor |
|
||||
And user "Brain" has a share "shared" synced
|
||||
And user "Brian" has a share "shared" synced
|
||||
And user "Carol" has a share "shared" synced
|
||||
When user "Alice" deletes file "/shared/sub/shared_file.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "204"
|
||||
@@ -179,7 +179,7 @@ Feature: using trashbin together with sharing
|
||||
| sharee | Brian |
|
||||
| shareType | user |
|
||||
| permissionsRole | Editor |
|
||||
And user "Brain" has a share "shared" synced
|
||||
And user "Brian" has a share "shared" synced
|
||||
And user "Brian" has moved folder "/Shares/shared" to "/Shares/renamed_shared"
|
||||
And user "Brian" has deleted file "/Shares/renamed_shared/shared_file.txt"
|
||||
When user "Brian" restores the file with original path "/Shares/renamed_shared/shared_file.txt" using the trashbin API
|
||||
|
||||
Reference in New Issue
Block a user