def update(self, updates, cancel=False, validate_credentials=False): """ Updates a host in the UI. Better to use utils.update.update context manager than call this directly. Args: updates (dict): fields that are changing. cancel (boolean): whether to cancel out of the update. """ sel.force_navigate('infrastructure_host_edit', context={'host': self}) change_stored_password() fill(credential_form, updates.get('credentials', None), validate=validate_credentials) # Workaround for issue with form_button staying dimmed. try: logger.debug("Trying to save update for host with id: " + str(self.get_db_id)) self._submit(cancel, self.forced_saved) logger.debug("save worked, no exception") except Exception as e: logger.debug("exception detected: " + str(e)) sel.browser().execute_script( "$j.ajax({type: 'POST', url: '/host/form_field_changed/%s'," " data: {'default_userid':'%s'}})" % (str(sel.current_url().split('/')[5]), updates.get('credentials', None).principal)) sel.browser().execute_script( "$j.ajax({type: 'POST', url: '/host/form_field_changed/%s'," " data: {'default_password':'******'}})" % (str(sel.current_url().split('/')[5]), updates.get('credentials', None).secret)) sel.browser().execute_script( "$j.ajax({type: 'POST', url: '/host/form_field_changed/%s'," " data: {'default_verify':'%s'}})" % (str(sel.current_url().split('/')[5]), updates.get('credentials', None).verify_secret)) self._submit(cancel, self.forced_saved)
def update(self, updates): navigate_to(self, 'Edit') change_stored_password() new_updates = {} if 'credential' in updates: new_updates.update({ 'userid_txt': updates.get('credential').principal, 'password_txt': updates.get('credential').secret, 'password_verify_txt': updates.get('credential').verify_secret }) if self.appliance.version >= '5.7': self.name = updates.get('credential').principal new_updates.update({ 'name_txt': updates.get('name'), 'email_txt': updates.get('email'), 'user_group_select': getattr(updates.get('group'), 'description', None) }) fill(self.user_form, new_updates, action=form_buttons.save) flash.assert_success_message('User "{}" was saved'.format( updates.get('name', self.name)))
def copy(self): navigate_to(self, 'Details') tb.select('Configuration', 'Copy this User to a new User') new_user = User(name=self.name + "copy", credential=Credential(principal='redhat', secret='redhat')) change_stored_password() fill(self.user_form, {'name_txt': new_user.name, 'userid_txt': new_user.credential.principal, 'password_txt': new_user.credential.secret, 'password_verify_txt': new_user.credential.verify_secret}, action=form_buttons.add) flash.assert_success_message('User "{}" was saved'.format(new_user.name)) return new_user
def copy(self): sel.force_navigate("cfg_accesscontrol_user_ed", context={"user": self}) tb.select('Configuration', 'Copy this User to a new User') new_user = User(name=self.name + "copy", credential=cfme.Credential(principal='redhat', secret='redhat')) change_stored_password() fill(self.user_form, {'name_txt': new_user.name, 'userid_txt': new_user.credential.principal, 'password_txt': new_user.credential.secret, 'password_verify_txt': new_user.credential.verify_secret}, action=form_buttons.add) flash.assert_success_message('User "%s" was saved' % new_user.name) return new_user
def update(self, updates): sel.force_navigate("cfg_accesscontrol_user_edit", context={"user": self}) change_stored_password() fill(self.user_form, {'name_txt': updates.get('name'), 'userid_txt': updates.get('credential').principal, 'password_txt': updates.get('credential').secret, 'password_verify_txt': updates.get('credential').verify_secret, 'email_txt': updates.get('email'), 'user_group_select': getattr(updates.get('group'), 'description', None)}, action=form_buttons.save) flash.assert_success_message( 'User "%s" was saved' % updates.get('name', self.name))
def copy(self): sel.force_navigate("cfg_accesscontrol_user_ed", context={"user": self}) tb.select('Configuration', 'Copy this User to a new User') new_user = User(name=self.name + "copy", credential=cfme.Credential(principal='redhat', secret='redhat')) change_stored_password() fill(self.user_form, {'name_txt': new_user.name, 'userid_txt': new_user.credential.principal, 'password_txt': new_user.credential.secret, 'password_verify_txt': new_user.credential.verify_secret}, action=form_buttons.add) flash.assert_success_message('User "{}" was saved'.format(new_user.name)) return new_user
def update(self, updates): sel.force_navigate("cfg_accesscontrol_user_edit", context={"user": self}) change_stored_password() fill(self.user_form, {'name_txt': updates.get('name'), 'userid_txt': updates.get('credential').principal, 'password_txt': updates.get('credential').secret, 'password_verify_txt': updates.get('credential').verify_secret, 'email_txt': updates.get('email'), 'user_group_select': getattr(updates.get('group'), 'description', None)}, action=form_buttons.save) flash.assert_success_message( 'User "{}" was saved'.format(updates.get('name', self.name)))
def update(self, updates): """ Update user method Args: updates: user data that should be changed Note: In case updates is the same as original user data, update will be canceled, as 'Save' button will not be active """ view = navigate_to(self, 'Edit') change_stored_password() new_updates = {} if 'credential' in updates: new_updates.update({ 'userid_txt': updates.get('credential').principal, 'password_txt': updates.get('credential').secret, 'password_verify_txt': updates.get('credential').verify_secret }) new_updates.update({ 'name_txt': updates.get('name'), 'email_txt': updates.get('email'), 'user_group_select': getattr(updates.get('group'), 'description', None) }) changed = view.fill({ 'name_txt': new_updates.get('name_txt'), 'userid_txt': new_updates.get('userid_txt'), 'password_txt': new_updates.get('password_txt'), 'password_verify_txt': new_updates.get('password_verify_txt'), 'email_txt': new_updates.get('email_txt'), 'user_group_select': new_updates.get('user_group_select') }) if changed: view.save_button.click() flash_message = 'User "{}" was saved'.format( updates.get('name', self.name)) else: view.cancel_button.click() flash_message = 'Edit of User was cancelled by the user' view = self.create_view(DetailsUserView, override=updates) view.flash.assert_message(flash_message) assert view.is_displayed
def set_replication_worker_host(host, port='5432'): """ Set replication worker host on Configure / Configuration pages. Args: host: Address of the hostname to replicate to. """ navigate_to(current_appliance.server, 'Workers') change_stored_password() fill(replication_worker, dict(host=host, port=port, username=conf.credentials['database']['username'], password=conf.credentials['database']['password'], password_verify=conf.credentials['database']['password']), action=form_buttons.save)
def update(self, updates, cancel=False, validate_credentials=False): """ Updates a host in the UI. Better to use utils.update.update context manager than call this directly. Args: updates (dict): fields that are changing. cancel (boolean): whether to cancel out of the update. """ navigate_to(self, 'Edit') change_stored_password() fill(credential_form, updates.get('credentials', None), validate=validate_credentials) logger.debug("Trying to save update for host with id: " + str(self.get_db_id)) self._submit(cancel, self.forced_saved)
def update(self, updates, cancel=False, validate_credentials=False): """ Updates a host in the UI. Better to use utils.update.update context manager than call this directly. Args: updates (dict): fields that are changing. cancel (boolean): whether to cancel out of the update. """ sel.force_navigate('infrastructure_host_edit', context={'host': self}) change_stored_password() fill(credential_form, updates.get('credentials', None), validate=validate_credentials) logger.debug("Trying to save update for host with id: " + str(self.get_db_id)) self._submit(cancel, self.forced_saved)
def update(self, updates): navigate_to(self, 'Edit') change_stored_password() new_updates = {} if 'credential' in updates: new_updates.update({ 'userid_txt': updates.get('credential').principal, 'password_txt': updates.get('credential').secret, 'password_verify_txt': updates.get('credential').verify_secret }) new_updates.update({ 'name_txt': updates.get('name'), 'email_txt': updates.get('email'), 'user_group_select': getattr( updates.get('group'), 'description', None) }) fill(self.user_form, new_updates, action=form_buttons.save) flash.assert_success_message( 'User "{}" was saved'.format(updates.get('name', self.name)))
def copy(self): """ Creates copy of existing user return: User object of copied user """ view = navigate_to(self, 'Details') view.configuration.item_select('Copy this User to a new User') view = self.create_view(AddUserView) new_user = User(name="{}copy".format(self.name), credential=Credential(principal='redhat', secret='redhat')) change_stored_password() view.fill({ 'name_txt': new_user.name, 'userid_txt': new_user.credential.principal, 'password_txt': new_user.credential.secret, 'password_verify_txt': new_user.credential.verify_secret }) view.add_button.click() view = self.create_view(AllUserView) view.flash.assert_success_message('User "{}" was saved'.format( new_user.name)) assert view.is_displayed return new_user