Skip to content

Commit a7d18e9

Browse files
feat: add support for ipv6 in web.settings.mgmtHostPort stanza (#205)
* feat: add support for ipv6 in web.settings.mgmtHostPort stanza (#201) It seems that you can add ipv6 string for web.settings.mgmtHostPort stanza. Docs: https://docs.splunk.com/Documentation/Splunk/9.0.0/Admin/ConfigureSplunkforIPv6 * chore(release): 4.8.0-beta.1 # [4.8.0-beta.1](v4.7.0...v4.8.0-beta.1) (2022-09-20) ### Features * add support for ipv6 in web.settings.mgmtHostPort stanza ([#201](#201)) ([446606e](446606e)) Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
1 parent 490f77f commit a7d18e9

File tree

4 files changed

+78
-9
lines changed

4 files changed

+78
-9
lines changed

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 = "solnlib"
19-
version = "4.7.0"
19+
version = "4.8.0-beta.1"
2020
description = "The Splunk Software Development Kit for Splunk Solutions"
2121
authors = ["Splunk <addonfactory@splunk.com>"]
2222
license = "Apache-2.0"

solnlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@
5454
"utils",
5555
]
5656

57-
__version__ = "4.7.0"
57+
__version__ = "4.8.0-beta.1"

solnlib/splunkenv.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ def get_splunkd_access_info() -> Tuple[str, str, int]:
184184

185185
host_port = get_conf_key_value("web", "settings", "mgmtHostPort")
186186
host_port = host_port.strip()
187-
host = host_port.split(":")[0]
188-
port = int(host_port.split(":")[1])
187+
host_port_split_parts = host_port.split(":")
188+
host = ":".join(host_port_split_parts[:-1])
189+
port = int(host_port_split_parts[-1])
189190

190191
if "SPLUNK_BINDIP" in os.environ:
191192
bindip = os.environ["SPLUNK_BINDIP"]

tests/unit/test_splunkenv.py

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
#
1616

1717
import os
18+
from unittest import mock
1819

1920
import common
21+
import pytest
2022

2123
from solnlib import splunkenv
2224

@@ -47,13 +49,79 @@ def test_splunk_bin(monkeypatch):
4749
)
4850

4951

50-
def test_get_splunkd_access_info(monkeypatch):
51-
common.mock_splunkhome(monkeypatch)
52+
@mock.patch.object(splunkenv, "get_conf_key_value")
53+
@pytest.mark.parametrize(
54+
"enable_splunkd_ssl,mgmt_host_port,expected_scheme,expected_host,expected_port",
55+
[
56+
(
57+
"true",
58+
"127.0.0.1:8089",
59+
"https",
60+
"127.0.0.1",
61+
8089,
62+
),
63+
(
64+
"true",
65+
"localhost:8089",
66+
"https",
67+
"localhost",
68+
8089,
69+
),
70+
(
71+
"false",
72+
"127.0.0.1:8089",
73+
"http",
74+
"127.0.0.1",
75+
8089,
76+
),
77+
(
78+
"false",
79+
"localhost:8089",
80+
"http",
81+
"localhost",
82+
8089,
83+
),
84+
(
85+
"false",
86+
"1.2.3.4:5678",
87+
"http",
88+
"1.2.3.4",
89+
5678,
90+
),
91+
(
92+
"true",
93+
"[::1]:8089",
94+
"https",
95+
"[::1]",
96+
8089,
97+
),
98+
(
99+
"false",
100+
"[::1]:8089",
101+
"http",
102+
"[::1]",
103+
8089,
104+
),
105+
],
106+
)
107+
def test_get_splunkd_access_info(
108+
mock_get_conf_key_value,
109+
enable_splunkd_ssl,
110+
mgmt_host_port,
111+
expected_scheme,
112+
expected_host,
113+
expected_port,
114+
):
115+
mock_get_conf_key_value.side_effect = [
116+
enable_splunkd_ssl,
117+
mgmt_host_port,
118+
]
52119

53120
scheme, host, port = splunkenv.get_splunkd_access_info()
54-
assert scheme == "https"
55-
assert host == "127.0.0.1"
56-
assert port == 8089
121+
122+
assert expected_scheme == scheme
123+
assert expected_host == host
124+
assert expected_port == port
57125

58126

59127
def test_splunkd_uri(monkeypatch):

0 commit comments

Comments
 (0)