Documentation
¶
Index ¶
- func AddMockResponse(req *http.Request, reqHeaders http.Header, respHeaders http.Header, ...) (respBody []byte, sharedVariables map[string]any, err error)
- func CheckChaosForScenarioGroup(groupConfigRepository repository.GroupConfigRepository, ...) []byte
- func GenerateMutatedScenarios(scenario *types.APIScenario) ([]*types.APIScenario, error)
- func TrackFieldCoverage(expected, actual interface{}, path string, coverage *ContractCoverage)
- type ConsumerExecutor
- type ContractCoverage
- type ContractDiffReport
- type ContractMutator
- type ContractValidationError
- type ContractValidationResult
- type ContractValidationStats
- type CoverageReport
- type OpenAPIContractCoverage
- type ProducerExecutor
- func (px *ProducerExecutor) Execute(ctx context.Context, req *http.Request, scenarioKey *types.APIKeyData, ...) *types.ProducerContractResponse
- func (px *ProducerExecutor) ExecuteByGroup(ctx context.Context, req *http.Request, group string, ...) *types.ProducerContractResponse
- func (px *ProducerExecutor) ExecuteByHistory(ctx context.Context, req *http.Request, group string, ...) *types.ProducerContractResponse
- func (px *ProducerExecutor) GetContractStats(scenarioName string) (*ContractValidationStats, error)
- type ValueMismatch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddMockResponse ¶
func AddMockResponse( req *http.Request, reqHeaders http.Header, respHeaders http.Header, scenario *types.APIScenario, started time.Time, ended time.Time, config *types.Configuration, scenarioRepository repository.APIScenarioRepository, fixtureRepository repository.APIFixtureRepository, groupConfigRepository repository.GroupConfigRepository, ) (respBody []byte, sharedVariables map[string]any, err error)
AddMockResponse method is shared so it cannot be instance method
func CheckChaosForScenarioGroup ¶
func CheckChaosForScenarioGroup( groupConfigRepository repository.GroupConfigRepository, scenario *types.APIScenario, respHeaders http.Header) []byte
CheckChaosForScenarioGroup helper method
func GenerateMutatedScenarios ¶
func GenerateMutatedScenarios(scenario *types.APIScenario) ([]*types.APIScenario, error)
GenerateMutatedScenarios creates test variations of a scenario
func TrackFieldCoverage ¶
func TrackFieldCoverage(expected, actual interface{}, path string, coverage *ContractCoverage)
TrackFieldCoverage tracks which fields were covered in the response
Types ¶
type ConsumerExecutor ¶
type ConsumerExecutor struct {
// contains filtered or unexported fields
}
ConsumerExecutor structure
func NewConsumerExecutor ¶
func NewConsumerExecutor( config *types.Configuration, scenarioRepository repository.APIScenarioRepository, fixtureRepository repository.APIFixtureRepository, groupConfigRepository repository.GroupConfigRepository, ) *ConsumerExecutor
NewConsumerExecutor instantiates controller for updating api-scenarios
func (*ConsumerExecutor) Execute ¶
func (cx *ConsumerExecutor) Execute(c web.APIContext) (err error)
Execute request and replays stubbed response
func (*ConsumerExecutor) ExecuteWithKey ¶
func (cx *ConsumerExecutor) ExecuteWithKey( req *http.Request, respHeaders http.Header, key *types.APIKeyData, overrides map[string]any) (matchedScenario *types.APIScenario, respBytes []byte, sharedVariables map[string]any, err error)
ExecuteWithKey request and replays stubbed response
type ContractCoverage ¶
type ContractCoverage struct {
ScenarioName string `json:"scenarioName"`
Timestamp time.Time `json:"timestamp"`
ResponseStatus int `json:"responseStatus"`
ResponseTime int64 `json:"responseTimeMs"`
CoveredFields []string `json:"coveredFields"`
UncoveredFields []string `json:"uncoveredFields"`
CoveragePercent float64 `json:"coveragePercent"`
FieldCoverage map[string]bool `json:"fieldCoverage"`
}
ContractCoverage include tracking
func (*ContractCoverage) CalculateCoverage ¶
func (c *ContractCoverage) CalculateCoverage()
CalculateCoverage calculates the coverage percentage
type ContractDiffReport ¶
type ContractDiffReport struct {
ExpectedFields map[string]interface{} `json:"expectedFields"`
ActualFields map[string]interface{} `json:"actualFields"`
MissingFields []string `json:"missingFields"`
ExtraFields []string `json:"extraFields"`
TypeMismatches map[string]string `json:"typeMismatches"`
ValueMismatches map[string]ValueMismatch `json:"valueMismatches"`
HeaderMismatches map[string]ValueMismatch `json:"headerMismatches"`
}
ContractDiffReport diff reporting structure and helper functions
type ContractMutator ¶
type ContractMutator struct {
// contains filtered or unexported fields
}
ContractMutator creates variations of a contract to test robustness
func NewContractMutator ¶
func NewContractMutator(scenario *types.APIScenario) *ContractMutator
NewContractMutator creates a new mutator
func (*ContractMutator) GenerateMutations ¶
func (m *ContractMutator) GenerateMutations() []*types.APIScenario
GenerateMutations Generate mutations to test boundary conditions and edge cases
type ContractValidationError ¶
type ContractValidationError struct {
OriginalError error
DiffReport *ContractDiffReport
Scenario string
URL string
}
func (*ContractValidationError) Error ¶
func (e *ContractValidationError) Error() string
Error implements the error interface
func (*ContractValidationError) Unwrap ¶
func (e *ContractValidationError) Unwrap() error
Unwrap returns the original error
type ContractValidationResult ¶
type ContractValidationResult struct {
Scenario string `json:"scenario"`
Path string `json:"path"`
Method string `json:"method"`
StatusCode int `json:"statusCode"`
ResponseTime int64 `json:"responseTimeMs"`
Timestamp time.Time `json:"timestamp"`
Success bool `json:"success"`
ErrorMessage string `json:"errorMessage,omitempty"`
ResponseBody string `json:"responseBody,omitempty"`
DiffReport *ContractDiffReport `json:"diffReport,omitempty"`
}
ContractValidationResult stores the result of a contract validation test
type ContractValidationStats ¶
type ContractValidationStats struct {
ScenarioName string
TotalExecutions int
SuccessCount int
FailureCount int
AverageLatency float64
Top5Failures []string
LastExecuted time.Time
SuccessRate float64
}
ContractValidationStats summarizes validation results over time
type CoverageReport ¶
type CoverageReport struct {
TotalPaths int `json:"totalPaths"`
CoveredPaths int `json:"coveredPaths"`
Coverage float64 `json:"coveragePercentage"`
PathCoverage map[string]float64 `json:"pathCoverage"`
UncoveredPaths []string `json:"uncoveredPaths"`
StatusCodes map[int]int `json:"statusCodeCoverage"`
MethodCoverage map[string]float64 `json:"methodCoverage"`
TagCoverage map[string]float64 `json:"tagCoverage"`
}
CoverageReport structure for API contract coverage
type OpenAPIContractCoverage ¶
type OpenAPIContractCoverage struct {
// contains filtered or unexported fields
}
OpenAPIContractCoverage analyzes contract coverage against OpenAPI spec
func NewOpenAPIContractCoverage ¶
func NewOpenAPIContractCoverage(spec *openapi3.T, contracts []*types.APIScenario) *OpenAPIContractCoverage
NewOpenAPIContractCoverage creates a new coverage analyzer
func (*OpenAPIContractCoverage) Analyze ¶
func (c *OpenAPIContractCoverage) Analyze() *CoverageReport
Analyze Enhanced Analyze method to include additional coverage metrics
type ProducerExecutor ¶
type ProducerExecutor struct {
// contains filtered or unexported fields
}
ProducerExecutor structure
func NewProducerExecutor ¶
func NewProducerExecutor( scenarioRepository repository.APIScenarioRepository, groupConfigRepository repository.GroupConfigRepository, client web.HTTPClient) *ProducerExecutor
NewProducerExecutor executes contracts for producers
func (*ProducerExecutor) Execute ¶
func (px *ProducerExecutor) Execute( ctx context.Context, req *http.Request, scenarioKey *types.APIKeyData, dataTemplate fuzz.DataTemplateRequest, contractReq *types.ProducerContractRequest, ) *types.ProducerContractResponse
Execute an API with fuzz data request
func (*ProducerExecutor) ExecuteByGroup ¶
func (px *ProducerExecutor) ExecuteByGroup( ctx context.Context, req *http.Request, group string, dataTemplate fuzz.DataTemplateRequest, contractReq *types.ProducerContractRequest, ) *types.ProducerContractResponse
ExecuteByGroup executes an API with fuzz data request
func (*ProducerExecutor) ExecuteByHistory ¶
func (px *ProducerExecutor) ExecuteByHistory( ctx context.Context, req *http.Request, group string, dataTemplate fuzz.DataTemplateRequest, contractReq *types.ProducerContractRequest, ) *types.ProducerContractResponse
ExecuteByHistory executes execution history for an API with fuzz data request
func (*ProducerExecutor) GetContractStats ¶
func (px *ProducerExecutor) GetContractStats(scenarioName string) (*ContractValidationStats, error)
GetContractStats analyzes validation history for a scenario
type ValueMismatch ¶
type ValueMismatch struct {
Expected interface{} `json:"expected"`
Actual interface{} `json:"actual"`
}