pytest-splunk-addon 5.2.6__tar.gz → 5.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. {pytest_splunk_addon-5.2.6 → pytest_splunk_addon-5.3.0}/PKG-INFO +1 -1
  2. {pytest_splunk_addon-5.2.6 → pytest_splunk_addon-5.3.0}/pyproject.toml +3 -3
  3. {pytest_splunk_addon-5.2.6 → pytest_splunk_addon-5.3.0}/pytest_splunk_addon/__init__.py +1 -1
  4. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/addon_parser/props_parser.py +3 -1
  5. {pytest_splunk_addon-5.2.6 → pytest_splunk_addon-5.3.0}/pytest_splunk_addon/plugin.py +4 -3
  6. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/sample_generation/rule.py +4 -1
  7. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/sample_generation/sample_xdist_generator.py +3 -5
  8. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/sample_generation/schema.xsd +2 -0
  9. {pytest_splunk_addon-5.2.6 → pytest_splunk_addon-5.3.0}/pytest_splunk_addon/splunk.py +48 -14
  10. {pytest_splunk_addon-5.2.6 → pytest_splunk_addon-5.3.0}/pytest_splunk_addon/standard_lib/addon_basic.py +4 -4
  11. {pytest_splunk_addon-5.2.6 → pytest_splunk_addon-5.3.0}/pytest_splunk_addon/tools/cim_field_report.py +1 -1
  12. pytest_splunk_addon-5.3.0/pytest_splunk_addon/utils.py +26 -0
  13. pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib/__init__.py +0 -37
  14. {pytest_splunk_addon-5.2.6 → pytest_splunk_addon-5.3.0}/LICENSE +0 -0
  15. {pytest_splunk_addon-5.2.6 → pytest_splunk_addon-5.3.0}/pytest_splunk_addon/.ignore_splunk_internal_errors +0 -0
  16. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/CIM_Models/__init__.py +0 -0
  17. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/CIM_Models/datamodel_definition.py +0 -0
  18. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/addon_parser/__init__.py +0 -0
  19. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/addon_parser/eventtype_parser.py +0 -0
  20. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/addon_parser/fields.py +0 -0
  21. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/addon_parser/savedsearches_parser.py +0 -0
  22. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/addon_parser/tags_parser.py +0 -0
  23. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/addon_parser/transforms_parser.py +0 -0
  24. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/app_test_generator.py +0 -0
  25. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_compliance/__init__.py +0 -0
  26. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_compliance/base_report.py +0 -0
  27. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_compliance/base_table.py +0 -0
  28. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_compliance/cim_report_generator.py +0 -0
  29. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_compliance/markdown_report.py +0 -0
  30. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_compliance/markdown_table.py +0 -0
  31. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_compliance/plugin.py +0 -0
  32. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/CommonFields.json +0 -0
  33. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/DatamodelSchema.json +0 -0
  34. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/__init__.py +0 -0
  35. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/base_schema.py +0 -0
  36. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/data_model.py +0 -0
  37. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/data_model_handler.py +0 -0
  38. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/data_set.py +0 -0
  39. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/field_test_adapter.py +0 -0
  40. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/field_test_helper.py +0 -0
  41. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/json_schema.py +0 -0
  42. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/test_generator.py +0 -0
  43. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/cim_tests/test_templates.py +0 -0
  44. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Alerts.json +0 -0
  45. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Authentication.json +0 -0
  46. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Certificates.json +0 -0
  47. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Change.json +0 -0
  48. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/DLP.json +0 -0
  49. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Email.json +0 -0
  50. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Endpoint.json +0 -0
  51. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Intrusion_Detection.json +0 -0
  52. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Malware.json +0 -0
  53. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Network_Resolution.json +0 -0
  54. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Network_Sessions.json +0 -0
  55. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Network_Traffic.json +0 -0
  56. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Updates.json +0 -0
  57. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Vulnerabilities.json +0 -0
  58. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/data_models/Web.json +0 -0
  59. {pytest_splunk_addon-5.2.6 → pytest_splunk_addon-5.3.0}/pytest_splunk_addon/docker_class.py +0 -0
  60. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/event_ingestors/__init__.py +0 -0
  61. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/event_ingestors/base_event_ingestor.py +0 -0
  62. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/event_ingestors/file_monitor_ingestor.py +0 -0
  63. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/event_ingestors/hec_event_ingestor.py +0 -0
  64. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/event_ingestors/hec_metric_ingestor.py +0 -0
  65. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/event_ingestors/hec_raw_ingestor.py +0 -0
  66. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/event_ingestors/ingestor_helper.py +0 -0
  67. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/event_ingestors/sc4s_event_ingestor.py +0 -0
  68. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/fields_tests/__init__.py +0 -0
  69. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/fields_tests/field_bank.py +0 -0
  70. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/fields_tests/requirement_test_datamodel_tag_constants.py +0 -0
  71. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/fields_tests/sample_parser.py +0 -0
  72. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/fields_tests/test_generator.py +0 -0
  73. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/fields_tests/test_templates.py +0 -0
  74. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/index_tests/__init__.py +0 -0
  75. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/index_tests/key_fields.py +0 -0
  76. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/index_tests/test_generator.py +0 -0
  77. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/index_tests/test_templates.py +0 -0
  78. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/sample_generation/__init__.py +0 -0
  79. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/sample_generation/pytest_splunk_addon_data_parser.py +0 -0
  80. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/sample_generation/sample_event.py +0 -0
  81. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/sample_generation/sample_generator.py +0 -0
  82. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/sample_generation/sample_stanza.py +0 -0
  83. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/sample_generation/time_parser.py +0 -0
  84. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/utilities/__init__.py +0 -0
  85. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/utilities/junit_parser.py +0 -0
  86. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/utilities/log_helper.py +0 -0
  87. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/utilities/sample_splitter.py +0 -0
  88. {pytest_splunk_addon-5.2.6/pytest_splunk_addon/standard_lib → pytest_splunk_addon-5.3.0/pytest_splunk_addon}/utilities/xml_event_parser.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytest-splunk-addon
3
- Version: 5.2.6
3
+ Version: 5.3.0
4
4
  Summary: A Dynamic test tool for Splunk Apps and Add-ons
5
5
  License: Apache-2.0
6
6
  Author: Splunk
@@ -16,7 +16,7 @@
16
16
 
17
17
  [tool.poetry]
18
18
  name = "pytest-splunk-addon"
19
- version = "5.2.6"
19
+ version = "5.3.0"
20
20
  description = "A Dynamic test tool for Splunk Apps and Add-ons"
21
21
  authors = ["Splunk <addonfactory@splunk.com>"]
22
22
  license = "APACHE-2.0"
@@ -59,9 +59,9 @@ pytz = "^2024.1"
59
59
  pytest11 = { plugin = "pytest_splunk_addon.plugin", "splunk" = "pytest_splunk_addon.splunk" }
60
60
 
61
61
  [tool.poetry.scripts]
62
- cim-report = 'pytest_splunk_addon.standard_lib.utilities.junit_parser:main'
62
+ cim-report = 'pytest_splunk_addon.utilities.junit_parser:main'
63
63
  cim-field-report = 'pytest_splunk_addon.tools.cim_field_report:main'
64
- sample_splitter = 'pytest_splunk_addon.standard_lib.utilities.sample_splitter:main'
64
+ sample_splitter = 'pytest_splunk_addon.utilities.sample_splitter:main'
65
65
 
66
66
  [build-system]
67
67
  requires = ["poetry>=1.0.2"]
@@ -18,4 +18,4 @@
18
18
 
19
19
  __author__ = """Splunk Inc."""
20
20
  __email__ = "addonfactory@splunk.com"
21
- __version__ = "5.2.6"
21
+ __version__ = "5.3.0"
@@ -28,6 +28,7 @@ import addonfactory_splunk_conf_parser_lib as conf_parser
28
28
 
