|
@@ -15,11 +15,11 @@ import (
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/cobra"
|
|
"gopkg.in/yaml.v2"
|
|
"gopkg.in/yaml.v2"
|
|
|
|
|
|
- "github.com/crowdsecurity/crowdsec/pkg/cstest"
|
|
|
|
|
|
+ "github.com/crowdsecurity/crowdsec/pkg/hubtest"
|
|
)
|
|
)
|
|
|
|
|
|
var (
|
|
var (
|
|
- HubTest cstest.HubTest
|
|
|
|
|
|
+ HubTest hubtest.HubTest
|
|
)
|
|
)
|
|
|
|
|
|
func NewHubTestCmd() *cobra.Command {
|
|
func NewHubTestCmd() *cobra.Command {
|
|
@@ -37,7 +37,7 @@ func NewHubTestCmd() *cobra.Command {
|
|
DisableAutoGenTag: true,
|
|
DisableAutoGenTag: true,
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
var err error
|
|
var err error
|
|
- HubTest, err = cstest.NewHubTest(hubPath, crowdsecPath, cscliPath)
|
|
|
|
|
|
+ HubTest, err = hubtest.NewHubTest(hubPath, crowdsecPath, cscliPath)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Fatalf("unable to load hubtest: %+v", err)
|
|
log.Fatalf("unable to load hubtest: %+v", err)
|
|
}
|
|
}
|
|
@@ -86,7 +86,7 @@ cscli hubtest create my-scenario-test --parsers crowdsecurity/nginx --scenarios
|
|
logFile.Close()
|
|
logFile.Close()
|
|
|
|
|
|
// create empty parser assertion file
|
|
// create empty parser assertion file
|
|
- parserAssertFilePath := filepath.Join(testPath, cstest.ParserAssertFileName)
|
|
|
|
|
|
+ parserAssertFilePath := filepath.Join(testPath, hubtest.ParserAssertFileName)
|
|
parserAssertFile, err := os.Create(parserAssertFilePath)
|
|
parserAssertFile, err := os.Create(parserAssertFilePath)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
log.Fatal(err)
|
|
@@ -94,7 +94,7 @@ cscli hubtest create my-scenario-test --parsers crowdsecurity/nginx --scenarios
|
|
parserAssertFile.Close()
|
|
parserAssertFile.Close()
|
|
|
|
|
|
// create empty scenario assertion file
|
|
// create empty scenario assertion file
|
|
- scenarioAssertFilePath := filepath.Join(testPath, cstest.ScenarioAssertFileName)
|
|
|
|
|
|
+ scenarioAssertFilePath := filepath.Join(testPath, hubtest.ScenarioAssertFileName)
|
|
scenarioAssertFile, err := os.Create(scenarioAssertFilePath)
|
|
scenarioAssertFile, err := os.Create(scenarioAssertFilePath)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
log.Fatal(err)
|
|
@@ -112,7 +112,7 @@ cscli hubtest create my-scenario-test --parsers crowdsecurity/nginx --scenarios
|
|
postoverflows = append(postoverflows, "")
|
|
postoverflows = append(postoverflows, "")
|
|
}
|
|
}
|
|
|
|
|
|
- configFileData := &cstest.HubTestItemConfig{
|
|
|
|
|
|
+ configFileData := &hubtest.HubTestItemConfig{
|
|
Parsers: parsers,
|
|
Parsers: parsers,
|
|
Scenarios: scenarios,
|
|
Scenarios: scenarios,
|
|
PostOVerflows: postoverflows,
|
|
PostOVerflows: postoverflows,
|
|
@@ -336,8 +336,8 @@ cscli hubtest create my-scenario-test --parsers crowdsecurity/nginx --scenarios
|
|
fmt.Printf(" Test name : %s\n", test.Name)
|
|
fmt.Printf(" Test name : %s\n", test.Name)
|
|
fmt.Printf(" Test path : %s\n", test.Path)
|
|
fmt.Printf(" Test path : %s\n", test.Path)
|
|
fmt.Printf(" Log file : %s\n", filepath.Join(test.Path, test.Config.LogFile))
|
|
fmt.Printf(" Log file : %s\n", filepath.Join(test.Path, test.Config.LogFile))
|
|
- fmt.Printf(" Parser assertion file : %s\n", filepath.Join(test.Path, cstest.ParserAssertFileName))
|
|
|
|
- fmt.Printf(" Scenario assertion file : %s\n", filepath.Join(test.Path, cstest.ScenarioAssertFileName))
|
|
|
|
|
|
+ fmt.Printf(" Parser assertion file : %s\n", filepath.Join(test.Path, hubtest.ParserAssertFileName))
|
|
|
|
+ fmt.Printf(" Scenario assertion file : %s\n", filepath.Join(test.Path, hubtest.ScenarioAssertFileName))
|
|
fmt.Printf(" Configuration File : %s\n", filepath.Join(test.Path, "config.yaml"))
|
|
fmt.Printf(" Configuration File : %s\n", filepath.Join(test.Path, "config.yaml"))
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -381,8 +381,8 @@ cscli hubtest create my-scenario-test --parsers crowdsecurity/nginx --scenarios
|
|
log.Fatalf("unable to load all tests: %+v", err)
|
|
log.Fatalf("unable to load all tests: %+v", err)
|
|
}
|
|
}
|
|
var err error
|
|
var err error
|
|
- scenarioCoverage := []cstest.ScenarioCoverage{}
|
|
|
|
- parserCoverage := []cstest.ParserCoverage{}
|
|
|
|
|
|
+ scenarioCoverage := []hubtest.ScenarioCoverage{}
|
|
|
|
+ parserCoverage := []hubtest.ParserCoverage{}
|
|
scenarioCoveragePercent := 0
|
|
scenarioCoveragePercent := 0
|
|
parserCoveragePercent := 0
|
|
parserCoveragePercent := 0
|
|
|
|
|
|
@@ -526,8 +526,8 @@ cscli hubtest create my-scenario-test --parsers crowdsecurity/nginx --scenarios
|
|
log.Fatalf("unable to load scenario result after run: %s", err)
|
|
log.Fatalf("unable to load scenario result after run: %s", err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- opts := cstest.DumpOpts{}
|
|
|
|
- cstest.DumpTree(*test.ParserAssert.TestData, *test.ScenarioAssert.PourData, opts)
|
|
|
|
|
|
+ opts := hubtest.DumpOpts{}
|
|
|
|
+ hubtest.DumpTree(*test.ParserAssert.TestData, *test.ScenarioAssert.PourData, opts)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
}
|