Skip to content

Commit db499c2

Browse files
Add line split unit test
1 parent 72ef539 commit db499c2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_rules_remote.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,23 @@ def test_esql_filtered_index_error(self):
155155
with pytest.raises(EsqlSchemaError):
156156
_ = RuleCollection().load_dict(production_rule)
157157

158+
def test_new_line_split_index(self):
159+
"""Test an ESQL rule's index validation to ensure that it can handle new line split indices."""
160+
file_path = get_path(["tests", "data", "command_control_dummy_production_rule.toml"])
161+
original_production_rule = load_rule_contents(file_path)
162+
# Test that a ValidationError is raised if the query doesn't match the schema
163+
production_rule = deepcopy(original_production_rule)[0]
164+
production_rule["metadata"]["integration"] = ["aws"]
165+
production_rule["rule"]["query"] = """
166+
from logs-aws.cloud*, logs-network_traffic.http-*,
167+
logs-nginx.access-* metadata _id, _version, _index
168+
| where @timestamp > now() - 30 minutes
169+
and aws.cloudtrail.user_identity.type == "IAMUser"
170+
| keep
171+
aws.*
172+
"""
173+
_ = RuleCollection().load_dict(production_rule)
174+
158175
def test_esql_endpoint_alerts_index(self):
159176
"""Test an ESQL rule's schema validation using ecs fields in the alerts index."""
160177
file_path = get_path(["tests", "data", "command_control_dummy_production_rule.toml"])

0 commit comments

Comments
 (0)