diff --git a/tests/acceptance/features/apiSharingNg/propfindShares.feature b/tests/acceptance/features/apiSharingNg/propfindShares.feature index 1b9aaf3a7..8f9d23beb 100644 --- a/tests/acceptance/features/apiSharingNg/propfindShares.feature +++ b/tests/acceptance/features/apiSharingNg/propfindShares.feature @@ -120,3 +120,22 @@ Feature: propfind a shares | oc:fileid | UUIDof:textfile.txt | | oc:name | textfile.txt | | oc:permissions | S | + + + Scenario Outline: check file-id from PROPFIND with shared-with-me drive-item-id + Given using spaces DAV path + And user "Alice" has uploaded file with content "to share" to "/textfile1.txt" + And user "Alice" has created folder "folderToShare" + And user "Alice" has sent the following share invitation: + | resource | | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When user "Brian" sends PROPFIND request to space "Shares" with depth "1" using the WebDAV API + Then the HTTP status code should be "207" + And as user "Brian" the key "oc:fileid" from PROPFIND response should match with shared-with-me drive-item-id of share "" + Examples: + | resource | + | textfile1.txt | + | folderToShare | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index b01e5504e..9d508e481 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -3830,6 +3830,38 @@ class SpacesContext implements Context { } } + /** + * @Then as user :user the key :key from PROPFIND response should match with shared-with-me drive-item-id of share :resource + * + * @param string $user + * @param string $key + * @param string $resource + * + * @return void + * @throws GuzzleException + */ + public function asUserTheKeyFromPropfindResponseShouldMatchWithSharedwithmeDriveitemidOfShare(string $user, string $key, string $resource): void { + $xmlResponse = $this->featureContext->getResponseXml(); + $fileId = $xmlResponse->xpath("//oc:name[text()='$resource']/preceding-sibling::$key")[0]->__toString(); + + $jsonResponse = GraphHelper::getSharesSharedWithMe( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user) + ); + $jsonResponseBody = $this->featureContext->getJsonDecodedResponseBodyContent($jsonResponse); + foreach ($jsonResponseBody->value as $value) { + if ($value->name === "$resource") { + $driveItemId = $value->id; + break; + } else { + throw new Error("Response didn't contain a share $resource"); + } + } + Assert::assertEquals($fileId, $driveItemId, "File-id '$fileId' doesn't match driveItemId '$driveItemId'"); + } + /** * @When /^public downloads the folder "([^"]*)" from the last created public link using the public files API$/ *