botGroupTaskScope.test.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { describe, expect, it } from "vitest";
  2. import { bindBotGroupTaskScope } from "../src/host/botGroupTaskScope.js";
  3. describe("group remote task attachment", () => {
  4. it("injects the validated remote identity and session over caller supplied routing", () => {
  5. expect(
  6. bindBotGroupTaskScope(
  7. { taskId: "task", workspaceIdentity: "forged", remoteSessionId: "stale" },
  8. {
  9. kind: "remote",
  10. workspacePath: "/work",
  11. workspaceIdentity: "ssh://host/work",
  12. remoteSessionId: "current",
  13. },
  14. ),
  15. ).toEqual({
  16. taskId: "task",
  17. workspacePath: "/work",
  18. workspaceIdentity: "ssh://host/work",
  19. remoteSessionId: "current",
  20. });
  21. });
  22. it("rejects source-settings attachments without a workspace task scope", () => {
  23. expect(() =>
  24. bindBotGroupTaskScope(
  25. { taskId: "task", workspaceIdentity: "forged", remoteSessionId: "forged" },
  26. { kind: "source-settings", sourceServerId: "source" },
  27. ),
  28. ).toThrow("Source settings attachment does not provide bot task routing");
  29. });
  30. it("keeps local task routing unchanged", () => {
  31. const params = { taskId: "task" };
  32. expect(bindBotGroupTaskScope(params, { kind: "local" })).toBe(params);
  33. });
  34. });