Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: requirement test generation #893

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pytest_splunk_addon/cim_tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ def generate_recommended_fields_tests(self):
3. yield object with datamodel, dataset, cim_version and list of fields
"""
for event in self.tokenized_events:
if not event.requirement_test_data:
if (
not event.requirement_test_data
or event.requirement_test_data.keys() == {"other_fields"}
):
continue
for _, datamodels in event.requirement_test_data["datamodels"].items():
if type(datamodels) is not list:
Expand Down
5 changes: 4 additions & 1 deletion pytest_splunk_addon/fields_tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ def generate_requirements_datamodels_tests(self):
pytest.params for the test templates
"""
for event in self.tokenized_events:
if not event.requirement_test_data:
if (
not event.requirement_test_data
or event.requirement_test_data.keys() == {"other_fields"}
):
continue
if event.metadata.get("input_type", "").startswith("syslog"):
stripped_event = xml_event_parser.strip_syslog_header(event.event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,23 @@
<field name="vendor_product" value="Pytest Splunk Addon"/>
</other_mappings>
</event>
</device>
<event code="" name="UnmappedEvent" format="">
<transport type="modinput" sourcetype="test:data:1" source="test_data.1" host="so1" />
<source>
<jira id="" />
<comment>lab</comment>
</source>
<raw><![CDATA[2021-12-31 15:15:30,340+0000 ip=1.1.1.1 tester=admin result=failed]]></raw>
<cim>
</cim>
<other_mappings>
<field name="action" value="failed" />
<field name="status" value="OTHER" />
<field name="app" value="psa" />
<field name="src" value="1.1.1.1" />
<field name="user" value="admin" />
<field name="dest" value="so1" />
<field name="vendor_product" value="Pytest Splunk Addon"/>
</other_mappings>
</event>
</device>
2 changes: 2 additions & 0 deletions tests/e2e/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@
"*test_splunk_app_req.py::Test_App::test_indextime_time[test:data:1::* PASSED*",
"*test_splunk_app_req.py::Test_App::test_indextime_time[test:data:1::* PASSED*",
"*test_splunk_app_req.py::Test_App::test_indextime_time[test:data:1::* PASSED*",
"*test_splunk_app_req.py::Test_App::test_indextime_time[test:data:1::* PASSED*",
"*test_splunk_app_req.py::Test_App::test_indextime_line_breaker[test:data:1::sample_modinput.xml* PASSED*",
'*test_splunk_app_req.py::Test_App::test_cim_required_fields[eventtype="test_auth"::Authentication* PASSED*',
'*test_splunk_app_req.py::Test_App::test_cim_required_fields[eventtype="test_auth"::Authentication::action* PASSED*',
Expand Down Expand Up @@ -802,6 +803,7 @@
"*test_splunk_app_req.py::Test_App::test_requirements_fields[sample_name::sample_modinput.xml::host::so1-4* PASSED*",
"*test_splunk_app_req.py::Test_App::test_requirements_fields[sample_name::sample_modinput.xml::host::so1-5* PASSED*",
"*test_splunk_app_req.py::Test_App::test_requirements_fields[sample_name::sample_modinput.xml::host::so1-6* PASSED*",
"*test_splunk_app_req.py::Test_App::test_requirements_fields[sample_name::sample_modinput.xml::host::so1* PASSED*",
"*test_splunk_app_req.py::Test_App::test_props_fields_no_dash_not_empty[test:data:1::field::action* PASSED*",
"*test_splunk_app_req.py::Test_App::test_props_fields_no_dash_not_empty[test:data:1::field::app* PASSED*",
"*test_splunk_app_req.py::Test_App::test_props_fields_no_dash_not_empty[test:data:1::field::dest* PASSED*",
Expand Down
Loading