def test_configure_authselect_task(self, execWithRedirect): """Test the configure authselect task.""" with tempfile.TemporaryDirectory() as sysroot: authselect_dir = os.path.normpath( sysroot + os.path.dirname(AUTHSELECT_TOOL_PATH)) authselect_path = os.path.normpath(sysroot + AUTHSELECT_TOOL_PATH) os.makedirs(authselect_dir) # The authselect command is missing execWithRedirect.reset_mock() task = ConfigureAuthselectTask( sysroot=sysroot, authselect_options=["select", "sssd", "with-mkhomedir"]) with pytest.raises(SecurityInstallationError): task.run() execWithRedirect.assert_not_called() # The authselect command is there execWithRedirect.reset_mock() os.mknod(authselect_path) task = ConfigureAuthselectTask( sysroot=sysroot, authselect_options=["select", "sssd", "with-mkhomedir"]) task.run() execWithRedirect.assert_called_once_with( AUTHSELECT_TOOL_PATH, ["select", "sssd", "with-mkhomedir", "--force"], root=sysroot) os.remove(authselect_path)
def install_with_tasks(self): """Return the installation tasks of this module. :returns: list of installation tasks """ return [ ConfigureSELinuxTask(sysroot=conf.target.system_root, selinux_mode=self.selinux), ConfigureFingerprintAuthTask( sysroot=conf.target.system_root, fingerprint_auth_enabled=self.fingerprint_auth_enabled), ConfigureAuthselectTask(sysroot=conf.target.system_root, authselect_options=self.authselect), ConfigureAuthconfigTask(sysroot=conf.target.system_root, authconfig_options=self.authconfig) ]