- surf.Router.MountStream and recoverStream: a raw, unbuffered route kind
whose http.Flusher reaches the client; panic after the first byte only
aborts the body
- surf.MCPBuildTag and the mountPier hook: mcp.enabled is inert without the
summercms_mcp tag until it is true, then boot fails naming the tag
(pier_off.go is the untagged side)
- wristband parseAuthorizeScopes takes the server's allowed set built from
Options.ScopesSupported; the default set is unchanged
- cooler.KeyPrefix exported for the MCP module's Redis keys
- smoke tests TestStreamingRouteSmoke, TestPierMountSmoke, TestMCPScopesSmoke
- surf, wristband and cooler READMEs, docs/services/{routing,oauth-server}.md
55 lines
1.8 KiB
Go
55 lines
1.8 KiB
Go
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)
|
|
}
|
|
}
|