From a6fc5820cc050013dc856901f514b5af746b8b15 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 18 Nov 2021 20:43:18 +0545 Subject: [PATCH 1/3] checks for if bucket is disabled --- app/controllers/api/storage.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index baa0b610d6..20bc7267e8 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -520,7 +520,7 @@ App::post('/v1/storage/buckets/:bucketId/files') $bucket = $dbForInternal->getDocument('buckets', $bucketId); - if($bucket->isEmpty()) { + if($bucket->isEmpty() || !$bucket->getAttribute('enabled')) { throw new Exception('Bucket not found', 404); } @@ -699,7 +699,7 @@ App::get('/v1/storage/buckets/:bucketId/files') $bucket = $dbForInternal->getDocument('buckets', $bucketId); - if($bucket->isEmpty()) { + if($bucket->isEmpty() || !$bucket->getAttribute('enabled')) { throw new Exception('Bucket not found', 404); } @@ -780,7 +780,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId') $bucket = $dbForInternal->getDocument('buckets', $bucketId); - if($bucket->isEmpty()) { + if($bucket->isEmpty() || !$bucket->getAttribute('enabled')) { throw new Exception('Bucket not found', 404); } @@ -858,7 +858,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') } $bucket = $dbForInternal->getDocument('buckets', $bucketId); - if($bucket->isEmpty()) { + if($bucket->isEmpty() || !$bucket->getAttribute('enabled')) { throw new Exception('Bucket not found', 404); } @@ -1016,7 +1016,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download') $bucket = $dbForInternal->getDocument('buckets', $bucketId); - if($bucket->isEmpty()) { + if($bucket->isEmpty() || !$bucket->getAttribute('enabled')) { throw new Exception('Bucket not found', 404); } @@ -1103,7 +1103,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view') $bucket = $dbForInternal->getDocument('buckets', $bucketId); - if($bucket->isEmpty()) { + if($bucket->isEmpty() || !$bucket->getAttribute('enabled')) { throw new Exception('Bucket not found', 404); } @@ -1205,7 +1205,7 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId') $bucket = $dbForInternal->getDocument('buckets', $bucketId); - if($bucket->isEmpty()) { + if($bucket->isEmpty() || !$bucket->getAttribute('enabled')) { throw new Exception('Bucket not found', 404); } @@ -1284,7 +1284,7 @@ App::delete('/v1/storage/buckets/:bucketId/files/:fileId') $bucket = $dbForInternal->getDocument('buckets', $bucketId); - if($bucket->isEmpty()) { + if($bucket->isEmpty() || !$bucket->getAttribute('enabled')) { throw new Exception('Bucket not found', 404); } From 2915678897d47c76925822ff511870e36a5ab97e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 19 Nov 2021 11:06:33 +0545 Subject: [PATCH 2/3] fix webhooks test --- tests/e2e/Services/Webhooks/WebhooksBase.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/e2e/Services/Webhooks/WebhooksBase.php b/tests/e2e/Services/Webhooks/WebhooksBase.php index 450d8f7b3f..acf4945165 100644 --- a/tests/e2e/Services/Webhooks/WebhooksBase.php +++ b/tests/e2e/Services/Webhooks/WebhooksBase.php @@ -347,6 +347,16 @@ trait WebhooksBase */ public function testCreateBucketFile(array $data): array { + //enable bucket + $bucket = $this->client->call(Client::METHOD_PUT, '/storage/buckets/' . $data['bucketId'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'enabled' => true, + ]); + + $this->assertEquals($bucket['headers']['status-code'], 200); /** * Test for SUCCESS */ From 4416ddf3ee418ac67f94aa141898c8fc0ea95cc3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 19 Nov 2021 12:30:46 +0545 Subject: [PATCH 3/3] fix test --- tests/e2e/Services/Webhooks/WebhooksBase.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/Services/Webhooks/WebhooksBase.php b/tests/e2e/Services/Webhooks/WebhooksBase.php index acf4945165..cb04a9c264 100644 --- a/tests/e2e/Services/Webhooks/WebhooksBase.php +++ b/tests/e2e/Services/Webhooks/WebhooksBase.php @@ -353,6 +353,7 @@ trait WebhooksBase 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'] ]), [ + 'name' => 'Test Bucket Updated', 'enabled' => true, ]);