Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(tests/falco): remove dropped CLI options test. #62

Merged
merged 3 commits into from
Sep 5, 2024
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
21 changes: 17 additions & 4 deletions pkg/falco/tester_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,30 @@ func WithConfig(f run.FileAccessor) TestOption {

// WithEnabledTags runs Falco with enabled rules tags through the `-t` option.
func WithEnabledTags(tags ...string) TestOption {
return withMultipleArgValues("-t", tags...)
return func(o *testOptions) {
o.args = append(o.args, "-o", "rules[].disable.rule=*")
for _, t := range tags {
o.args = append(o.args, "-o", "rules[].enable.tag="+t)
}
}
}

// WithDisabledTags runs Falco with disabled rules tags through the `-T` option.
func WithDisabledTags(tags ...string) TestOption {
return withMultipleArgValues("-T", tags...)
return func(o *testOptions) {
for _, t := range tags {
o.args = append(o.args, "-o", "rules[].disable.tag="+t)
}
}
}

// WithDisabledRules runs Falco with disabled rules through the `-D` option.
// WithDisabledRules runs Falco with disabled rules through the `rules:` config option.
func WithDisabledRules(rules ...string) TestOption {
return withMultipleArgValues("-D", rules...)
return func(o *testOptions) {
for _, r := range rules {
o.args = append(o.args, "-o", "rules[].disable.rule="+r)
}
}
}

// WithEnabledSources runs Falco with enabled event sources through the `--enable-source` option.
Expand Down
30 changes: 0 additions & 30 deletions tests/falco/legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,6 @@ func TestFalco_Legacy_Endswith(t *testing.T) {
assert.Equal(t, 0, res.ExitCode())
}

func TestFalco_Legacy_DisabledAndEnabledRules1(t *testing.T) {
t.Parallel()
checkConfig(t)
res := falco.Test(
tests.NewFalcoExecutableRunner(t),
falco.WithRules(rules.SingleRule),
falco.WithDisabledTags("a"),
falco.WithEnabledTags("a"),
falco.WithCaptureFile(captures.CatWrite),
)
assert.Regexp(t, `Error: You can not specify both disabled .-D/-T. and enabled .-t. rules`, res.Stderr())
assert.Error(t, res.Err(), "%s", res.Stderr())
assert.Equal(t, 1, res.ExitCode())
}

func TestFalco_Legacy_StdoutOutputStrict(t *testing.T) {
t.Parallel()
res := falco.Test(
Expand Down Expand Up @@ -1582,21 +1567,6 @@ func TestFalco_Legacy_InvalidAppendRuleMultipleDocs(t *testing.T) {
assert.Equal(t, 1, res.ExitCode())
}

func TestFalco_Legacy_DisabledAndEnabledRules2(t *testing.T) {
t.Parallel()
checkConfig(t)
res := falco.Test(
tests.NewFalcoExecutableRunner(t),
falco.WithRules(rules.SingleRule),
falco.WithDisabledRules("open.*"),
falco.WithEnabledTags("a"),
falco.WithCaptureFile(captures.CatWrite),
)
assert.Regexp(t, `Error: You can not specify both disabled .-D/-T. and enabled .-t. rules`, res.Stderr())
assert.Error(t, res.Err(), "%s", res.Stderr())
assert.Equal(t, 1, res.ExitCode())
}

func TestFalco_Legacy_RunTagsAb(t *testing.T) {
t.Parallel()
checkConfig(t)
Expand Down
Loading