From 50f4bc172ddebc40d40bcbbc9cf90d0441bbb1bd Mon Sep 17 00:00:00 2001 From: Luca Guerra Date: Thu, 19 Sep 2024 14:40:43 +0000 Subject: [PATCH] update(tests): add test for plugin init_config map Signed-off-by: Luca Guerra --- .../falco/test_configuration_schema.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/unit_tests/falco/test_configuration_schema.cpp b/unit_tests/falco/test_configuration_schema.cpp index 9a740fd7e0e..ebb133613c8 100644 --- a/unit_tests/falco/test_configuration_schema.cpp +++ b/unit_tests/falco/test_configuration_schema.cpp @@ -97,6 +97,34 @@ TEST(Configuration, schema_wrong_embedded_key) EXPECT_VALIDATION_STATUS(res, yaml_helper::validation_failed); } +TEST(Configuration, plugin_init_config) +{ + falco_configuration falco_config; + config_loaded_res res; + + std::string config = R"( +plugins: + - name: k8saudit + library_path: libk8saudit.so + init_config: + maxEventSize: 262144 + sslCertificate: /etc/falco/falco.pem +)"; + + EXPECT_NO_THROW(res = falco_config.init_from_content(config, {})); + EXPECT_VALIDATION_STATUS(res, yaml_helper::validation_ok); + + config = R"( +plugins: + - name: k8saudit + library_path: libk8saudit.so + init_config: '{"maxEventSize": 262144, "sslCertificate": "/etc/falco/falco.pem"}' +)"; + + EXPECT_NO_THROW(res = falco_config.init_from_content(config, {})); + EXPECT_VALIDATION_STATUS(res, yaml_helper::validation_ok); +} + TEST(Configuration, schema_yaml_helper_validator) { yaml_helper conf;