From b0f352e7b94ac3ab85c744a90ed31963a3bfa7bc Mon Sep 17 00:00:00 2001 From: Melissa Kilby Date: Fri, 17 May 2024 08:03:47 +0000 Subject: [PATCH] cleanup(test): add test cases for sanitize_metric_name Signed-off-by: Melissa Kilby --- unit_tests/engine/test_falco_utils.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/unit_tests/engine/test_falco_utils.cpp b/unit_tests/engine/test_falco_utils.cpp index c6c5ef5d585..9f9a56c0389 100644 --- a/unit_tests/engine/test_falco_utils.cpp +++ b/unit_tests/engine/test_falco_utils.cpp @@ -73,6 +73,14 @@ TEST(FalcoUtils, parse_prometheus_interval) ASSERT_EQ(falco::utils::parse_prometheus_interval("200"), 0UL); } +TEST(FalcoUtils, sanitize_metric_name) +{ + ASSERT_EQ(falco::utils::sanitize_metric_name("Testing rule 2 (CVE-2244)"), "Testing_rule_2_CVE_2244"); + ASSERT_EQ(falco::utils::sanitize_metric_name("Testing rule__:2)"), "Testing_rule_:2"); + ASSERT_EQ(falco::utils::sanitize_metric_name("This@is_a$test rule123"), "This_is_a_test_rule123"); + ASSERT_EQ(falco::utils::sanitize_metric_name("RULEwith:special#characters"), "RULEwith:special_characters"); +} + TEST(FalcoUtils, matches_wildcard) { ASSERT_TRUE(falco::utils::matches_wildcard("*", "anything"));