Conversation
…mart-mcp-proxy#1178) Fixing smart-mcp-proxy#1166/smart-mcp-proxy#1167 took three passes because the GET surface was enumerated by hand and each pass missed a door. This walks the production chi router instead, collects every GET under /api/v1, and requires each route to be classified as refused, filtered, or open with a written reason. A new GET route added without an entry fails the test until someone classifies it, and a floor on the route count stops a walk that matches nothing from passing. Adds a Doctor method to the shared scope-test management mock, mirroring the production service including its scope gate, so /diagnostics is exercised through the same path production takes.
|
Good catches, both. You're right that "not 403" was doing almost nothing for the rows that never reach the handler, I confirmed the same 11: the scan subroutes and the /{id} detail routes 404 on the synthetic id before canSeeServer, connect 503s (not wired in the fixture), and index/search 400s with no query. Reworked it: routes that actually reach the handler now assert 2xx, and the pre-gate ones are in an explicit shortCircuitCodes map with a reason each, so a route that starts reaching the handler trips it. Also fixed the routeParamSubstitutions comment, which was just wrong about the scan routes. On diagnostics, yes, the old test only exercised the mock's own filter. I swapped it to run the httpapi handler with withManagement:false so it drives the real visibleServers path in the legacy branch, which had no coverage before. Removing that call now fails the test. For the management path I'm citing TestDoctor_ScopedTokenSeesOnlyAllowedServers in the map instead of pretending this file covers it. |
Refs #1178.
Fixing #1166/#1167 took three passes because the /api/v1 GET surface was enumerated by hand and each pass turned up another door that wasn't scope-gated. This adds a test that walks the production chi router instead of trusting a hand-kept list.
What it does:
There's already a similar walk for the server edition (tenant_allowlist_walk_test.go, //go:build server) covering session principals. This is the personal-edition agent-token counterpart, which is the axis #1166/#1167 were about and didn't have a guard.
Also adds a Doctor method to the shared scope-test management mock so /diagnostics runs through the same path production uses, plus TestDiagnostics_ScopedCallerDoesNotSeeHiddenServer backing that route's classification.
Verification: