(t *testing.T)
| 103 | } |
| 104 | |
| 105 | func TestToolsCallUnknownTool(t *testing.T) { |
| 106 | gin.SetMode(gin.TestMode) |
| 107 | srv := newTestServer(map[string]*session{ |
| 108 | "s3": {id: "s3", userID: 1, initialized: true}, |
| 109 | }) |
| 110 | |
| 111 | r := gin.New() |
| 112 | r.POST("/mcp", func(c *gin.Context) { |
| 113 | common.GinAppendValues(c, conf.UserKey, &model.User{ID: 1, Role: model.ADMIN}) |
| 114 | srv.handlePost(c) |
| 115 | }) |
| 116 | |
| 117 | req := httptest.NewRequest(http.MethodPost, "http://example.com/mcp", strings.NewReader(`{ |
| 118 | "jsonrpc":"2.0", |
| 119 | "id":3, |
| 120 | "method":"tools/call", |
| 121 | "params":{"name":"openlist.fs.unknown","arguments":{"path":"/"}} |
| 122 | }`)) |
| 123 | req.Header.Set("Accept", "application/json, text/event-stream") |
| 124 | req.Header.Set("Origin", "http://example.com") |
| 125 | req.Header.Set(ProtocolVersionHeader, ProtocolVersion) |
| 126 | req.Header.Set(SessionHeader, "s3") |
| 127 | |
| 128 | w := httptest.NewRecorder() |
| 129 | r.ServeHTTP(w, req) |
| 130 | |
| 131 | if w.Code != http.StatusOK { |
| 132 | t.Fatalf("unexpected status: got %d want %d", w.Code, http.StatusOK) |
| 133 | } |
| 134 | resp := decodeResponse(t, w) |
| 135 | if resp.Error == nil || resp.Error.Code != -32601 { |
| 136 | t.Fatalf("unexpected error response: %+v", resp.Error) |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | func TestToolsCallInvalidParams(t *testing.T) { |
| 141 | gin.SetMode(gin.TestMode) |
nothing calls this directly
no test coverage detected