Skip to content

Chore: Add cookies test #10352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2025
Merged

Chore: Add cookies test #10352

merged 1 commit into from
Aug 21, 2025

Conversation

Meldiron
Copy link
Contributor

What does this PR do?

Ensures behaviour of cookies for sites

Test Plan

new test

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Copy link
Contributor

coderabbitai bot commented Aug 21, 2025

📝 Walkthrough

Walkthrough

  • Added a new E2E test method testCookieHeader in tests/e2e/Services/Sites/SitesCustomServerTest.php. The test deploys an Astro SSR site, sends a GET request to /cookies with a custom-session-id cookie set to abcd123, asserts a 200 status and response body abcd123, then cleans up.
  • Introduced tests/resources/sites/astro/src/pages/cookies.js with an exported async GET(context) that reads context.cookies.get('custom-session-id')?.value ?? 'Custom session ID missing' and returns it in the response body.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore-improve-cookie-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
binutils 2.42-r0 CVE-2025-0840 HIGH
git 2.45.3-r0 CVE-2025-46334 HIGH
git 2.45.3-r0 CVE-2025-48384 HIGH
git 2.45.3-r0 CVE-2025-48385 HIGH
git-init-template 2.45.3-r0 CVE-2025-46334 HIGH
git-init-template 2.45.3-r0 CVE-2025-48384 HIGH
git-init-template 2.45.3-r0 CVE-2025-48385 HIGH
icu 74.2-r0 CVE-2025-5222 HIGH
icu-data-en 74.2-r0 CVE-2025-5222 HIGH
icu-dev 74.2-r0 CVE-2025-5222 HIGH
icu-libs 74.2-r0 CVE-2025-5222 HIGH
libecpg 16.8-r0 CVE-2025-8714 HIGH
libecpg 16.8-r0 CVE-2025-8715 HIGH
libecpg-dev 16.8-r0 CVE-2025-8714 HIGH
libecpg-dev 16.8-r0 CVE-2025-8715 HIGH
libexpat 2.6.4-r0 CVE-2024-8176 HIGH
libpq 16.8-r0 CVE-2025-8714 HIGH
libpq 16.8-r0 CVE-2025-8715 HIGH
libpq-dev 16.8-r0 CVE-2025-8714 HIGH
libpq-dev 16.8-r0 CVE-2025-8715 HIGH
libxml2 2.12.7-r0 CVE-2024-56171 HIGH
libxml2 2.12.7-r0 CVE-2025-24928 HIGH
libxml2 2.12.7-r0 CVE-2025-27113 HIGH
libxml2 2.12.7-r0 CVE-2025-32414 HIGH
libxml2 2.12.7-r0 CVE-2025-32415 HIGH
postgresql16-dev 16.8-r0 CVE-2025-8714 HIGH
postgresql16-dev 16.8-r0 CVE-2025-8715 HIGH
pyc 3.12.9-r0 CVE-2024-12718 HIGH
pyc 3.12.9-r0 CVE-2025-4138 HIGH
pyc 3.12.9-r0 CVE-2025-4330 HIGH
pyc 3.12.9-r0 CVE-2025-4517 HIGH
python3 3.12.9-r0 CVE-2024-12718 HIGH
python3 3.12.9-r0 CVE-2025-4138 HIGH
python3 3.12.9-r0 CVE-2025-4330 HIGH
python3 3.12.9-r0 CVE-2025-4517 HIGH
python3-pyc 3.12.9-r0 CVE-2024-12718 HIGH
python3-pyc 3.12.9-r0 CVE-2025-4138 HIGH
python3-pyc 3.12.9-r0 CVE-2025-4330 HIGH
python3-pyc 3.12.9-r0 CVE-2025-4517 HIGH
python3-pycache-pyc0 3.12.9-r0 CVE-2024-12718 HIGH
python3-pycache-pyc0 3.12.9-r0 CVE-2025-4138 HIGH
python3-pycache-pyc0 3.12.9-r0 CVE-2025-4330 HIGH
python3-pycache-pyc0 3.12.9-r0 CVE-2025-4517 HIGH
sqlite-libs 3.45.3-r1 CVE-2025-29087 HIGH
xz 5.6.2-r0 CVE-2025-31115 HIGH
xz-libs 5.6.2-r0 CVE-2025-31115 HIGH
golang.org/x/crypto v0.31.0 CVE-2025-22869 HIGH
golang.org/x/oauth2 v0.24.0 CVE-2025-22868 HIGH
stdlib 1.22.10 CVE-2025-47907 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
tests/resources/sites/astro/src/pages/cookies.js (1)

