testing

package
v3.0.0-...-a62b8d8 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Test

type Test struct {
	Name string

	// public variables
	// RequestAddress contains the address of the request
	RequestAddress string
	// RequestPort contains the port of the request
	RequestPort int
	// RequestURI contains the uri of the request
	RequestURI string
	// RequestMethod contains the method of the request
	RequestMethod string
	// RequestProtocol contains the protocol of the request
	RequestProtocol string
	// RequestHeaders contains the headers of the request
	RequestHeaders map[string]string
	// ResponseHeaders contains the headers of the response
	ResponseHeaders map[string]string
	// ResponseCode contains the response code of the response
	ResponseCode int
	// ResponseProtocol contains the protocol of the response
	ResponseProtocol string
	// ServerAddress contains the address of the server
	ServerAddress string
	// ServerPort contains the port of the server
	ServerPort int
	// Expected contains the expected result of the test
	ExpectedOutput profile.ExpectedOutput
	// contains filtered or unexported fields
}

Test represents a unique transaction within a WAF instance for a test case

func NewTest

func NewTest(name string, waf coraza.WAF) *Test

NewTest creates a new test with default properties

func (*Test) DisableMagic

func (t *Test) DisableMagic()

DisableMagic disables the magic flag which auto sets content-type and content-length

func (*Test) LogContains

func (t *Test) LogContains(log string) bool

LogContains checks if the log contains a string

func (*Test) OutputErrors

func (t *Test) OutputErrors() []string

OutputErrors returns a list of errors that occurred during the test when comparing log and rule ids

func (*Test) OutputInterruptionErrors

func (t *Test) OutputInterruptionErrors() []string

OutputInterruptionErrors returns a list of errors that occured when comparing the interruption result

func (*Test) Request

func (t *Test) Request() string

Request returns the raw request

func (*Test) RunPhases

func (t *Test) RunPhases() error

RunPhases runs the phases of the test from 1 to 5

func (*Test) SetEncodedRequest

func (t *Test) SetEncodedRequest(request string) error

SetEncodedRequest reads a base64 encoded request and sets it as the current request

func (*Test) SetRawRequest

func (t *Test) SetRawRequest(request []byte) error

SetRawRequest reads a raw request and sets it as the current request

func (*Test) SetRequestBody

func (t *Test) SetRequestBody(body interface{}) error

SetRequestBody sets the request body

func (*Test) SetResponseBody

func (t *Test) SetResponseBody(body interface{}) error

SetResponseBody sets the request body

func (*Test) SetWAF

func (t *Test) SetWAF(waf coraza.WAF)

SetWAF sets the waf instance pointer

func (*Test) Transaction

func (t *Test) Transaction() types.Transaction

Transaction returns the transaction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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