From a48a4e01d6e3ae42c90f921de057f83983c05414 Mon Sep 17 00:00:00 2001 From: Melissa Kilby Date: Wed, 4 Oct 2023 04:44:15 +0000 Subject: [PATCH] new(tests/falco): add TestFalco_Config_Metrics_Enabled Signed-off-by: Melissa Kilby --- tests/data/configs/configs.go | 10 ++++++++++ tests/falco/config_test.go | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/tests/data/configs/configs.go b/tests/data/configs/configs.go index 1f89dc0..e457642 100644 --- a/tests/data/configs/configs.go +++ b/tests/data/configs/configs.go @@ -442,3 +442,13 @@ var RuleMatchingWrongValue = run.NewStringFileAccessor( rule_matching: test `, ) + +var MetricsEnabled = run.NewStringFileAccessor( + "rule_metrics_enabled.yaml", + ` +metrics: + enabled: true + interval: 5s + output_rule: true + `, +) diff --git a/tests/falco/config_test.go b/tests/falco/config_test.go index 0f8b938..8559fdd 100644 --- a/tests/falco/config_test.go +++ b/tests/falco/config_test.go @@ -74,3 +74,16 @@ func TestFalco_Config_RuleMatchingWrongValue(t *testing.T) { assert.Contains(t, res.Stderr(), "Unknown rule matching strategy") assert.Equal(t, 1, res.ExitCode()) } + +func TestFalco_Config_Metrics_Enabled(t *testing.T) { + t.Parallel() + res := falco.Test( + tests.NewFalcoExecutableRunner(t), + falco.WithRules(rules.ShadowingRules), + falco.WithConfig(configs.MetricsEnabled), + falco.WithCaptureFile(captures.TracesPositiveReadSensitiveFileUntrusted), + falco.WithOutputJSON(), + ) + assert.NoError(t, res.Err(), "%s", res.Stderr()) + assert.Equal(t, 0, res.ExitCode()) +}