Skip to content

Commit c8510f3

Browse files
Merge branch 'main' into develop
2 parents 575c440 + f754cf1 commit c8510f3

File tree

5 files changed

+53
-12
lines changed

5 files changed

+53
-12
lines changed

NOTICE

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
The following 3rd-party software packages may be used by or distributed with pytest-splunk-addon. Any information relevant to third-party vendors listed below are collected using common, reasonable means.
99

10-
Date generated: 2024-7-24
10+
Date generated: 2024-8-7
1111

12-
Revision ID: b2f6dc5b09c05a3eef5f7973cbf38c55ca498db3
12+
Revision ID: ec9101152540485a3cc7b35fbea07c1ea7a5e06d
1313

1414
================================================================================
1515
================================================================================
@@ -3005,7 +3005,7 @@ PERFORMANCE OF THIS SOFTWARE.
30053005

30063006

30073007
--------------------------------------------------------------------------------
3008-
Package Title: urllib3 (1.26.18)
3008+
Package Title: urllib3 (1.26.19)
30093009
--------------------------------------------------------------------------------
30103010

30113011
* Declared Licenses *
@@ -6010,10 +6010,10 @@ Copyright (c) JS Foundation and other contributors
60106010

60116011
Copyright (c) 2008-2020 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
60126012

6013-
Copyright (c) 2012 Senko Rasic <[email protected]>
6014-
60156013
Copyright (c) 2015-2016 Will Bond <[email protected]>
60166014

6015+
Copyright (c) 2012 Senko Rasic <[email protected]>
6016+
60176017
Copyright (c) 2019 TAHRI Ahmed R.
60186018

60196019
Copyright (c) Ahmed TAHRI @Ousret](https://github.com/Ousret).<br
@@ -6327,4 +6327,4 @@ Public Domain
63276327
--------------------------------------------------------------------------------
63286328
--------------------------------------------------------------------------------
63296329

6330-
Report Generated by FOSSA on 2024-7-24
6330+
Report Generated by FOSSA on 2024-8-7

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
[tool.poetry]
1818
name = "pytest-splunk-addon"
19-
version = "5.3.0-beta.10"
19+
version = "5.3.0"
2020
description = "A Dynamic test tool for Splunk Apps and Add-ons"
2121
authors = ["Splunk <[email protected]>"]
2222
license = "APACHE-2.0"

pytest_splunk_addon/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818

1919
__author__ = """Splunk Inc."""
2020
__email__ = "[email protected]"
21-
__version__ = "5.3.0-beta.10"
21+
__version__ = "5.3.0"

pytest_splunk_addon/splunk.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ def splunk_external(request):
639639
"Could not connect to Splunk HEC"
640640
"Please check the log file for possible errors."
641641
)
642+
is_valid_hec(request, splunk_info)
642643
return splunk_info
643644

644645

@@ -835,6 +836,16 @@ def update_recommended_fields(model, datasets, cim_version):
835836
return update_recommended_fields
836837

837838

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+
838849
@pytest.fixture(scope="session")
839850
def docker_ip():
840851
"""Determine IP address for TCP connections to Docker containers."""
@@ -1006,6 +1017,36 @@ def is_responsive(url):
10061017
return False
10071018

10081019

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+
10091050
def pytest_unconfigure(config):
10101051
if PYTEST_XDIST_TESTRUNUID:
10111052
if os.path.exists(PYTEST_XDIST_TESTRUNUID + "_wait"):

0 commit comments

Comments
 (0)