From df943c62ca674d75278c8e00e43b4fe01cf14868 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Fri, 21 Mar 2025 17:53:22 +0530 Subject: [PATCH 1/4] Add test for permanent redirect --- .../Services/Sites/SitesCustomServerTest.php | 37 +++++++++++++++++++ tests/resources/sites/subProjects/index.html | 17 +++++++++ .../sites/subProjects/project1/index.html | 13 +++++++ .../sites/subProjects/project2/index.html | 13 +++++++ 4 files changed, 80 insertions(+) create mode 100644 tests/resources/sites/subProjects/index.html create mode 100644 tests/resources/sites/subProjects/project1/index.html create mode 100644 tests/resources/sites/subProjects/project2/index.html diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index a95568c7ce..e4ff30f86e 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2331,4 +2331,41 @@ class SitesCustomServerTest extends Scope $this->cleanupSite($siteId); } + + public function testSubProjects(): void + { + $siteId = $this->setupSite([ + 'siteId' => ID::unique(), + 'name' => 'Sub project site', + 'framework' => 'other', + 'buildRuntime' => 'node-22', + 'outputDirectory' => './' + ]); + $this->assertNotEmpty($siteId); + + $site = $this->getSite($siteId); + $this->assertEquals('200', $site['headers']['status-code']); + $this->assertArrayHasKey('adapter', $site['body']); + + $domain = $this->setupSiteDomain($siteId); + $this->assertNotEmpty($domain); + + $deploymentId = $this->setupDeployment($siteId, [ + 'code' => $this->packageSite('subProjects'), + 'activate' => 'true' + ]); + $this->assertNotEmpty($deploymentId); + + $site = $this->getSite($siteId); + + $proxyClient = new Client(); + $proxyClient->setEndpoint('http://' . $domain); + $response = $proxyClient->call(Client::METHOD_GET, '/'); + $this->assertEquals(200, $response['headers']['status-code']); + $response1 = $proxyClient->call(Client::METHOD_GET, '/project1'); + $this->assertEquals(200, $response1['headers']['status-code']); + $response2 = $proxyClient->call(Client::METHOD_GET, '/project1/'); + $this->assertEquals(308, $response2['headers']['status-code']); + $this->cleanupSite($siteId); + } } diff --git a/tests/resources/sites/subProjects/index.html b/tests/resources/sites/subProjects/index.html new file mode 100644 index 0000000000..cb9af4b5ac --- /dev/null +++ b/tests/resources/sites/subProjects/index.html @@ -0,0 +1,17 @@ + + + + + + Main Project Index + + +

Welcome to My Website

+

Select a project to explore:

+ + + + diff --git a/tests/resources/sites/subProjects/project1/index.html b/tests/resources/sites/subProjects/project1/index.html new file mode 100644 index 0000000000..43b5eae40b --- /dev/null +++ b/tests/resources/sites/subProjects/project1/index.html @@ -0,0 +1,13 @@ + + + + + + Project 1 + + +

Project 1

+

Welcome to Project 1!

+ Back to Main Page + + diff --git a/tests/resources/sites/subProjects/project2/index.html b/tests/resources/sites/subProjects/project2/index.html new file mode 100644 index 0000000000..5fea34c1ce --- /dev/null +++ b/tests/resources/sites/subProjects/project2/index.html @@ -0,0 +1,13 @@ + + + + + + Project 2 + + +

Project 2

+

Welcome to Project 2!

