From 19a7100e160d682c2754a6b7ae297672606ea2ee Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 15 Oct 2026 13:06:31 +0200 Subject: [PATCH] test(acceptance): public link boundaries through the real drive --- tests/acceptance/bootstrap/GraphContext.php | 43 +++++++++++++++++-- .../publicLinkDriveItemListing.feature | 37 +++++++++++++++- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/tests/acceptance/bootstrap/GraphContext.php b/tests/acceptance/bootstrap/GraphContext.php index 135a147f86..7bacfe9885 100644 --- a/tests/acceptance/bootstrap/GraphContext.php +++ b/tests/acceptance/bootstrap/GraphContext.php @@ -3761,20 +3761,24 @@ class GraphContext implements Context { /** * @param string $action * @param string $child + * @param string $throughRealDrive * @param string $password * * @return void */ - #[When('/^the public tries to (create a link for|delete|rename|list the permissions of) the child "([^"]*)" of the last created public link with password "([^"]*)" using the Graph API$/')] + #[When('/^the public tries to (create a link for|delete|rename|list the permissions of) the child "([^"]*)" of the last created public link( through the real drive)? with password "([^"]*)" using the Graph API$/')] public function thePublicTriesToMutateTheChildOfTheLastCreatedPublicLink( string $action, string $child, + string $throughRealDrive, string $password ): void { - $rootId = $this->publicLinkDriveId($this->featureContext->shareNgGetLastCreatedLinkShareToken()); $childId = $this->publicLinkChildId($child, $password); + $driveId = $throughRealDrive === "" + ? $this->publicLinkDriveId($this->featureContext->shareNgGetLastCreatedLinkShareToken()) + : \explode("!", $childId)[0]; - $base = "/v1beta1/drives/$rootId/items/$childId"; + $base = "/v1beta1/drives/$driveId/items/$childId"; switch ($action) { case "create a link for": $method = "POST"; @@ -3983,4 +3987,37 @@ class GraphContext implements Context { [$driveId] = $this->realDriveOfResource($user, $path); $this->publicSendsRawGraphRequest("/drives/$driveId/root:/$relativePath:", $password); } + + /** + * @param string $relativePath + * @param string $path + * @param string $user + * @param string $password + * + * @return void + */ + #[When('the public tries to get the path :relativePath below resource :path of user :user through the real drive of the last created public link with password :password using the Graph API')] + public function thePublicTriesToGetThePathBelowResourceThroughTheRealDrive( + string $relativePath, + string $path, + string $user, + string $password + ): void { + [$driveId, $resourceId] = $this->realDriveOfResource($user, $path); + $this->publicSendsRawGraphRequest("/drives/$driveId/items/$resourceId:/$relativePath:", $password); + } + + /** + * @param string $path + * @param string $user + * @param string $password + * + * @return void + */ + #[When('the public tries to get the root item of the real drive of resource :path of user :user through the last created public link with password :password using the Graph API')] + public function thePublicTriesToGetTheRootItemOfTheRealDrive(string $path, string $user, string $password): void { + [$driveId] = $this->realDriveOfResource($user, $path); + $spaceId = \explode("$", $driveId)[1]; + $this->publicSendsRawGraphRequest("/drives/$driveId/items/$driveId!$spaceId", $password); + } } diff --git a/tests/acceptance/features/apiGraph/publicLinkDriveItemListing.feature b/tests/acceptance/features/apiGraph/publicLinkDriveItemListing.feature index 4d90d480df..a685d12b23 100644 --- a/tests/acceptance/features/apiGraph/publicLinkDriveItemListing.feature +++ b/tests/acceptance/features/apiGraph/publicLinkDriveItemListing.feature @@ -549,10 +549,43 @@ Feature: listing the content of a public link via the Graph API Examples: | action | code | - | create a link for | 404 | + | create a link for | 403 | | delete | 400 | | rename | 400 | - | list the permissions of | 404 | + | list the permissions of | 403 | + + + Scenario Outline: writes through the real drive are rejected + Given user "Alice" has created the following resource link share: + | resource | publicfolder | + | space | Personal | + | permissionsRole | edit | + | password | %public% | + When the public tries to the child "a.txt" of the last created public link through the real drive with password "%public%" using the Graph API + Then the HTTP status code should be "" + And as "Alice" file "publicfolder/a.txt" should exist + + Examples: + | action | code | + | create a link for | 403 | + | delete | 400 | + | rename | 400 | + | list the permissions of | 403 | + + + Scenario Outline: a colon path does not climb above the public link through the real drive + When the public tries to get the path "" below resource "publicfolder" of user "Alice" through the real drive of the last created public link with password "%public%" using the Graph API + Then the HTTP status code should be "404" + Examples: + | path | + | ../private.txt | + | %2E%2E/private.txt | + | sub/../../private.txt | + + + Scenario: the root item of the real drive is not readable through a public link + When the public tries to get the root item of the real drive of resource "publicfolder" of user "Alice" through the last created public link with password "%public%" using the Graph API + Then the HTTP status code should be "404" Scenario: the public sees who shared the link on the drive