matchers

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package matchers implements matchers for http response matching with templates.

Index

Constants

This section is empty.

Variables

View Source
var ConditionTypes = map[string]ConditionType{
	"and": ANDCondition,
	"or":  ORCondition,
}

ConditionTypes is an table for conversion of condition type from string.

View Source
var MatcherTypes = map[string]MatcherType{
	"status": StatusMatcher,
	"size":   SizeMatcher,
	"word":   WordsMatcher,
	"regex":  RegexMatcher,
	"binary": BinaryMatcher,
	"dsl":    DSLMatcher,
}

MatcherTypes is an table for conversion of matcher type from string.

View Source
var PartTypes = map[string]Part{
	"body":   BodyPart,
	"header": HeaderPart,
	"all":    AllPart,
}

PartTypes is an table for conversion of part type from string.

Functions

This section is empty.

Types

type ConditionType

type ConditionType int

ConditionType is the type of condition for matcher

const (
	// ANDCondition matches responses with AND condition in arguments.
	ANDCondition ConditionType = iota + 1
	// ORCondition matches responses with AND condition in arguments.
	ORCondition
)

type Matcher

type Matcher struct {
	// Type is the type of the matcher
	Type string `yaml:"type"`

	// Name is matcher Name to be displayed in result output.
	Name string `yaml:"name,omitempty"`
	// Status are the acceptable status codes for the response
	Status []int `yaml:"status,omitempty"`
	// Size is the acceptable size for the response
	Size []int `yaml:"size,omitempty"`
	// Words are the words required to be present in the response
	Words []string `yaml:"words,omitempty"`
	// Regex are the regex pattern required to be present in the response
	Regex []string `yaml:"regex,omitempty"`

	// Binary are the binary characters required to be present in the response
	Binary []string `yaml:"binary,omitempty"`
	// DSL are the dsl queries
	DSL []string `yaml:"dsl,omitempty"`

	// Condition is the optional condition between two matcher variables
	//
	// By default, the condition is assumed to be OR.
	Condition string `yaml:"condition,omitempty"`

	// Part is the part of the request to match
	//
	// By default, matching is performed in request body.
	Part string `yaml:"part,omitempty"`
	// contains filtered or unexported fields
}

Matcher is used to identify whether a template was successful.

func (*Matcher) CompileMatchers

func (m *Matcher) CompileMatchers() error

CompileMatchers performs the initial setup operation on a matcher

func (*Matcher) GetPart

func (m *Matcher) GetPart() Part

GetPart returns the part of the matcher

func (*Matcher) Match

func (m *Matcher) Match(resp *http.Response, body, headers string) bool

Match matches a http response again a given matcher

func (*Matcher) MatchDNS added in v1.1.1

func (m *Matcher) MatchDNS(msg *dns.Msg) bool

MatchDNS matches a dns response against a given matcher

type MatcherType

type MatcherType = int

MatcherType is the type of the matcher specified

const (
	// WordsMatcher matches responses with words
	WordsMatcher MatcherType = iota + 1
	// RegexMatcher matches responses with regexes
	RegexMatcher
	// BinaryMatcher matches responses with words
	BinaryMatcher
	// StatusMatcher matches responses with status codes
	StatusMatcher
	// SizeMatcher matches responses with response size
	SizeMatcher
	// DSLMatcher matches based upon dsl syntax
	DSLMatcher
)

type Part

type Part int

Part is the part of the request to match

const (
	// BodyPart matches body of the response.
	BodyPart Part = iota + 1
	// HeaderPart matches headers of the response.
	HeaderPart
	// AllPart matches both response body and headers of the response.
	AllPart
)

Jump to

Keyboard shortcuts

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