def userdata_validation(*user_obj): """ Verify User data The function validates the user data in the users and groups page. Example: | `userdata validation` | | """ # retrieving data from data file if isinstance(user_obj, test_data.DataObj): user_obj = [user_obj] elif isinstance(user_obj, tuple): user_obj = list(user_obj) navigate() for user in user_obj: if user.name.lower() == "administrator" or user.has_property( 'domainName'): continue VerifyUser.verify_user_exist(user.name) GeneralUserandGroups.click_user(user.name) VerifyUser.verify_user_title(user.name) VerifyUser.verify_user_login_name(user.name) if user.has_property("fullname"): VerifyUser.verify_user_full_name(user.fullname) if user.has_property("email"): VerifyUser.verify_user_email(user.email) if user.has_property("officephone"): VerifyUser.verify_user_office_phone(user.officephone) if user.has_property("mobilephone"): VerifyUser.verify_user_mobile_phone(user.mobilephone) return True
def remove_user(*user_obj): # get the s2lrary reference if isinstance(user_obj, test_data.DataObj): user_obj = [user_obj] elif isinstance(user_obj, tuple): user_obj = list(user_obj) # Navigate to the users and groups page if not already there navigate() error = 0 for user in user_obj: # ignore administrator - note that this is checked below to see if we get the # correct message when trying to delete the administrator. However Fusion # lists the account as 'administrator' not 'Administrator' in the list, so we # get an 'element not found' error. Also, it appears that xpath2.0 is not supported, # so we can't make the locator lower case. if user.name.lower() == 'administrator': continue # if the user doesn't exist, warn and be done if not VerifyUser.verify_user_exist(user.name): logger.warn('%s does not exist in user list' % user.name) else: # locate the user in the list and remove them logger.info('Removing user "%s"' % user.name) BuiltIn().sleep(5) GeneralUserandGroups.click_user(user.name) VerifyUser.verify_user_title(user.name) RemoveUser.click_action_remove_user_button() # make sure the remove dialog is displayed RemoveUser.wait_remove_user_dialog_shown() # delete the user RemoveUser.click_yes_remove_button() RemoveUser.wait_cannot_remove_user_dialog_disappear() if not VerifyUser.verify_user_not_exist(user.name): logger.warn("Not able to remove user %s" % user.name) error += 1 else: logger.info("Successfully removed %s" % user.name) if error > 0: return False else: return True
def edit_current_session_user(user_obj): """ Edit Current Session User This functions allows you to edit current session user whoever users listed in user page retrieving data from data.xml """ logger.info("Edit Current Session User...") user = test_data.get().currentSessionUser user = user[0] if isinstance(user_obj, test_data.DataObj): user_obj = [user_obj] elif isinstance(user_obj, tuple): user_obj = list(user_obj) # Login with current session user credentials EditCurrentSessionUser.input_login_user_name(user.name) EditCurrentSessionUser.input_login_password(user.password) EditCurrentSessionUser.click_login_button() if EditCurrentSessionUser.wait_login_dashboard_shown(30, False): logger.info("Login Successful") else: logger.warn( "Login Fail. Invalid username or password. Enter correct credentials and try again." ) return False EditCurrentSessionUser.click_current_session_user_edit_button() EditCurrentSessionUser.wait_edit_user_dialog_shown() # Edit full name if user.has_property('fullname'): EditCurrentSessionUser.input_full_name(user.fullname) # Enter current password if user.has_property('password'): EditCurrentSessionUser.input_current_password(user.password) # Enter New password if user.has_property('newpassword'): EditCurrentSessionUser.input_new_password(user.newpassword) EditCurrentSessionUser.input_confirm_password(user.newpassword) # Enter confirm password if user.has_property('confirmpassword'): EditCurrentSessionUser.input_confirm_password(user.confirmpassword) # Edit email if user.has_property('email'): EditCurrentSessionUser.input_email(user.email) # Edit office phone number if user.has_property('officephone'): EditCurrentSessionUser.input_office_phone(user.officephone) # Edit Mobile number if user.has_property('mobilephone'): EditCurrentSessionUser.input_mobile_phone(user.mobilephone) # Confirm Edit - Clicking OK EditCurrentSessionUser.click_ok_button() EditCurrentSessionUser.wait_edit_user_dialog_disappear() # Logging out logger.info("LOGOUT") EditCurrentSessionUser.click_logout_button() # Login with Current User if password has changed if user.has_property('newpassword'): logger.info("Login with new password") EditCurrentSessionUser.input_login_user_name(user.name) EditCurrentSessionUser.input_login_password(user.newpassword) EditCurrentSessionUser.click_login_button() if EditCurrentSessionUser.wait_login_dashboard_shown(30, False): logger.info("Changed Password of '%s' is verified Successfully" % user.name) # Logging out logger.info("LOGOUT") EditCurrentSessionUser.click_logout_button() else: logger.warn("Password verification of '%s' failed" % user.name) # Login with Administrator and verify edit logger.info("Login with Administrator") EditCurrentSessionUser.input_login_user_name(user.adminuser) EditCurrentSessionUser.input_login_password(user.adminpassword) EditCurrentSessionUser.click_login_button() if EditCurrentSessionUser.wait_login_dashboard_shown(30, False): logger.info("Administrator successfully logged in") else: logger.warn( "Login Fail. Invalid username or password. Enter correct credentials and try again." ) return False navigate() GeneralUserandGroups.click_user(user.name) VerifyUser.verify_user_title(user.name) VerifyUser.verify_user_login_name(user.name) if user.has_property("fullname"): VerifyUser.verify_user_full_name(user.fullname) if user.has_property("email"): VerifyUser.verify_user_email(user.email) if user.has_property("officephone"): VerifyUser.verify_user_office_phone(user.officephone) if user.has_property("mobilephone"): VerifyUser.verify_user_mobile_phone(user.mobilephone) return True