testutils

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAuthContext

func CreateAuthContext(username, password string) context.Context

CreateAuthContext creates an authentication context for API calls

func CreateOrgClient

func CreateOrgClient(t *testing.T, cfg *Config) *thehive.APIClient

CreateOrgClient creates a client configured for a specific organisation

func DummyElicitationAccept

func DummyElicitationAccept(ctx context.Context, request mcp.ElicitationRequest) (*mcp.ElicitationResult, error)

func DummySamplingHandlerCreateMessage

func DummySamplingHandlerCreateMessage(ctx context.Context, request mcp.CreateMessageRequest) (*mcp.CreateMessageResult, error)

func GetAdminAuthContext

func GetAdminAuthContext(testConfig *HiveTestConfig) context.Context

GetAdminAuthContext creates a context with admin authentication for API calls

func GetAuthContext

func GetAuthContext(testConfig *HiveTestConfig) context.Context

GetAuthContext creates a context with authentication for API calls

func GetMCPTestClient

func GetMCPTestClient(
	t *testing.T,
	samplingHandlerCreateMessage func(ctx context.Context, request mcp.CreateMessageRequest) (*mcp.CreateMessageResult, error),
	elicitationHandlerElicit func(ctx context.Context, request mcp.ElicitationRequest) (*mcp.ElicitationResult, error),
) *client.Client

func GetMCPTestClientWithPermissions

func GetMCPTestClientWithPermissions(
	t *testing.T,
	samplingHandlerCreateMessage func(ctx context.Context, request mcp.CreateMessageRequest) (*mcp.CreateMessageResult, error),
	elicitationHandlerElicit func(ctx context.Context, request mcp.ElicitationRequest) (*mcp.ElicitationResult, error),
	permissionsConfigPath string,
) *client.Client

GetMCPTestClientWithPermissions creates a test client with specific permissions configuration permissionsConfigPath can be: - types.PermissionConfigAdmin for admin permissions - types.PermissionConfigReadOnly for read-only permissions - "docs/examples/permissions/analyst.yaml" for analyst permissions (file path) - "" for default read-only permissions (empty string)

func MockInputAlert

func MockInputAlert() *thehive.InputCreateAlert

func MockInputAnalyzerJob

func MockInputAnalyzerJob() *thehive.InputJob

MockInputAnalyzerJob returns a valid InputJob for testing Cortex analyzer functionality.

func MockInputCase

func MockInputCase() *thehive.InputCreateCase

func MockInputCaseTemplate

func MockInputCaseTemplate() *thehive.InputCreateCaseTemplate

MockInputCaseTemplate returns a valid InputCaseTemplate for testing.

func MockInputObservable

func MockInputObservable() *thehive.InputCreateObservable

MockInputObservable returns a valid InputObservable for testing.

func MockInputOrganisation

func MockInputOrganisation() *thehive.InputCreateOrganisation

func MockInputTask

func MockInputTask() *thehive.InputCreateTask

MockInputTask returns a valid InputTask for testing.

func MockInputUser

func MockInputUser() *thehive.InputCreateUser

func MockInputUserOrganisation

func MockInputUserOrganisation() []thehive.InputUserOrganisation

func NewMCPTestConfig

func NewMCPTestConfig() *types.TheHiveMcpDefaultOptions

func NewTestClient

func NewTestClient(t *testing.T) *thehive.APIClient

func ResetHiveInstance

func ResetHiveInstance(t *testing.T, hiveUrl string, testConfig *HiveTestConfig) error

ResetHiveInstance clears all data from the test organisations

func SamplingHandlerCreateMessageFromStringResponse

func SamplingHandlerCreateMessageFromStringResponse(response string) func(ctx context.Context, request mcp.CreateMessageRequest) (*mcp.CreateMessageResult, error)

func SetupTestWithCleanup

func SetupTestWithCleanup(t *testing.T) *thehive.APIClient

SetupTestWithCleanup creates a test client and registers automatic cleanup Call this at the beginning of each test function

func StartTheHiveContainer

func StartTheHiveContainer(t *testing.T) (string, error)

StartTheHiveContainer starts a TheHive container for testing

Types

type Config

type Config struct {
	URL      string
	Username string
	Password string
	OrgName  string
}

type HiveTestConfig

type HiveTestConfig struct {
	ImageName     string
	ContainerName string
	User          string
	Password      string
	MainOrg       string
	AdminOrg      string
}

func NewHiveTestConfig

func NewHiveTestConfig() *HiveTestConfig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL