From caa234f14058d21a8551b6986db20ce0fa264349 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 8 Aug 2024 19:15:00 +0530 Subject: [PATCH 1/2] Add scopes to function template --- src/Appwrite/Utopia/Response/Model/TemplateFunction.php | 7 +++++++ tests/e2e/Services/Functions/FunctionsCustomClientTest.php | 1 + 2 files changed, 8 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Model/TemplateFunction.php b/src/Appwrite/Utopia/Response/Model/TemplateFunction.php index f5df10986f..c630880a95 100644 --- a/src/Appwrite/Utopia/Response/Model/TemplateFunction.php +++ b/src/Appwrite/Utopia/Response/Model/TemplateFunction.php @@ -110,6 +110,13 @@ class TemplateFunction extends Model 'default' => [], 'example' => [], 'array' => true + ]) + ->addRule('scopes', [ + 'type' => self::TYPE_STRING, + 'description' => 'Function scopes.', + 'default' => [], + 'example' => 'users.read', + 'array' => true, ]); } diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 3aaa18594e..2bd6880239 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -881,6 +881,7 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals($expectedTemplates[$i]['vcsProvider'], $templates['body']['templates'][$i]['vcsProvider']); $this->assertEquals($expectedTemplates[$i]['runtimes'], $templates['body']['templates'][$i]['runtimes']); $this->assertEquals($expectedTemplates[$i]['variables'], $templates['body']['templates'][$i]['variables']); + $this->assertEquals($expectedTemplates[$i]['scopes'], $templates['body']['templates'][$i]['scopes']); } $templates_offset = $this->client->call(Client::METHOD_GET, '/functions/templates', array_merge([ From 7cfdf40b4784ba807229f713fa646686f0bfac41 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 8 Aug 2024 19:38:59 +0530 Subject: [PATCH 2/2] Fix tests --- tests/e2e/Services/Functions/FunctionsCustomClientTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 2bd6880239..79e7a83dda 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -881,7 +881,9 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals($expectedTemplates[$i]['vcsProvider'], $templates['body']['templates'][$i]['vcsProvider']); $this->assertEquals($expectedTemplates[$i]['runtimes'], $templates['body']['templates'][$i]['runtimes']); $this->assertEquals($expectedTemplates[$i]['variables'], $templates['body']['templates'][$i]['variables']); - $this->assertEquals($expectedTemplates[$i]['scopes'], $templates['body']['templates'][$i]['scopes']); + if (array_key_exists('scopes', $expectedTemplates[$i])) { + $this->assertEquals($expectedTemplates[$i]['scopes'], $templates['body']['templates'][$i]['scopes']); + } } $templates_offset = $this->client->call(Client::METHOD_GET, '/functions/templates', array_merge([