Skip to content
Merged
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
70 changes: 70 additions & 0 deletions tests/test_docker_splunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,76 @@ def test_adhoc_1uf_change_tailed_files(self):
if cid:
self.client.remove_container(cid, v=True, force=True)

def test_adhoc_1so_splunk_secret_env(self):
# Create a splunk container
cid = None
try:
splunk_container_name = generate_random_string()
cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, ports=[8089], name=splunk_container_name,
environment={
"DEBUG": "true",
"SPLUNK_START_ARGS": "--accept-license",
"SPLUNK_PASSWORD": self.password,
"SPLUNK_SECRET": "wubbalubbadubdub"
},
host_config=self.client.create_host_config(port_bindings={8089: ("0.0.0.0",)})
)
cid = cid.get("Id")
self.client.start(cid)
# Poll for the container to be ready
assert self.wait_for_containers(1, name=splunk_container_name)
# Check splunkd
splunkd_port = self.client.port(cid, 8089)[0]["HostPort"]
url = "https://localhost:{}/services/server/info".format(splunkd_port)
kwargs = {"auth": ("admin", self.password), "verify": False}
status, content = self.handle_request_retry("GET", url, kwargs)
assert status == 200
# Check if the created file exists
exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/auth/splunk.secret", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "wubbalubbadubdub" in std_out
except Exception as e:
self.logger.error(e)
raise e
finally:
if cid:
self.client.remove_container(cid, v=True, force=True)

def test_adhoc_1uf_splunk_secret_env(self):
# Create a uf container
cid = None
try:
splunk_container_name = generate_random_string()
cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, ports=[8089], name=splunk_container_name,
environment={
"DEBUG": "true",
"SPLUNK_START_ARGS": "--accept-license",
"SPLUNK_PASSWORD": self.password,
"SPLUNK_SECRET": "wubbalubbadubdub"
},
host_config=self.client.create_host_config(port_bindings={8089: ("0.0.0.0",)})
)
cid = cid.get("Id")
self.client.start(cid)
# Poll for the container to be ready
assert self.wait_for_containers(1, name=splunk_container_name)
# Check splunkd
splunkd_port = self.client.port(cid, 8089)[0]["HostPort"]
url = "https://localhost:{}/services/server/info".format(splunkd_port)
kwargs = {"auth": ("admin", self.password), "verify": False}
status, content = self.handle_request_retry("GET", url, kwargs)
assert status == 200
# Check if the created file exists
exec_command = self.client.exec_create(cid, "cat /opt/splunkforwarder/etc/auth/splunk.secret", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "wubbalubbadubdub" in std_out
except Exception as e:
self.logger.error(e)
raise e
finally:
if cid:
self.client.remove_container(cid, v=True, force=True)

def test_adhoc_1so_preplaybook_with_sudo(self):
# Create a splunk container
cid = None
Expand Down