You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cors-worker: run the shared shell suite through the Node shell's real guarded fetch #132
node.test.mjs runs the shared behaviour suite (shell-cases.mjs) against the Node shell, but with fetch replaced by a passthrough to the stubbed globalThis.fetch. So the ~30 shared cases (token auth, allowlist, size cap, log hygiene, redirects…) exercise core.js + createHandler, but never guarded-fetch.js, the hand-written node:http/https client the Node shell actually uses in production. Its translation of a Node response into a standard Response is covered only by targeted tests in guarded-fetch.test.mjs:
hop-by-hop header stripping;
HEAD/204/304 bodies;
raw encoded bodies;
multi-value set-cookie;
statuses Response refuses.
The suite also calls the handler directly rather than over HTTP, so createServer's request/response adapter only has its own tests.
Why it isn't a quick PR
The shared cases stub upstreams as fetchImpl functions and target https://example.com/.... To route them through the real client, the test harness has to turn each stub into a real upstream. That's a design decision:
Local relay server (recommended). Start one local HTTP server whose handler calls the case's fetchImpl and writes the Response back. Give the guarded fetch an injected lookup that maps every host to 127.0.0.1, plus a test policy that allows 127.0.0.1 (as guard-fixtures.mjs already does). Open question: the targets are https://, so this needs either a self-signed cert trusted by the test agent, or a test-only option that lets createGuardedFetch speak plain HTTP to an https: URL. Option 1a (the cert) keeps production code untouched.
Rewrite the targets to http:// in the shared cases. Simpler, but it changes the suite both shells share, and a few cases assert on the target URL.
Run the suite over HTTP through createServer as well, which would also cover the adapter. This can be combined with 1.
Acceptance
node.test.mjs runs defineShellSuite with the Node shell's real guarded fetch (and ideally over createServer), with no external network or DNS.
The Cloudflare run of the suite is unchanged.
A deliberately broken translation in guarded-fetch.js (e.g. not stripping transfer-encoding) fails the shared suite.
Activity