chore: drop the server tests that only test the platform - #17037
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/cab2a84e8d7dac42b89ab54c67fffc509f0007dcOpen in |
|
📝 WalkthroughWalkthroughThe CSRF test suite now contains one successful POST form request from Merge Risk: 🔵 Low · up to This test-only change reduces CSRF coverage to a trusted-origin case, leaving configured trusted-origin propagation less protected against regression. The change is mergeable with owner awareness of this bounded coverage gap. 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Comment |
There was a problem hiding this comment.
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (1)
packages/kit/test/apps/basics/unit-test/server.spec.js-201-201 (1)
201-201: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRetain multi-entry
csrf.trustedOriginscoverage.This test validates only one trusted-origin entry.
packages/kit/src/runtime/server/csrf.spec.jsalso tests only a singletontrusted_originsarray. If server configuration drops entries after the first, all remaining tests pass. Keep the additional trusted-origin case here, or add a focused test that passes at least two configured origins.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: QUIET
Plan: Advanced
Run ID: 06cdfebf-a730-47cc-96bc-22cbf983b8c3
📒 Files selected for processing (1)
packages/kit/test/apps/basics/unit-test/server.spec.js
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
sveltejs/vite-plugin-svelte(manual)vitejs/vite(manual)sveltejs/svelte(manual)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
ff6cb45 to
bb9841b
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/kit/test/apps/basics/unit-test/server.spec.js (1)
176-190: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAlign the retained CSRF test with the case it sends.
This test sends no
Originheader, so it covers a missing origin, not an incorrect origin. Rename the test to reflect that case. The response text varies bymethod, not bycontent_type, so use one representative form content type per method.Proposed narrowing
- test('Blocks requests with incorrect origin', async () => { - const content_types = [ - 'application/x-www-form-urlencoded', - 'multipart/form-data', - 'text/plain', - 'text/plaiN' - ]; + test('Reports forbidden response text for mutating form methods', async () => { const methods = ['POST', 'PUT', 'PATCH', 'DELETE']; for (const method of methods) { - for (const content_type of content_types) { - const res = await get('/csrf', { method, headers: { 'content-type': content_type } }); - const message = `request method: ${method}, content-type: ${content_type}`; + const res = await get('/csrf', { + method, + headers: { 'content-type': 'application/x-www-form-urlencoded' } + }); + const message = `request method: ${method}`; expect(res.status, message).toBe(403); expect(await res.text(), message).toBe( `Cross-site ${method} form submissions are forbidden` ); - } } });
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: QUIET
Plan: Advanced
Run ID: 5f3b44b1-0548-4aa0-a4be-4ace4fa91141
📒 Files selected for processing (2)
packages/kit/test/apps/basics/src/routes/endpoint-input/sha256/+server.jspackages/kit/test/apps/basics/unit-test/server.spec.js
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
sveltejs/vite-plugin-svelte(manual)vitejs/vite(manual)sveltejs/svelte(manual)
💤 Files with no reviewable changes (1)
- packages/kit/test/apps/basics/src/routes/endpoint-input/sha256/+server.js
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
63bdd7b to
7fee9c8
Compare
Co-authored-by: Rich Harris <rich.harris@vercel.com>
…yer where it can run
ef26fc7 to
ed15255
Compare
|
I don't think |
|
ah whoops meant to comment that in #16872 |
ed15255 to
6d7ab37
Compare
6d7ab37 to
fe67096
Compare
|
|
|
Yeah I did a 'find all references' on #16872 and it didn't show up anywhere else, so I figured it had been part of an earlier exploration and was no longer needed. I think my language server was just glitching. I did put them back, downstack, but somehow that didn't affect this PR, which is further evidence that stacks are a stupid buggy feature that we should avoid like the plague. We should just have standalone PRs that target other branches like we used to — almost all the same benefits for authors but without the absolute clusterfuck that comes from trying to merge them. If this PR had been done like that we could just merge
Luckily in this case the merge conflict was trivial to resolve, but it could have been a real PITA |
Two kinds of test in the moved server suite exercise nothing in kit under a direct
Server.respondcall.Six of the eight CSRF cases repeat
csrf.spec.jsone for one: same origin, non-allowed origins, GET, non-form content types, the method loop, missing origin. Only the 403 body text and thecsrf.trustedOriginswiring are checked nowhere else, so those two stay.The slow-read test hands the endpoint an in-memory buffer, so nothing is read slowly and the digest round-trip only proves
Request.body. The backpressure it used to reach over HTTP has its own cases innode/index.spec.js.