2-3: Set an explicit content-type for predictable client behavior

Returning a Response without a content-type relies on client heuristics. Make it explicit to avoid future surprises and to aid debugging.

-  return new Response(sessionId);
+  return new Response(sessionId, {
+    headers: {
+      'content-type': 'text/plain; charset=utf-8',
+    },
+  });
tests/e2e/Services/Sites/SitesCustomServerTest.php (3)

2701-2701: Reduce potential flakiness with Retry attribute

Similar E2E tests use Retry, which helps when infra (proxy/runtimes) is momentarily slow. Recommend adding it here as well.

-    public function testCookieHeader()
+    #[Retry(count: 3)]
+    public function testCookieHeader()

2726-2736: Broaden assertions: multi-cookie parsing and missing-cookie fallback

Two quick follow-ups make this test more robust:

  • Ensure the target cookie is correctly extracted when multiple cookies are present.
  • Verify the fallback message when the cookie is absent (matches the handler).
         $response = $proxyClient->call(Client::METHOD_GET, '/cookies', [
             'cookie' => 'custom-session-id=abcd123'
         ]);
 
         $this->assertEquals(200, $response['headers']['status-code']);
         $this->assertEquals("abcd123", $response['body']);
 
+        // Multiple cookies: ensure correct extraction
+        $response = $proxyClient->call(Client::METHOD_GET, '/cookies', [
+            'cookie' => 'foo=bar; custom-session-id=abcd123; baz=qux'
+        ]);
+        $this->assertEquals(200, $response['headers']['status-code']);
+        $this->assertEquals("abcd123", $response['body']);
+
+        // Missing cookie: verify fallback behavior from the route handler
+        $response = $proxyClient->call(Client::METHOD_GET, '/cookies', [
+            'cookie' => 'foo=bar'
+        ]);
+        $this->assertEquals(200, $response['headers']['status-code']);
+        $this->assertEquals("Custom session ID missing", $response['body']);

2717-2729: Minor: reuse existing $domain instead of re-querying

You already get $domain from setupSiteDomain($siteId). Unless you specifically need the value from getSiteDomain(), you can reuse the existing variable and avoid the extra call.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 36049cf and 669844b.

📒 Files selected for processing (2)
  • tests/e2e/Services/Sites/SitesCustomServerTest.php (1 hunks)
  • tests/resources/sites/astro/src/pages/cookies.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/e2e/Services/Sites/SitesCustomServerTest.php (2)
tests/e2e/Services/Sites/SitesBase.php (6)
  • setupSite (21-34)
  • setupSiteDomain (345-363)
  • setupDeployment (36-83)
  • packageSite (239-251)
  • getSiteDomain (365-386)
  • cleanupSite (85-94)
tests/e2e/Client.php (2)
  • Client (8-328)
  • setEndpoint (126-131)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan
🔇 Additional comments (2)
tests/resources/sites/astro/src/pages/cookies.js (1)

1-4: LGTM: endpoint correctly echoes the cookie value

The handler uses Astro’s cookies API and returns the expected plain-text body, matching the E2E test expectations.

tests/e2e/Services/Sites/SitesCustomServerTest.php (1)

2701-2738: LGTM: solid E2E coverage that validates cookie forwarding

The test provisions an Astro SSR site, deploys it, sends a Cookie header, and asserts the echoed value. Flow and assertions look good, and cleanup is handled.

Copy link

✨ Benchmark results

  • Requests per second: 975
  • Requests with 200 status code: 175,496
  • P99 latency: 0.187038288

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 975 1,002
200 175,496 180,475
P99 0.187038288 0.192880196

@Meldiron Meldiron merged commit d68e394 into 1.7.x Aug 21, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants