From 7ca9e6923f921cacb372e62b7a57df6a9dae6ff3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 5 May 2024 10:47:54 +0545 Subject: [PATCH] add test --- .../Projects/ProjectsCustomServerTest.php | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Services/Projects/ProjectsCustomServerTest.php b/tests/e2e/Services/Projects/ProjectsCustomServerTest.php index 436d1df61..bae0d8bda 100644 --- a/tests/e2e/Services/Projects/ProjectsCustomServerTest.php +++ b/tests/e2e/Services/Projects/ProjectsCustomServerTest.php @@ -2,17 +2,43 @@ namespace Tests\E2E\Services\Projects; +use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; +use Utopia\System\System; class ProjectsCustomServerTest extends Scope { use ProjectCustom; use SideServer; - public function testMock() + // Domains + + public function testCreateProjectRule() { - $this->assertEquals(true, true); + $headers = array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-mode' => 'admin', + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]); + + $response = $this->client->call(Client::METHOD_POST, '/proxy/rules', $headers, [ + 'resourceType' => 'api', + 'domain' => 'api.appwrite.test', + ]); + + $this->assertEquals(201, $response['headers']['status-code']); + + // prevent functions domain + $functionsDomain = System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); + + $response = $this->client->call(Client::METHOD_POST, '/proxy/rules', $headers, [ + 'resourceType' => 'api', + 'domain' => $functionsDomain, + ]); + + $this->assertEquals(400, $response['headers']['status-code']); } }