Documentation
¶
Index ¶
- func AssertAtlasAllowed(t TestingT, result AtlasTestResult, pattern string)
- func AssertAtlasBlocked(t TestingT, result AtlasTestResult, pattern string)
- func AssertScoreAboveThreshold(t TestingT, result AtlasTestResult, threshold float64)
- func AssertTechniqueDetected(t TestingT, result AtlasTestResult, technique string)
- func CreateBlockingMockLLMServer() *httptest.Server
- func CreateMockLLMServer(responses map[string]MockLLMResponse) *httptest.Server
- func GetAtlasChecker() *compliance.ATLASFramework
- func GetTestPaths() (string, string, string)
- func PrintBenchmarkResults(results []BenchmarkResult)
- func PrintTestSummary(tracker *CoverageTracker)
- func RunWithFixtures(t *testing.T, fixtures []TestFixture)
- func SaveTestConfig(config TestConfig, path string) error
- func SaveTestFixtures(fixtures []TestFixture, path string) error
- func TestMainWithConfig(m *testing.M)
- func ValidateTestEnvironment() error
- type ATLASParams
- type AtlasTestResult
- type BenchmarkResult
- type CoverageReport
- type CoverageTracker
- type MockLLMResponse
- type TestConfig
- type TestFixture
- type TestLogger
- type TestReport
- type TestResult
- type TestRunnerConfig
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertAtlasAllowed ¶
func AssertAtlasAllowed(t TestingT, result AtlasTestResult, pattern string)
AssertAtlasAllowed verifies that a request was allowed through
func AssertAtlasBlocked ¶
func AssertAtlasBlocked(t TestingT, result AtlasTestResult, pattern string)
AssertAtlasBlocked verifies that an ATLAS pattern was blocked
func AssertScoreAboveThreshold ¶
func AssertScoreAboveThreshold(t TestingT, result AtlasTestResult, threshold float64)
AssertScoreAboveThreshold verifies that detection score is above threshold
func AssertTechniqueDetected ¶
func AssertTechniqueDetected(t TestingT, result AtlasTestResult, technique string)
AssertTechniqueDetected verifies that a technique was detected
func CreateBlockingMockLLMServer ¶
CreateBlockingMockLLMServer creates a mock server that blocks ATLAS patterns
func CreateMockLLMServer ¶
func CreateMockLLMServer(responses map[string]MockLLMResponse) *httptest.Server
CreateMockLLMServer creates a configurable mock LLM server for testing
func GetAtlasChecker ¶
func GetAtlasChecker() *compliance.ATLASFramework
GetAtlasChecker returns the ATLAS compliance checker
func GetTestPaths ¶
GetTestPaths returns the paths to test resources
func PrintBenchmarkResults ¶
func PrintBenchmarkResults(results []BenchmarkResult)
PrintBenchmarkResults prints benchmark results
func PrintTestSummary ¶
func PrintTestSummary(tracker *CoverageTracker)
PrintTestSummary prints a summary of test results
func RunWithFixtures ¶
func RunWithFixtures(t *testing.T, fixtures []TestFixture)
RunWithFixtures runs ATLAS tests using fixtures
func SaveTestConfig ¶
func SaveTestConfig(config TestConfig, path string) error
SaveTestConfig saves test configuration to file
func SaveTestFixtures ¶
func SaveTestFixtures(fixtures []TestFixture, path string) error
SaveTestFixtures saves test fixtures to a JSON file
func TestMainWithConfig ¶
TestMainWithConfig runs the test suite with configuration
func ValidateTestEnvironment ¶
func ValidateTestEnvironment() error
ValidateTestEnvironment validates the test environment
Types ¶
type ATLASParams ¶
type ATLASParams struct {
Technique string `json:"technique"`
PatternID string `json:"pattern_id"`
Severity string `json:"severity"`
BlockMode bool `json:"block_mode"`
}
ATLASParams holds ATLAS-specific test parameters
type AtlasTestResult ¶
type AtlasTestResult struct {
Blocked bool
Detected bool
Technique string
Pattern string
Score float64
}
AtlasTestResult represents the result of an ATLAS pattern test
type BenchmarkResult ¶
type BenchmarkResult struct {
Name string
Iterations int
AvgDuration time.Duration
MinDuration time.Duration
MaxDuration time.Duration
TotalDuration time.Duration
BytesAlloc int64
Allocs int64
}
BenchmarkResult holds benchmark results
func RunBenchmark ¶
func RunBenchmark(name string, fn func(), iterations int) BenchmarkResult
RunBenchmark runs a benchmark test
type CoverageReport ¶
type CoverageReport struct {
TechniquesCovered int `json:"techniques_covered"`
TechniquesTotal int `json:"techniques_total"`
PatternsCovered int `json:"patterns_covered"`
PatternsTotal int `json:"patterns_total"`
Techniques []string `json:"techniques"`
}
CoverageReport represents test coverage information
type CoverageTracker ¶
type CoverageTracker struct {
Techniques map[string]bool
Patterns map[string]bool
TotalTests int
PassedTests int
FailedTests int
}
CoverageTracker tracks test coverage
func NewCoverageTracker ¶
func NewCoverageTracker() *CoverageTracker
NewCoverageTracker creates a new coverage tracker
func (*CoverageTracker) GetCoverage ¶
func (c *CoverageTracker) GetCoverage() (techniqueCov, patternCov float64, total int)
GetCoverage returns coverage statistics
func (*CoverageTracker) PrintCoverage ¶
func (c *CoverageTracker) PrintCoverage()
PrintCoverage prints coverage report
func (*CoverageTracker) RecordTest ¶
func (c *CoverageTracker) RecordTest(technique, pattern string, passed bool)
RecordTest records a test result
type MockLLMResponse ¶
type MockLLMResponse struct {
StatusCode int
Body string
Headers map[string]string
Delay time.Duration
}
MockLLMResponse defines a mock LLM response configuration
type TestConfig ¶
type TestConfig struct {
// ATLAS Configuration
ATLASEnabled bool `json:"atlas_enabled"`
ATLASBlockMode bool `json:"atlas_block_mode"`
ATLASThreshold float64 `json:"atlas_threshold"`
ExcludedParams []string `json:"excluded_params"`
// Server Configuration
UpstreamURL string `json:"upstream_url"`
Timeout time.Duration `json:"timeout"`
MaxRetries int `json:"max_retries"`
// Test Configuration
Parallel bool `json:"parallel"`
Verbose bool `json:"verbose"`
Seed int64 `json:"seed"`
TimeoutDS time.Duration `json:"test_timeout"`
}
TestConfig holds test configuration
func DefaultTestConfig ¶
func DefaultTestConfig() TestConfig
DefaultTestConfig returns default test configuration
func LoadConfig ¶
func LoadConfig(path string) (TestConfig, error)
LoadConfig loads the test configuration
func LoadTestConfig ¶
func LoadTestConfig(path string) (TestConfig, error)
LoadTestConfig loads test configuration from file
type TestFixture ¶
type TestFixture struct {
Name string `json:"name"`
Category string `json:"category"`
Input map[string]string `json:"input"`
Expected map[string]interface{} `json:"expected"`
ATLASParams ATLASParams `json:"atlas_params"`
}
TestFixture represents a test fixture with expected results
func LoadFixtures ¶
func LoadFixtures(path string) ([]TestFixture, error)
LoadFixtures loads the test fixtures
func LoadTestFixtures ¶
func LoadTestFixtures(path string) ([]TestFixture, error)
LoadTestFixtures loads test fixtures from a JSON file
type TestLogger ¶
TestLogger provides structured logging for tests
func (*TestLogger) GetLogs ¶
func (l *TestLogger) GetLogs() string
GetLogs returns the accumulated logs
func (*TestLogger) Log ¶
func (l *TestLogger) Log(format string, args ...interface{})
Log logs a message with timestamp
type TestReport ¶
type TestReport struct {
Timestamp time.Time `json:"timestamp"`
Duration time.Duration `json:"duration"`
TotalTests int `json:"total_tests"`
PassedTests int `json:"passed_tests"`
FailedTests int `json:"failed_tests"`
SkippedTests int `json:"skipped_tests"`
Coverage CoverageReport `json:"coverage"`
Results []TestResult `json:"results"`
}
TestReport represents the test execution report
type TestResult ¶
type TestResult struct {
Name string `json:"name"`
Category string `json:"category"`
Status string `json:"status"`
Duration time.Duration `json:"duration"`
Techniques []string `json:"techniques"`
Error string `json:"error,omitempty"`
}
TestResult represents an individual test result