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

Function TestClient_MCPAuthInterestRegistration

go/client_test.go:1397–1522  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1395}
1396
1397func TestClient_MCPAuthInterestRegistration(t *testing.T) {
1398 t.Run("create skips MCP OAuth interest without auth handler", func(t *testing.T) {
1399 client, requests, cleanup := newInMemoryClient(t)
1400 defer cleanup()
1401
1402 session, err := client.CreateSession(t.Context(), &SessionConfig{
1403 OnPermissionRequest: PermissionHandler.ApproveAll,
1404 OnEvent: func(SessionEvent) {},
1405 })
1406 if err != nil {
1407 t.Fatalf("CreateSession failed: %v", err)
1408 }
1409 defer session.Disconnect()
1410
1411 assertNoMCPAuthInterest(t, requests.snapshot())
1412 assertRequestMethod(t, requests.snapshot(), "session.create")
1413 assertCreateRequestPermission(t, requests.snapshot())
1414 })
1415
1416 t.Run("create registers MCP OAuth interest after local session create when auth handler is configured", func(t *testing.T) {
1417 client, requests, cleanup := newInMemoryClient(t)
1418 defer cleanup()
1419
1420 session, err := client.CreateSession(t.Context(), &SessionConfig{
1421 OnPermissionRequest: PermissionHandler.ApproveAll,
1422 OnMCPAuthRequest: func(MCPAuthRequest, MCPAuthInvocation) (*MCPAuthResult, error) {
1423 return MCPAuthResultCancelled(), nil
1424 },
1425 })
1426 if err != nil {
1427 t.Fatalf("CreateSession failed: %v", err)
1428 }
1429 defer session.Disconnect()
1430
1431 snapshot := requests.snapshot()
1432 assertRequestMethod(t, snapshot, "session.eventLog.registerInterest")
1433 if snapshot[0].Method != "session.create" {
1434 t.Fatalf("expected session.create before MCP auth interest, got %s", snapshot[0].Method)
1435 }
1436 if snapshot[1].Method != "session.eventLog.registerInterest" {
1437 t.Fatalf("expected MCP auth interest after session.create, got %s", snapshot[1].Method)
1438 }
1439 assertMCPAuthInterest(t, snapshot[1])
1440 assertCreateRequestPermission(t, snapshot)
1441 })
1442
1443 t.Run("cloud create registers MCP OAuth interest after server assigns id only when auth handler is configured", func(t *testing.T) {
1444 client, requests, cleanup := newInMemoryClient(t)
1445 defer cleanup()
1446
1447 withoutAuth, err := client.CreateSession(t.Context(), &SessionConfig{
1448 OnPermissionRequest: PermissionHandler.ApproveAll,
1449 Cloud: &CloudSessionOptions{
1450 Repository: &CloudSessionRepository{Owner: "github", Name: "copilot-sdk", Branch: "main"},
1451 },
1452 })
1453 if err != nil {
1454 t.Fatalf("CreateSession without auth failed: %v", err)

Callers

nothing calls this directly

Calls 11

newInMemoryClientFunction · 0.85
assertNoMCPAuthInterestFunction · 0.85
assertRequestMethodFunction · 0.85
MCPAuthResultCancelledFunction · 0.85
assertMCPAuthInterestFunction · 0.85
CreateSessionMethod · 0.80
DisconnectMethod · 0.80
ResumeSessionMethod · 0.80
snapshotMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…