Skip to content

test(contract): expect Content-Encoding among the exposed headers - #12

Merged
alpergundogdu merged 3 commits into
mainfrom
fix/expose-content-encoding
Nov 11, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
fix/expose-content-encoding

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

The public gateway adds Content-Encoding to Access-Control-Expose-Headers (decdn/decdn#2817, gateway change in decdn/decdn#2870), so a page on another origin can tell that a proxy in front encoded the body.

Changes

  • tests/fake_gateway.py and tests/unit/test_fake_gateway.py: EXPOSED lists Content-Encoding after Content-Length, as the gateway does.
  • tests/contract/test_public.py: a blob read with an Origin finds content-encoding and content-length in access-control-expose-headers.
  • tests/contract/fixture.py: shipped_after(version) says whether the gateway under test carries behaviour decdn shipped after that release. scripts/decdn-contract.sh --tag sets DECDN_CONTRACT_RELEASE; the fake and --ref runs carry everything.
  • The new test is declared inside if shipped_after("0.3.1"):. It is left out, not skipped, because decdn's harness fails a run where any collected test is skipped. CONTRIBUTING.md describes the pattern. This is the same gate as test(contract): expect Content-Encoding among the exposed headers sdk-typescript#25.

Order

This PR merges first. decdn/decdn#2870 pins .github/sdk-python.sha to this branch's head.

Gateway floor

gateway-floor stays as is: the SDK code does not change, and the weekly release-gateway runs do not collect the new test.

Tests

  • uv run ruff check ., uv run ruff format --check ., uv run mypy, shellcheck scripts/decdn-contract.sh: pass.
  • uv run pytest tests/unit tests/contract: 354 passed.
  • With DECDN_CONTRACT_RELEASE=0.3.1 the new test is not collected; with 0.3.2 or 0.4.0-rc.1 it runs and passes.
  • tests/scripts/test_decdn_contract.py fails locally on macOS, unrelated to this change.

🤖 Generated with Claude Code

The public gateway lists Content-Encoding in Access-Control-Expose-Headers
(decdn/decdn#2817), so a page on another origin can tell a body was decoded
on the way. The fake mirrors the list and the public contract asserts it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 17:23

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.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

Two active review nits remain in the test suite—one requesting a more accurate test name in tests/contract/test_public.py and another to remove a duplicated EXPOSED constant in tests/unit/test_fake_gateway.py by importing it from tests.fake_gateway to prevent drift.

2 open issues
What changed in this PR

Aligns the fake gateway and public contract tests with the gateway behavior that exposes Content-Encoding via CORS so cross-origin callers can detect response encoding.

Changes:

  • Add Content-Encoding to the fake gateway’s Access-Control-Expose-Headers list (matching gateway ordering).
  • Update unit expectations for the exposed-headers list.
  • Add a contract assertion that cross-origin blob reads observe content-encoding (and content-length) in access-control-expose-headers.
File Description
tests/​unit/​test_fake_gateway.py Updates unit test expectations around the fake gateway’s exposed CORS headers to include Content-Encoding.
tests/​fake_gateway.py Adjusts the fake gateway’s Access-Control-Expose-Headers list to expose Content-Encoding in the intended order.
tests/​contract/​test_public.py Adds a public contract test asserting access-control-expose-headers includes content-encoding and content-length for cross-origin requests.

Review effort: Balanced

Comment thread tests/contract/test_public.py Resolved
Comment thread tests/unit/test_fake_gateway.py Resolved
scripts/decdn-contract.sh --tag names its release in DECDN_CONTRACT_RELEASE,
and shipped_after(version) in the fixture gates a contract test on it. The
test is declared only when the gateway carries the behaviour, since decdn's
harness fails a run that skips a test. The Content-Encoding expose test runs
on gateways after v0.3.1, the fake and every --ref run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alpergundogdu
alpergundogdu requested a review from thiras November 11, 2026 19:57
@alpergundogdu
alpergundogdu merged commit a08e55a into main Nov 11, 2026
12 checks passed
@alpergundogdu
alpergundogdu deleted the fix/expose-content-encoding branch November 11, 2026 19:58
alpergundogdu added a commit to decdn/decdn that referenced this pull request Nov 13, 2026
decdn/sdk-typescript#25 and decdn/sdk-python#12 squash-merged, so the
pins move from the PR branch heads to the commits on each SDK's main.
The trees are identical.

Co-authored-by: Claude Fable 5.2 <[email protected]>
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