Documentation
¶
Index ¶
- Constants
- Variables
- func AllServerToolNames() []string
- func AssertHandlerError(t *testing.T, err error, mcpResult *mcp.CallToolResult, output interface{}, ...)
- func AssertMcpCallError(t *testing.T, result *mcp.CallToolResult, wantErrContains string)
- func AssertMcpCallSuccess(t *testing.T, err error, result *mcp.CallToolResult)
- func AssertStructuredHandlerSuccess(t *testing.T, err error, mcpResult *mcp.CallToolResult, output interface{})
- func AssertUnstructuredHandlerSuccess(t *testing.T, err error, mcpResult *mcp.CallToolResult, output interface{})
- func AssertUnstructuredOutputMatches(t *testing.T, mcpResult *mcp.CallToolResult, expectedOutput any)
- func ExecuteCliLogoutCommand(t *testing.T, ctx context.Context, ...) (err error)
- func ExecuteCliRootCommand(t *testing.T, ctx context.Context, args ...string) (err error)
- func ExecuteCliRunCommand(t *testing.T, ctx context.Context, ...) (err error)
- func ExecuteCliSessionCommand(t *testing.T, ctx context.Context, ...) (err error)
- func MockContextInitializer() func(ctx context.Context) (context.Context, error)
- func MockContextInitializerWithError(err error) func(ctx context.Context) (context.Context, error)
- func MockLegacySdkPaginationIterator(pages []LegacySdkMockPage) management.EntityArrayPagedIterator
- func MockPaginationIterator[T pingone.MappedNullable](pages []MockPage[T]) pingone.PagedIterator[T]
- func Pointer[T any](v T) *T
- func ReadOnlyToolNames() []string
- func WriteToolNames() []string
- type APIErrorTestCase
- type InMemoryTokenStore
- type LegacySdkMockPage
- type MockAuthClient
- type MockAuthClientFactory
- type MockPage
- type MockTokenStoreFactory
- type StaticTokenSource
Constants ¶
const TestServerVersion = "test"
Variables ¶
var CancelledContextMatcher = mock.MatchedBy(func(ctx context.Context) bool { if ctx == nil { return false } select { case <-ctx.Done(): return ctx.Err() == context.Canceled default: return false } })
var (
ErrSessionNotFound = errors.New("session not found")
)
Functions ¶
func AllServerToolNames ¶
func AllServerToolNames() []string
func AssertHandlerError ¶
func AssertHandlerError(t *testing.T, err error, mcpResult *mcp.CallToolResult, output interface{}, wantErrContains string)
AssertHandlerError is a helper to assert that a tool handler returned an expected error
func AssertMcpCallError ¶
func AssertMcpCallError(t *testing.T, result *mcp.CallToolResult, wantErrContains string)
AssertMcpCallError is a helper to assert that an MCP call returned an expected error
func AssertMcpCallSuccess ¶
func AssertMcpCallSuccess(t *testing.T, err error, result *mcp.CallToolResult)
AssertMcpCallSuccess is a helper to assert that an MCP call succeeded
func AssertStructuredHandlerSuccess ¶
func AssertStructuredHandlerSuccess(t *testing.T, err error, mcpResult *mcp.CallToolResult, output interface{})
AssertStructuredHandlerSuccess is a helper to assert that a tool handler that returns structured output succeeded
func AssertUnstructuredHandlerSuccess ¶
func AssertUnstructuredHandlerSuccess(t *testing.T, err error, mcpResult *mcp.CallToolResult, output interface{})
AssertUnstructuredHandlerSuccess is a helper to assert that a tool handler that returns unstructured output succeeded
func AssertUnstructuredOutputMatches ¶
func AssertUnstructuredOutputMatches(t *testing.T, mcpResult *mcp.CallToolResult, expectedOutput any)
func ExecuteCliLogoutCommand ¶
func ExecuteCliLogoutCommand(t *testing.T, ctx context.Context, tokenStoreFactory tokenstore.TokenStoreFactory, args ...string) (err error)
func ExecuteCliRootCommand ¶
func ExecuteCliRunCommand ¶
func ExecuteCliRunCommand(t *testing.T, ctx context.Context, tokenStoreFactory tokenstore.TokenStoreFactory, clientFactory sdk.ClientFactory, legacyClientFactory legacy.ClientFactory, authClientFactory client.AuthClientFactory, transport mcp.Transport, args ...string) (err error)
func ExecuteCliSessionCommand ¶
func ExecuteCliSessionCommand(t *testing.T, ctx context.Context, tokenStoreFactory tokenstore.TokenStoreFactory, args ...string) (err error)
func MockContextInitializer ¶
Just returns the context as-is, without modification or error
func MockContextInitializerWithError ¶
Returns a context initializer that always returns the specified error
func MockLegacySdkPaginationIterator ¶
func MockLegacySdkPaginationIterator(pages []LegacySdkMockPage) management.EntityArrayPagedIterator
func MockPaginationIterator ¶
func MockPaginationIterator[T pingone.MappedNullable](pages []MockPage[T]) pingone.PagedIterator[T]
func ReadOnlyToolNames ¶
func ReadOnlyToolNames() []string
func WriteToolNames ¶
func WriteToolNames() []string
Types ¶
type APIErrorTestCase ¶
APIErrorTestCase represents a test case for API error scenarios
func CommonAPIErrorTestCases ¶
func CommonAPIErrorTestCases() []APIErrorTestCase
type InMemoryTokenStore ¶
type InMemoryTokenStore struct {
// Errors to simulate failures for testing
PutSessionError error
GetSessionError error
HasSessionError error
DeleteSessionError error
// contains filtered or unexported fields
}
func NewInMemoryTokenStore ¶
func NewInMemoryTokenStore() *InMemoryTokenStore
func NewInMemoryTokenStoreWithDefaultSession ¶
func NewInMemoryTokenStoreWithDefaultSession() *InMemoryTokenStore
func (*InMemoryTokenStore) DeleteSession ¶
func (s *InMemoryTokenStore) DeleteSession() error
func (*InMemoryTokenStore) GetSession ¶
func (s *InMemoryTokenStore) GetSession() (*auth.AuthSession, error)
func (*InMemoryTokenStore) HasSession ¶
func (s *InMemoryTokenStore) HasSession() (bool, error)
func (*InMemoryTokenStore) PutSession ¶
func (s *InMemoryTokenStore) PutSession(session auth.AuthSession) error
type LegacySdkMockPage ¶
type LegacySdkMockPage struct {
EntityArray *management.EntityArray
HTTPResponse *http.Response
Error error
}
type MockAuthClient ¶
func NewMockAuthClient ¶
func NewMockAuthClient(tokenSource oauth2.TokenSource) *MockAuthClient
func (*MockAuthClient) BrowserLoginAvailable ¶
func (m *MockAuthClient) BrowserLoginAvailable(grantType auth.GrantType) bool
func (*MockAuthClient) TokenSource ¶
func (m *MockAuthClient) TokenSource(ctx context.Context, grantType auth.GrantType) (oauth2.TokenSource, error)
type MockAuthClientFactory ¶
func NewEmptyMockAuthClientFactory ¶
func NewEmptyMockAuthClientFactory() *MockAuthClientFactory
func NewMockAuthClientFactory ¶
func NewMockAuthClientFactory(tokenSource oauth2.TokenSource) *MockAuthClientFactory
func (*MockAuthClientFactory) NewAuthClient ¶
func (f *MockAuthClientFactory) NewAuthClient() (client.AuthClient, error)
type MockTokenStoreFactory ¶
MockTokenStoreFactory is a mock implementation of tokenstore.TokenStoreFactory using testify mock
func NewMockTokenStoreFactory ¶
func NewMockTokenStoreFactory() *MockTokenStoreFactory
func NewMockTokenStoreFactoryWithError ¶
func NewMockTokenStoreFactoryWithError(err error) *MockTokenStoreFactory
NewMockTokenStoreFactoryWithError creates a MockTokenStoreFactory that returns an error for any StoreType
func NewMockTokenStoreFactoryWithStore ¶
func NewMockTokenStoreFactoryWithStore(store tokenstore.TokenStore) *MockTokenStoreFactory
NewMockTokenStoreFactoryWithStore creates a MockTokenStoreFactory that returns the given store for any StoreType
func (*MockTokenStoreFactory) NewTokenStore ¶
func (m *MockTokenStoreFactory) NewTokenStore(storeType tokenstore.StoreType) (tokenstore.TokenStore, error)
type StaticTokenSource ¶
type StaticTokenSource struct {
// contains filtered or unexported fields
}
func NewDefaultStaticTokenSource ¶
func NewDefaultStaticTokenSource() *StaticTokenSource
func NewStaticTokenSource ¶
func NewStaticTokenSource(token *oauth2.Token) *StaticTokenSource