TestClientRootCapabilities verifies that the server correctly observes RootsV2 for various client capability configurations. This tests the fix for #607.
(t *testing.T)
| 660 | // RootsV2 for various client capability configurations. This tests the fix |
| 661 | // for #607. |
| 662 | func TestClientRootCapabilities(t *testing.T) { |
| 663 | testCases := []struct { |
| 664 | name string |
| 665 | capabilities *string // JSON for the capabilities field; nil means omit the field |
| 666 | wantRootsV2 *RootCapabilities |
| 667 | }{ |
| 668 | { |
| 669 | name: "capabilities field omitted", |
| 670 | capabilities: nil, |
| 671 | wantRootsV2: nil, |
| 672 | }, |
| 673 | { |
| 674 | name: "empty capabilities", |
| 675 | capabilities: ptr(`{}`), |
| 676 | wantRootsV2: nil, |
| 677 | }, |
| 678 | { |
| 679 | name: "capabilities with no roots", |
| 680 | capabilities: ptr(`{"sampling": {}}`), |
| 681 | wantRootsV2: nil, |
| 682 | }, |
| 683 | { |
| 684 | name: "capabilities with empty roots", |
| 685 | capabilities: ptr(`{"roots": {}}`), |
| 686 | wantRootsV2: &RootCapabilities{ListChanged: false}, |
| 687 | }, |
| 688 | { |
| 689 | name: "capabilities with roots without listChanged", |
| 690 | capabilities: ptr(`{"roots": {"listChanged": false}}`), |
| 691 | wantRootsV2: &RootCapabilities{ListChanged: false}, |
| 692 | }, |
| 693 | { |
| 694 | name: "capabilities with roots with listChanged", |
| 695 | capabilities: ptr(`{"roots": {"listChanged": true}}`), |
| 696 | wantRootsV2: &RootCapabilities{ListChanged: true}, |
| 697 | }, |
| 698 | } |
| 699 | |
| 700 | for _, tc := range testCases { |
| 701 | t.Run(tc.name, func(t *testing.T) { |
| 702 | ctx := context.Background() |
| 703 | |
| 704 | // Create a minimal server. |
| 705 | impl := &Implementation{Name: "testServer", Version: "v1.0.0"} |
| 706 | s := NewServer(impl, nil) |
| 707 | |
| 708 | // Connect the server. |
| 709 | cTransport, sTransport := NewInMemoryTransports() |
| 710 | ss, err := s.Connect(ctx, sTransport, nil) |
| 711 | if err != nil { |
| 712 | t.Fatal(err) |
| 713 | } |
| 714 | |
| 715 | // Connect the client JSON-RPC connection (raw, no client). |
| 716 | cConn, err := cTransport.Connect(ctx) |
| 717 | if err != nil { |
| 718 | t.Fatal(err) |
| 719 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…