From 99994f627808fcd8782ecefe510f5a21517f09d4 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 22 Apr 2024 21:43:57 +0200 Subject: [PATCH] Fixed storage tests --- app/controllers/api/storage.php | 2 +- composer.lock | 8 ++++---- tests/e2e/Services/Storage/StorageCustomClientTest.php | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index cec4c115a..3390a963a 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -1621,7 +1621,7 @@ Http::delete('/v1/storage/buckets/:bucketId/files/:fileId') } // Make sure we don't delete the file before the document permission check occurs - if ($fileSecurity && !$valid && !$authorization->isValid($file->getDelete())) { + if ($fileSecurity && !$valid && !$authorization->isValid(new Input(Database::PERMISSION_DELETE, $file->getDelete()))) { throw new Exception(Exception::USER_UNAUTHORIZED); } diff --git a/composer.lock b/composer.lock index 9c6618c9c..2024225af 100644 --- a/composer.lock +++ b/composer.lock @@ -2287,12 +2287,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/queue.git", - "reference": "309796b08891eac135540c241d8943dd42eccc9e" + "reference": "8749796c05bf9a0abc9c949af5ceb2efa8531960" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/queue/zipball/309796b08891eac135540c241d8943dd42eccc9e", - "reference": "309796b08891eac135540c241d8943dd42eccc9e", + "url": "https://api.github.com/repos/utopia-php/queue/zipball/8749796c05bf9a0abc9c949af5ceb2efa8531960", + "reference": "8749796c05bf9a0abc9c949af5ceb2efa8531960", "shasum": "" }, "require": { @@ -2342,7 +2342,7 @@ "issues": "https://github.com/utopia-php/queue/issues", "source": "https://github.com/utopia-php/queue/tree/feat-coroutine-and-di" }, - "time": "2024-04-21T18:59:04+00:00" + "time": "2024-04-22T18:32:34+00:00" }, { "name": "utopia-php/registry", diff --git a/tests/e2e/Services/Storage/StorageCustomClientTest.php b/tests/e2e/Services/Storage/StorageCustomClientTest.php index c723fba50..55340ab84 100644 --- a/tests/e2e/Services/Storage/StorageCustomClientTest.php +++ b/tests/e2e/Services/Storage/StorageCustomClientTest.php @@ -1089,7 +1089,7 @@ class StorageCustomClientTest extends Scope $this->assertEquals(200, $file['headers']['status-code']); - // Team 1 view success + // Team 2 view success $file = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId . '/view', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -1112,6 +1112,8 @@ class StorageCustomClientTest extends Scope 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'), ]); + $this->assertEquals($file['headers']['status-code'], 401); + // Team 2 create failure $file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', [ 'content-type' => 'multipart/form-data',