def test_import_all_nix_system(core_session, cleanup_accounts, cleanup_resources): """ Test case: C279397 :param core_session: Centrify session """ # datframe to store systems with unique name in csv import template # dataframe to store systems in csv import template # datframe to store systems with unique name in csv import template system_list = cleanup_resources[0] accounts_list = cleanup_accounts[0] dataframe = pd.read_csv('Assets\\serverimport.csv') server_list = dataframe['Name'] for server in server_list: dataframe = dataframe.replace(server, f'{server}{guid()}') temp_server_csv = f"Assets\\serverimport{guid()}.csv" dataframe.to_csv(temp_server_csv, encoding='utf-8', index=False) # API call with server import template result, success = ResourceManager.bulk_import_system(core_session, temp_server_csv) assert success, f"failed to add systems, return result is: {result}" logger.info('bulk import successful') server = RedrockController.get_accounts(core_session) for row in server: if row['User'].__contains__("Administrator"): accounts_list.append(row["ID"]) server = RedrockController.get_computers(core_session) for row in server: if row['Name'].__contains__("host"): system_list.append(row["ID"]) if os.path.exists(temp_server_csv): os.remove(temp_server_csv) else: pass
def test_system_password_rotation_switch_page(core_session, pas_setup, core_admin_ui): """ Test Case ID: C1672 :param core_session: Returns API session :param pas_setup: Creates System and Account :param core_admin_ui: Authenticates Centrify UI session """ # Creating windows system. system_id, account_id, sys_info = pas_setup system_name = sys_info[0] # Navigating to System and enabling the "password rotation duration" option with valid values. ui = core_admin_ui ui.navigate('Resources', 'Systems') ui.search(system_name) ui.click_row(GridRowByGuid(system_id)) ui.tab('Advanced') ui.switch_context(RenderedTab("Advanced")) ui.select_option("AllowPasswordRotation", "Yes") expected_password_rotation_duration = 5 ui.input("PasswordRotateDuration", expected_password_rotation_duration) ui.save() ui.navigate('Resources', 'Domains') # Leaving the page and coming back to the System's page as per the test case. ui.navigate('Resources', 'Systems') system_list = RedrockController.get_computers(core_session) discovered_system = [] for system in system_list: if system['Name'] == sys_info[0]: discovered_system.append(system['ID']) discovered_system.append(system['PasswordRotateDuration']) assert expected_password_rotation_duration == discovered_system[1], f"password rotation duration count {expected_password_rotation_duration} not matched with actual count {discovered_system[1]}" logger.info( f"Password rotation duration of the system {system_name} with id {system_id} saved with count {discovered_system[1]}")
def test_system_password_rotation(core_session, pas_setup, core_admin_ui): """ Test Case ID: C1671 :param core_session: Returns API session :param pas_setup: Creates System and Account :param core_admin_ui: Authenticates Centrify UI session """ # Creating windows system. system_id, account_id, sys_info = pas_setup system_name = sys_info[0] # Navigating to System and enabling the "All Password Rotation" option with valid and invalid values. ui = core_admin_ui ui.navigate('Resources', 'Systems') ui.search(system_name) ui.click_row(GridRowByGuid(system_id)) ui.tab('Advanced') ui.switch_context(RenderedTab("Advanced")) ui.select_option("AllowPasswordRotation", "Yes") expected_password_rotation_duration = 1 ui.input("PasswordRotateDuration", expected_password_rotation_duration) ui.expect(Button("Save"), "Save button should enabled") logger.info("Save button enabled") ui.save() logger.info("Valid value 1 is accepted and saved successfully") # Checking the value is saved and reflected with the system's settings. system_list = RedrockController.get_computers(core_session) discovered_system = [] for system in system_list: if system['Name'] == sys_info[0]: discovered_system.append(system['ID']) discovered_system.append(system['PasswordRotateDuration']) actual_password_rotation_duration = discovered_system[1] assert expected_password_rotation_duration == actual_password_rotation_duration, f"password rotation duration count {expected_password_rotation_duration} not matched with actual count {actual_password_rotation_duration}" logger.info( f"Password rotation duration of the system {system_name} with id {system_id} saved with count {actual_password_rotation_duration} ") # Changing the value of password rotation duration with invalid value 0. ui.tab('Advanced') ui.switch_context(RenderedTab("Advanced")) ui.select_option("AllowPasswordRotation", "Yes") ui.input("PasswordRotateDuration", 0) ui.save() ui.switch_context(ErrorModal()) ui.expect(Div("Please correct the errors in your form before submitting."), " Error pop up should appear") logger.info("Invalid value 0 is not accepted and thrown error popup successfully")
def test_add_root_using_managed_password( core_session, unix_machine_environment_config, ssh_session_as_root, create_unix_users, cleanup_resources_with_admin, cleanup_accounts): """ Test case C283102: Add system with root using managed proxy account :param core_session: Authorised centrify session. :param ssh_session_as_root: session to create a user_account in unix :param cleanup_accounts: cleanup all accounts :param cleanup_resources_with_admin: to delete the all the systems from portal :param unix_machine_environment_config: to get the unix system details :param create_unix_users: add system with account and yield system ID, account ID, and system information """ # Getting yaml data. systems_list = cleanup_resources_with_admin accounts_list = cleanup_accounts[0] conf = unix_machine_environment_config hostname = conf['host'] + "_" + Util.random_string(5) # add users on target system. users = create_unix_users(ssh_session_as_root, "manage-unix", 1) logger.info("Users created " + str(len(users))) proxy_user = users[0] # Adding system with managed proxy. new_system_id, add_system_success = ResourceManager.add_system( core_session, hostname, conf["ipaddress"], "Unix", "Ssh", "Unix system", proxyuserismanaged=True, proxyuser=proxy_user['Name'], proxyuserpassword=proxy_user['Password']) assert add_system_success, f"Failed to add system with managed proxy:API response result:{new_system_id}" logger.info(f"Successfully added with managed proxy: {new_system_id}") systems_list.append(new_system_id) # Adding local account to the system. admin_account_id, add_account_success = ResourceManager.add_account( core_session, 'root', conf['rootpassword'], new_system_id, ismanaged=False) assert add_account_success, f"Failed to add root user:API response result:{admin_account_id}" logger.info( f"Successfully added root account to the system: {admin_account_id}") accounts_list.append(admin_account_id) # checking added system in the system list. computer_lists = RedrockController.get_computers(core_session) for computer_detail in computer_lists: if computer_detail['ID'] == new_system_id: assert computer_detail['Name'] == hostname, f'Failed to found created system in the list:' \ f'API response result:{computer_lists}' logger.info( f"Successfully found created system in the list:{computer_lists}" ) break
def test_add_system_discovery(core_session, ad_discovery_profile, pas_ad_discovery_config, core_value, delete_discovered_system): """ Test Case: Add System (C1555) :param core_session: Authenticated Centrify Session :param ad_discovery_profile: Fixture to create AD profile for system discovery :param pas_ad_discovery_config: fixture to read yaml file to create profile :param core_value: fixture to read core.yaml :param delete_discovered_system: fixture for cleanup before and after discovery """ config_profile = pas_ad_discovery_config profile_data = config_profile['ad_profile_data'][0] domain_details = config_profile['domains'] domain_name = [] domain_id_list = [] for domains in domain_details: domain_name.append(domains['Name']) for domain in domain_name: domain_id = RedrockController.get_id_from_name(core_session, domain, 'VaultDomain') domain_id_list.append(domain_id) # Delete System and account before discovery delete_discovered_system(profile_data['discovered_system'], domain_id_list) profile_list, profile_name, profile_id, account_list, account_id = ad_discovery_profile( domain_name, profile_data['account_in_domain']) # Run Discovery to discover window system result_run, success, response = Discovery.run_discovery_profile( core_session, profile_id, wait_for_run=True) assert success, f"Failed to run discovery profile: {response}" logger.info(f"Discovery ran successfully, API response: {result_run} ") # Check Last Verify and Last Verify Result for Account last_verify = None last_verify_result = None account_list = RedrockController.get_accounts(core_session) discovered_account = [] for account in account_list: if account['AccountDiscoveredTime'] is not None: discovered_account.append(account['ID']) last_verify = account['Status'] last_verify_result = account['LastHealthCheck'] assert len( discovered_account ) != 0, f"Failed to discover system, account and services {discovered_account}" logger.info(f"Discovered Account is: {discovered_account}") assert last_verify_result is not None, "Failed to test account" assert last_verify == "Missing Password", "Failed to test account" logger.info( f"Last Test:{last_verify} and Last Test Result: {last_verify_result}") # Check Last Test Result and Last Test for Domain result = ServerManager.get_all_domains(core_session) for domain in result: if domain['Name'] in domain_name: last_test = domain['LastHealthCheck'] last_test_result = domain['HealthCheckInterval'] assert last_test is not None, "Failed to test Domain" assert last_test_result is None, "Failed to test Domain" logger.info( f"Domain Name: {domain['Name']}, Last Test:{last_test} and Last Test Result: {last_test_result}" ) # Check Last Test Result and Last Test for Discovered System result = RedrockController.get_computers(core_session) last_test = None last_test_result = None discovered_system = [] for system in result: if system['DiscoveredTime'] is not None: discovered_system.append(system['ID']) last_test = system['LastHealthCheck'] last_test_result = system['HealthCheckInterval'] assert last_test is not None, "Failed to test system" assert last_test_result is None, "Failed to test system" logger.info( f"Last Test:{last_test} and Last Test Result: {last_test_result}") # Cleanup after discovery delete_discovered_system(profile_data['discovered_system'], domain_id_list)
def test_check_message_no_system(core_session, users_and_roles): """ TC:C2047 Check message when there are no systems. :param:core_session:Returns a API session. :param:users_and_roles:Fixture to manage roles and user. :param:cleanup_resources: Fixture for cleanup resources. """ # finding all systems for cleanup: acc_script = "@/lib/server/get_accounts.js(mode:'AllAccounts', newcode:true, localOnly:true, colmemberfilter:" \ "'Select ID from VaultAccount WHERE Host IS NOT NULL')" acc = RedrockController.redrock_query(core_session, acc_script) for account in acc: if account['Row']['FQDN'] == "Check.Point": # Removing Admin Account for successful cleanup of system and account result, success, message = ResourceManager.set_administrative_account( core_session, systems=[account['Row']['Host']]) assert success, f"Failed to update Administrative account for system {account['Row']['Name']}" # Removing Admin Account for successful cleanup of system and account update_result, update_success = ResourceManager.update_system( core_session, account['Row']['Host'], account['Row']['Name'], account['Row']['FQDN'], 'CheckPointGaia', sessiontype=account['Row']['SessionType']) assert update_success, f"Unable to remove admin account from this system: {account['Row']['Host']}" logger.info(f'System successfully updated with result: {result}') # deleting administrative account from this system del_result, del_success = ResourceManager.del_account( core_session, account['Row']['ID']) assert del_success, "Account could not be deleted" logger.info( f'account successfully deleted with result: {del_result}') # Removing Admin Account for successful cleanup of system and account result, success, message = ResourceManager.set_administrative_account( core_session, systems=[account['Row']['Host']]) assert success, f"Failed to update Administrative account for system {account['Row']['Name']}" accounts = RedrockController.redrock_query(core_session, acc_script) for account in accounts: ResourceManager.del_account(core_session, account['Row']['ID']) # Delete computers from tenant system = RedrockController.get_computers(core_session) for SYS in system: ResourceManager.del_system(core_session, SYS["ID"]) # Trying to get the data from system_by_type on dashboard and expecting no data or an empty list. get_system_type_result = RedrockController.get_system_type_dashboard_pie_chart( core_session) assert len(get_system_type_result) == 0, f"Data found in system_by_type in dashboard:" \ f"API response result:{get_system_type_result}" logger.info( f"Could not found any data in system_by_type on" f" dashboard in without any system in tenant{get_system_type_result}") # Trying to get the data form system health on dashboard and expecting no data or an empty list. get_system_health_dashboard = RedrockController.get_systems_health_dashboard( core_session) assert len(get_system_health_dashboard) == 0, f"Data found in system health in dashboard:" \ f" API response result:{get_system_health_dashboard}" logger.info( f"Could not found any data in system health on " f"dashboard without any system in tenant{get_system_health_dashboard}")