Skip to content

Add route_request dispatch coverage#689

Open
ChristianPavilonis wants to merge 1 commit into
mainfrom
test-route-request-dispatch-451
Open

Add route_request dispatch coverage#689
ChristianPavilonis wants to merge 1 commit into
mainfrom
test-route-request-dispatch-451

Conversation

@ChristianPavilonis
Copy link
Copy Markdown
Collaborator

Summary

  • Add focused Fastly adapter route_request dispatch coverage.
  • Cover static TSJS success and unknown bundle handling.
  • Cover public discovery and unauthenticated admin dispatch.
  • Cover auction dispatch through consent-dependent setup.
  • Cover unknown-route publisher fallback dispatch without configured consent persistence.

Closes #451

Tests

  • cargo test -p trusted-server-adapter-fastly route_tests -- --nocapture
  • cargo fmt --all -- --check
  • cargo test --workspace
  • cargo clippy --workspace --all-targets --all-features -- -D warnings

@ChristianPavilonis ChristianPavilonis marked this pull request as ready for review May 13, 2026 19:06
Copy link
Copy Markdown
Collaborator

@prk-Jr prk-Jr left a comment

Choose a reason for hiding this comment

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

Summary

This PR adds focused Fastly adapter coverage for route_request. The overall direction is useful, but one assertion currently does not prove the route branch it is intended to cover because another branch can produce the same failure status.

CI Status

  • cargo fmt: PASS
  • cargo test: PASS
  • vitest: PASS
  • integration tests: PASS
  • browser integration tests: PASS
  • CodeQL: PASS
  • analysis jobs: PASS


let resp = route_with_settings(&settings, req).expect("should route auction request");

assert_eq!(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔧 wrench — Auction route test can pass through the fallback path

auction_route_dispatches_to_consent_dependent_path asserts 503 with a missing consent store. That does not prove /auction dispatched to handle_auction, because the unknown-route publisher fallback also calls runtime_services_for_consent_route first and would return the same 503 if the /auction matcher were removed or typoed.

Fix: use a route-specific auction failure that fallback would not produce, for example settings without a consent store plus an invalid banner size:

let settings = create_test_settings_without_consent_store();
let req = Request::post("https://test.com/auction").with_body(
    r#"{"adUnits":[{"code":"slot","mediaTypes":{"banner":{"sizes":[[300]]}},"bids":[]}],"config":null}"#,
);

let mut resp = route_with_settings(&settings, req).expect("should route auction request");

assert_eq!(resp.get_status(), StatusCode::BAD_REQUEST);
assert!(resp.take_body_str().contains("Invalid banner size"));


#[test]
fn unknown_route_falls_back_to_publisher_proxy_path() {
let settings = create_test_settings_without_consent_store();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤔 thinking — Publisher fallback test depends on ambient DNS failure

unknown_route_falls_back_to_publisher_proxy_path gets 502 because the configured origin cannot be resolved; the local run emitted a Viceroy DNS error. To make the failure mode intentional, consider a fallback-specific settings helper with an RFC-reserved .invalid origin host.

}

#[test]
fn static_tsjs_route_serves_unified_bundle() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🌱 seedling — Static route coverage misses deferred module success

The static route tests cover unified bundle success and unknown bundle failure. Since this config enables Prebid, adding /static/tsjs=tsjs-prebid.min.js would also cover the deferred-module branch in handle_tsjs_dynamic.

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.

Add integration coverage for route_request dispatch behavior

2 participants