cstest

package
v1.4.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ParserAssertFileName = "parser.assert"
	ParserResultFileName = "parser-dump.yaml"

	ScenarioAssertFileName = "scenario.assert"
	ScenarioResultFileName = "bucket-dump.yaml"

	BucketPourResultFileName = "bucketpour-dump.yaml"
)

Variables

This section is empty.

Functions

func AssertErrorContains added in v1.3.1

func AssertErrorContains(t *testing.T, err error, expectedErr string)

func Copy

func Copy(sourceFile string, destinationFile string) error

func CopyDir

func CopyDir(src string, dest string) error

func DumpTree

func DumpTree(parser_results ParserResults, bucket_pour BucketPourInfo, opts DumpOpts)

func Escape

func Escape(val string) string

Types

type AssertFail

type AssertFail struct {
	File       string
	Line       int
	Expression string
	Debug      map[string]string
}

type BucketPourInfo

type BucketPourInfo map[string][]types.Event

func LoadBucketPourDump

func LoadBucketPourDump(filepath string) (*BucketPourInfo, error)

type BucketResults

type BucketResults []types.Event

func LoadScenarioDump

func LoadScenarioDump(filepath string) (*BucketResults, error)

func (BucketResults) Len

func (b BucketResults) Len() int

func (BucketResults) Less

func (b BucketResults) Less(i, j int) bool

func (BucketResults) Swap

func (b BucketResults) Swap(i, j int)

type DumpOpts added in v1.2.2

type DumpOpts struct {
	Details bool
	SkipOk  bool
}

type HubIndex

type HubIndex struct {
	Data map[string]map[string]cwhub.Item
}

type HubTest

type HubTest struct {
	CrowdSecPath           string
	CscliPath              string
	HubPath                string
	HubTestPath            string
	HubIndexFile           string
	TemplateConfigPath     string
	TemplateProfilePath    string
	TemplateSimulationPath string
	HubIndex               *HubIndex
	Tests                  []*HubTestItem
}

func NewHubTest

func NewHubTest(hubPath string, crowdsecPath string, cscliPath string) (HubTest, error)

func (*HubTest) GetParsersCoverage

func (h *HubTest) GetParsersCoverage() ([]ParserCoverage, error)

func (*HubTest) GetScenariosCoverage

func (h *HubTest) GetScenariosCoverage() ([]ScenarioCoverage, error)

func (*HubTest) LoadAllTests

func (h *HubTest) LoadAllTests() error

func (*HubTest) LoadTestItem

func (h *HubTest) LoadTestItem(name string) (*HubTestItem, error)

type HubTestItem

type HubTestItem struct {
	Name string
	Path string

	CrowdSecPath string
	CscliPath    string

	RuntimePath               string
	RuntimeHubPath            string
	RuntimeDataPath           string
	RuntimePatternsPath       string
	RuntimeConfigFilePath     string
	RuntimeProfileFilePath    string
	RuntimeSimulationFilePath string
	RuntimeHubConfig          *csconfig.Hub

	ResultsPath          string
	ParserResultFile     string
	ScenarioResultFile   string
	BucketPourResultFile string

	HubPath                string
	HubTestPath            string
	HubIndexFile           string
	TemplateConfigPath     string
	TemplateProfilePath    string
	TemplateSimulationPath string
	HubIndex               *HubIndex

	Config *HubTestItemConfig

	Success    bool
	ErrorsList []string

	AutoGen        bool
	ParserAssert   *ParserAssert
	ScenarioAssert *ScenarioAssert

	CustomItemsLocation []string
}

func NewTest

func NewTest(name string, hubTest *HubTest) (*HubTestItem, error)

func (*HubTestItem) Clean

func (t *HubTestItem) Clean() error

func (*HubTestItem) InstallHub

func (t *HubTestItem) InstallHub() error

func (*HubTestItem) Run

func (t *HubTestItem) Run() error

type HubTestItemConfig

type HubTestItemConfig struct {
	Parsers         []string           `yaml:"parsers"`
	Scenarios       []string           `yaml:"scenarios"`
	PostOVerflows   []string           `yaml:"postoverflows"`
	LogFile         string             `yaml:"log_file"`
	LogType         string             `yaml:"log_type"`
	Labels          map[string]string  `yaml:"labels"`
	IgnoreParsers   bool               `yaml:"ignore_parsers"`   // if we test a scenario, we don't want to assert on Parser
	OverrideStatics []types.ExtraField `yaml:"override_statics"` //Allow to override statics. Executed before s00
}

type ParserAssert

type ParserAssert struct {
	File              string
	AutoGenAssert     bool
	AutoGenAssertData string
	NbAssert          int
	Fails             []AssertFail
	Success           bool
	TestData          *ParserResults
}

func NewParserAssert

func NewParserAssert(file string) *ParserAssert

func (*ParserAssert) AssertFile

func (p *ParserAssert) AssertFile(testFile string) error

func (*ParserAssert) AutoGenFromFile

func (p *ParserAssert) AutoGenFromFile(filename string) (string, error)

func (*ParserAssert) AutoGenParserAssert

func (p *ParserAssert) AutoGenParserAssert() string

func (*ParserAssert) EvalExpression

func (p *ParserAssert) EvalExpression(expression string) (string, error)

func (*ParserAssert) LoadTest

func (p *ParserAssert) LoadTest(filename string) error

func (*ParserAssert) Run

func (p *ParserAssert) Run(assert string) (bool, error)

func (*ParserAssert) RunExpression

func (p *ParserAssert) RunExpression(expression string) (interface{}, error)

type ParserCoverage

type ParserCoverage struct {
	Parser     string
	TestsCount int
	PresentIn  map[string]bool //poorman's set
}

type ParserResult

type ParserResult struct {
	Evt     types.Event
	Success bool
}

type ParserResults

type ParserResults map[string]map[string][]ParserResult

func LoadParserDump

func LoadParserDump(filepath string) (*ParserResults, error)

type ScenarioAssert

type ScenarioAssert struct {
	File              string
	AutoGenAssert     bool
	AutoGenAssertData string
	NbAssert          int
	Fails             []AssertFail
	Success           bool
	TestData          *BucketResults
	PourData          *BucketPourInfo
}

func NewScenarioAssert

func NewScenarioAssert(file string) *ScenarioAssert

func (*ScenarioAssert) AssertFile

func (s *ScenarioAssert) AssertFile(testFile string) error

func (*ScenarioAssert) AutoGenFromFile

func (s *ScenarioAssert) AutoGenFromFile(filename string) (string, error)

func (*ScenarioAssert) AutoGenScenarioAssert

func (s *ScenarioAssert) AutoGenScenarioAssert() string

func (*ScenarioAssert) EvalExpression

func (s *ScenarioAssert) EvalExpression(expression string) (string, error)

func (*ScenarioAssert) LoadTest

func (s *ScenarioAssert) LoadTest(filename string, bucketpour string) error

func (*ScenarioAssert) Run

func (s *ScenarioAssert) Run(assert string) (bool, error)

func (*ScenarioAssert) RunExpression

func (s *ScenarioAssert) RunExpression(expression string) (interface{}, error)

type ScenarioCoverage

type ScenarioCoverage struct {
	Scenario   string
	TestsCount int
	PresentIn  map[string]bool
}

Jump to

Keyboard shortcuts

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