Documentation
¶
Index ¶
- Constants
- func CheckJSONResponse(resp *http.Response) error
- func ParseJSONResponse(resp *http.Response, result interface{}) error
- func ParseJSONToString(data interface{}) (string, error)
- func ReadResponseBody(resp *http.Response) (string, error)
- type APIResponse
- type BinaryTestEnv
- func (env *BinaryTestEnv) CallMCPTool(toolName string, args map[string]interface{}) ([]byte, error)
- func (env *BinaryTestEnv) Cleanup()
- func (env *BinaryTestEnv) GetAPIURL() string
- func (env *BinaryTestEnv) GetBaseURL() string
- func (env *BinaryTestEnv) GetConfigPath() string
- func (env *BinaryTestEnv) GetHTTPClient() *HTTPClient
- func (env *BinaryTestEnv) GetPort() int
- func (env *BinaryTestEnv) InitializeMCPSession()
- func (env *BinaryTestEnv) Start()
- func (env *BinaryTestEnv) WaitForEverythingServer()
- func (env *BinaryTestEnv) WaitForReady()
- type HTTPClient
- func (c *HTTPClient) Get(path string) (*http.Response, error)
- func (c *HTTPClient) GetJSON(path string, result interface{}) error
- func (c *HTTPClient) Post(path string, body io.Reader) (*http.Response, error)
- func (c *HTTPClient) PostJSON(path string, data interface{}) (*http.Response, error)
- func (c *HTTPClient) PostJSONExpectStatus(path string, data interface{}, expectedStatus int) (*http.Response, error)
- type MCPCallRequest
- type SSEReader
- type TestLogEntry
- type TestSearchResults
- type TestSearchTool
- type TestServer
- type TestServerList
- type TestServerLogsResponse
- type TestTool
- type TestToolList
Constants ¶
const TestAPIKey = "test-binary-api-key-12345"
TestAPIKey is the fixed API key used in binary tests
Variables ¶
This section is empty.
Functions ¶
func CheckJSONResponse ¶
CheckJSONResponse checks if a response contains valid JSON
func ParseJSONResponse ¶
ParseJSONResponse parses a JSON response into the given interface
func ParseJSONToString ¶
ParseJSONToString converts an interface to a JSON string
Types ¶
type APIResponse ¶
type APIResponse struct {
Success bool `json:"success"`
Data interface{} `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
APIResponse represents a standard API response
func ExpectAPISuccess ¶
func ExpectAPISuccess(resp *http.Response) (*APIResponse, error)
ExpectAPISuccess checks that an API response indicates success
func ParseAPIResponse ¶
func ParseAPIResponse(resp *http.Response) (*APIResponse, error)
ParseAPIResponse parses a standard API response
type BinaryTestEnv ¶
type BinaryTestEnv struct {
// contains filtered or unexported fields
}
BinaryTestEnv manages a test environment with the actual mcpproxy binary
func NewBinaryTestEnv ¶
func NewBinaryTestEnv(t *testing.T) *BinaryTestEnv
NewBinaryTestEnv creates a new binary test environment
func (*BinaryTestEnv) CallMCPTool ¶
func (env *BinaryTestEnv) CallMCPTool(toolName string, args map[string]interface{}) ([]byte, error)
CallMCPTool calls an MCP tool through the proxy using the MCP client library
func (*BinaryTestEnv) Cleanup ¶
func (env *BinaryTestEnv) Cleanup()
Cleanup cleans up the test environment
func (*BinaryTestEnv) GetAPIURL ¶
func (env *BinaryTestEnv) GetAPIURL() string
GetAPIURL returns the API base URL of the test server
func (*BinaryTestEnv) GetBaseURL ¶
func (env *BinaryTestEnv) GetBaseURL() string
GetBaseURL returns the base URL of the test server
func (*BinaryTestEnv) GetConfigPath ¶
func (env *BinaryTestEnv) GetConfigPath() string
GetConfigPath returns the path to the test config file
func (*BinaryTestEnv) GetHTTPClient ¶
func (env *BinaryTestEnv) GetHTTPClient() *HTTPClient
GetHTTPClient returns an HTTP client configured with the test API key
func (*BinaryTestEnv) GetPort ¶
func (env *BinaryTestEnv) GetPort() int
GetPort returns the port the server is running on
func (*BinaryTestEnv) InitializeMCPSession ¶
func (env *BinaryTestEnv) InitializeMCPSession()
InitializeMCPSession initializes an MCP session with the server using the MCP client library
func (*BinaryTestEnv) WaitForEverythingServer ¶
func (env *BinaryTestEnv) WaitForEverythingServer()
WaitForEverythingServer waits for the test server to connect and be ready
func (*BinaryTestEnv) WaitForReady ¶
func (env *BinaryTestEnv) WaitForReady()
WaitForReady waits for the server to be ready to accept requests
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient wraps http.Client with convenience methods for testing
func NewHTTPClient ¶
func NewHTTPClient(baseURL string) *HTTPClient
NewHTTPClient creates a new HTTP client for testing
func NewHTTPClientWithAPIKey ¶
func NewHTTPClientWithAPIKey(baseURL string, apiKey string) *HTTPClient
NewHTTPClientWithAPIKey creates a new HTTP client with API key authentication
func (*HTTPClient) Get ¶
func (c *HTTPClient) Get(path string) (*http.Response, error)
Get performs a GET request
func (*HTTPClient) GetJSON ¶
func (c *HTTPClient) GetJSON(path string, result interface{}) error
GetJSON performs a GET request and parses JSON response
func (*HTTPClient) PostJSON ¶
func (c *HTTPClient) PostJSON(path string, data interface{}) (*http.Response, error)
PostJSON performs a POST request with JSON data
func (*HTTPClient) PostJSONExpectStatus ¶
func (c *HTTPClient) PostJSONExpectStatus(path string, data interface{}, expectedStatus int) (*http.Response, error)
PostJSONExpectStatus performs a POST request and checks the status code
type MCPCallRequest ¶
type MCPCallRequest struct {
ToolName string `json:"name"`
Args map[string]interface{} `json:"args"`
}
MCPCallRequest represents an MCP call_tool request
type SSEReader ¶
type SSEReader struct {
// contains filtered or unexported fields
}
SSEReader reads Server-Sent Events
func NewSSEReader ¶
NewSSEReader creates a new SSE reader
type TestLogEntry ¶
type TestLogEntry struct {
Timestamp string `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
Server string `json:"server,omitempty"`
Fields map[string]interface{} `json:"fields,omitempty"`
}
TestLogEntry represents a single log entry
type TestSearchResults ¶
type TestSearchResults struct {
Success bool `json:"success"`
Data struct {
Query string `json:"query"`
Results []TestSearchTool `json:"results"`
} `json:"data"`
}
TestSearchResults represents search results
type TestSearchTool ¶
type TestSearchTool struct {
Name string `json:"name"`
Description string `json:"description"`
Server string `json:"server"`
Score float64 `json:"score"`
}
TestSearchTool represents a search result tool
type TestServer ¶
type TestServer struct {
Name string `json:"name"`
Protocol string `json:"protocol"`
Enabled bool `json:"enabled"`
Quarantined bool `json:"quarantined"`
Connected bool `json:"connected"`
Connecting bool `json:"connecting"`
ToolCount int `json:"tool_count"`
LastError string `json:"last_error"`
ConnectionStatus string `json:"connection_status,omitempty"`
}
TestServer represents a server in the test environment
type TestServerList ¶
type TestServerList struct {
Success bool `json:"success"`
Data struct {
Servers []TestServer `json:"servers"`
} `json:"data"`
}
TestServerList represents a simplified server list response
type TestServerLogsResponse ¶
type TestServerLogsResponse struct {
Success bool `json:"success"`
Data struct {
ServerName string `json:"server_name"`
Logs []TestLogEntry `json:"logs"`
Count int `json:"count"`
} `json:"data"`
}
TestServerLogsResponse represents a server logs response
type TestToolList ¶
type TestToolList struct {
Success bool `json:"success"`
Data struct {
Server string `json:"server"`
Tools []TestTool `json:"tools"`
} `json:"data"`
}
TestToolList represents a tool list response