test(acceptance): public link boundaries through the real drive

This commit is contained in:
Dominik Schmidt committed 2026-11-26 10:24:48 +01:00
1 parent ffa1382cdc
commit 19a7100e16
2 files changed
+75 -5

No files matched your search

+40 -3
View File
@@ -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);
}
}
@@ -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 <action> 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 "<code>"
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 "<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