29
29
  from .fields import convert_to_fields
30
30
  from .transforms_parser import TransformsParser
31
+ from pytest_splunk_addon import utils
31
32
 
32
33
  LOGGER = logging.getLogger("pytest-splunk-addon")
33
34
 
@@ -110,7 +111,8 @@ class PropsParser(object):
110
111
  LOGGER.info(f"Matched method of type={each_type}")
111
112
  return method_mapping[each_type]
112
113
  else:
113
- LOGGER.warning(f"No parser available for {class_name}. Skipping...")
114
+ if utils.check_first_worker():
115
+ LOGGER.warning(f"No parser available for {class_name}. Skipping...")
114
116
 
115
117
  def _get_props_stanzas(self) -> Optional[Generator]:
116
118
  """
@@ -15,10 +15,11 @@
15
15
  #
16
16
  import logging
17
17
  import pytest
18
- from .standard_lib.sample_generation.sample_xdist_generator import SampleXdistGenerator
18
+
19
+ from .app_test_generator import AppTestGenerator
20
+ from .sample_generation.sample_xdist_generator import SampleXdistGenerator
19
21
  import traceback
20
- from .standard_lib import AppTestGenerator
21
- from .standard_lib.cim_compliance import CIMReportPlugin
22
+ from .cim_compliance import CIMReportPlugin
22
23
  from filelock import FileLock
23
24
 
24
25
  LOG_FILE = "pytest_splunk_addon.log"
@@ -934,6 +934,8 @@ class UrlRule(Rule):
934
934
  url = self.fake.url()
935
935
 
936
936
  if bool(set(["full", "path"]).intersection(value_list)):
937
+ if value_list == ["path"]:
938
+ url = ""
937
939
  url = (
938
940
  url
939
941
  + "/"
@@ -944,8 +946,9 @@ class UrlRule(Rule):
944
946
  ]
945
947
  )
946
948
  )
947
-
948
949
  if bool(set(["full", "query"]).intersection(value_list)):
950
+ if value_list == ["query"]:
951
+ url = ""
949
952
  url = url + self.generate_url_query_params()
950
953
  yield self.token_value(*([str(url)] * 2))
951
954
  else:
@@ -20,6 +20,8 @@ from filelock import FileLock
20
20
  import json
21
21
  import pytest
22
22
 
23
+ from pytest_splunk_addon import utils
24
+
23
25
 
24
26
  class SampleXdistGenerator:
25
27
  def __init__(self, addon_path, config_path=None, process_count=4):
@@ -28,14 +30,10 @@ class SampleXdistGenerator:
28
30
  self.config_path = config_path
29
31
 
30
32
  def get_samples(self, store_events):
31
-
32
33
  if self.tokenized_event_source == "pregenerated":
33
34
  with open(self.event_path, "rb") as file_obj:
34
35
  store_sample = pickle.load(file_obj)
35
- if store_events and (
36
- "PYTEST_XDIST_WORKER" not in os.environ
37
- or os.environ.get("PYTEST_XDIST_WORKER") == "gw0"
38
- ):
36
+ if store_events and utils.check_first_worker():
39
37
  try:
40
38
  tokenized_events = store_sample.get("tokenized_events")
41
39
  self.store_events(tokenized_events)
@@ -83,6 +83,7 @@
83
83
  </xs:sequence>
84
84
  </xs:complexType>
85
85
  </xs:element>
86
+ <xs:element type="xs:string" name="note" minOccurs="0" />
86
87
  <xs:element type="xs:string" name="raw"/>
87
88
  <xs:element name="cim">
88
89
  <xs:complexType>
@@ -103,6 +104,7 @@
103
104
  <xs:extension base="xs:string">
104
105
  <xs:attribute type="xs:string" name="name" use="optional"/>
105
106
  <xs:attribute type="xs:string" name="value" use="optional"/>
107
+ <xs:attribute type="xs:string" name="note" use="optional"/>
106
108
  </xs:extension>
107
109
  </xs:simpleContent>
108
110
  </xs:complexType>
@@ -26,12 +26,14 @@ import splunklib.client as client
26
26
  from splunksplwrapper.manager.jobs import Jobs
27
27
  from splunksplwrapper.splunk.cloud import CloudSplunk
28
28
  from splunksplwrapper.SearchUtil import SearchUtil
29
- from .standard_lib.event_ingestors import IngestorHelper
29
+ from .event_ingestors import IngestorHelper
30
30
  from .docker_class import Services
31
- from .standard_lib.CIM_Models.datamodel_definition import datamodels
31
+ from .CIM_Models.datamodel_definition import datamodels
32
32
  import configparser
33
33
  from filelock import FileLock
34
34
 
35
+ from pytest_splunk_addon import utils
36
+
35
37
  RESPONSIVE_SPLUNK_TIMEOUT = 300 # seconds
36
38
 
37
39
  LOGGER = logging.getLogger("pytest-splunk-addon")
@@ -637,6 +639,7 @@ def splunk_external(request):
637
639
  "Could not connect to Splunk HEC"
638
640
  "Please check the log file for possible errors."
639
641
  )
642
+ is_valid_hec(request, splunk_info)
640
643
  return splunk_info
641
644
 
642
645
 
@@ -732,10 +735,7 @@ def splunk_ingest_data(request, splunk_hec_uri, sc4s, uf, splunk_events_cleanup)
732
735
  if request.config.getoption("ingest_events").lower() in ["n", "no", "false", "f"]:
733
736
  return
734
737
  global PYTEST_XDIST_TESTRUNUID
735
- if (
736
- "PYTEST_XDIST_WORKER" not in os.environ
737
- or os.environ.get("PYTEST_XDIST_WORKER") == "gw0"
738
- ):
738
+ if utils.check_first_worker():
739
739
  addon_path = request.config.getoption("splunk_app")
740
740
  config_path = request.config.getoption("splunk_data_generator")
741
741
  ingest_meta_data = {
@@ -783,10 +783,7 @@ def splunk_events_cleanup(request, splunk_search_util):
783
783
 
784
784
  """
