Documentation
¶
Overview ¶
Package e2e provides end-to-end testing utilities for ToolHive.
Index ¶
- func CheckTHVBinaryAvailable(config *TestConfig) error
- func DebugServerState(config *TestConfig, serverName string)
- func GetMCPServerURL(config *TestConfig, serverName string) (string, error)
- func GetServerLogs(config *TestConfig, serverName string) (string, error)
- func StartDockerCommand(args ...string) *exec.Cmd
- func StartLongRunningTHVCommand(config *TestConfig, args ...string) *exec.Cmd
- func StopAndRemoveMCPServer(config *TestConfig, serverName string) error
- func TestMCPServerBasicFunctionality(config *TestConfig, serverURL string) error
- func WaitForMCPServer(config *TestConfig, serverName string, timeout time.Duration) error
- func WaitForMCPServerReady(config *TestConfig, serverURL string, mode string, timeout time.Duration) error
- func WithAccessTokenLifespan(d time.Duration) func(*fosite.Config)
- type AuthRequest
- type MCPClientHelper
- func (h *MCPClientHelper) CallTool(ctx context.Context, toolName string, arguments map[string]interface{}) (*mcp.CallToolResult, error)
- func (h *MCPClientHelper) Close() error
- func (h *MCPClientHelper) ExpectResourceExists(ctx context.Context, uri string)
- func (h *MCPClientHelper) ExpectToolCall(ctx context.Context, toolName string, arguments map[string]interface{}) *mcp.CallToolResult
- func (h *MCPClientHelper) ExpectToolExists(ctx context.Context, toolName string)
- func (h *MCPClientHelper) Initialize(ctx context.Context) error
- func (h *MCPClientHelper) ListResources(ctx context.Context) (*mcp.ListResourcesResult, error)
- func (h *MCPClientHelper) ListTools(ctx context.Context) (*mcp.ListToolsResult, error)
- func (h *MCPClientHelper) Ping(ctx context.Context) error
- func (h *MCPClientHelper) ReadResource(ctx context.Context, uri string) (*mcp.ReadResourceResult, error)
- type OIDCMockServer
- func (*OIDCMockServer) CompleteAuthRequest(authReq *AuthRequest) error
- func (m *OIDCMockServer) EnableAutoComplete()
- func (m *OIDCMockServer) GetBaseURL() string
- func (m *OIDCMockServer) Start() error
- func (m *OIDCMockServer) Stop() error
- func (m *OIDCMockServer) WaitForAuthRequest(timeout time.Duration) (*AuthRequest, error)
- type THVCommand
- func (c *THVCommand) ExpectFailure() (string, string, error)
- func (c *THVCommand) ExpectSuccess() (string, string)
- func (c *THVCommand) Run() (string, string, error)
- func (c *THVCommand) RunWithTimeout(timeout time.Duration) (string, string, error)
- func (c *THVCommand) WithDir(dir string) *THVCommand
- func (c *THVCommand) WithEnv(env ...string) *THVCommand
- type TestConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckTHVBinaryAvailable ¶
func CheckTHVBinaryAvailable(config *TestConfig) error
CheckTHVBinaryAvailable checks if the thv binary is available
func DebugServerState ¶
func DebugServerState(config *TestConfig, serverName string)
DebugServerState prints debugging information about a server
func GetMCPServerURL ¶
func GetMCPServerURL(config *TestConfig, serverName string) (string, error)
GetMCPServerURL gets the URL for an MCP server
func GetServerLogs ¶
func GetServerLogs(config *TestConfig, serverName string) (string, error)
GetServerLogs gets the logs for a server to help with debugging
func StartDockerCommand ¶ added in v0.0.40
StartDockerCommand starts a docker command with proper environment setup and returns the command
func StartLongRunningTHVCommand ¶ added in v0.0.40
func StartLongRunningTHVCommand(config *TestConfig, args ...string) *exec.Cmd
StartLongRunningTHVCommand starts a long-running ToolHive command and returns the process
func StopAndRemoveMCPServer ¶
func StopAndRemoveMCPServer(config *TestConfig, serverName string) error
StopAndRemoveMCPServer stops and removes an MCP server This function is designed for cleanup and tolerates servers that don't exist
func TestMCPServerBasicFunctionality ¶
func TestMCPServerBasicFunctionality(config *TestConfig, serverURL string) error
TestMCPServerBasicFunctionality tests basic MCP server functionality
func WaitForMCPServer ¶
func WaitForMCPServer(config *TestConfig, serverName string, timeout time.Duration) error
WaitForMCPServer waits for an MCP server to be running
func WaitForMCPServerReady ¶
func WaitForMCPServerReady(config *TestConfig, serverURL string, mode string, timeout time.Duration) error
WaitForMCPServerReady waits for an MCP server to be ready and responsive
Types ¶
type AuthRequest ¶ added in v0.0.40
type AuthRequest struct { ClientID string RedirectURI string State string CodeChallenge string ResponseType string Scope string }
AuthRequest contains the parameters from an OAuth authorization request
type MCPClientHelper ¶
type MCPClientHelper struct {
// contains filtered or unexported fields
}
MCPClientHelper provides high-level MCP client operations for e2e tests
func NewMCPClientForSSE ¶
func NewMCPClientForSSE(config *TestConfig, serverURL string) (*MCPClientHelper, error)
NewMCPClientForSSE creates a new MCP client for SSE transport
func NewMCPClientForStreamableHTTP ¶ added in v0.0.48
func NewMCPClientForStreamableHTTP(config *TestConfig, serverURL string) (*MCPClientHelper, error)
NewMCPClientForStreamableHTTP creates a new MCP client for streamable HTTP transport
func (*MCPClientHelper) CallTool ¶
func (h *MCPClientHelper) CallTool( ctx context.Context, toolName string, arguments map[string]interface{}, ) (*mcp.CallToolResult, error)
CallTool calls a specific tool with the given arguments
func (*MCPClientHelper) Close ¶
func (h *MCPClientHelper) Close() error
Close closes the MCP client connection
func (*MCPClientHelper) ExpectResourceExists ¶
func (h *MCPClientHelper) ExpectResourceExists(ctx context.Context, uri string)
ExpectResourceExists verifies that a resource with the given URI exists
func (*MCPClientHelper) ExpectToolCall ¶
func (h *MCPClientHelper) ExpectToolCall( ctx context.Context, toolName string, arguments map[string]interface{}, ) *mcp.CallToolResult
ExpectToolCall verifies that a tool can be called successfully
func (*MCPClientHelper) ExpectToolExists ¶
func (h *MCPClientHelper) ExpectToolExists(ctx context.Context, toolName string)
ExpectToolExists verifies that a tool with the given name exists
func (*MCPClientHelper) Initialize ¶
func (h *MCPClientHelper) Initialize(ctx context.Context) error
Initialize initializes the MCP connection
func (*MCPClientHelper) ListResources ¶
func (h *MCPClientHelper) ListResources(ctx context.Context) (*mcp.ListResourcesResult, error)
ListResources lists all available resources from the MCP server
func (*MCPClientHelper) ListTools ¶
func (h *MCPClientHelper) ListTools(ctx context.Context) (*mcp.ListToolsResult, error)
ListTools lists all available tools from the MCP server
func (*MCPClientHelper) Ping ¶
func (h *MCPClientHelper) Ping(ctx context.Context) error
Ping sends a ping to test connectivity
func (*MCPClientHelper) ReadResource ¶
func (h *MCPClientHelper) ReadResource(ctx context.Context, uri string) (*mcp.ReadResourceResult, error)
ReadResource reads a specific resource
type OIDCMockServer ¶ added in v0.0.40
type OIDCMockServer struct {
// contains filtered or unexported fields
}
OIDCMockServer represents a lightweight OIDC server using Ory Fosite
func NewOIDCMockServer ¶ added in v0.0.40
func NewOIDCMockServer(port int, clientID, clientSecret string, opts ...func(*fosite.Config)) (*OIDCMockServer, error)
NewOIDCMockServer creates a new OIDC mock server using Ory Fosite
func (*OIDCMockServer) CompleteAuthRequest ¶ added in v0.0.40
func (*OIDCMockServer) CompleteAuthRequest(authReq *AuthRequest) error
CompleteAuthRequest automatically completes an OAuth request by making a callback
func (*OIDCMockServer) EnableAutoComplete ¶ added in v0.0.40
func (m *OIDCMockServer) EnableAutoComplete()
EnableAutoComplete enables automatic OAuth flow completion for testing
func (*OIDCMockServer) GetBaseURL ¶ added in v0.0.40
func (m *OIDCMockServer) GetBaseURL() string
GetBaseURL returns the base URL of the mock server
func (*OIDCMockServer) Start ¶ added in v0.0.40
func (m *OIDCMockServer) Start() error
Start starts the OIDC mock server
func (*OIDCMockServer) Stop ¶ added in v0.0.40
func (m *OIDCMockServer) Stop() error
Stop stops the OIDC mock server
func (*OIDCMockServer) WaitForAuthRequest ¶ added in v0.0.40
func (m *OIDCMockServer) WaitForAuthRequest(timeout time.Duration) (*AuthRequest, error)
WaitForAuthRequest waits for an OAuth authorization request and returns its parameters
type THVCommand ¶
type THVCommand struct {
// contains filtered or unexported fields
}
THVCommand represents a ToolHive CLI command execution
func NewTHVCommand ¶
func NewTHVCommand(config *TestConfig, args ...string) *THVCommand
NewTHVCommand creates a new ToolHive command
func (*THVCommand) ExpectFailure ¶
func (c *THVCommand) ExpectFailure() (string, string, error)
ExpectFailure runs the command and expects it to fail
func (*THVCommand) ExpectSuccess ¶
func (c *THVCommand) ExpectSuccess() (string, string)
ExpectSuccess runs the command and expects it to succeed
func (*THVCommand) Run ¶
func (c *THVCommand) Run() (string, string, error)
Run executes the ToolHive command and returns stdout, stderr, and error
func (*THVCommand) RunWithTimeout ¶
RunWithTimeout executes the ToolHive command with a specific timeout
func (*THVCommand) WithDir ¶
func (c *THVCommand) WithDir(dir string) *THVCommand
WithDir sets the working directory for the command
func (*THVCommand) WithEnv ¶
func (c *THVCommand) WithEnv(env ...string) *THVCommand
WithEnv adds environment variables to the command
type TestConfig ¶
TestConfig holds configuration for e2e tests
func NewTestConfig ¶
func NewTestConfig() *TestConfig
NewTestConfig creates a new test configuration with defaults