From 1429c82aa07b2ffda8407ddb68462594c57be7ed Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 6 Nov 2023 12:04:56 +1300 Subject: [PATCH 1/2] Make VCS, proxy and migrations services non-optional so they aren't toggled with enable/disable all service routes --- app/config/services.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/config/services.php b/app/config/services.php index 3700af659a..5c2233dfc6 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -170,7 +170,7 @@ return [ 'docs' => false, 'docsUrl' => '', 'tests' => false, - 'optional' => true, + 'optional' => false, 'icon' => '', ], 'functions' => [ @@ -196,7 +196,7 @@ return [ 'docs' => true, 'docsUrl' => 'https://appwrite.io/docs/proxy', 'tests' => false, - 'optional' => true, + 'optional' => false, 'icon' => '/images/services/proxy.png', ], 'mock' => [ @@ -248,7 +248,7 @@ return [ 'docs' => true, 'docsUrl' => 'https://appwrite.io/docs/migrations', 'tests' => true, - 'optional' => true, + 'optional' => false, 'icon' => '/images/services/migrations.png', ], ]; From 2292143750a4b1527b159469bd5d70690146874f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 6 Nov 2023 12:34:44 +1300 Subject: [PATCH 2/2] Add service/all test --- .../Projects/ProjectsConsoleClientTest.php | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index ff3f8e8e94..f90a04f290 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -1606,6 +1606,100 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(false, $response['body']['authPersonalDataCheck']); } + public function testUpdateProjectServicesAll(): void + { + $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]), [ + 'teamId' => ID::unique(), + 'name' => 'Project Test', + ]); + + $this->assertEquals(201, $team['headers']['status-code']); + $this->assertNotEmpty($team['body']['$id']); + + $project = $this->client->call(Client::METHOD_POST, '/projects', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]), [ + 'projectId' => ID::unique(), + 'name' => 'Project Test', + 'teamId' => $team['body']['$id'], + 'region' => 'default' + ]); + + $this->assertEquals(201, $project['headers']['status-code']); + $this->assertNotEmpty($project['body']['$id']); + + $id = $project['body']['$id']; + + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/service/all', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]), [ + 'status' => false, + ]); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']['$id']); + + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ])); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']['$id']); + + $matches = []; + $pattern = '/serviceStatusFor.*/'; + + foreach ($response['body'] as $key => $value) { + if (\preg_match($pattern, $key)) { + \var_dump('Matched key: ' . $key); + $matches[$key] = $value; + } + } + + foreach ($matches as $value) { + $this->assertFalse($value); + } + + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/service/all', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]), [ + 'status' => true, + ]); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']['$id']); + + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ])); + + $this->assertEquals(200, $response['headers']['status-code']); + + $matches = []; + foreach ($response['body'] as $key => $value) { + if (\preg_match($pattern, $key)) { + $matches[$key] = $value; + } + } + + foreach ($matches as $value) { + $this->assertTrue($value); + } + } public function testUpdateProjectServiceStatusAdmin(): array {