785
785
  if request.config.getoption("splunk_cleanup"):
786
- if (
787
- "PYTEST_XDIST_WORKER" not in os.environ
788
- or os.environ.get("PYTEST_XDIST_WORKER") == "gw0"
789
- ):
786
+ if utils.check_first_worker():
790
787
  LOGGER.info("Running the old events cleanup")
791
788
  splunk_search_util.deleteEventsFromIndex()
792
789
  else:
@@ -801,10 +798,7 @@ def file_system_prerequisite():
801
798
  """
802
799
  UF_FILE_MONTOR_DIR = "uf_files"
803
800
  monitor_dir = os.path.join(os.getcwd(), UF_FILE_MONTOR_DIR)
804
- if (
805
- "PYTEST_XDIST_WORKER" not in os.environ
806
- or os.environ.get("PYTEST_XDIST_WORKER") == "gw0"
807
- ):
801
+ if utils.check_first_worker():
808
802
  if os.path.exists(monitor_dir):
809
803
  shutil.rmtree(monitor_dir, ignore_errors=True)
810
804
  os.mkdir(monitor_dir)
@@ -842,6 +836,16 @@ def splunk_dm_recommended_fields():
842
836
  return update_recommended_fields
843
837
 
844
838
 
839
+ @pytest.hookimpl(hookwrapper=True)
840
+ def pytest_runtest_makereport(item):
841
+ """
842
+ Show user properties in report only in case of failure
843
+ """
844
+ output = yield
845
+ if output.get_result().outcome == "passed":
846
+ item.user_properties = []
847
+
848
+
845
849
  @pytest.fixture(scope="session")
846
850
  def docker_ip():
847
851
  """Determine IP address for TCP connections to Docker containers."""
@@ -1013,6 +1017,36 @@ def is_responsive(url):
1013
1017
  return False
1014
1018
 
1015
1019
 
1020
+ def is_valid_hec(request, splunk):
1021
+ """
1022
+ Verify if provided hec token is valid by sending simple post request.
1023
+
1024
+ Args:
1025
+ splunk (dict): details of the Splunk instance
1026
+
1027
+ Returns:
1028
+ None
1029
+ """
1030
+
1031
+ LOGGER.info(
1032
+ "Validating HEC token... splunk=%s",
1033
+ json.dumps(splunk),
1034
+ )
1035
+ response = requests.post(
1036
+ url=f'{request.config.getoption("splunk_hec_scheme")}://{splunk["forwarder_host"]}:{splunk["port_hec"]}/services/collector/raw',
1037
+ headers={
1038
+ "Authorization": f'Splunk {request.config.getoption("splunk_hec_token")}'
1039
+ },
1040
+ data={"event": "test_hec", "sourcetype": "hec_token_test"},
1041
+ verify=False,
1042
+ )
1043
+ LOGGER.debug("Status code: {}".format(response.status_code))
1044
+ if response.status_code == 200:
1045
+ LOGGER.info("Splunk HEC is valid.")
1046
+ else:
1047
+ pytest.exit("Exiting pytest due to invalid HEC token value.")
1048
+
1049
+
1016
1050
  def pytest_unconfigure(config):
1017
1051
  if PYTEST_XDIST_TESTRUNUID:
1018
1052
  if os.path.exists(PYTEST_XDIST_TESTRUNUID + "_wait"):
@@ -19,10 +19,10 @@ Base class for test cases. Provides test cases to verify
19
19
  field extractions and CIM compatibility.
20
20
  """