+ Back to Main Page + + From 65aa218aac1c742c232019e10f66d7107114369f Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Fri, 21 Mar 2025 17:54:07 +0530 Subject: [PATCH 2/4] Add test for permanent redirect --- tests/e2e/Services/Sites/SitesCustomServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index e4ff30f86e..cc2e1f9bbb 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2332,7 +2332,7 @@ class SitesCustomServerTest extends Scope $this->cleanupSite($siteId); } - public function testSubProjects(): void + public function testPermanentRedirect(): void { $siteId = $this->setupSite([ 'siteId' => ID::unique(), From 2e0a6f9b9ebefd0dff756a8c49b3dae6eb7c4bdf Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Wed, 26 Mar 2025 17:22:49 +0530 Subject: [PATCH 3/4] Update swoole version --- composer.lock | 16 ++++++++-------- .../e2e/Services/Sites/SitesCustomServerTest.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.lock b/composer.lock index ee5f16f7c9..88cb3586d6 100644 --- a/composer.lock +++ b/composer.lock @@ -4700,16 +4700,16 @@ }, { "name": "utopia-php/swoole", - "version": "0.8.2", + "version": "0.8.3", "source": { "type": "git", "url": "https://github.com/utopia-php/swoole.git", - "reference": "5fa9d42c608ad46a4ce42a6d2b2eae00592fccd4" + "reference": "1af73dd3e73987cf729c7db399054e4a70befd99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/swoole/zipball/5fa9d42c608ad46a4ce42a6d2b2eae00592fccd4", - "reference": "5fa9d42c608ad46a4ce42a6d2b2eae00592fccd4", + "url": "https://api.github.com/repos/utopia-php/swoole/zipball/1af73dd3e73987cf729c7db399054e4a70befd99", + "reference": "1af73dd3e73987cf729c7db399054e4a70befd99", "shasum": "" }, "require": { @@ -4745,9 +4745,9 @@ ], "support": { "issues": "https://github.com/utopia-php/swoole/issues", - "source": "https://github.com/utopia-php/swoole/tree/0.8.2" + "source": "https://github.com/utopia-php/swoole/tree/0.8.3" }, - "time": "2024-02-01T14:54:12+00:00" + "time": "2025-03-26T10:09:05+00:00" }, { "name": "utopia-php/system", @@ -8507,7 +8507,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8531,5 +8531,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 99a1c47f42..ec941a9f56 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2427,7 +2427,7 @@ class SitesCustomServerTest extends Scope $response1 = $proxyClient->call(Client::METHOD_GET, '/project1'); $this->assertEquals(200, $response1['headers']['status-code']); $response2 = $proxyClient->call(Client::METHOD_GET, '/project1/'); - $this->assertEquals(308, $response2['headers']['status-code']); + $this->assertEquals(200, $response2['headers']['status-code']); $this->cleanupSite($siteId); } } From 9404e9225e8dd5b908a6a1eead4a6365a396fa00 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 27 Mar 2025 16:36:37 +0530 Subject: [PATCH 4/4] Update test --- .../Services/Sites/SitesCustomServerTest.php | 11 ++++------- .../resources/sites/sub-directories/index.html | 5 +++++ .../sites/sub-directories/project1/index.html | 5 +++++ tests/resources/sites/subProjects/index.html | 17 ----------------- .../sites/subProjects/project1/index.html | 13 ------------- .../sites/subProjects/project2/index.html | 13 ------------- 6 files changed, 14 insertions(+), 50 deletions(-) create mode 100644 tests/resources/sites/sub-directories/index.html create mode 100644 tests/resources/sites/sub-directories/project1/index.html delete mode 100644 tests/resources/sites/subProjects/index.html delete mode 100644 tests/resources/sites/subProjects/project1/index.html delete mode 100644 tests/resources/sites/subProjects/project2/index.html diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index bfef38ee10..249e4d6edb 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2442,29 +2442,26 @@ class SitesCustomServerTest extends Scope ]); $this->assertNotEmpty($siteId); - $site = $this->getSite($siteId); - $this->assertEquals('200', $site['headers']['status-code']); - $this->assertArrayHasKey('adapter', $site['body']); - $domain = $this->setupSiteDomain($siteId); $this->assertNotEmpty($domain); $deploymentId = $this->setupDeployment($siteId, [ - 'code' => $this->packageSite('subProjects'), + 'code' => $this->packageSite('sub-directories'), 'activate' => 'true' ]); $this->assertNotEmpty($deploymentId); - $site = $this->getSite($siteId); - $proxyClient = new Client(); $proxyClient->setEndpoint('http://' . $domain); $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); + $this->assertStringContainsString('Sub-directory index', $response['body']); $response1 = $proxyClient->call(Client::METHOD_GET, '/project1'); $this->assertEquals(200, $response1['headers']['status-code']); + $this->assertStringContainsString('Sub-directory project1', $response1['body']); $response2 = $proxyClient->call(Client::METHOD_GET, '/project1/'); $this->assertEquals(200, $response2['headers']['status-code']); + $this->assertStringContainsString('Sub-directory project1', $response2['body']); $this->cleanupSite($siteId); } } diff --git a/tests/resources/sites/sub-directories/index.html b/tests/resources/sites/sub-directories/index.html new file mode 100644 index 0000000000..d21a10191c --- /dev/null +++ b/tests/resources/sites/sub-directories/index.html @@ -0,0 +1,5 @@ + + +

Sub-directory index

+ + diff --git a/tests/resources/sites/sub-directories/project1/index.html b/tests/resources/sites/sub-directories/project1/index.html new file mode 100644 index 0000000000..8fc477991c --- /dev/null +++ b/tests/resources/sites/sub-directories/project1/index.html @@ -0,0 +1,5 @@ + + +

Sub-directory project1

+ + \ No newline at end of file diff --git a/tests/resources/sites/subProjects/index.html b/tests/resources/sites/subProjects/index.html deleted file mode 100644 index cb9af4b5ac..0000000000 --- a/tests/resources/sites/subProjects/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Main Project Index - - -

Welcome to My Website

-

Select a project to explore:

- - - - diff --git a/tests/resources/sites/subProjects/project1/index.html b/tests/resources/sites/subProjects/project1/index.html deleted file mode 100644 index 43b5eae40b..0000000000 --- a/tests/resources/sites/subProjects/project1/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Project 1 - - -

Project 1

-

Welcome to Project 1!

- Back to Main Page - - diff --git a/tests/resources/sites/subProjects/project2/index.html b/tests/resources/sites/subProjects/project2/index.html deleted file mode 100644 index 5fea34c1ce..0000000000 --- a/tests/resources/sites/subProjects/project2/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Project 2 - - -

Project 2

-

Welcome to Project 2!

- Back to Main Page - -