test(ingestion): /mcp's JWT validator and resource_metadata; narrow comments
PR #183 review (comment 15474): - TestBuildMuxAnswers503ToAJWTOnMCPWhileTheIssuerIsUnresolved: building /mcp's middleware with a nil validator turns it red. - TestBuildMuxMCP401CarriesResourceMetadataInWWWAuthenticate: building it with resourceMetadataURL "" turns it red. - main.go, routes.go and the testMux comment now say exactly what is untested: main's restAuth fields and public map passed to buildMux, and ListenAndServe (hyperguild#182). Stale public-route list in the TestBuildMuxDoesNotWrapPublicRoutes comment corrected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,11 +22,13 @@ func okHandler(body string) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(body)) })
|
||||
}
|
||||
|
||||
// testMux builds the router exactly as main does: buildMux with the full
|
||||
// public set main registers (stub handlers), a stub MCP server, and real
|
||||
// bearer config. hyperguild#149: the REST API is authenticated as a whole;
|
||||
// the PR #152 review showed a test of a COPY of the router let main.go
|
||||
// regress unseen.
|
||||
// testMux builds the router through buildMux, the function main calls, with
|
||||
// every allowlisted public pattern (stub handlers), a stub MCP server and a
|
||||
// static token only: no JWT validator and no resourceMetadataURL (the tests
|
||||
// in jwt_validator_test.go pass those). It does not use main's own restAuth
|
||||
// or public map (hyperguild#182). hyperguild#149: the REST API is
|
||||
// authenticated as a whole; the PR #152 review showed a test of a COPY of
|
||||
// the router let main.go regress unseen.
|
||||
func testMux(t *testing.T) http.Handler {
|
||||
t.Helper()
|
||||
mux, _ := testMuxAndRegistry(t)
|
||||
@@ -87,8 +89,9 @@ func TestBuildMuxAuthenticatesAnUnregisteredPath(t *testing.T) {
|
||||
}
|
||||
|
||||
// buildMux registers public handlers as given, without adding auth: each
|
||||
// public route owns its own (bearer on /mcp, HMAC on the webhook, client
|
||||
// secret on /oauth/token) or is meant to be open (/metrics, OAuth metadata).
|
||||
// public route owns its own (bearer/JWT on /capture, HMAC on the webhook,
|
||||
// client secret on /oauth/token) or is meant to be open (OAuth metadata).
|
||||
// /mcp and /metrics are not public routes: buildMux builds them itself.
|
||||
func TestBuildMuxDoesNotWrapPublicRoutes(t *testing.T) {
|
||||
r := testMux(t)
|
||||
for p := range publicRoutes {
|
||||
|
||||
Reference in New Issue
Block a user