Skip to content

Commit ba80bb5

Browse files
committed
Implement feedback
1 parent c870261 commit ba80bb5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/foreman/destructive/test_remoteexecution.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def test_positive_use_alternate_directory(
141141

142142

143143
def create_CA(host, path='/root/CA', name=None):
144+
"""Create a new CA keypair"""
144145
assert host.execute(f'mkdir -p {path}').status == 0
145146
filename = 'id_ca' if name is None else f'id_{name}_ca'
146147
assert (
@@ -154,6 +155,7 @@ def create_CA(host, path='/root/CA', name=None):
154155

155156
@pytest.fixture
156157
def ca_sat(target_sat):
158+
"""Setup SSH key certs and CA public key on Satellite"""
157159
path = "/root/CA"
158160
sat_ssh_path = '/var/lib/foreman-proxy/ssh/'
159161
filename = create_CA(target_sat, path)
@@ -177,6 +179,7 @@ def ca_sat(target_sat):
177179

178180
@pytest.fixture
179181
def ca_contenthost(rhel_contenthost):
182+
"""Setup SSH key certs and CA public key on content host"""
180183
path = '/root/CA'
181184
host_ssh_path = '/etc/ssh'
182185
filename = create_CA(rhel_contenthost, path, 'host')
@@ -186,7 +189,7 @@ def ca_contenthost(rhel_contenthost):
186189
cert_name = f'{key_name}-cert.pub'
187190
assert (
188191
rhel_contenthost.execute(
189-
f'cd {host_ssh_path} && if ! [ -f ssh_host_ed25519_key ]; then ssh-keygen -t ed25519 -f {key_name} -N ""; fi'
192+
f'cd {host_ssh_path} && if ! [ -f {key_name} ]; then ssh-keygen -t ed25519 -f {key_name} -N ""; fi'
190193
).status
191194
== 0
192195
)
@@ -209,10 +212,12 @@ def ca_contenthost(rhel_contenthost):
209212

210213
@pytest.fixture
211214
def host_ca_file_on_satellite(ca_contenthost):
215+
"""Return path of CA public key on Satellite"""
212216
return f'/var/lib/foreman-proxy/ssh/{ca_contenthost[1].split("/")[-1]}'
213217

214218

215219
def register_host(satellite, host, cockpit=False):
220+
"""Register a content host to Satellite"""
216221
org = satellite.api.Organization().create()
217222
if cockpit:
218223
rhelver = host.os_version.major
@@ -227,6 +232,7 @@ def register_host(satellite, host, cockpit=False):
227232

228233

229234
def test_execution(satellite, host):
235+
"""Run a job invocation and return its results"""
230236
command = "echo rex_passed $(date) > /root/test"
231237
invocation_command = satellite.cli_factory.job_invocation(
232238
{
@@ -239,18 +245,25 @@ def test_execution(satellite, host):
239245

240246

241247
def log_save(satellite, host):
248+
"""Save a number of lines mentioning CA was used in sshd log,
249+
for later use
250+
"""
242251
host.execute(
243252
f'journalctl -u sshd | grep {satellite.ip_addr} | grep CA | wc -l > /root/saved_sshd_log'
244253
)
245254

246255

247256
def log_compare(satellite, host):
257+
"""Compare a number of lines mentioning CA was used in sshd log
258+
with previously stored value
259+
"""
248260
return host.execute(
249261
f'[ $(( $(cat /root/saved_sshd_log) + 1 )) -eq $(journalctl -u sshd | grep {satellite.ip_addr} | grep " CA " | wc -l) ]'
250262
).status
251263

252264

253265
def copy_host_CA(host, satellite, host_path, satellite_path):
266+
"""Copy CA public key from host to Satellite (for use in installer)"""
254267
host_ca_file_local = f'/tmp/{gen_string("alpha")}'
255268
host.get(host_path, host_ca_file_local)
256269
satellite.put(host_ca_file_local, satellite_path)

0 commit comments

Comments
 (0)