Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Under windows, don't mess with line endings at least for yaml test files,
# otherwise the reported line numbers don't match the expected errors.

**/testdata/**/*.yaml text eol=lf
**/testdata/**/*.yml text eol=lf
148 changes: 0 additions & 148 deletions cmd/crowdsec-cli/clisetup/setup/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,29 +345,6 @@ detect:
datasource: {}`,
want: nil,
wantErr: "invalid acquisition spec for wizard: datasource configuration is empty",
}, {
name: "missing acquisition file name",
config: `
detect:
wizard:
acquisition_spec:
filename: something.yaml
datasource:
labels:
type: something`,
want: nil,
wantErr: "invalid acquisition spec for wizard: source field is required",
}, {
name: "source is unknown",
config: `
detect:
foobar:
acquisition_spec:
filename: wombat.yaml
datasource:
source: wombat`,
want: nil,
wantErr: "invalid acquisition spec for foobar: unknown data source wombat",
}, {
name: "source is misplaced",
config: `
Expand All @@ -379,131 +356,6 @@ detect:
source: file`,
want: nil,
wantErr: "yaml: unmarshal errors:\n line 7: field source not found in type setup.AcquisitionSpec",
}, {
name: "source is mismatched",
config: `
detect:
foobar:
acquisition_spec:
filename: journalctl.yaml
datasource:
source: journalctl
filename: /path/to/file.log`,
want: nil,
wantErr: `invalid acquisition spec for foobar: cannot parse: [1:1] unknown field "filename"`,
}, {
name: "source file: required fields",
config: `
detect:
foobar:
acquisition_spec:
filename: file.yaml
datasource:
source: file`,
want: nil,
wantErr: "invalid acquisition spec for foobar: no filename or filenames configuration provided",
}, {
name: "source journalctl: required fields",
config: `
detect:
foobar:
acquisition_spec:
filename: foobar.yaml
datasource:
source: journalctl`,
want: nil,
wantErr: "invalid acquisition spec for foobar: journalctl_filter is required",
}, {
name: "source cloudwatch: required fields",
config: `
detect:
foobar:
acquisition_spec:
filename: cloudwatch.yaml
datasource:
source: cloudwatch`,
want: nil,
wantErr: "invalid acquisition spec for foobar: group_name is mandatory for CloudwatchSource",
}, {
name: "source syslog: all fields are optional",
config: `
detect:
foobar:
acquisition_spec:
filename: syslog.yaml
datasource:
source: syslog`,
want: &Setup{
Plans: []ServicePlan{
{
Name: "foobar",
InstallRecommendation: InstallRecommendation{
AcquisitionSpec: AcquisitionSpec{
Filename: "syslog.yaml",
Datasource: DatasourceConfig{
"source": "syslog",
},
},
},
},
},
},
}, {
name: "source docker: required fields",
config: `
detect:
foobar:
acquisition_spec:
filename: docker.yaml
datasource:
source: docker`,
want: nil,
wantErr: "invalid acquisition spec for foobar: no containers or services configuration provided",
}, {
name: "source kinesis: required fields (enhanced fanout=false)",
config: `
detect:
foobar:
acquisition_spec:
filename: kinesis.yaml
datasource:
source: kinesis`,
want: nil,
wantErr: "invalid acquisition spec for foobar: stream_name is mandatory when use_enhanced_fanout is false",
}, {
name: "source kinesis: required fields (enhanced fanout=true)",
config: `
detect:
foobar:
acquisition_spec:
filename: kinesis.yaml
datasource:
source: kinesis
use_enhanced_fanout: true`,
want: nil,
wantErr: "invalid acquisition spec for foobar: stream_arn is mandatory when use_enhanced_fanout is true",
}, {
name: "source kafka: required fields",
config: `
detect:
foobar:
acquisition_spec:
filename: kafka.yaml
datasource:
source: kafka`,
want: nil,
wantErr: "invalid acquisition spec for foobar: cannot create a kafka reader with an empty list of broker addresses",
}, {
name: "source loki: required fields",
config: `
detect:
foobar:
acquisition_spec:
filename: loki.yaml
datasource:
source: loki`,
want: nil,
wantErr: "invalid acquisition spec for foobar: loki query is mandatory",
},
}

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ require (
github.com/prometheus/common v0.66.1
github.com/r3labs/diff/v2 v2.15.1
github.com/sanity-io/litter v1.5.8
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2
github.com/segmentio/kafka-go v0.4.48
github.com/shirou/gopsutil/v4 v4.25.8
github.com/sirupsen/logrus v1.9.3
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94=
github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
Expand Down Expand Up @@ -508,6 +510,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sanity-io/litter v1.5.8 h1:uM/2lKrWdGbRXDrIq08Lh9XtVYoeGtcQxk9rtQ7+rYg=
github.com/sanity-io/litter v1.5.8/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/segmentio/kafka-go v0.4.48 h1:9jyu9CWK4W5W+SroCe8EffbrRZVqAOkuaLd/ApID4Vs=
github.com/segmentio/kafka-go v0.4.48/go.mod h1:HjF6XbOKh0Pjlkr5GVZxt6CsjjwnmhVOfURM5KMd8qg=
Expand Down
Loading