def test_root_ssh_password_config_task_enabled(self): """Test the root password SSH login configuration task - enabled (write config file).""" # the config file should be written out when the override is enabled with tempfile.TemporaryDirectory() as sysroot: config_path = os.path.join(sysroot, self.SSHD_OVERRIDE_PATH) os.makedirs(os.path.dirname(config_path)) # no config should exist before we run the task assert not os.path.exists(config_path) task = ConfigureRootPasswordSSHLoginTask(sysroot=sysroot, password_allowed=True) task.run() # correct override config should exist after we run the task assert os.path.exists(config_path) expected_content = dedent(""" # This file has been generated by the Anaconda Installer. # Allow root to log in using ssh. Remove this file to opt-out. PermitRootLogin yes """) with open(config_path, "rt") as f: config_content = f.read() assert config_content.strip() == expected_content.strip()
def test_root_ssh_password_config_task_disabled(self): """Test the root password SSH login configuration task - disabled (no config file).""" # the config file should not be written out when the override is disabled with tempfile.TemporaryDirectory() as sysroot: config_path = os.path.join(sysroot, self.SSHD_OVERRIDE_PATH) os.makedirs(os.path.dirname(config_path)) # no config should exist before we run the task assert not os.path.exists(config_path) task = ConfigureRootPasswordSSHLoginTask(sysroot=sysroot, password_allowed=False) task.run() # correct override config should exist after we run the task assert not os.path.exists(config_path)
def configure_root_password_ssh_login_with_task(self): """Return the root password SSH login configuration task. :returns: a root password SSH login configuration task """ return ConfigureRootPasswordSSHLoginTask( sysroot=conf.target.system_root, password_allowed=self.root_password_ssh_login_allowed)
def configure_root_password_ssh_login_with_task(self): """Return the root password SSH login configuration task. :returns: object path of the root password SSH login configuration task """ task = ConfigureRootPasswordSSHLoginTask( sysroot=conf.target.system_root, password_allowed=self.root_password_ssh_login_allowed ) return self.publish_task(USERS.namespace, task)