action

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePlaybook

func CreatePlaybook(scriptFile *string, data []byte, playbook *config.TestDef, actions *[]FullAction) bool

Create a Playbook from the YAML data

func DisableDNSCache

func DisableDNSCache(discache bool)

func DisableLogAction

func DisableLogAction(noLog bool)

DisableAction is called upon --no-log arg on command line

func DoHTTPRequest

func DoHTTPRequest(httpAction HTTPAction, resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

DoHTTPRequest accepts a Httpaction and a one-way channel to write the results to.

func DoMQTTRequest

func DoMQTTRequest(mqttAction MQTTAction, resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

DoMQTTRequest accepts a MqttAction and a one-way channel to write the results to.

func DoTCPRequest

func DoTCPRequest(tcpAction TCPAction, resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry)

DoTCPRequest accepts a TcpAction and a one-way channel to write the results to.

func DoUDPRequest

func DoUDPRequest(udpAction UDPAction, resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry)

DoUDPRequest accepts a UdpAction and a one-way channel to write the results to.

func DoWSRequest

func DoWSRequest(wsAction WSAction, resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

DoWSRequest handles requests made using WebSocket Protocol TODO: manage cookies !

func GetEmbeddedFilenames

func GetEmbeddedFilenames() []string

Return the list of embedded filenames

func JSONProcessor

func JSONProcessor(responseHandler ResponseHandler, sessionMap map[string]string, vulog *log.Entry, responseBody []byte) bool

JSONProcessor applies JSON expression to extract data from responses and fill variables

func RedecodeEscapedPath

func RedecodeEscapedPath(escapedURL string) string

RedecodeEscapedPath gives the canonical value of un escaped path

func RegexpProcessor

func RegexpProcessor(responseHandler ResponseHandler, sessionMap map[string]string, vulog *log.Entry, responseBody []byte, respHeader http.Header) bool

RegexpProcessor applies the Regexp from responses to fill variables

func SetContext

func SetContext(displaySrvResp bool, mustTraceReq bool)

func SubstParams

func SubstParams(sessionMap map[string]string, textData string, vulog *log.Entry) string

SubstParams compute the result of variables interpolation

func XMLPathProcessor

func XMLPathProcessor(responseHandler ResponseHandler, sessionMap map[string]string, vulog *log.Entry, responseBody []byte) bool

XMLPathProcessor extracts XML data from responses to fill variables

Types

type Action

type Action interface {
	// Returns false if an error occurred during the execution
	Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool
}

Action is an interface which is able to execute a Request

type AssertAction

type AssertAction struct {
	Expression   string `yaml:"expression"`
	CompiledExpr *govaluate.EvaluableExpression
}

AssertAction describes an assert Action

func NewAssertAction

func NewAssertAction(a map[interface{}]interface{}) (AssertAction, bool)

NewAssertAction creates a new Assert Action

func (AssertAction) Execute

func (s AssertAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

Execute an assert Action

type FormData

type FormData struct {
	Name    string `yaml:"name"`
	Value   string `yaml:"value"`
	Type    string `yaml:"type"`
	Content []byte
}

FormData describes the data that will be sent with the HTTP Request

func NewFormData

func NewFormData(a map[interface{}]interface{}) (FormData, error)

NewFormData build a new structure to handle form data to be sent

func NewFormDatas

func NewFormDatas(a map[interface{}]interface{}) ([]FormData, bool)

NewFormDatas builds all the FormDatas from the Action described in YAML Playbook

type FullAction

type FullAction struct {
	When         string `yaml:"when"`
	CompiledWhen *govaluate.EvaluableExpression
	Action       Action
}

FullAction embeds the global parameters for all actions as well as an Action

func BuildActionList

func BuildActionList(playbook *config.TestDef, scriptDir string) ([]FullAction, bool)

BuildActionList builds all the Actions !

type HTTPAction

type HTTPAction struct {
	Method           string            `yaml:"method"`
	URL              string            `yaml:"url"`
	Body             string            `yaml:"body"`
	Template         string            `yaml:"template"`
	FormDatas        []FormData        `yaml:"formdatas"`
	Headers          map[string]string `yaml:"headers"`
	Title            string            `yaml:"title"`
	StoreCookie      string            `yaml:"storeCookie"`
	ResponseHandlers []ResponseHandler `yaml:"responses"`
}

HTTPAction describes a HTTP Action

func NewHTTPAction

func NewHTTPAction(a map[interface{}]interface{}, dflt config.Default) (HTTPAction, bool)

NewHTTPAction creates a new HTTP Action

func (HTTPAction) Execute

func (h HTTPAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

Execute a HTTP Action

type LogAction

type LogAction struct {
	Message string `yaml:"message"`
}

LogAction describes a log Action

func NewLogAction

func NewLogAction(a map[interface{}]interface{}) (LogAction, bool)

NewLogAction creates a new Log Action

func (LogAction) Execute

func (s LogAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

Execute a log Action

type MQTTAction

type MQTTAction struct {
	URL                  string        `yaml:"url"`
	Title                string        `yaml:"title"`
	Username             string        `yaml:"username"`
	Password             string        `yaml:"password"`
	ClientID             string        `yaml:"clientid"`
	MaxReconnectInterval time.Duration `yaml:"maxreconnectinterval"`
	KeepAlive            time.Duration `yaml:"keppalive"`
	Payload              string        `yaml:"payload"`
	Qos                  byte          `yaml:"qos"`
	Topic                string        `yaml:"topic"`
	CertificatePath      string        `yaml:"certificatepath"`
	PrivateKeyPath       string        `yaml:"privatekeypath"`
	TLSConfig            *tls.Config
}

MQTTAction describes a MQTT Action

func NewMQTTAction

func NewMQTTAction(a map[interface{}]interface{}, dflt config.Default) (MQTTAction, bool)

NewMQTTAction creates a new MQTT Action

func (MQTTAction) Execute

func (h MQTTAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

Execute a MQTT Action

type ResponseHandler

type ResponseHandler struct {
	FromHeader   string           `yaml:"from_header"`
	Jsonpaths    []*jsonpath.Path `yaml:"jsonpath"`
	Xmlpath      *xmlpath.Path    `yaml:"xmlpath"`
	Regex        *regexp.Regexp   `yaml:"regex"`
	Variable     string           `yaml:"variable"`
	Index        string           `yaml:"index"`
	Defaultvalue string           `yaml:"default_value"`
}

ResponseHandler describes the actions to apply on returned data

func NewResponseHandler

func NewResponseHandler(a map[interface{}]interface{}) (ResponseHandler, error)

NewResponseHandler builds the ResponseHandler from the Action described in YAML playbook

func NewResponseHandlers

func NewResponseHandlers(a map[interface{}]interface{}) ([]ResponseHandler, bool)

NewResponseHandlers builds all the ResponseHandler from the Action described in YAML Playbook

type SetVarAction

type SetVarAction struct {
	Variable     string `yaml:"variable"`
	Expression   string `yaml:"expression"`
	CompiledExpr *govaluate.EvaluableExpression
}

SetVarAction describes a setvar Action

func NewSetVarAction

func NewSetVarAction(a map[interface{}]interface{}) (SetVarAction, bool)

NewSetVarAction creates a new setvar Action

func (SetVarAction) Execute

func (s SetVarAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

Execute a setvar Action

type SleepAction

type SleepAction struct {
	Duration int `yaml:"duration"` // in milli-seconds
}

SleepAction describes a sleep Action

func NewSleepAction

func NewSleepAction(a map[interface{}]interface{}) (SleepAction, bool)

NewSleepAction creates a new sleep Action

func (SleepAction) Execute

func (s SleepAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

Execute a sleep Action

type TCPAction

type TCPAction struct {
	Address string `yaml:"address"`
	Payload string `yaml:"payload"`
	Title   string `yaml:"title"`
}

TCPAction describes a TCP Action

func NewTCPAction

func NewTCPAction(a map[interface{}]interface{}) (TCPAction, bool)

NewTCPAction createsa new TCP Action

func (TCPAction) Execute

func (t TCPAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

Execute a TCP Action

type TCPReqResult

type TCPReqResult struct {
	Type    string
	Latency int64
	Size    int
	Status  int
	Title   string
	When    int64
}

TCPReqResult describes a TCP or UDP Result

type UDPAction

type UDPAction struct {
	Address string `yaml:"address"`
	Payload string `yaml:"payload"`
	Title   string `yaml:"title"`
}

UDPAction describes a UDP Action

func NewUDPAction

func NewUDPAction(a map[interface{}]interface{}) (UDPAction, bool)

NewUDPAction creates a new UDP Action

func (UDPAction) Execute

func (t UDPAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

Execute an UDP Request

type WSAction

type WSAction struct {
	//Method          string              `yaml:"method"`
	URL              string            `yaml:"url"`
	Body             string            `yaml:"body"`
	Title            string            `yaml:"title"`
	StoreCookie      string            `yaml:"storeCookie"`
	ResponseHandlers []ResponseHandler `yaml:"responses"`
}

WSAction describes the structure of WebSocket Action

func NewWSAction

func NewWSAction(a map[interface{}]interface{}, dflt config.Default) (WSAction, bool)

NewWSAction builds a new WebSocket Action

func (WSAction) Execute

func (h WSAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vulog *log.Entry, playbook *config.TestDef) bool

Execute a WebSocket Action

Jump to

Keyboard shortcuts

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