From a413235f8d1fb51ffd5dccc3a6e12476db751c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 26 Aug 2025 15:29:11 +0200 Subject: [PATCH] add new tests --- .../Utopia/Database/Validator/Queries/Base.php | 14 +++++++------- .../Database/Validator/Queries/Deployments.php | 2 +- .../Functions/FunctionsCustomServerTest.php | 12 ++++++++++++ tests/e2e/Services/Sites/SitesCustomServerTest.php | 12 ++++++++++++ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php index 60c9e03c70..34d00e426b 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -49,7 +49,7 @@ class Base extends Queries if (!isset($allowedAttributesLookup[$key])) { continue; } - + $attributeDocument = new Document([ 'key' => $key, 'type' => $attribute['type'], @@ -59,7 +59,7 @@ class Base extends Queries $attributes[] = $attributeDocument; $allAttributes[] = $attributeDocument; } - + $internalAttributes = [ new Document([ 'key' => '$id', @@ -82,8 +82,8 @@ class Base extends Queries 'array' => false, ]) ]; - - foreach($internalAttributes as $attribute) { + + foreach ($internalAttributes as $attribute) { $attributes[] = $attribute; $allAttributes[] = $attribute; } @@ -95,14 +95,14 @@ class Base extends Queries new Filter($attributes, APP_DATABASE_QUERY_MAX_VALUES), new Order($attributes), ]; - - if($this->isSelectQueryAllowed()) { + + if ($this->isSelectQueryAllowed()) { $validators[] = new Select($allAttributes); } parent::__construct($validators); } - + public function isSelectQueryAllowed(): bool { return true; diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php b/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php index 0d5565c968..6348e69cd9 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php @@ -22,7 +22,7 @@ class Deployments extends Base { parent::__construct('deployments', self::ALLOWED_ATTRIBUTES); } - + public function isSelectQueryAllowed(): bool { return true; diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 1d993c19b7..a4fbc37933 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -721,6 +721,18 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals($deployments['headers']['status-code'], 200); $this->assertCount(1, $deployments['body']['deployments']); + $deployments = $this->listDeployments($functionId, [ + 'queries' => [ + Query::select(['status'])->toString(), + ], + ]); + + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertArrayHasKey('status', $deployments['body']['deployments'][0]); + $this->assertArrayHasKey('status', $deployments['body']['deployments'][1]); + $this->assertArrayNotHasKey('sourceSize', $deployments['body']['deployments'][0]); + $this->assertArrayNotHasKey('sourceSize', $deployments['body']['deployments'][1]); + $deployments = $this->listDeployments($functionId, [ 'queries' => [ Query::offset(1)->toString(), diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 0e792d6c36..8d1ee2f637 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -1052,6 +1052,18 @@ class SitesCustomServerTest extends Scope $this->assertEquals($deployments['headers']['status-code'], 200); $this->assertCount(1, $deployments['body']['deployments']); + $deployments = $this->listDeployments($siteId, [ + 'queries' => [ + Query::select(['status'])->toString(), + ], + ]); + + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertArrayHasKey('status', $deployments['body']['deployments'][0]); + $this->assertArrayHasKey('status', $deployments['body']['deployments'][1]); + $this->assertArrayNotHasKey('sourceSize', $deployments['body']['deployments'][0]); + $this->assertArrayNotHasKey('sourceSize', $deployments['body']['deployments'][1]); + $deployments = $this->listDeployments($siteId, [ 'queries' => [ Query::offset(1)->toString(),