package surf import ( "reflect" "strings" "testing" "git.golem15.com/golem15/summercms/modules/party" ) // TestPierMountSmoke covers the MCP mount hook of phase 19.7 in a binary // built without the summercms_mcp tag: mcp.enabled unset mounts nothing and // changes nothing (D-30); mcp.enabled true fails boot naming the tag (D-33). func TestPierMountSmoke(t *testing.T) { if mountPier != nil { t.Skip("mountPier is set: this binary carries the summercms_mcp tag") } plugins := []party.Plugin{dispatchPlugin{}} base, err := BuildRouter(transportApp(t, "development", map[string]string{"http.yaml": transportBodyLimits}), plugins) if err != nil { t.Fatal(err) } for name, mcp := range map[string]string{ "unset": "", "enabled false": "enabled: false\n", "only the path": "path: /mcp\n", } { t.Run(name, func(t *testing.T) { files := map[string]string{"http.yaml": transportBodyLimits} if mcp != "" { files["mcp.yaml"] = mcp } router, err := BuildRouter(transportApp(t, "development", files), plugins) if err != nil { t.Fatal(err) } for _, ri := range router.Routes() { if strings.HasPrefix(ri.Pattern, "/mcp") || strings.HasPrefix(ri.Pattern, "/.well-known/oauth-protected-resource") { t.Fatalf("route mounted while mcp is off: %+v", ri) } } if !reflect.DeepEqual(router.Routes(), base.Routes()) { t.Fatalf("route table differs from a build without the key:\n%+v\n%+v", router.Routes(), base.Routes()) } }) } _, err = BuildRouter(transportApp(t, "development", map[string]string{ "http.yaml": transportBodyLimits, "mcp.yaml": "enabled: true\n", }), plugins) if err == nil || !strings.Contains(err.Error(), "summercms_mcp") { t.Fatalf("mcp.enabled without the tag: err = %v, want an error naming summercms_mcp", err) } }