buildStaticInventoryFromTools is a test helper that mirrors buildStaticInventory but uses the provided mock tools instead of calling github.AllTools.
(cfg *ServerConfig, tools []inventory.ServerTool)
| 757 | // buildStaticInventoryFromTools is a test helper that mirrors buildStaticInventory |
| 758 | // but uses the provided mock tools instead of calling github.AllTools. |
| 759 | func buildStaticInventoryFromTools(cfg *ServerConfig, tools []inventory.ServerTool) ([]inventory.ServerTool, []inventory.ServerResourceTemplate, []inventory.ServerPrompt) { |
| 760 | if !hasStaticConfig(cfg) { |
| 761 | return tools, nil, nil |
| 762 | } |
| 763 | |
| 764 | b := inventory.NewBuilder(). |
| 765 | SetTools(tools). |
| 766 | WithReadOnly(cfg.ReadOnly). |
| 767 | WithToolsets(github.ResolvedEnabledToolsets(cfg.EnabledToolsets, cfg.EnabledTools)) |
| 768 | |
| 769 | if len(cfg.EnabledTools) > 0 { |
| 770 | b = b.WithTools(github.CleanTools(cfg.EnabledTools)) |
| 771 | } |
| 772 | |
| 773 | if len(cfg.ExcludeTools) > 0 { |
| 774 | b = b.WithExcludeTools(cfg.ExcludeTools) |
| 775 | } |
| 776 | |
| 777 | inv, err := b.Build() |
| 778 | if err != nil { |
| 779 | return tools, nil, nil |
| 780 | } |
| 781 | |
| 782 | ctx := context.Background() |
| 783 | return inv.AvailableTools(ctx), inv.AvailableResourceTemplates(ctx), inv.AvailablePrompts(ctx) |
| 784 | } |
| 785 | |
| 786 | func TestCrossOriginProtection(t *testing.T) { |
| 787 | jsonRPCBody := `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"0.1"}}}` |
no test coverage detected