mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
Windows Support (#1159)
This commit is contained in:
parent
a49b023a28
commit
0449ec1868
100 changed files with 3401 additions and 437 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/csplugin"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -26,12 +27,12 @@ type LAPI struct {
|
|||
|
||||
func SetupLAPITest(t *testing.T) LAPI {
|
||||
t.Helper()
|
||||
router, loginResp, err := InitMachineTest()
|
||||
router, loginResp, config, err := InitMachineTest()
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
|
||||
APIKey, err := CreateTestBouncer()
|
||||
APIKey, err := CreateTestBouncer(config.API.Server.DbConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("%s", err.Error())
|
||||
}
|
||||
|
@ -59,25 +60,25 @@ func (l *LAPI) RecordResponse(verb string, url string, body *strings.Reader) *ht
|
|||
return w
|
||||
}
|
||||
|
||||
func InitMachineTest() (*gin.Engine, models.WatcherAuthResponse, error) {
|
||||
router, err := NewAPITest()
|
||||
func InitMachineTest() (*gin.Engine, models.WatcherAuthResponse, csconfig.Config, error) {
|
||||
router, config, err := NewAPITest()
|
||||
if err != nil {
|
||||
return nil, models.WatcherAuthResponse{}, fmt.Errorf("unable to run local API: %s", err)
|
||||
return nil, models.WatcherAuthResponse{}, config, fmt.Errorf("unable to run local API: %s", err)
|
||||
}
|
||||
|
||||
loginResp, err := LoginToTestAPI(router)
|
||||
loginResp, err := LoginToTestAPI(router, config)
|
||||
if err != nil {
|
||||
return nil, models.WatcherAuthResponse{}, fmt.Errorf("%s", err.Error())
|
||||
return nil, models.WatcherAuthResponse{}, config, fmt.Errorf("%s", err.Error())
|
||||
}
|
||||
return router, loginResp, nil
|
||||
return router, loginResp, config, nil
|
||||
}
|
||||
|
||||
func LoginToTestAPI(router *gin.Engine) (models.WatcherAuthResponse, error) {
|
||||
func LoginToTestAPI(router *gin.Engine, config csconfig.Config) (models.WatcherAuthResponse, error) {
|
||||
body, err := CreateTestMachine(router)
|
||||
if err != nil {
|
||||
return models.WatcherAuthResponse{}, fmt.Errorf("%s", err.Error())
|
||||
}
|
||||
err = ValidateMachine("test")
|
||||
err = ValidateMachine("test", config.API.Server.DbConfig)
|
||||
if err != nil {
|
||||
log.Fatalln(err.Error())
|
||||
}
|
||||
|
@ -141,14 +142,14 @@ func TestCreateAlert(t *testing.T) {
|
|||
|
||||
func TestCreateAlertChannels(t *testing.T) {
|
||||
|
||||
apiServer, err := NewAPIServer()
|
||||
apiServer, config, err := NewAPIServer()
|
||||
if err != nil {
|
||||
log.Fatalln(err.Error())
|
||||
}
|
||||
apiServer.controller.PluginChannel = make(chan csplugin.ProfileAlert)
|
||||
apiServer.InitController()
|
||||
|
||||
loginResp, err := LoginToTestAPI(apiServer.router)
|
||||
loginResp, err := LoginToTestAPI(apiServer.router, config)
|
||||
if err != nil {
|
||||
log.Fatalln(err.Error())
|
||||
}
|
||||
|
@ -427,7 +428,7 @@ func TestDeleteAlertTrustedIPS(t *testing.T) {
|
|||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
loginResp, err := LoginToTestAPI(router)
|
||||
loginResp, err := LoginToTestAPI(router, cfg)
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue