Skip to content

Add Phase 5 cross-adapter verification suite (PR 18)#725

Open
prk-Jr wants to merge 28 commits into
feature/edgezero-pr17-cloudflare-adapterfrom
feature/edgezero-pr18-phase5-verification
Open

Add Phase 5 cross-adapter verification suite (PR 18)#725
prk-Jr wants to merge 28 commits into
feature/edgezero-pr17-cloudflare-adapterfrom
feature/edgezero-pr18-phase5-verification

Conversation

@prk-Jr
Copy link
Copy Markdown
Collaborator

@prk-Jr prk-Jr commented May 20, 2026

Summary

  • Implements the Phase 5 verification gate suite from issue Verification gates #499: route parity, auth parity, cross-adapter behavior, auction error-correlation, HTML golden tests, and Criterion benchmarks
  • Adds a dedicated parity test binary in crates/integration-tests that drives the Axum and Cloudflare adapters with identical requests in-process, proving behavioral equivalence before cutover
  • Establishes CI gates for both the parity suite and a benchmark smoke-run so regressions are caught on every PR

Changes

File Change
crates/trusted-server-adapter-cloudflare/tests/routes.rs 10 route smoke tests + 5 basic-auth parity tests + 4 admin key path tests
crates/trusted-server-adapter-axum/tests/routes.rs 5 basic-auth parity tests + 3 admin key path tests
crates/trusted-server-adapter-cloudflare/Cargo.toml Added base64 dev-dependency
crates/trusted-server-adapter-axum/Cargo.toml Added base64 dev-dependency
crates/integration-tests/Cargo.toml New [[test]] parity binary + adapter path deps + edgezero git deps
crates/integration-tests/tests/parity.rs New — 8 cross-adapter in-process parity tests (Axum vs Cloudflare)
crates/trusted-server-core/src/platform/http.rs PlatformResponse::backend_name unit tests (error-correlation, pre-EdgeZero #213)
crates/trusted-server-core/src/html_processor.rs 4 golden regression tests: injection position, URL rewriting, no double-inject, size bounds
crates/trusted-server-core/Cargo.toml Added [[bench]] html_processor_bench entry
crates/trusted-server-core/benches/html_processor_bench.rs New — Criterion benchmarks for 10 KB and 100 KB HTML processing
.github/workflows/test.yml New test-parity CI job + benchmark smoke step in test-axum job
docs/superpowers/plans/2026-05-20-pr18-phase5-verification.md Implementation plan

Closes

Closes #499

Test plan

  • cargo fmt --all -- --check
  • cargo clippy-axum
  • cargo test-axum (16 tests pass)
  • cargo test-cloudflare (22 tests pass)
  • cargo test --manifest-path crates/integration-tests/Cargo.toml --test parity (8 tests pass)
  • cargo test --lib -p trusted-server-core (956 tests pass)
  • cargo bench -p trusted-server-core --bench html_processor_bench -- --test (smoke passes)
  • cargo test-fastly (Viceroy-based — not run locally; covered by existing CI job)
  • JS tests / JS format / Docs format (no JS or docs changes)

Checklist

  • Changes follow CLAUDE.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses tracing macros (not println!)
  • New code has tests
  • No secrets or credentials committed

prk-Jr added 15 commits May 20, 2026 20:32
Adds 10 tests to tests/routes.rs covering every explicitly registered
route plus the tsjs catch-all wildcard. Assertions are scoped to routing
only (not 404) for handlers that require live settings or outbound
connections, matching the pattern established by the existing auction test.
Verifies that /admin/* routes return 401 without credentials, include
a WWW-Authenticate: Basic realm=... header, and reject wrong credentials;
also confirms /.well-known and /auction are not gated by admin auth.
…enchmarks

- Add golden_script_tag_injected_at_head_start: verifies script tag is
  the first child of <head> with nothing between the opening tag and the
  injected <script>.
- Add golden_url_rewriting_replaces_origin_in_href: verifies origin host
  is fully replaced by proxy host in href/src attributes.
- Add golden_integration_script_is_not_double_injected: verifies the
  /static/tsjs= script tag appears exactly once.
- Add response_size_does_not_grow_disproportionately: verifies processed
  HTML stays within 2× of input size to catch buffer/double-processing bugs.
- Add Criterion benchmark (html_processor_bench) for process_chunk at
  10 KB and 100 KB payload sizes.
@prk-Jr prk-Jr self-assigned this May 20, 2026
prk-Jr added 13 commits May 20, 2026 21:43
The build script writes trusted-server-out.toml to ../../target/ relative
to crates/trusted-server-core/. When the test-parity CI job builds this
crate as a dependency from crates/integration-tests/ (workspace-excluded),
the workspace-root target/ directory may not yet exist, causing a panic.

Add fs::create_dir_all for the parent path before the write to handle
this case robustly.
The renamed tests duplicated coverage already provided by
admin_route_with_wrong_credentials_returns_401. Auth middleware rejects
any wrong credentials with 401 regardless of body content, so the extra
variants added no unique signal.
The previous comment described the wrong divergence (authenticated path).
For unauthenticated requests both adapters return 401. Add the missing
assert_eq!(axum_status, 401) and assert_eq!(axum_status, cf_status) so
the parity claim is actually verified for both adapters.
crates/integration-tests is workspace-excluded so cargo clippy --workspace
is blind to it. Add an explicit step so lint regressions in parity.rs
are caught on every PR.
2.0 was a magic number. Named constant with comment makes the bound
self-documenting: 2× covers injected script tag plus URL rewrites.
The setup-rust-toolchain action does not guarantee clippy is installed
when restoring a shared cache. Explicitly request the component so the
Clippy (parity test crate) step can find cargo-clippy.
Matches the convention used by the Axum adapter tests and parity tests.
Single-threaded tokio can miss races in middleware that spawns tasks.
Matches the five first-party route tests already present in the
Cloudflare adapter test suite. A silently removed route in the Axum
adapter now fails the test run instead of going undetected.
- Assert Axum also returns WWW-Authenticate header on 401 (was CF-only)
- Add admin_deactivate_unauthenticated_parity covering the deactivate path
- Rename cookie_behavior_note → publisher_proxy_fallback_parity (name
  now reflects what the test actually verifies)
- Fix expect("collect body") → expect("should collect body") per style guide
Adds inline comment so future maintainers know why the version is pinned
with `=` rather than a range constraint.
@prk-Jr prk-Jr requested a review from aram356 May 20, 2026 17:15
@prk-Jr prk-Jr requested a review from ChristianPavilonis May 20, 2026 17:15
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.

1 participant