Skip to content

Commit

Permalink
feat(decl/cmd/test): add test command
Browse files Browse the repository at this point in the history
The test command allows to run tests and verify that Falco generates
alerts matching the expected outcome. The
--skip-outcome-verification flag can be used to disable outcome
verification.

Signed-off-by: Leonardo Di Giovanna <[email protected]>
Co-authored-by: Aldo Lacuku <[email protected]>
  • Loading branch information
ekoops and alacuku committed Nov 13, 2024
1 parent 8757f80 commit a805881
Show file tree
Hide file tree
Showing 4 changed files with 484 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/declarative/declarative.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package declarative
import (
"github.com/spf13/cobra"

"github.com/falcosecurity/event-generator/cmd/declarative/config"
"github.com/falcosecurity/event-generator/cmd/declarative/run"
"github.com/falcosecurity/event-generator/cmd/declarative/test"
)

// New creates a new declarative command.
Expand All @@ -30,7 +32,11 @@ func New(declarativeEnvKey, envKeysPrefix string) *cobra.Command {
DisableAutoGenTag: true,
}

c.AddCommand(run.New(declarativeEnvKey, envKeysPrefix).Command)
commonConf := config.New(c, declarativeEnvKey, envKeysPrefix)

runCmd := run.New(declarativeEnvKey, envKeysPrefix).Command
testCmd := test.New(commonConf, false).Command
c.AddCommand(runCmd)
c.AddCommand(testCmd)
return c
}
18 changes: 18 additions & 0 deletions cmd/declarative/test/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2024 The Falco Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package test provides the implementation of the "test" command. This command lets users run tests and verify their
// outcomes by providing a YAML description of them containing their expected outcomes.
package test
Loading

0 comments on commit a805881

Please sign in to comment.