From aff9dbfb3101af19ad655dd3b7588036720d038b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 28 Aug 2023 21:14:37 -0400 Subject: [PATCH 1/6] Disable swoole curl hook --- app/http.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/http.php b/app/http.php index b6696775b8..1993b10e4b 100644 --- a/app/http.php +++ b/app/http.php @@ -25,7 +25,7 @@ use Utopia\Logger\Log; use Utopia\Logger\Log\User; use Utopia\Pools\Group; -Runtime::enableCoroutine(SWOOLE_HOOK_NATIVE_CURL); +//Runtime::enableCoroutine(SWOOLE_HOOK_NATIVE_CURL); $http = new Server("0.0.0.0", App::getEnv('PORT', 80)); From 0a1ab4ae6030d11cc426f2dedd6c65b538a2cb7b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 28 Aug 2023 22:24:52 -0400 Subject: [PATCH 2/6] Add back codes env var --- app/http.php | 1 - docker-compose.yml | 1 + src/Appwrite/Utopia/Response.php | 1 - tests/e2e/Services/GraphQL/FunctionsServerTest.php | 2 -- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/http.php b/app/http.php index 1993b10e4b..1059a2d713 100644 --- a/app/http.php +++ b/app/http.php @@ -20,7 +20,6 @@ use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Swoole\Files; use Appwrite\Utopia\Request; -use Swoole\Runtime; use Utopia\Logger\Log; use Utopia\Logger\Log\User; use Utopia\Pools\Group; diff --git a/docker-compose.yml b/docker-compose.yml index f9b273296a..e195b5f5df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -100,6 +100,7 @@ services: - _APP_CONSOLE_WHITELIST_ROOT - _APP_CONSOLE_WHITELIST_EMAILS - _APP_CONSOLE_WHITELIST_IPS + - _APP_CONSOLE_WHITELIST_CODES - _APP_SYSTEM_EMAIL_NAME - _APP_SYSTEM_EMAIL_ADDRESS - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index c5aece71bb..7e52536eed 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -544,7 +544,6 @@ class Response extends SwooleResponse if ($rule['array']) { if (!is_array($data[$key])) { - \var_dump($data); throw new Exception($key . ' must be an array of type ' . $rule['type']); } diff --git a/tests/e2e/Services/GraphQL/FunctionsServerTest.php b/tests/e2e/Services/GraphQL/FunctionsServerTest.php index dd5f179744..49a8fd61f2 100644 --- a/tests/e2e/Services/GraphQL/FunctionsServerTest.php +++ b/tests/e2e/Services/GraphQL/FunctionsServerTest.php @@ -166,8 +166,6 @@ class FunctionsServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); - \var_dump($execution); - $this->assertIsArray($execution['body']['data']); $this->assertArrayNotHasKey('errors', $execution['body']); From 34cb1a2229c91a5545adbf1e296d53bf332ce554 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 28 Aug 2023 22:25:11 -0400 Subject: [PATCH 3/6] Fix graphql tests --- tests/e2e/Services/GraphQL/Base.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/e2e/Services/GraphQL/Base.php b/tests/e2e/Services/GraphQL/Base.php index c2319ffa2a..3a4b88e2c2 100644 --- a/tests/e2e/Services/GraphQL/Base.php +++ b/tests/e2e/Services/GraphQL/Base.php @@ -1477,6 +1477,7 @@ trait Base return 'query getExecution($functionId: String!$executionId: String!) { functionsGetExecution(functionId: $functionId, executionId: $executionId) { _id + functionId status logs errors @@ -1488,6 +1489,7 @@ trait Base total executions { _id + functionId status logs errors @@ -1498,6 +1500,7 @@ trait Base return 'mutation createExecution($functionId: String!, $body: String, $async: Boolean) { functionsCreateExecution(functionId: $functionId, body: $body, async: $async) { _id + functionId status logs errors From f43f155224607a96eb9a0fa942a8216250bdce56 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 28 Aug 2023 22:41:48 -0400 Subject: [PATCH 4/6] Fix template test --- .../Projects/ProjectsConsoleClientTest.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 26f584ec5e..0cc4229ea4 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -571,24 +571,13 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('password', $response['body']['smtpPassword']); $this->assertEquals('', $response['body']['smtpSecure']); - /** Reset */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/smtp', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'enabled' => false, - 'sender' => 'mailer@appwrite.io', - 'host' => 'maildev', - 'port' => 1025, - 'username' => 'user', - 'password' => 'password', - ]); return $data; } /** * @group smtpAndTemplates - * @depends testUpdateProject */ + * @depends testUpdateProjectSMTP + */ public function testUpdateTemplates($data): array { $id = $data['projectId']; @@ -601,11 +590,9 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals('Account Verification', $response['body']['subject']); - $this->assertEquals('Project Test 2 Team', $response['body']['senderName']); $this->assertEquals('team@appwrite.io', $response['body']['senderEmail']); $this->assertEquals('verification', $response['body']['type']); $this->assertEquals('en-us', $response['body']['locale']); - $this->assertMatchesRegularExpression('//', $response['body']['message']); /** Update Email template */ $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/templates/email/verification/en-us', array_merge([ From 49fa5550bb71878ad8a23b3320f57c168beae3d7 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 28 Aug 2023 23:15:02 -0400 Subject: [PATCH 5/6] Fix sleep wait --- .../Realtime/RealtimeCustomClientTest.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php index 79e65faa02..56796280ad 100644 --- a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php @@ -1294,8 +1294,23 @@ class RealtimeCustomClientTest extends Scope $this->assertEquals($deployment['headers']['status-code'], 202); $this->assertNotEmpty($deployment['body']['$id']); - // Wait for deployment to be built. - sleep(10); + // Poll until deployment is built + while (true) { + $deployment = $this->client->call(Client::METHOD_GET, '/functions/' . $function['body']['$id'] . '/deployments/' . $deploymentId, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]); + + if ( + $deployment['headers']['status-code'] >= 400 + || \in_array($deployment['body']['status'], ['ready', 'failed']) + ) { + break; + } + + \sleep(1); + } $response = $this->client->call(Client::METHOD_PATCH, '/functions/' . $functionId . '/deployments/' . $deploymentId, array_merge([ 'content-type' => 'application/json', From 8530830d906a2b30f06daf423717b73ff6d5313a Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 29 Aug 2023 12:01:37 -0400 Subject: [PATCH 6/6] Clean up --- app/http.php | 2 -- docker-compose.yml | 1 - 2 files changed, 3 deletions(-) diff --git a/app/http.php b/app/http.php index 1059a2d713..053db20ffc 100644 --- a/app/http.php +++ b/app/http.php @@ -24,8 +24,6 @@ use Utopia\Logger\Log; use Utopia\Logger\Log\User; use Utopia\Pools\Group; -//Runtime::enableCoroutine(SWOOLE_HOOK_NATIVE_CURL); - $http = new Server("0.0.0.0", App::getEnv('PORT', 80)); $payloadSize = 6 * (1024 * 1024); // 6MB diff --git a/docker-compose.yml b/docker-compose.yml index e195b5f5df..f9b273296a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -100,7 +100,6 @@ services: - _APP_CONSOLE_WHITELIST_ROOT - _APP_CONSOLE_WHITELIST_EMAILS - _APP_CONSOLE_WHITELIST_IPS - - _APP_CONSOLE_WHITELIST_CODES - _APP_SYSTEM_EMAIL_NAME - _APP_SYSTEM_EMAIL_ADDRESS - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS