@@ -206,6 +206,11 @@ def ca_contenthost(rhel_contenthost):
206206 return (rhel_contenthost , f'{ ca_path } .pub' )
207207
208208
209+ @pytest .fixture
210+ def host_ca_file_on_satellite (ca_contenthost ):
211+ return f'/var/lib/foreman-proxy/ssh/{ ca_contenthost [1 ].split ("/" )[- 1 ]} '
212+
213+
209214def register_host (satellite , host ):
210215 org = satellite .cli .Org .create ({'name' : gen_string ('alpha' )})
211216 # repo = settings.repos['SATCLIENT_REPO'][f'RHEL{host.os_version.major}']
@@ -252,6 +257,12 @@ def log_compare(satellite, host):
252257 ).status
253258
254259
260+ def copy_host_CA (host , satellite , host_path , satellite_path ):
261+ host_ca_file_local = f'/tmp/{ gen_string ("alpha" )} '
262+ host .get (host_path , host_ca_file_local )
263+ satellite .put (host_ca_file_local , satellite_path )
264+
265+
255266@pytest .mark .no_containers
256267@pytest .mark .rhel_ver_match ([settings .content_host .default_rhel_version ])
257268def test_positive_ssh_ca_sat_only (ca_sat , rhel_contenthost ):
@@ -260,55 +271,78 @@ def test_positive_ssh_ca_sat_only(ca_sat, rhel_contenthost):
260271 sat_ca_file = ca_sat [1 ]
261272 log_save (sat , host )
262273 command = InstallerCommand (
263- foreman_proxy_plugin_remote_execution_script_ssh_user_ca_public_key_file = sat_ca_file ,
274+ foreman_proxy_plugin_remote_execution_script_ssh_user_ca_public_keys_file = sat_ca_file ,
264275 )
265276 assert sat .install (command ).status == 0
266277 register_host (sat , host )
267278 result = test_execution (sat , host )
268279 # assert the run actually happened and it was authenticated using cert
269- result = sat .execute ('grep rex_passed /root/test' )
270280 assert result .status == 0
271281 logger .debug (result )
272282 assert log_compare (sat , host ) == 0
283+ check = host .execute ('grep rex_passed /root/test' )
284+ assert check .status == 0
273285
274286
275287@pytest .mark .no_containers
276288@pytest .mark .rhel_ver_match ([settings .content_host .default_rhel_version ])
277- def test_positive_ssh_ca_host_only (target_sat , ca_contenthost ):
289+ def test_positive_ssh_ca_host_only (target_sat , ca_contenthost , host_ca_file_on_satellite ):
278290 sat = target_sat
279291 host = ca_contenthost [0 ]
280292 host_ca_file = ca_contenthost [1 ]
281- host_ca_cert = host .execute (f'cat { host_ca_file } ' ).stdout .strip ()
293+ copy_host_CA (host , sat , host_ca_file , host_ca_file_on_satellite )
294+ log_save (sat , host )
282295 command = InstallerCommand (
283- foreman_proxy_plugin_remote_execution_script_ssh_host_ca_public_key = f'" { host_ca_cert } "' ,
296+ foreman_proxy_plugin_remote_execution_script_ssh_host_ca_public_keys_file = host_ca_file_on_satellite ,
284297 )
285298 assert sat .install (command ).status == 0
286299 register_host (sat , host )
287300 result = test_execution (sat , host )
288301 # assert the run actually happened and it was NOT authenticated using cert
289- result = sat .execute ('grep rex_passed /root/test' )
290- assert result .status == 0
302+ assert result ['success' ] == '1'
291303 logger .debug (result )
292304 assert log_compare (sat , host ) != 0
305+ check = host .execute ('grep rex_passed /root/test' )
306+ assert check .status == 0
293307
294308
295309@pytest .mark .no_containers
296310@pytest .mark .rhel_ver_match ([settings .content_host .default_rhel_version ])
297- def test_positive_ssh_ca_sat_and_host (ca_sat , ca_contenthost ):
311+ def test_positive_ssh_ca_sat_and_host (ca_sat , ca_contenthost , host_ca_file_on_satellite ):
298312 sat = ca_sat [0 ]
299313 sat_ca_file = ca_sat [1 ]
300314 host = ca_contenthost [0 ]
301315 host_ca_file = ca_contenthost [1 ]
302- host_ca_cert = host .execute (f'cat { host_ca_file } ' ).stdout .strip ()
316+ copy_host_CA (host , sat , host_ca_file , host_ca_file_on_satellite )
317+ log_save (sat , host )
303318 command = InstallerCommand (
304319 foreman_proxy_plugin_remote_execution_script_ssh_user_ca_public_key_file = sat_ca_file ,
305- foreman_proxy_plugin_remote_execution_script_ssh_host_ca_public_key = f'" { host_ca_cert } "' ,
320+ foreman_proxy_plugin_remote_execution_script_ssh_host_ca_public_keys_file = host_ca_file_on_satellite ,
306321 )
307322 assert sat .install (command ).status == 0
308323 register_host (sat , host )
324+ # SSH REX
309325 result = test_execution (sat , host )
310326 # assert the run actually happened and it was authenticated using cert
311- result = sat .execute ('grep rex_passed /root/test' )
312- assert result .status == 0
327+ assert result ['success' ] == '1'
328+ logger .debug (result )
329+ assert log_compare (sat , host ) == 0
330+ check = host .execute ('grep rex_passed /root/test' )
331+ assert check .status == 0
332+ # ANSIBLE REX
333+ log_save (sat , host )
334+ command = "echo rex2_passed $(date) > /root/test"
335+ invocation_command = sat .cli_factory .job_invocation (
336+ {
337+ 'job-template' : 'Run Command - Ansible Default' ,
338+ 'inputs' : f'command={ command } ' ,
339+ 'search-query' : f'name ~ { host .hostname } ' ,
340+ }
341+ )
342+ result = sat .cli .JobInvocation .info ({'id' : invocation_command ['id' ]})
343+ # assert the run actually happened and it was authenticated using cert
344+ assert result ['success' ] == '1'
313345 logger .debug (result )
314346 assert log_compare (sat , host ) == 0
347+ check = host .execute ('grep rex2_passed /root/test' )
348+ assert check .status == 0
0 commit comments