Skip to content

Commit

Permalink
lib/filterx: add E2E test for startswith/endswith/includes
Browse files Browse the repository at this point in the history
Signed-off-by: Szilard Parrag <[email protected]>
  • Loading branch information
OverOrion committed Oct 1, 2024
1 parent 008982a commit 087a1ee
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/light/functional_tests/filterx/test_filterx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2304,3 +2304,36 @@ def test_parse_windows_eventlog_xml(config, syslog_ng):
},
},
}


def test_startswith_endswith_includes(config, syslog_ng):
(file_true, file_false) = create_config(
config, r"""
result = json();
if (startswith($MSG, ["dummy_prefix", "foo"]))
{
result.startswith_foo = true;
};
bar_var = "bar";
if (includes($MSG, bar_var, ignorecase=true))
{
result.contains_bar = true;
};
baz_var = "baz";
baz_list = ["dummy_suffix", baz_var];
if (endswith($MSG, baz_list, ignorecase=true))
{
result.endswith_baz = true;
};
if (includes(${values.str}, ${values.str}))
{
result.works_with_message_value = true;
};
$MSG = json();
$MSG = result;
""", msg="fooBARbAz",
)
syslog_ng.start(config)

assert "processed" not in file_false.get_stats()
assert file_true.read_log() == '{"startswith_foo":true,"contains_bar":true,"endswith_baz":true,"works_with_message_value":true}\n'

0 comments on commit 087a1ee

Please sign in to comment.