Files
tutti/services/tuttid/api/daemon_agent_capability_refs_test.go
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

72 lines
2.1 KiB
Go

package api
import (
"context"
"net/http"
"testing"
agenttargetbiz "github.com/tutti-os/tutti/services/tuttid/biz/agenttarget"
agentservice "github.com/tutti-os/tutti/services/tuttid/service/agent"
)
func TestAgentSessionRoutesRejectDuplicateCapabilityReferencesAtTransportBoundary(t *testing.T) {
t.Parallel()
duplicateReferences := []map[string]any{
{"capability": "tutti", "source": "slash_command"},
{"capability": "tutti", "source": "slash_command"},
}
tests := []struct {
name string
method string
path string
body map[string]any
}{
{
name: "create",
method: http.MethodPost,
path: "/v1/workspaces/ws-1/agent-sessions",
body: map[string]any{
"agentSessionId": "11111111-1111-4111-8111-111111111111",
"agentTargetId": agenttargetbiz.IDLocalCodex,
"clientSubmitId": "submit-1",
"capabilityRefs": duplicateReferences,
},
},
{
name: "send",
method: http.MethodPost,
path: "/v1/workspaces/ws-1/agent-sessions/session-1/input",
body: map[string]any{
"clientSubmitId": "submit-1",
"capabilityRefs": duplicateReferences,
"content": []map[string]any{{"type": "text", "text": "hello"}},
},
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
mux := http.NewServeMux()
RegisterRoutes(mux, NewRoutes(DaemonAPI{
AgentSessionService: stubAgentSessionService{
createFn: func(context.Context, string, agentservice.CreateSessionInput) (agentservice.Session, error) {
t.Fatal("Create should not be called for duplicate capabilityRefs")
return agentservice.Session{}, nil
},
sendInputFn: func(context.Context, string, string, agentservice.SendInput) (agentservice.SendInputResult, error) {
t.Fatal("SendInput should not be called for duplicate capabilityRefs")
return agentservice.SendInputResult{}, nil
},
},
}))
response := performGeneratedRouteRequest(t, mux, test.method, test.path, test.body)
if response.Code != http.StatusBadRequest {
t.Fatalf("status = %d, want %d; body: %s", response.Code, http.StatusBadRequest, response.Body.String())
}
})
}
}