MCPcopy Create free account
hub / github.com/github/copilot-sdk / TestSession_MCPAuthRequestSendsHostToken

Function TestSession_MCPAuthRequestSendsHostToken

go/session_test.go:63–204  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestSession_MCPAuthRequestSendsHostToken(t *testing.T) {
64 stdinR, stdinW := io.Pipe()
65 stdoutR, stdoutW := io.Pipe()
66 defer stdinR.Close()
67 defer stdinW.Close()
68 defer stdoutR.Close()
69 defer stdoutW.Close()
70
71 client := jsonrpc2.NewClient(stdinW, stdoutR)
72 client.Start()
73 defer client.Stop()
74
75 paramsCh := make(chan map[string]any, 1)
76 errCh := make(chan error, 1)
77
78 go func() {
79 frame, err := readTestJSONRPCFrame(stdinR)
80 if err != nil {
81 errCh <- err
82 return
83 }
84
85 var request struct {
86 ID json.RawMessage `json:"id"`
87 Method string `json:"method"`
88 Params map[string]any `json:"params"`
89 }
90 if err := json.Unmarshal(frame, &request); err != nil {
91 errCh <- err
92 return
93 }
94 if request.Method != "session.mcp.oauth.handlePendingRequest" {
95 errCh <- fmt.Errorf("expected session.mcp.oauth.handlePendingRequest, got %s", request.Method)
96 return
97 }
98
99 paramsCh <- request.Params
100
101 response := map[string]any{
102 "jsonrpc": "2.0",
103 "id": json.RawMessage(request.ID),
104 "result": map[string]any{"success": true},
105 }
106 data, err := json.Marshal(response)
107 if err != nil {
108 errCh <- err
109 return
110 }
111 if _, err := fmt.Fprintf(stdoutW, "Content-Length: %d\r\n\r\n%s", len(data), data); err != nil {
112 errCh <- err
113 }
114 }()
115
116 session := &Session{
117 SessionID: "session-1",
118 client: client,
119 RPC: rpc.NewSessionRPC(client, "session-1"),
120 }

Callers

nothing calls this directly

Calls 9

StartMethod · 0.95
StopMethod · 0.95
handleBroadcastEventMethod · 0.95
readTestJSONRPCFrameFunction · 0.85
MCPAuthResultTokenFunction · 0.85
NewClientMethod · 0.80
MarshalMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…