operators

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalBoolSlice

func EvalBoolSlice(slice []bool, isAnd bool) bool

EvalBoolSlice evaluates a slice of bools using a logical AND

func GetMatcherName

func GetMatcherName(matcher *matchers.Matcher, matcherIndex int) string

GetMatcherName returns matchername of given matcher

func MakeDynamicValuesCallback

func MakeDynamicValuesCallback(input map[string][]string, iterateAllValues bool, callback func(map[string]interface{}) bool)

MakeDynamicValuesCallback takes an input dynamic values map and calls the callback function with all variations of the data in input in form of map[string]string (interface{}).

Types

type ExtractFunc

type ExtractFunc func(data map[string]interface{}, matcher *extractors.Extractor) map[string]struct{}

ExtractFunc performs extracting operation for an extractor on model and returns true or false.

type MatchFunc

type MatchFunc func(data map[string]interface{}, matcher *matchers.Matcher) (bool, []string)

MatchFunc performs matching operation for a matcher on model and returns true or false.

type Operators

type Operators struct {
	// description: |
	//   Matchers contains the detection mechanism for the request to identify
	//   whether the request was successful by doing pattern matching
	//   on request/responses.
	//
	//   Multiple matchers can be combined with `matcher-condition` flag
	//   which accepts either `and` or `or` as argument.
	Matchers []*matchers.Matcher `` /* 203-byte string literal not displayed */
	// description: |
	//   Extractors contains the extraction mechanism for the request to identify
	//   and extract parts of the response.
	Extractors []*extractors.Extractor `` /* 223-byte string literal not displayed */
	// description: |
	//   MatchersCondition is the condition between the matchers. Default is OR.
	// values:
	//   - "and"
	//   - "or"
	MatchersCondition string `` /* 182-byte string literal not displayed */

	// TemplateID is the ID of the template for matcher
	TemplateID string `json:"-" yaml:"-" jsonschema:"-"`
	// ExcludeMatchers is a list of excludeMatchers items
	ExcludeMatchers *excludematchers.ExcludeMatchers `json:"-" yaml:"-" jsonschema:"-"`
	// contains filtered or unexported fields
}

Operators contains the operators that can be applied on protocols

func (*Operators) Compile

func (operators *Operators) Compile() error

Compile compiles the operators as well as their corresponding matchers and extractors

func (*Operators) Execute

func (operators *Operators) Execute(data map[string]interface{}, match MatchFunc, extract ExtractFunc, isDebug bool) (*Result, bool)

Execute executes the operators on data and returns a result structure

func (*Operators) ExecuteInternalExtractors

func (operators *Operators) ExecuteInternalExtractors(data map[string]interface{}, extract ExtractFunc) map[string]interface{}

ExecuteInternalExtractors executes internal dynamic extractors

func (*Operators) GetMatchersCondition

func (operators *Operators) GetMatchersCondition() matchers.ConditionType

GetMatchersCondition returns the condition for the matchers

func (*Operators) HasDSL

func (operators *Operators) HasDSL() bool

func (*Operators) IsEmpty

func (operators *Operators) IsEmpty() bool

IsEmpty determines if the operator has matchers or extractors

func (*Operators) Len

func (operators *Operators) Len() int

Len calculates the sum of the number of matchers and extractors

type Result

type Result struct {
	// Matched is true if any matchers matched
	Matched bool
	// Extracted is true if any result type values were extracted
	Extracted bool
	// Matches is a map of matcher names that we matched
	Matches map[string][]string
	// Extracts contains all the data extracted from inputs
	Extracts map[string][]string
	// OutputExtracts is the list of extracts to be displayed on screen.
	OutputExtracts []string

	// DynamicValues contains any dynamic values to be templated
	DynamicValues map[string][]string
	// PayloadValues contains payload values provided by user. (Optional)
	PayloadValues map[string]interface{}

	// Optional lineCounts for file protocol
	LineCount string
	// Operators is reference to operators that generated this result (Read-Only)
	Operators *Operators
	// contains filtered or unexported fields
}

Result is a result structure created from operators running on data.

func (*Result) HasExtract

func (result *Result) HasExtract(name string) bool

func (*Result) HasMatch

func (result *Result) HasMatch(name string) bool

func (*Result) Merge

func (r *Result) Merge(result *Result)

Merge merges a result structure into the other.

Directories

Path Synopsis
common
dsl
Package extractors implements extractors for http response data retrieval.
Package extractors implements extractors for http response data retrieval.
Package matchers implements matchers for http response matching with templates.
Package matchers implements matchers for http response matching with templates.

Jump to

Keyboard shortcuts

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