21
21
 
22
- from .fields_tests import FieldTestTemplates
23
- from .cim_tests import CIMTestTemplates
24
- from .index_tests import IndexTimeTestTemplate
25
- from .utilities.log_helper import get_table_output
22
+ from ..fields_tests import FieldTestTemplates
23
+ from ..cim_tests import CIMTestTemplates
24
+ from ..index_tests import IndexTimeTestTemplate
25
+ from ..utilities.log_helper import get_table_output
26
26
  import pytest
27
27
 
28
28
 
@@ -25,7 +25,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
25
25
 
26
26
  from splunksplwrapper.manager.jobs import Jobs
27
27
  from splunksplwrapper.splunk.cloud import CloudSplunk
28
- from pytest_splunk_addon.standard_lib.addon_parser import AddonParser
28
+ from pytest_splunk_addon.addon_parser import AddonParser
29
29
 
30
30
  from splunklib import binding
31
31
 
@@ -0,0 +1,26 @@
1
+ #
2
+ # Copyright 2024 Splunk Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import os
17
+
18
+
19
+ def check_first_worker() -> bool:
20
+ """
21
+ returns True if the current execution is under gw0 (first worker)
22
+ """
23
+ return (
24
+ "PYTEST_XDIST_WORKER" not in os.environ
25
+ or os.environ.get("PYTEST_XDIST_WORKER") == "gw0"
26
+ )
@@ -1,37 +0,0 @@
1
- #
2
- # Copyright 2024 Splunk Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- # -*- coding: utf-8 -*-
17
- """
18
- There are 3 types of tests included:
19
-
20
- 1. Knowledge objects test cases
21
- 2. CIM Compatibility test cases
22
- 3. Index Time test cases
23
-
24
-
25
- The test generation mechanism is divided into 3 types of class
26
-
27
- 1. Tests: Test templates
28
- 2. TestGenerator: Generates the test cases using pytest.params
29
- 3. SampleGenerator: Generates the data for which the test cases will be executed.
30
- 4. EventIngestor: Ingests the generated data to Splunk.
31
- 5. Other utility classes like Add-on parser & Data model handlers.
32
-
33
- """
34
-
35
- from .app_test_generator import AppTestGenerator
36
- from .addon_basic import Basic
37
- from .utilities import escape_char_event