From c7eb915d28a16903f7ed9f7c4308b464de7e71c3 Mon Sep 17 00:00:00 2001 From: dbeltran Date: Thu, 21 Nov 2024 08:44:38 +0100 Subject: [PATCH 01/10] (wip) user_mapping --- autosubmit/platforms/paramiko_platform.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autosubmit/platforms/paramiko_platform.py b/autosubmit/platforms/paramiko_platform.py index 8b19730a8..1355e43df 100644 --- a/autosubmit/platforms/paramiko_platform.py +++ b/autosubmit/platforms/paramiko_platform.py @@ -242,7 +242,10 @@ class ParamikoPlatform(Platform): self._ssh = paramiko.SSHClient() self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self._ssh_config = paramiko.SSHConfig() - self._user_config_file = os.path.expanduser("~/.ssh/config") + # get env variable + mapped_config_file = "~/.ssh/config" if "AS_ENV_PLATFORMS_PATH" not in os.environ else f"~/.ssh/config_{os.getenv('SUDO_USER')}" + + self._user_config_file = os.path.expanduser(mapped_config_file) if os.path.exists(self._user_config_file): with open(self._user_config_file) as f: self._ssh_config.parse(f) -- GitLab From 19298f0ea7d3da01d2133c211ac0017153cea9aa Mon Sep 17 00:00:00 2001 From: dbeltran Date: Thu, 21 Nov 2024 15:59:22 +0100 Subject: [PATCH 02/10] (Added tentative rst) --- docs/source/userguide/user_mapping.rst | 123 +++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 docs/source/userguide/user_mapping.rst diff --git a/docs/source/userguide/user_mapping.rst b/docs/source/userguide/user_mapping.rst new file mode 100644 index 000000000..e972b6aa3 --- /dev/null +++ b/docs/source/userguide/user_mapping.rst @@ -0,0 +1,123 @@ +############ +User Mapping +############ + +About +----- + +For Autosubmit, User mapping is the process of associating all the personal users account with a shared account. + +The personal user account is personal account to access to each remote platform. While the shared account is the one that is used to run the experiments on the machine where Autosubmit is deployed. + +When to use +----------- + +To run a set of shared experiments on a machine where Autosubmit is deployed. Using the hpc resources of the user that triggers the experiment. + +More specifically, this is useful to launch a testing suite on a shared machine without having redundancy of experiments for each user that wants to run the tests. + +Pre-requisites +-------------- + +* The sysadmin of the machine where Autosubmit is deployed must have created a shared user account that will be used to run the experiments. + +* The sysadmin is the responsable of handling the security of the remote keys used so that the personal user accounts are not compromised. + +* The personal user is reponsable of not sharing/access the ssh keys with other users. + +* The platform_${SUDO_USER}.yml file for each user that has access to the shared account must be created. + +* The ssh_config_${SUDO_USER} file for each user that has access to the shared account must be created. + +How it works +------------ + +The idea is to map two different stuff depending on the user that is logged in the shared account to ensure a correct Autosubmit behavior. + +* Platform.yml file that contains the personal user for each platform. + +(Personal user action): The user must set some enviroment variables "AS_ENV_PLATFORMS_PATH" to point to a file that contains the personal platforms.yml file. + +Defaults to: None + +(One time, all shared experiments): Has to have this defined in the $autosubmit_data/$expid/conf + +.. code-block:: yaml + + ... + DEFAULT: + ... + CUSTOM_CONFIG: + ... + POST: %AS_ENV_PLATFORMS_PATH% + ... + ... + + +* (OPTIONAL) ssh_config file that contains the ssh config for each platform + +(Personal user action): Must set some enviroment variables "AS_ENV_SSH_CONFIG_PATH" to point to a file that contains the personal ~/.ssh/config file. + +Defaults to: "~/.ssh/config" or "~/.ssh/config_${SUDO_USER}" if the env variable: "AS_ENV_PLATFORMS_PATH" is set. + + +How to activate it with examples +-------------------------------- + +* (once) Generate the platform_${SUDO_USER}.yml + +.. code-block:: yaml + + Platforms: + Platform: + User: bscXXXXX + +* (once) Generate the ssh_config_${SUDO_USER}.yml + +.. code-block:: ini + + Host marenostrum5 + Hostname glogin1.bsc.es + User bscXXXXX + Host marenostrum5.2 + Hostname glogin2.bsc.es + User bscXXXXX + +1) Set the environment variable "AS_ENV_PLATFORMS_PATH". + +.. code-block:: bash + + export AS_ENV_PLATFORMS_PATH="~/platforms/platform_${SUDO_USER}.yml" + +Tip: Add it to the shared account .bashrc file. + +2) Set the environment variable "AS_ENV_SSH_CONFIG_PATH" (OPTIONAL). + +.. code-block:: bash + + export AS_ENV_SSH_CONFIG_PATH="~/ssh/config_${SUDO_USER}.yml" + +Tip: Add it to the shared account .bashrc file. + +3) Ensure that the experiments has set the %CUSTOM_CONFIG.POST% to the "AS_ENV_PLATFORMS_PATH" variable. + +.. code-block:: bash + + cat $autosubmit_data/$expid/conf/minimal.yml + +.. code-block:: yaml + + ... + DEFAULT: + ... + CUSTOM_CONFIG: + ... + POST: %AS_ENV_PLATFORMS_PATH% + ... + ... + +4) Run the experiments. + +.. code-block:: bash + + autosubmit run $expid -- GitLab From 53f32ad1da91b8dc30891c5be5e08908841ae823 Mon Sep 17 00:00:00 2001 From: dbeltran Date: Fri, 22 Nov 2024 09:36:49 +0100 Subject: [PATCH 03/10] doc feedback addressed --- docs/source/userguide/user_mapping.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/source/userguide/user_mapping.rst b/docs/source/userguide/user_mapping.rst index e972b6aa3..02a53d06a 100644 --- a/docs/source/userguide/user_mapping.rst +++ b/docs/source/userguide/user_mapping.rst @@ -5,29 +5,29 @@ User Mapping About ----- -For Autosubmit, User mapping is the process of associating all the personal users account with a shared account. +For Autosubmit, user mapping is the process of associating all the personal user accounts with a shared account. -The personal user account is personal account to access to each remote platform. While the shared account is the one that is used to run the experiments on the machine where Autosubmit is deployed. +The personal user account is the account used to access to each remote platform. While the shared account is the one that is used to run the experiments on the machine where Autosubmit is deployed. When to use ----------- -To run a set of shared experiments on a machine where Autosubmit is deployed. Using the hpc resources of the user that triggers the experiment. +To run a set of shared experiments on a machine where Autosubmit is deployed. Using the HPC resources of the user that triggers the experiment. -More specifically, this is useful to launch a testing suite on a shared machine without having redundancy of experiments for each user that wants to run the tests. +More specifically, this can be useful to launch something like an experiment testing suite on a shared machine without having redundancy of experiments for each user that wants to run the tests. -Pre-requisites +Prerequisites -------------- * The sysadmin of the machine where Autosubmit is deployed must have created a shared user account that will be used to run the experiments. -* The sysadmin is the responsable of handling the security of the remote keys used so that the personal user accounts are not compromised. +* The sysadmin is the responsible for handling the security of the remote keys used so that the personal user accounts are not compromised. -* The personal user is reponsable of not sharing/access the ssh keys with other users. +* The user is reponsible for keeping their personal user account details (e.g SSH keys) secure, e.g. not sharing them with others. -* The platform_${SUDO_USER}.yml file for each user that has access to the shared account must be created. +* The ``platform_${SUDO_USER}.yml`` file for each user that has access to the shared account must be created. -* The ssh_config_${SUDO_USER} file for each user that has access to the shared account must be created. +* The ``ssh_config_${SUDO_USER}`` file for each user that has access to the shared account must be created. How it works ------------ -- GitLab From 43b972cc83423cb4fbe341a66b15708de09d2a67 Mon Sep 17 00:00:00 2001 From: dbeltran Date: Fri, 22 Nov 2024 10:00:34 +0100 Subject: [PATCH 04/10] v2, with feedback and more active voice --- docs/source/userguide/user_mapping.rst | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/source/userguide/user_mapping.rst b/docs/source/userguide/user_mapping.rst index 02a53d06a..dc94a9836 100644 --- a/docs/source/userguide/user_mapping.rst +++ b/docs/source/userguide/user_mapping.rst @@ -5,38 +5,38 @@ User Mapping About ----- -For Autosubmit, user mapping is the process of associating all the personal user accounts with a shared account. +For Autosubmit, user mapping means associating selected personal user accounts with a shared account. -The personal user account is the account used to access to each remote platform. While the shared account is the one that is used to run the experiments on the machine where Autosubmit is deployed. +The personal user account is used to access each remote platform, while the shared account is used to run the experiments on the machine where Autosubmit is deployed. When to use ------------ +------------- -To run a set of shared experiments on a machine where Autosubmit is deployed. Using the HPC resources of the user that triggers the experiment. +When to use: When you want to run a set of shared experiments using different HPC users. -More specifically, this can be useful to launch something like an experiment testing suite on a shared machine without having redundancy of experiments for each user that wants to run the tests. +More specifically, this can be useful for launching something like an experiment testing suite on a shared machine without having to create redundant experiments for each user who wants to run the tests. Prerequisites -------------- * The sysadmin of the machine where Autosubmit is deployed must have created a shared user account that will be used to run the experiments. -* The sysadmin is the responsible for handling the security of the remote keys used so that the personal user accounts are not compromised. +* The sysadmin is responsible for securing the remote keys used so that the personal user accounts are not compromised. -* The user is reponsible for keeping their personal user account details (e.g SSH keys) secure, e.g. not sharing them with others. +* The user is responsible for keeping their personal user account details (e.g., SSH keys) secure, including not sharing them with others. -* The ``platform_${SUDO_USER}.yml`` file for each user that has access to the shared account must be created. +* Someone has to create the ``platform_${SUDO_USER}.yml`` file for each user with access to the shared account. -* The ``ssh_config_${SUDO_USER}`` file for each user that has access to the shared account must be created. +* Someone has to create the ``ssh_config_${SUDO_USER}`` file for each user with access to the shared account. How it works ------------- +-------------- -The idea is to map two different stuff depending on the user that is logged in the shared account to ensure a correct Autosubmit behavior. +The idea is to map two different things depending on the user logged in to the shared account to ensure the correct Autosubmit behavior. * Platform.yml file that contains the personal user for each platform. -(Personal user action): The user must set some enviroment variables "AS_ENV_PLATFORMS_PATH" to point to a file that contains the personal platforms.yml file. +(Personal user action): The user must set the environment variable "AS_ENV_PLATFORMS_PATH" to point to the file that contains the personal platforms.yml file. Defaults to: None @@ -56,13 +56,13 @@ Defaults to: None * (OPTIONAL) ssh_config file that contains the ssh config for each platform -(Personal user action): Must set some enviroment variables "AS_ENV_SSH_CONFIG_PATH" to point to a file that contains the personal ~/.ssh/config file. +(Personal user action): The user must set the environment variable "AS_ENV_SSH_CONFIG_PATH" to point to a file that contains the personal ~/.ssh/config file. Defaults to: "~/.ssh/config" or "~/.ssh/config_${SUDO_USER}" if the env variable: "AS_ENV_PLATFORMS_PATH" is set. How to activate it with examples --------------------------------- +---------------------------------- * (once) Generate the platform_${SUDO_USER}.yml @@ -99,7 +99,7 @@ Tip: Add it to the shared account .bashrc file. Tip: Add it to the shared account .bashrc file. -3) Ensure that the experiments has set the %CUSTOM_CONFIG.POST% to the "AS_ENV_PLATFORMS_PATH" variable. +3) Ensure that the experiments have set the %CUSTOM_CONFIG.POST% to the "AS_ENV_PLATFORMS_PATH" variable. .. code-block:: bash -- GitLab From 504a3a76b1b1db1f78a4fef81b4d562d157f25e7 Mon Sep 17 00:00:00 2001 From: dbeltran Date: Fri, 22 Nov 2024 12:38:12 +0100 Subject: [PATCH 05/10] Added mapping to index.rst --- docs/source/userguide/index.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/source/userguide/index.rst b/docs/source/userguide/index.rst index f8cc26e6f..3816c097c 100644 --- a/docs/source/userguide/index.rst +++ b/docs/source/userguide/index.rst @@ -16,6 +16,7 @@ User Guide /userguide/expids /userguide/provenance /userguide/traceability + /userguide/user_mapping Command list ============ @@ -68,6 +69,3 @@ TODO add ``workflow_validation``. * :ref:`archive` * :ref:`advanced_features` - - - -- GitLab From 321c9feb8cd9bd49d3840ca59343387dd0a311aa Mon Sep 17 00:00:00 2001 From: dbeltran Date: Fri, 22 Nov 2024 15:48:22 +0100 Subject: [PATCH 06/10] Added is_current_real_user_owner To be used in the connect function of AS --- autosubmit/platforms/paramiko_platform.py | 33 +++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/autosubmit/platforms/paramiko_platform.py b/autosubmit/platforms/paramiko_platform.py index 1355e43df..fbaf53129 100644 --- a/autosubmit/platforms/paramiko_platform.py +++ b/autosubmit/platforms/paramiko_platform.py @@ -226,6 +226,29 @@ class ParamikoPlatform(Platform): # pass return tuple(answers) + def map_user_config_file(self) -> None: + """ + Maps the shared account user ssh config file to the current user config file. + Defaults to ~/.ssh/config if the mapped file does not exist. + """ + self._user_config_file = os.path.expanduser("~/.ssh/config") + if os.environ.get('AS_ENV_PLATFORMS_PATH', None): + mapped_config_file = f"~/.ssh/config_{self.expid}" + if mapped_config_file.startswith("~"): + mapped_config_file = os.path.expanduser(mapped_config_file) + if not Path(mapped_config_file).exists(): + Log.debug(f"{mapped_config_file} not found") + else: + Log.info(f"Using {mapped_config_file} as ssh config file") + self._user_config_file = mapped_config_file + + if Path(self._user_config_file).exists(): + Log.info(f"Using {self._user_config_file} as ssh config file") + with open(self._user_config_file) as f: + self._ssh_config.parse(f) + else: + Log.warning(f"SSH config file {self._user_config_file} not found") + def connect(self, as_conf, reconnect=False): """ Creates ssh connection to host @@ -242,13 +265,7 @@ class ParamikoPlatform(Platform): self._ssh = paramiko.SSHClient() self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self._ssh_config = paramiko.SSHConfig() - # get env variable - mapped_config_file = "~/.ssh/config" if "AS_ENV_PLATFORMS_PATH" not in os.environ else f"~/.ssh/config_{os.getenv('SUDO_USER')}" - - self._user_config_file = os.path.expanduser(mapped_config_file) - if os.path.exists(self._user_config_file): - with open(self._user_config_file) as f: - self._ssh_config.parse(f) + self.map_user_config_file() self._host_config = self._ssh_config.lookup(self.host) if "," in self._host_config['hostname']: if reconnect: @@ -258,7 +275,7 @@ class ParamikoPlatform(Platform): self._host_config['hostname'] = self._host_config['hostname'].split(',')[0] if 'identityfile' in self._host_config: self._host_config_id = self._host_config['identityfile'] - port = int(self._host_config.get('port',22)) + port = int(self._host_config.get('port', 22) ) if not self.two_factor_auth: # Agent Auth if not self.agent_auth(port): -- GitLab From 6cf7435e00b6c9dc77a80e5e0c85d6b3525a465f Mon Sep 17 00:00:00 2001 From: dbeltran Date: Fri, 22 Nov 2024 15:50:00 +0100 Subject: [PATCH 07/10] added map_user_config --- autosubmit/platforms/paramiko_platform.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autosubmit/platforms/paramiko_platform.py b/autosubmit/platforms/paramiko_platform.py index fbaf53129..937548a23 100644 --- a/autosubmit/platforms/paramiko_platform.py +++ b/autosubmit/platforms/paramiko_platform.py @@ -226,13 +226,13 @@ class ParamikoPlatform(Platform): # pass return tuple(answers) - def map_user_config_file(self) -> None: + def map_user_config_file(self, as_conf) -> None: """ Maps the shared account user ssh config file to the current user config file. Defaults to ~/.ssh/config if the mapped file does not exist. """ self._user_config_file = os.path.expanduser("~/.ssh/config") - if os.environ.get('AS_ENV_PLATFORMS_PATH', None): + if not as_conf.is_current_real_user_owner: # Using shared account mapped_config_file = f"~/.ssh/config_{self.expid}" if mapped_config_file.startswith("~"): mapped_config_file = os.path.expanduser(mapped_config_file) @@ -265,7 +265,7 @@ class ParamikoPlatform(Platform): self._ssh = paramiko.SSHClient() self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self._ssh_config = paramiko.SSHConfig() - self.map_user_config_file() + self.map_user_config_file(as_conf) self._host_config = self._ssh_config.lookup(self.host) if "," in self._host_config['hostname']: if reconnect: -- GitLab From 5ba45683ce9dffc8aa79182d49b70f6ed6bf4671 Mon Sep 17 00:00:00 2001 From: dbeltran Date: Mon, 25 Nov 2024 13:05:23 +0100 Subject: [PATCH 08/10] Added pytest, fixed mapping function --- autosubmit/platforms/paramiko_platform.py | 8 ++- test/unit/test_paramiko_platform_pytest.py | 58 ++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 test/unit/test_paramiko_platform_pytest.py diff --git a/autosubmit/platforms/paramiko_platform.py b/autosubmit/platforms/paramiko_platform.py index 937548a23..cf5be6d8c 100644 --- a/autosubmit/platforms/paramiko_platform.py +++ b/autosubmit/platforms/paramiko_platform.py @@ -230,10 +230,16 @@ class ParamikoPlatform(Platform): """ Maps the shared account user ssh config file to the current user config file. Defaults to ~/.ssh/config if the mapped file does not exist. + Defaults to ~/.ssh/config_%AS_ENV_CURRENT_USER% if %AS_ENV_SSH_CONFIG_PATH% is not defined. + param as_conf: Autosubmit configuration + return: None """ self._user_config_file = os.path.expanduser("~/.ssh/config") if not as_conf.is_current_real_user_owner: # Using shared account - mapped_config_file = f"~/.ssh/config_{self.expid}" + if 'AS_ENV_SSH_CONFIG_PATH' not in self.config: # if not defined in the ENV variables, use the default + current user + mapped_config_file = os.path.expanduser(f"~/.ssh/config_{self.config['AS_ENV_CURRENT_USER']}") + else: + mapped_config_file = self.config['AS_ENV_SSH_CONFIG_PATH'] if mapped_config_file.startswith("~"): mapped_config_file = os.path.expanduser(mapped_config_file) if not Path(mapped_config_file).exists(): diff --git a/test/unit/test_paramiko_platform_pytest.py b/test/unit/test_paramiko_platform_pytest.py new file mode 100644 index 000000000..4c691e785 --- /dev/null +++ b/test/unit/test_paramiko_platform_pytest.py @@ -0,0 +1,58 @@ +import pytest +from autosubmit.platforms.paramiko_platform import ParamikoPlatform +import os + +def add_ssh_config_file(tmpdir, user, content): + if not tmpdir.join(".ssh").exists(): + tmpdir.mkdir(".ssh") + if user: + ssh_config_file = tmpdir.join(f".ssh/config_{user}") + else: + ssh_config_file = tmpdir.join(".ssh/config") + ssh_config_file.write(content) + +@pytest.fixture(scope="function") +def generate_all_files(tmpdir): + ssh_content = """ +Host mn5-gpp + User %change% + HostName glogin1.bsc.es + ForwardAgent yes +""" + for user in [os.environ["USER"], "dummy-one"]: + ssh_content_user = ssh_content.replace("%change%", user) + add_ssh_config_file(tmpdir, user, ssh_content_user) + return tmpdir + + +@pytest.mark.parametrize("user, env_ssh_config_defined", + [(os.environ["USER"], False), + ("dummy-one", True), + ("dummy-one", False), + ("not-exists", True), + ("not_exists", False)], + ids=["OWNER", + "SUDO USER(exists) + AS_ENV_CONFIG_SSH_PATH(defined)", + "SUDO USER(exists) + AS_ENV_CONFIG_SSH_PATH(not defined)", + "SUDO USER(not exists) + AS_ENV_CONFIG_SSH_PATH(defined)", + "SUDO USER(not exists) + AS_ENV_CONFIG_SSH_PATH(not defined)"]) +def test_map_user_config_file(tmpdir, autosubmit_config, mocker, generate_all_files, user, env_ssh_config_defined): + experiment_data = { + "ROOTDIR": str(tmpdir), + "PROJDIR": str(tmpdir), + "LOCAL_TMP_DIR": str(tmpdir), + "LOCAL_ROOT_DIR": str(tmpdir), + "AS_ENV_CURRENT_USER": user, + } + if env_ssh_config_defined: + experiment_data["AS_ENV_SSH_CONFIG_PATH"] = str(tmpdir.join(f".ssh/config_{user}")) + as_conf = autosubmit_config(expid='a000', experiment_data=experiment_data) + as_conf.is_current_real_user_owner = os.environ["USER"] == user + platform = ParamikoPlatform(expid='a000', name='ps', config=experiment_data) + platform._ssh_config = mocker.MagicMock() + mocker.patch('os.path.expanduser', side_effect=lambda x: x) # Easier to test, and also not mess with the real user's config + platform.map_user_config_file(as_conf) + if not env_ssh_config_defined or not tmpdir.join(f".ssh/config_{user}").exists(): + assert platform._user_config_file == "~/.ssh/config" + else: + assert platform._user_config_file == str(tmpdir.join(f".ssh/config_{user}")) -- GitLab From 0f2a95fce012eb88c54f81f2aa38d84db619a049 Mon Sep 17 00:00:00 2001 From: dbeltran Date: Mon, 25 Nov 2024 14:34:35 +0100 Subject: [PATCH 09/10] Fix docs --- docs/source/userguide/user_mapping.rst | 4 ++-- test/unit/test_paramiko_platform_pytest.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/source/userguide/user_mapping.rst b/docs/source/userguide/user_mapping.rst index dc94a9836..1952bce28 100644 --- a/docs/source/userguide/user_mapping.rst +++ b/docs/source/userguide/user_mapping.rst @@ -49,7 +49,7 @@ Defaults to: None ... CUSTOM_CONFIG: ... - POST: %AS_ENV_PLATFORMS_PATH% + POST: "%AS_ENV_PLATFORMS_PATH%" ... ... @@ -112,7 +112,7 @@ Tip: Add it to the shared account .bashrc file. ... CUSTOM_CONFIG: ... - POST: %AS_ENV_PLATFORMS_PATH% + POST: "%AS_ENV_PLATFORMS_PATH%" ... ... diff --git a/test/unit/test_paramiko_platform_pytest.py b/test/unit/test_paramiko_platform_pytest.py index 4c691e785..32a77cdd6 100644 --- a/test/unit/test_paramiko_platform_pytest.py +++ b/test/unit/test_paramiko_platform_pytest.py @@ -2,6 +2,7 @@ import pytest from autosubmit.platforms.paramiko_platform import ParamikoPlatform import os + def add_ssh_config_file(tmpdir, user, content): if not tmpdir.join(".ssh").exists(): tmpdir.mkdir(".ssh") @@ -11,6 +12,7 @@ def add_ssh_config_file(tmpdir, user, content): ssh_config_file = tmpdir.join(".ssh/config") ssh_config_file.write(content) + @pytest.fixture(scope="function") def generate_all_files(tmpdir): ssh_content = """ -- GitLab From fa81bd70b78966b9a3b6ef2658414d7d88b46ec5 Mon Sep 17 00:00:00 2001 From: dbeltran Date: Fri, 29 Nov 2024 14:41:43 +0100 Subject: [PATCH 10/10] Update test to match that is_current_real_user_owner is now a property --- setup.py | 2 +- test/unit/test_paramiko_platform_pytest.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 230582c20..807ed719a 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ install_requires = [ 'py3dotplus==1.1.0', 'numpy<2', 'rocrate==0.*', - 'autosubmitconfigparser==1.0.73', + 'autosubmitconfigparser==1.0.75', 'configparser', 'setproctitle', 'invoke>=2.0', diff --git a/test/unit/test_paramiko_platform_pytest.py b/test/unit/test_paramiko_platform_pytest.py index 32a77cdd6..dd9fa0b5d 100644 --- a/test/unit/test_paramiko_platform_pytest.py +++ b/test/unit/test_paramiko_platform_pytest.py @@ -1,7 +1,7 @@ import pytest from autosubmit.platforms.paramiko_platform import ParamikoPlatform import os - +import autosubmitconfigparser.config.configcommon def add_ssh_config_file(tmpdir, user, content): if not tmpdir.join(".ssh").exists(): @@ -49,7 +49,7 @@ def test_map_user_config_file(tmpdir, autosubmit_config, mocker, generate_all_fi if env_ssh_config_defined: experiment_data["AS_ENV_SSH_CONFIG_PATH"] = str(tmpdir.join(f".ssh/config_{user}")) as_conf = autosubmit_config(expid='a000', experiment_data=experiment_data) - as_conf.is_current_real_user_owner = os.environ["USER"] == user + mocker.patch('autosubmitconfigparser.config.configcommon.AutosubmitConfig.is_current_real_user_owner', os.environ["USER"] == user) platform = ParamikoPlatform(expid='a000', name='ps', config=experiment_data) platform._ssh_config = mocker.MagicMock() mocker.patch('os.path.expanduser', side_effect=lambda x: x) # Easier to test, and also not mess with the real user's config -- GitLab