mirror of
https://github.com/appwrite/appwrite
synced 2026-05-05 22:38:37 +00:00
Merge pull request #10352 from appwrite/chore-improve-cookie-tests
Chore: Add cookies test
This commit is contained in:
commit
d68e394c60
2 changed files with 43 additions and 0 deletions
|
|
@ -2697,4 +2697,43 @@ class SitesCustomServerTest extends Scope
|
|||
|
||||
$this->cleanupSite($siteId);
|
||||
}
|
||||
|
||||
public function testCookieHeader()
|
||||
{
|
||||
$siteId = $this->setupSite([
|
||||
'siteId' => ID::unique(),
|
||||
'name' => 'Astro site',
|
||||
'framework' => 'astro',
|
||||
'adapter' => 'ssr',
|
||||
'buildRuntime' => 'node-22',
|
||||
'outputDirectory' => './dist',
|
||||
'buildCommand' => 'npm run build',
|
||||
'installCommand' => 'npm install',
|
||||
'fallbackFile' => '',
|
||||
]);
|
||||
|
||||
$this->assertNotEmpty($siteId);
|
||||
|
||||
$domain = $this->setupSiteDomain($siteId);
|
||||
|
||||
$deploymentId = $this->setupDeployment($siteId, [
|
||||
'code' => $this->packageSite('astro'),
|
||||
'activate' => 'true'
|
||||
]);
|
||||
|
||||
$this->assertNotEmpty($deploymentId);
|
||||
|
||||
$domain = $this->getSiteDomain($siteId);
|
||||
$proxyClient = new Client();
|
||||
$proxyClient->setEndpoint('http://' . $domain);
|
||||
|
||||
$response = $proxyClient->call(Client::METHOD_GET, '/cookies', [
|
||||
'cookie' => 'custom-session-id=abcd123'
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals("abcd123", $response['body']);
|
||||
|
||||
$this->cleanupSite($siteId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
tests/resources/sites/astro/src/pages/cookies.js
Normal file
4
tests/resources/sites/astro/src/pages/cookies.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export async function GET(context) {
|
||||
const sessionId = context.cookies.get("custom-session-id")?.value ?? 'Custom session ID missing';
|
||||
return new Response(sessionId);
|
||||
}
|
||||
Loading…
Reference in a new issue