MCPcopy
hub / github.com/crowdsecurity/crowdsec / TestLoadAcquisitionFromFiles

Function TestLoadAcquisitionFromFiles

pkg/acquisition/acquisition_test.go:224–323  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

222}
223
224func TestLoadAcquisitionFromFiles(t *testing.T) {
225 appendMockSource(t)
226 t.Setenv("TEST_ENV", "test_value2")
227
228 ctx := t.Context()
229
230 tests := []struct {
231 TestName string
232 Config csconfig.CrowdsecServiceCfg
233 ExpectedError string
234 ExpectedLen int
235 }{
236 {
237 TestName: "non_existent_file",
238 Config: csconfig.CrowdsecServiceCfg{
239 AcquisitionFiles: []string{"does_not_exist"},
240 },
241 ExpectedError: "open does_not_exist: " + cstest.FileNotFoundMessage,
242 ExpectedLen: 0,
243 },
244 {
245 TestName: "invalid_yaml_file",
246 Config: csconfig.CrowdsecServiceCfg{
247 AcquisitionFiles: []string{"testdata/badyaml.yaml"},
248 },
249 ExpectedError: "[1:1] string was used where mapping is expected",
250 ExpectedLen: 0,
251 },
252 {
253 TestName: "invalid_empty_yaml",
254 Config: csconfig.CrowdsecServiceCfg{
255 AcquisitionFiles: []string{"testdata/emptyitem.yaml"},
256 },
257 ExpectedLen: 0,
258 },
259 {
260 TestName: "basic_valid",
261 Config: csconfig.CrowdsecServiceCfg{
262 AcquisitionFiles: []string{"testdata/basic_filemode.yaml"},
263 },
264 ExpectedLen: 2,
265 },
266 {
267 TestName: "missing_labels",
268 Config: csconfig.CrowdsecServiceCfg{
269 AcquisitionFiles: []string{"testdata/missing_labels.yaml"},
270 },
271 ExpectedError: "testdata/missing_labels.yaml: missing labels",
272 },
273 {
274 TestName: "backward_compat",
275 Config: csconfig.CrowdsecServiceCfg{
276 AcquisitionFiles: []string{"testdata/backward_compat.yaml"},
277 },
278 ExpectedLen: 2,
279 },
280 {
281 TestName: "bad_type",

Callers

nothing calls this directly

Calls 5

appendMockSourceFunction · 0.85
LoadAcquisitionFromFilesFunction · 0.85
RunMethod · 0.65
DumpMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…