mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
lint: style, autofix (#3354)
This commit is contained in:
parent
bbe7752967
commit
7a1ad8376a
48 changed files with 177 additions and 169 deletions
|
@ -51,93 +51,86 @@ func TestBadBucketsConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLeakyBucketsConfig(t *testing.T) {
|
||||
var CfgTests = []cfgTest{
|
||||
//leaky with bad capacity
|
||||
CfgTests := []cfgTest{
|
||||
// leaky with bad capacity
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "leaky", Capacity: 0}, false, false},
|
||||
//leaky with empty leakspeed
|
||||
// leaky with empty leakspeed
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "leaky", Capacity: 1}, false, false},
|
||||
//leaky with missing filter
|
||||
// leaky with missing filter
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "leaky", Capacity: 1, LeakSpeed: "1s"}, false, true},
|
||||
//leaky with invalid leakspeed
|
||||
// leaky with invalid leakspeed
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "leaky", Capacity: 1, LeakSpeed: "abs", Filter: "true"}, false, false},
|
||||
//leaky with valid filter
|
||||
// leaky with valid filter
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "leaky", Capacity: 1, LeakSpeed: "1s", Filter: "true"}, true, true},
|
||||
//leaky with invalid filter
|
||||
// leaky with invalid filter
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "leaky", Capacity: 1, LeakSpeed: "1s", Filter: "xu"}, false, true},
|
||||
//leaky with valid filter
|
||||
// leaky with valid filter
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "leaky", Capacity: 1, LeakSpeed: "1s", Filter: "true"}, true, true},
|
||||
//leaky with bad overflow filter
|
||||
// leaky with bad overflow filter
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "leaky", Capacity: 1, LeakSpeed: "1s", Filter: "true", OverflowFilter: "xu"}, false, true},
|
||||
}
|
||||
|
||||
if err := runTest(CfgTests); err != nil {
|
||||
t.Fatalf("%s", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestBlackholeConfig(t *testing.T) {
|
||||
var CfgTests = []cfgTest{
|
||||
//basic bh
|
||||
CfgTests := []cfgTest{
|
||||
// basic bh
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "trigger", Filter: "true", Blackhole: "15s"}, true, true},
|
||||
//bad bh
|
||||
// bad bh
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "trigger", Filter: "true", Blackhole: "abc"}, false, true},
|
||||
}
|
||||
|
||||
if err := runTest(CfgTests); err != nil {
|
||||
t.Fatalf("%s", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestTriggerBucketsConfig(t *testing.T) {
|
||||
var CfgTests = []cfgTest{
|
||||
//basic valid counter
|
||||
CfgTests := []cfgTest{
|
||||
// basic valid counter
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "trigger", Filter: "true"}, true, true},
|
||||
}
|
||||
|
||||
if err := runTest(CfgTests); err != nil {
|
||||
t.Fatalf("%s", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCounterBucketsConfig(t *testing.T) {
|
||||
var CfgTests = []cfgTest{
|
||||
|
||||
//basic valid counter
|
||||
CfgTests := []cfgTest{
|
||||
// basic valid counter
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "counter", Capacity: -1, Duration: "5s", Filter: "true"}, true, true},
|
||||
//missing duration
|
||||
// missing duration
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "counter", Capacity: -1, Filter: "true"}, false, false},
|
||||
//bad duration
|
||||
// bad duration
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "counter", Capacity: -1, Duration: "abc", Filter: "true"}, false, false},
|
||||
//capacity must be -1
|
||||
// capacity must be -1
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "counter", Capacity: 0, Duration: "5s", Filter: "true"}, false, false},
|
||||
}
|
||||
if err := runTest(CfgTests); err != nil {
|
||||
t.Fatalf("%s", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestBayesianBucketsConfig(t *testing.T) {
|
||||
var CfgTests = []cfgTest{
|
||||
|
||||
//basic valid counter
|
||||
CfgTests := []cfgTest{
|
||||
// basic valid counter
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "bayesian", Capacity: -1, Filter: "true", BayesianPrior: 0.5, BayesianThreshold: 0.5, BayesianConditions: []RawBayesianCondition{{ConditionalFilterName: "true", ProbGivenEvil: 0.5, ProbGivenBenign: 0.5}}}, true, true},
|
||||
//bad capacity
|
||||
// bad capacity
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "bayesian", Capacity: 1, Filter: "true", BayesianPrior: 0.5, BayesianThreshold: 0.5, BayesianConditions: []RawBayesianCondition{{ConditionalFilterName: "true", ProbGivenEvil: 0.5, ProbGivenBenign: 0.5}}}, false, false},
|
||||
//missing prior
|
||||
// missing prior
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "bayesian", Capacity: -1, Filter: "true", BayesianThreshold: 0.5, BayesianConditions: []RawBayesianCondition{{ConditionalFilterName: "true", ProbGivenEvil: 0.5, ProbGivenBenign: 0.5}}}, false, false},
|
||||
//missing threshold
|
||||
// missing threshold
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "bayesian", Capacity: -1, Filter: "true", BayesianPrior: 0.5, BayesianConditions: []RawBayesianCondition{{ConditionalFilterName: "true", ProbGivenEvil: 0.5, ProbGivenBenign: 0.5}}}, false, false},
|
||||
//bad prior
|
||||
// bad prior
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "bayesian", Capacity: -1, Filter: "true", BayesianPrior: 1.5, BayesianThreshold: 0.5, BayesianConditions: []RawBayesianCondition{{ConditionalFilterName: "true", ProbGivenEvil: 0.5, ProbGivenBenign: 0.5}}}, false, false},
|
||||
//bad threshold
|
||||
// bad threshold
|
||||
{BucketFactory{Name: "test", Description: "test1", Type: "bayesian", Capacity: -1, Filter: "true", BayesianPrior: 0.5, BayesianThreshold: 1.5, BayesianConditions: []RawBayesianCondition{{ConditionalFilterName: "true", ProbGivenEvil: 0.5, ProbGivenBenign: 0.5}}}, false, false},
|
||||
}
|
||||
if err := runTest(CfgTests); err != nil {
|
||||
t.Fatalf("%s", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue