Skip to content

Commit af3af5c

Browse files
krukowCopilot
andcommitted
Strengthen fleet-start! test to verify session-id scoping
Assert that fleet-start! always uses the session's own ID and that user-provided params cannot override it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c414af2 commit af3af5c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

test/github/copilot_sdk/integration_test.clj

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,16 +2078,21 @@
20782078
(is (some #(= "session.agent.deselect" (:method %)) @requests)))))
20792079

20802080
(deftest test-fleet-start
2081-
(testing "fleet-start! calls session.fleet.start RPC"
2081+
(testing "fleet-start! calls session.fleet.start RPC with session-id forced"
20822082
(let [requests (atom [])
20832083
_ (mock/set-request-hook! *mock-server*
20842084
(fn [method params]
20852085
(swap! requests conj {:method method :params params})))
20862086
session (sdk/create-session *test-client*
2087-
{:on-permission-request sdk/approve-all})]
2088-
(session/fleet-start! session {:prompt "do stuff"})
2087+
{:on-permission-request sdk/approve-all})
2088+
session-id (sdk/session-id session)]
2089+
;; Pass params that attempt to override session-id
2090+
(session/fleet-start! session {:prompt "do stuff" :session-id "evil-override"})
20892091
(let [rpcs (filter #(= "session.fleet.start" (:method %)) @requests)]
2090-
(is (= 1 (count rpcs)))))))
2092+
(is (= 1 (count rpcs)))
2093+
;; Session-id must be the real one, not the override
2094+
(is (= session-id (:sessionId (:params (first rpcs)))))
2095+
(is (= "do stuff" (:prompt (:params (first rpcs)))))))))
20912096

20922097
(deftest test-mcp-config-list
20932098
(testing "mcp-config-list calls mcp.config.list RPC"

0 commit comments

Comments
 (0)