Skip to content

Commit a99088d

Browse files
committed
Fix use same ssh key
1 parent 498e325 commit a99088d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

tests/functional/modules/test_zos_fetch_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,10 +1080,10 @@ def managed_user_limited_become_method(get_config_for_become, get_config_raw, ca
10801080
method = get_config_for_become["method"]
10811081
promp = get_config_for_become["promp"]
10821082
password = get_config_for_become["key"]
1083-
ssh_key = get_config_for_become["ssh_key"]
10841083

10851084
# Get values from the new configuration file
10861085
configuration = json.loads(get_config_raw)
1086+
ssh_key = configuration["ssh_key"]
10871087
hosts = configuration["host"]
10881088
user = configuration["user"]
10891089
python_path = configuration["python_interpreter"]

tests/helpers/users.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def from_fixture(cls, pytest_module_fixture, pytest_interpreter_fixture):
192192

193193
# TODO: To make this dynamic, we need to update AC and then also test with the new fixture because
194194
# 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.
196196
volumes = "000000,222222"
197197
hostpattern = pytest_module_fixture["options"]["host_pattern"]
198198
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
489489
capture = " -s"
490490
verbosity = " -vvvv"
491491

492+
escaped_user = re.escape(self._managed_racf_user)
493+
492494
inventory: dict [str, str] = {}
493495
inventory.update({'host': self._remote_host})
494496
inventory.update({'user': self._managed_racf_user})
495497
inventory.update({'zoau': self._zoau_path}) # get this from fixture
496498
inventory.update({'pyz': self._pyz_path}) # get this from fixture
497499
inventory.update({'python_interpreter': self._python_interpreter}) # get this from fixture
500+
inventory.update({'ssh_key': f"/tmp/{escaped_user}/id_rsa"})
498501
extra_args = {}
499502
extra_args.update({'extra_args':{'volumes':self._volumes.split(",")}}) # get this from fixture
500503
inventory.update(extra_args)
@@ -506,9 +509,8 @@ def execute_managed_user_become_test(self, managed_user_test_case: str, become_m
506509
method = become_method["method"]
507510
promp = become_method["promp"]
508511
key = become_method["key"]
509-
ssh_key = become_method["ssh_key"]
510512
# 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}"""
512514
result = subprocess.run(pytest_cmd, capture_output=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True)
513515
if result.returncode != 0:
514516
raise Exception(result.stdout + result.stderr)

0 commit comments

Comments
 (0)