Skip to content

Commit 3aa2c7e

Browse files
authored
pkg/acquisition: register mock datasource for YAML tests (#4205)
* pkg/acquisition: register mock datasource for YAML tests * relax appsec test timing
1 parent d9d0f56 commit 3aa2c7e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/acquisition/config_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"github.com/stretchr/testify/require"
1616
"github.com/goccy/go-yaml"
1717

18+
"github.com/crowdsecurity/crowdsec/pkg/acquisition/registry"
19+
"github.com/crowdsecurity/crowdsec/pkg/acquisition/types"
1820
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
1921
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
2022
"github.com/crowdsecurity/crowdsec/pkg/metrics"
@@ -91,6 +93,10 @@ func TestParseSourceConfig(t *testing.T) {
9193
// load a hub, appsec needs it
9294
hub := cwhub.Hub{}
9395

96+
// some tests use the mock datasource
97+
restore := registry.RegisterTestFactory("mock", func() types.DataSource { return &MockSource{} })
98+
t.Cleanup(restore)
99+
94100
suites := []suite{
95101
{name: "valid", root: filepath.Join("testdata", "valid"), expectValid: true},
96102
{name: "invalid", root: filepath.Join("testdata", "invalid"), expectValid: false},

pkg/acquisition/modules/appsec/appsec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func testAppSecEngine(t *testing.T, test appsecRuleTest) {
194194
input.ResponseChannel = make(chan appsec.AppsecTempResponse)
195195

196196
// collect both responses and events until no activity for idleDuration
197-
idleDuration := 50 * time.Millisecond
197+
idleDuration := 200 * time.Millisecond
198198
idle := time.NewTimer(idleDuration)
199199
defer idle.Stop()
200200

0 commit comments

Comments
 (0)