From ea68308838f6af7dc89c59ef301ad4bebfd3936a Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 6 Jul 2026 20:36:55 +0400 Subject: [PATCH] Test folder listing visibility with file security --- .../Storage/StorageCustomClientTest.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/e2e/Services/Storage/StorageCustomClientTest.php b/tests/e2e/Services/Storage/StorageCustomClientTest.php index 7f188241b4..a851018e6d 100644 --- a/tests/e2e/Services/Storage/StorageCustomClientTest.php +++ b/tests/e2e/Services/Storage/StorageCustomClientTest.php @@ -1606,4 +1606,44 @@ final class StorageCustomClientTest extends Scope ]); $this->assertEquals(204, $response['headers']['status-code']); } + + public function testListFoldersFileSecurityVisibility(): void + { + $bucket = $this->client->call(Client::METHOD_POST, '/storage/buckets', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], [ + 'bucketId' => ID::unique(), + 'name' => 'Folder Visibility', + 'fileSecurity' => true, + 'permissions' => [], + ]); + $this->assertEquals(201, $bucket['headers']['status-code']); + $bucketId = $bucket['body']['$id']; + + $upload = function (string $parent, array $permissions) use ($bucketId): void { + $file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', [ + 'content-type' => 'multipart/form-data', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], [ + 'fileId' => ID::unique(), + 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), + 'parent' => $parent, + 'permissions' => $permissions, + ]); + $this->assertEquals(201, $file['headers']['status-code']); + }; + + $upload('secret', []); + $upload('shared', [Permission::read(Role::any())]); + + $response = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/folders', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals(['shared/'], \array_column($response['body']['folders'], 'key')); + } }