diff --git a/tests/TestHelpers/WebDavHelper.php b/tests/TestHelpers/WebDavHelper.php index b7bf86af2f..76623770ac 100644 --- a/tests/TestHelpers/WebDavHelper.php +++ b/tests/TestHelpers/WebDavHelper.php @@ -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; } diff --git a/tests/acceptance/expected-failures-API-on-OCIS-storage.md b/tests/acceptance/expected-failures-API-on-OCIS-storage.md index c71c5c2c1f..fc83aae9b2 100644 --- a/tests/acceptance/expected-failures-API-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-API-on-OCIS-storage.md @@ -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 diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index 1a9a102efb..98c6d7143f 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -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, diff --git a/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareReceivedInMultipleWays.feature b/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareReceivedInMultipleWays.feature index 042187b860..f569f3e212 100644 --- a/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareReceivedInMultipleWays.feature +++ b/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareReceivedInMultipleWays.feature @@ -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 | diff --git a/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature b/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature index 3db3b5eba4..45598c596a 100644 --- a/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature +++ b/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature @@ -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