Skip to content

test: snapshot boot HTTP registration and auth contracts - #1791

Open
zack-dev-cm wants to merge 1 commit into
rohitg00:mainfrom
zack-dev-cm:chore/1740-route-registration-safety
Open

zack-dev-cm wants to merge 1 commit into
rohitg00:mainfrom
zack-dev-cm:chore/1740-route-registration-safety

Conversation

@zack-dev-cm

@zack-dev-cm zack-dev-cm commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Related to #1740: adds the route-safety prerequisite before splitting the API into modules.

The boot snapshot covers all 153 HTTP registrations: 147 REST routes and six MCP bridges, including delegated graph, compression and viewer routes. It compares complete registration objects in their original order with a checked-in fixture, for both configured and unset secrets, and verifies that every target function exists.

Auth checks dispatch a wrong bearer through each route's middleware and registered handler: 152 routes reject it and liveness stays public. This also covers handlers that enforce auth without middleware metadata. Separate checks cover valid and missing tokens, hostile Origin, unset-secret behavior and denial before graph-status fanout.

The test collector preserves complete trigger configuration and observer source/target/options, rejects empty inventories and duplicate method/path pairs, and has focused coverage for webhook flags, observer IDs and concurrency limits. Its observer tests cover the capture contract; the boot snapshot targets the current trigger runtime.

Validation: nine focused tests pass; seven isolated mutations demonstrate detection of route omission, method/middleware drift, duplicates, manual-auth bypass, lost observer options and empty capture. The full suite passes 4,940 tests with seven skipped, using a child-only DNS fixture for eight example peer names. Build, skills generation/check, docs sync/check and eval type check pass. The collector passes a dedicated strict check; the test roots retain 17 existing transitive diagnostics, with no new diagnostics.

The tests use real registration/auth functions with SDK dispatch and in-memory KV doubles. They do not start an engine HTTP worker or cover every authorized handler body. Route extraction, the MCP tool table and CLI split remain separate work.

Summary by CodeRabbit

  • Tests
    • Added coverage to verify HTTP route registrations, authentication behavior, liveness access, and registration data integrity across API and MCP endpoints.
    • Added a route inventory with expected authentication and response behavior for each endpoint.
  • Documentation
    • Documented the route registration tests, their coverage and limitations, how to run them, and how to update the route inventory.

Signed-off-by: zack-dev-cm <112114097+zack-dev-cm@users.noreply.github.com>
@vercel

vercel Bot commented Nov 15, 2026

Copy link
Copy Markdown

@zack-dev-cm is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes add HTTP registration recording and validation, a JSON route fixture, and tests for route registration and authentication responses. The tests cover API, event, viewer-stream, viewer-SSE, and MCP registrations.

Changes: HTTP Route Registration Tests

Layer / File(s) Summary
Registration recorder and validation
test/helpers/http-registrations.ts, test/http-registration-recorder.test.ts
The recorder captures HTTP triggers and request observers, validates route identities, and returns cloned snapshots. Tests cover filtering, cloning, empty captures, duplicate routes, and incomplete registrations.
Route inventory and boot registration
test/fixtures/http-route-registration.json, test/http-route-registration.test.ts
The fixture lists expected routes and authentication outcomes. Tests boot the trigger registrars and compare their ordered registrations with the fixture.
Authentication checks across registered routes
test/http-route-registration.test.ts, docs/http-route-registration-tests.md
Tests check middleware and selected handler responses, then dispatch an incorrect bearer token across registered routes and compare results with the fixture. Documentation describes the test coverage, limitations, focused command, and fixture updates.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Merge Risk: Minimal · up to 342e3

This PR adds route-registration and authentication tests plus documentation, and it does not change runtime behavior. The risk of merging is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "test: snapshot boot HTTP registration and auth contracts" matches the main change. The PR adds a boot snapshot of all 153 HTTP registrations compared against a checked-in fixture, plus auth…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "test: snapshot boot HTTP registration and auth contracts" matches the main change. The PR adds a boot snapshot of all 153 HTTP registrations compared against a checked-in fixture, plus auth contract tests that dispatch a wrong bearer token to each route. The collector recorder and its tests also match the title's focus on registration contracts. The title is specific, short, and follows a conventional prefix.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 73ec4d83-f915-432c-93b4-60ece9e2bbd3
Commits

Reviewing files that changed from the base of the PR and between cf9a738 and 342e3ef.

Files selected for processing: 5

  • docs/http-route-registration-tests.md
  • test/fixtures/http-route-registration.json
  • test/helpers/http-registrations.ts
  • test/http-registration-recorder.test.ts
  • test/http-route-registration.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

This branch has not been deployed

No deployments
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