Skip to content

test(fake): redirect a site directory and serve one under /_decdn/ as its index.html - #17

Merged
yigitdot merged 3 commits into
mainfrom
test/fake-directory-redirect
Nov 23, 2026
Merged

yigitdot merged 3 commits into
mainfrom
test/fake-directory-redirect

Conversation

@yigitdot

@yigitdot yigitdot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #16. The fake gateway now mirrors decdn/decdn#2941.

What changed

Fake gateway (tests/fake_gateway.py)

  • Site directory redirect: on a site, a path that names a directory with an index.html (and no entry of its own) answers 302 Location: <dir>/. The request's query is kept (/docs?tab=2 → docs/?tab=2), for GET and HEAD.
  • /_decdn/ directory index: a trailing / inside a bundle maps to index.html before parsing. So /_decdn/<h>/docs/ serves docs/index.html, and /_decdn/<h>/docs?ns=7 redirects to docs/?ns=7. The bundle root <h>/ is unchanged.
  • HEAD or navigation under /_decdn/: a request with no Sec-Fetch-Mode, or with navigate, counts as a navigation, as site::is_navigation does.
    • A HEAD or a navigation of a bundle or an entry redirects to that bundle's site, without reading the manifest or charging the allowance.
    • When the request named a directory, the redirect goes to the directory itself (/_decdn/<h>/docs/ → http://<site>/docs/).
    • A blob is still served. Before this, a HEAD of a bundle or entry here served the content, and so did a navigation.

Contract

  • The fixture bundle gains docs/index.html, with no docs entry.
  • A new public contract test, gated on shipped_after("0.3.1") since v0.3.1 is decdn's latest release, checks:
    • the site's own /docs, /docs?tab=2, /docs/ and /docs/?tab=2, plus HEAD /docs?tab=2;
    • /_decdn/<h>/docs, …/docs?ns=7 and …/docs/;
    • HEAD /_decdn/<h>/docs/ redirecting to the site's /docs/.
  • It sends sec-fetch-mode: cors and sec-fetch-site: same-origin, as sdk-typescript does, so the real gateway treats each request as the page's own.
  • It doesn't fetch /_decdn/<h>/docs/?ns=7 from the real gateway: there, ?ns= routes the fetch through a namespace the e2e network may not serve. The unit tests cover that case against the fake.

Where this follows #2941 rather than the issue text

  • A site's own directory redirect also keeps the query.
  • HEAD of a /_decdn/ directory goes to the directory on the site, not to docs/index.html.

Order of changes

This PR lands first. decdn/decdn#2941 then adds docs/index.html to the bundle in crates/e2e/src/sdk_contract.rs and moves both SDK pins. harness-floor is empty, so the floor doesn't change.

Known gaps (not in this PR)

#20 tracks two older fake/real mismatches that nothing reads today:

  • a blob navigation's Content-Disposition;
  • the loopback site gate refusing a link from another site.

Testing

  • uv run ruff check ., uv run ruff format --check . and uv run mypy are clean.
  • uv run pytest --ignore=tests/scripts: 359 passed.
  • The new contract test has run against the fake, not yet against the real gateway. That needs #2941's harness change.

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings November 23, 2026 02:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@yigitdot
yigitdot force-pushed the test/fake-directory-redirect branch from 5714cbb to f4f4793 Compare November 23, 2026 02:53
yigitdot and others added 2 commits November 23, 2026 06:11
… its index.html

The fake gateway mirrors decdn/decdn#2941. On a site, a path naming a
directory with an index.html answers 302 to `<dir>/`, with the request's
query kept, for GET and HEAD. Under /_decdn/, a trailing `/` inside a
bundle serves the directory's index.html. HEAD of a bundle or an entry
under /_decdn/ redirects to its site at no pull, to the directory itself
when the request named one.

The contract fixture bundle gains docs/index.html, and a public contract
test covers these cases. It sends Sec-Fetch-Mode: cors and Sec-Fetch-Site:
same-origin, as a page's own request does.

Closes #16

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The real gateway takes a request with no Sec-Fetch-Mode, or with
Sec-Fetch-Mode: navigate, as a navigation. Under /_decdn/ it redirects
a navigation of a bundle or an entry to that bundle's site, to the
directory itself when the request named one. The fake now does the
same.

The unit tests now send a page's own request where they mean one, and
they cover the navigation redirect, the bundle root, a folder with no
index.html, and the bare-host location. The contract test adds HEAD of
a site directory with a query and builds the site origin from the
gateway URL. Comments are clarified.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot
yigitdot force-pushed the test/fake-directory-redirect branch from f4f4793 to 714acef Compare November 23, 2026 03:11
Under /_decdn/, ?ns= becomes the URI's namespace, so on the real gateway
the pull of docs/index.html is routed through a namespace the e2e
network need not serve. It passes now only because an earlier request
in the same test cached the entry. The contract test keeps checking the
?ns=7 redirect, which pulls nothing, and fetches the index without the
query. The unit test still covers the hinted index against the fake.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot
yigitdot merged commit 7b1982b into main Nov 23, 2026
13 checks passed
@yigitdot
yigitdot deleted the test/fake-directory-redirect branch November 23, 2026 04:23
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.

fake gateway: redirect a site directory, and serve a directory under /_decdn/ as its index.html

2 participants