@@ -192,7 +192,7 @@ def from_fixture(cls, pytest_module_fixture, pytest_interpreter_fixture):
192
192
193
193
# TODO: To make this dynamic, we need to update AC and then also test with the new fixture because
194
194
# the legacy fixture is using a VOLUMES keyword while raw fixture uses extra_args. Best to move
195
- # volumes to extra_args.
195
+ # volumes to extra_args.
196
196
volumes = "000000,222222"
197
197
hostpattern = pytest_module_fixture ["options" ]["host_pattern" ]
198
198
return cls (model_user , remote_host , zoau_path , pyz_path , pythonpath , volumes , python_interpreter , hostpattern )
@@ -489,12 +489,15 @@ def execute_managed_user_become_test(self, managed_user_test_case: str, become_m
489
489
capture = " -s"
490
490
verbosity = " -vvvv"
491
491
492
+ escaped_user = re .escape (self ._managed_racf_user )
493
+
492
494
inventory : dict [str , str ] = {}
493
495
inventory .update ({'host' : self ._remote_host })
494
496
inventory .update ({'user' : self ._managed_racf_user })
495
497
inventory .update ({'zoau' : self ._zoau_path }) # get this from fixture
496
498
inventory .update ({'pyz' : self ._pyz_path }) # get this from fixture
497
499
inventory .update ({'python_interpreter' : self ._python_interpreter }) # get this from fixture
500
+ inventory .update ({'ssh_key' : f"/tmp/{ escaped_user } /id_rsa" })
498
501
extra_args = {}
499
502
extra_args .update ({'extra_args' :{'volumes' :self ._volumes .split ("," )}}) # get this from fixture
500
503
inventory .update (extra_args )
@@ -506,9 +509,8 @@ def execute_managed_user_become_test(self, managed_user_test_case: str, become_m
506
509
method = become_method ["method" ]
507
510
promp = become_method ["promp" ]
508
511
key = become_method ["key" ]
509
- ssh_key = become_method ["ssh_key" ]
510
512
# Carefully crafted 'pytest' command to be allow for it to be called from anther test driven by pytest and uses the zinventory-raw fixture.
511
- pytest_cmd = f"""pytest { testcase } --override-ini "python_functions=managed_user_" --host-pattern={ self ._hostpattern } { capture if debug else "" } { verbosity if verbose else "" } --zinventory-raw='{ node_inventory } ' --user_adm { user } --user_method { method } --ansible_promp '{ promp } ' --password { key } --ssh_key ' { ssh_key } ' """
513
+ pytest_cmd = f"""pytest { testcase } --override-ini "python_functions=managed_user_" --host-pattern={ self ._hostpattern } { capture if debug else "" } { verbosity if verbose else "" } --zinventory-raw='{ node_inventory } ' --user_adm { user } --user_method { method } --ansible_promp '{ promp } ' --password { key } """
512
514
result = subprocess .run (pytest_cmd , capture_output = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True , shell = True )
513
515
if result .returncode != 0 :
514
516
raise Exception (result .stdout + result .stderr )
0 commit comments