Skip to content

Commit

Permalink
chore: add e2e test for only other_mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
dvarasani-crest committed Oct 23, 2024
1 parent b31fca1 commit 37b0b14
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pytest_splunk_addon/cim_tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ 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 or (
len(event.requirement_test_data) == 1
and "other_fields" in 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():
Expand Down
6 changes: 3 additions & 3 deletions pytest_splunk_addon/fields_tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def generate_requirements_datamodels_tests(self):
pytest.params for the test templates
"""
for event in self.tokenized_events:
if not event.requirement_test_data or (
len(event.requirement_test_data) == 1
and "other_fields" in 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"):
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>
<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

0 comments on commit 37b0b14

Please sign in to comment.