Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
test(community): lock §5 red line + Fork-C projection (phase 6)
Simoned232e0d8ee1a
diff --git a/src/daemon/src/cli/proxyServerApi.test.ts b/src/daemon/src/cli/proxyServerApi.test.tsindex 8febf0fe1..d2b6d4b4b 100644--- a/src/daemon/src/cli/proxyServerApi.test.ts+++ b/src/daemon/src/cli/proxyServerApi.test.ts@@ -96,13 +96,29 @@ describe("createProxyServerApi — parseJsonResponse via call<T>", () => {}});- it("returns parsed JSON on 2xx", async () => {- const fetchImpl: FetchLike = vi.fn(async () =>- jsonBody(JSON.stringify({ servers: [{ id: "srv_1" }] }), { status: 200 }),- );+ it("GETs /api/community/servers and projects the SUPERSET row down to lean {id,name} (Fork C)", async () => {+ const seen: Array<{ url: string; init?: RequestInit }> = [];+ const fetchImpl: FetchLike = vi.fn(async (url: string, init?: RequestInit) => {+ seen.push({ url, init });+ // Superset response the unified GET /servers returns for a bot: full rows+ // with icon/ownerId/description that MUST NOT reach the bot's context.+ return jsonBody(+ JSON.stringify({+ servers: [+ { id: "srv_1", name: "Studio", icon: "https://cdn/x.png", ownerId: "u_owner", description: "secret" },+ { id: "srv_2", name: "Lab", icon: null, ownerId: "u_owner" },+ ],+ }),+ { status: 200 },+ );+ });const api = createProxyServerApi({ ...cfg, fetchImpl: fetchImpl as typeof fetch });const out = await api.listServers({ agentId: "a1" as never });- expect(out).toEqual({ servers: [{ id: "srv_1" }] });+ // Single projection point: only {id,name} survives — no icon/ownerId/description.+ expect(out).toEqual({ servers: [{ id: "srv_1", name: "Studio" }, { id: "srv_2", name: "Lab" }] });+ // Folded verb hits the real REST path (GET), not a flat POST /api/listServers.+ expect(seen.at(-1)!.url).toBe("http://proxy.test/api/community/servers");+ expect(seen.at(-1)!.init?.method).toBe("GET");});});diff --git a/src/web/src/lib/middleware/auth.test.ts b/src/web/src/lib/middleware/auth.test.tsindex 2c2fc19a6..8e3ad4daa 100644--- a/src/web/src/lib/middleware/auth.test.ts+++ b/src/web/src/lib/middleware/auth.test.ts@@ -92,6 +92,23 @@ describe("withAuth middleware", () => {expect(body.error).toBe("unauthorized");});+ it("rejects a crk_ runner-key bearer — a bot never authenticates as a human here (§5 red line)", async () => {+ // Privilege-escalation red line (plans/22 §5): the human-only community+ // surfaces (/bots/*, /daemon/*, human inbox, channel management) stay on+ // withAuth, NOT withCommunityActor. A crk_ bearer is neither an al_ machine+ // token nor a session, so it falls through to the session path and finds no+ // session → 401. This is what keeps a bot structurally unable to reach a+ // human-only route after the actor unification.+ const req = new NextRequest("http://localhost/api/test", {+ headers: { Authorization: "Bearer crk_somebottoken" },+ });+ mockGetSession.mockResolvedValue({ headers: new Headers(), response: null });++ const res = await wrapped(req);+ expect(res.status).toBe(401);+ expect((await res.json()).error).toBe("unauthorized");+ });+it("authenticates valid Better Auth session and passes userId/email to handler", async () => {mockGetSession.mockResolvedValue({headers: new Headers(),