コード例 #1
0
def test_bulk_system_by_api_set_correct_systems_and_accounts_fast_track(clean_bulk_delete_systems_and_accounts,
                                                                        core_session, list_of_created_systems):
    batch1 = ResourceManager.add_multiple_systems_with_accounts(core_session, 3, 4, list_of_created_systems)
    batch2 = ResourceManager.add_multiple_systems_with_accounts(core_session, 1, 2, list_of_created_systems,
                                                                sys_type="Unix")
    batch3 = ResourceManager.add_multiple_systems_with_accounts(core_session, 5, 1, list_of_created_systems,
                                                                sys_type="Unix")

    delete_system_ids, delete_account_ids = DataManipulation.aggregate_lists_in_dict_values([batch2])
    keep_system_ids, keep_account_ids = DataManipulation.aggregate_lists_in_dict_values([batch1, batch3])

    all_systems, all_accounts = DataManipulation.aggregate_lists_in_dict_values([batch1, batch2, batch3])

    some_set_name = "ApiSet" + guid()
    SetsManager.create_manual_collection(core_session, some_set_name, "Server", None)
    set_id = SetsManager.get_collection_id(core_session, some_set_name, "Server")
    SetsManager.update_members_collection(core_session, 'add', list(delete_system_ids), 'Server', set_id)

    collection_and_filters = SetsManager.get_object_collection_and_filter_by_name(core_session, some_set_name, "Server")
    filters = collection_and_filters['Filters']

    logger.info(f'Manual set {collection_and_filters} - members - {delete_system_ids}')
    result, success = ResourceManager.del_multiple_systems_by_query(core_session, filters, savepasswords=False,
                                                                    secretname="", run_sync=True)
    assert success is True, f'Delete systems job failed when expected success'

    SetsManager.delete_collection(core_session, set_id)

    assert set(ResourceManager.get_multi_added_system_ids(core_session,
                                                          all_systems).values()) == keep_system_ids, "Set of expected remaining systems did not match search"
    assert set(ResourceManager.get_multi_added_account_ids(core_session,
                                                           all_systems)) == keep_account_ids, "Set of expected remaining accounts did not match search"
コード例 #2
0
def test_bulk_system_unenroll_by_api_set_correct_systems_fast_track(core_session, test_four_virtual_aapm_agents):
    agents, _ = test_four_virtual_aapm_agents
    all_agent_ids, all_server_ids = _setup_agents(core_session, agents)
    unenroll_agent_ids = all_agent_ids[:2]
    unenroll_server_ids = all_server_ids[:2]
    keep_agent_ids = all_agent_ids[2:]
    _validate_aapm_agent_details(core_session, all_agent_ids, True)

    some_set_name = "ApiSet" + guid()
    SetsManager.create_manual_collection(core_session, some_set_name, "Server", None)
    set_id = SetsManager.get_collection_id(core_session, some_set_name, "Server")
    SetsManager.update_members_collection(core_session, 'add', list(unenroll_server_ids), 'Server', set_id)

    collection_and_filters = SetsManager.get_object_collection_and_filter_by_name(core_session, some_set_name, "Server")
    filters = collection_and_filters['Filters']

    logger.info(f'Manual set {collection_and_filters} - members - {unenroll_server_ids}')
    _, success = ResourceManager.unenroll_multiple_systems_by_query(core_session, filters, wait_time=0,
                                                                         SkipIfAgentReconciliationEnabled=True,
                                                                         run_sync=True)
    assert success, f'Unenroll systems job failed when expected success: {unenroll_server_ids}'

    SetsManager.delete_collection(core_session, set_id)
    _validate_aapm_agent_details(core_session, unenroll_agent_ids, False)
    _validate_aapm_agent_details(core_session, keep_agent_ids, True)
コード例 #3
0
def test_option_all_system_admins_option_has_no_effect_on_non_admins(core_session, cds_session, set_cleaner, global_option, _modifying_setting_mutex):

    update_result, update_success = ServerManager.update_server_security_settings(core_session, all_system_admin_see_all_sets_created_by_sys_admin=global_option)
    assert update_success, f"Failed to update security Settings {update_result}"

    results, success = ServerManager.get_server_settings(core_session, key='policy')
    assert success, f"Failed to retrieve policy settings {results}"

    assert results["AllSystemAdminSeeAllSetsCreatedBySysAdmin"] is global_option, f"Policy key AllSystemAdminSeeAllSetsCreatedBySysAdmin should be {global_option} {results}"

    non_admin_session, api_user = cds_session
    admin1_session = core_session

    set_name1 = f"test_visibility_{guid()}"
    set_name2 = f"test_visibility_{guid()}"

    success, set_id1 = SetsManager.create_manual_collection(admin1_session, set_name1, 'DataVault', object_ids=None)
    assert success is True, f'Failed to create manual set {set_id1}'
    set_cleaner.append(set_id1)

    success, set_id2 = SetsManager.create_manual_collection(non_admin_session, set_name2, 'DataVault', object_ids=None)
    assert success is True, f'Failed to create manual set {set_id2}'
    set_cleaner.append(set_id2)

    assert SetsManager.get_collection_id(admin1_session, set_name1, "DataVault", reduce_sys_admin=True) is not None, "Admin 1 should be able to see own set"
    assert SetsManager.get_collection_id(non_admin_session, set_name2, "DataVault", reduce_sys_admin=True) is not None, "Non admin should be able to see own set"
    assert SetsManager.get_collection_id(non_admin_session, set_name1, "DataVault", reduce_sys_admin=True) is None, "Non admin should NOT be able to see Admin 1 set"
    assert SetsManager.get_collection_id(admin1_session, set_name2, "DataVault", reduce_sys_admin=True) is None, "Admin 1 should NOT be able to see non admin set"

    assert SetsManager.get_collection_id(non_admin_session, set_name1, "DataVault", reduce_sys_admin=False) is None, "Non admin should not be able to see Admin 1 set when reduce_sys_admin is False (because lacking permission)"
    assert SetsManager.get_collection_id(admin1_session, set_name2, "DataVault", reduce_sys_admin=False) is not None, "Admin 1 should be able to see Admin 2 set when reduce_sys_admin is False"
コード例 #4
0
def test_bulk_manage_works_with_different_methods_of_specifying_systems(
        core_session,
        remote_unmanaged_users_with_mirrored_managed_local_users_qty3,
        windows_test_machine_config, change_method):
    account_ids = remote_unmanaged_users_with_mirrored_managed_local_users_qty3

    job_result = None
    if change_method == "ids":
        job_result, success = ResourceManager.manage_multiple_accounts(
            core_session, account_ids)
        assert success, "Did not bulk manage account"
    elif change_method == "ids_with_invalid":
        job_result, success = ResourceManager.manage_multiple_accounts(
            core_session, ["foo"] + list(account_ids))
        assert success, "Did not bulk manage account"
    elif change_method == "sql":
        sql_query = 'SELECT * FROM VaultAccount WHERE ' + ' OR '.join(
            ('VaultAccount.ID = "' + str(n) + '"' for n in account_ids))
        job_result, success = ResourceManager.manage_multiple_accounts(
            core_session, [], set_query=sql_query)
        assert success, "Did not bulk manage accounts"
    elif change_method == "group":
        some_set_name = "ApiSet" + guid()
        SetsManager.create_manual_collection(core_session, some_set_name,
                                             "VaultAccount", None)
        set_id = SetsManager.get_collection_id(core_session, some_set_name,
                                               "VaultAccount")
        SetsManager.update_members_collection(core_session, 'add', account_ids,
                                              'VaultAccount', set_id)
        filters = SetsManager.get_object_collection_and_filter_by_name(
            core_session, some_set_name, "VaultAccount")['Filters']
        job_result, success = ResourceManager.manage_multiple_accounts(
            core_session, [], set_query=filters)
        assert success, "Did not bulk manage accounts"
    else:
        raise Exception(f"Bad input variable change_method {change_method}")

    _validate_accounts_are_managed(core_session, account_ids, job_result)

    user_info = core_session.get_current_session_user_info().json()['Result']
    username = user_info['Name']
    start_type = 'Cloud.Core.AsyncOperation.AccountBulkManagement.Start.Multi'
    end_type = 'Cloud.Core.AsyncOperation.AccountBulkManagement.Success.Multi'
    start_message = f'{username} initiated management of {len(account_ids)} accounts'
    end_message = f'{username} successfully managed {len(account_ids)} accounts'

    RedrockController.expect_event_message_by_type(core_session, start_type,
                                                   start_message)
    RedrockController.expect_event_message_by_type(core_session, end_type,
                                                   end_message)
コード例 #5
0
def test_bulk_rotate_works_with_different_methods_of_specifying_systems(
        core_session,
        remote_users_with_mirrored_managed_local_users_qty3, windows_test_machine_config, change_method):

    remote_ip = windows_test_machine_config['ip_address']

    account_ids, accounts = BulkOperations.grab_relevant_users(core_session, remote_users_with_mirrored_managed_local_users_qty3)
    passwords_fetched = BulkOperations.checkout_users(core_session, accounts)
    BulkOperations.validate_users_with_login(remote_ip, passwords_fetched)

    if change_method == "checkin":   # disabled, out of scope
        BulkOperations.check_in_users(core_session, passwords_fetched)
    elif change_method == "ids":
        result, success = ResourceManager.rotate_multiple_passwords(core_session, account_ids)
        assert success, "Did not bulk rotate passwords"
    elif change_method == "ids_with_invalid":
        result, success = ResourceManager.rotate_multiple_passwords(core_session, account_ids)
        assert success, "Did not bulk rotate passwords"
    elif change_method == "sql":
        sql_query = 'SELECT * FROM VaultAccount ' \
                    'WHERE ' + ' OR '.join(('VaultAccount.ID = "' + str(n) + '"' for n in account_ids))
        result, success = ResourceManager.rotate_multiple_passwords(core_session, [], set_query=sql_query)
        assert success, "Did not bulk rotate passwords"
    elif change_method == "group":
        some_set_name = "ApiSet" + guid()
        SetsManager.create_manual_collection(core_session, some_set_name, "VaultAccount", None)
        set_id = SetsManager.get_collection_id(core_session, some_set_name, "VaultAccount")
        SetsManager.update_members_collection(core_session, 'add', account_ids, 'VaultAccount', set_id)
        filters = SetsManager.get_object_collection_and_filter_by_name(core_session,
                                                                       some_set_name, "VaultAccount")['Filters']
        result, success = ResourceManager.rotate_multiple_passwords(core_session, [], set_query=filters)
        assert success, "Did not bulk rotate passwords"
    else:
        raise Exception(f"Bad input variable change_method {change_method}")

    BulkOperations.validate_users_with_login(remote_ip, passwords_fetched, [False] * len(passwords_fetched), change_method)
    # Verify passwords are no longer right

    user_info = core_session.get_current_session_user_info().json()['Result']
    username = user_info['Name']
    start_type = 'Cloud.Core.AsyncOperation.BulkPasswordRotationJob.Start.Multi'
    end_type = 'Cloud.Core.AsyncOperation.BulkPasswordRotationJob.Success.Multi'
    start_message = f'{username} initiated password rotation of {len(account_ids)} accounts'
    end_message = f'{username} successfully rotated {len(account_ids)} account passwords'

    RedrockController.expect_event_message_by_type(core_session, start_type, start_message)
    RedrockController.expect_event_message_by_type(core_session, end_type, end_message)
コード例 #6
0
def test_login_stored_account(core_session, setup_pas_system_for_unix,
                              set_cleaner, core_admin_ui):
    """
    Test Case ID: C2087
    Test Case Description: Login as stored account after proxy account enabled
    :param core_session: Returns API session
    :param setup_pas_system_for_unix: Creates Unix System and Account
    :param set_cleaner: Delete Set
    :param core_admin_ui: Authenticates Centrify UI session
    """
    system_id, account_id, sys_info = setup_pas_system_for_unix
    system_name = sys_info[0]
    FQDN = sys_info[1]
    computer_class = sys_info[2]
    account_name = sys_info[4]
    systems_data = Configs.get_environment_node('resources_data',
                                                'automation_main')
    expected_system_class = systems_data['Unix_infrastructure_data']
    result, success = ResourceManager.update_system(
        core_session,
        system_id,
        system_name,
        FQDN,
        computer_class,
        proxyuser=expected_system_class['proxy_user'],
        proxyuserpassword=expected_system_class['proxy_password'],
        proxyuserismanaged=False,
        allowremote=True)
    assert success, 'Failed to update system'
    logger.info(f'System successfully updated with result: {result}')
    ui = core_admin_ui
    name_of_set = f'Set{guid()}'
    ui.navigate('Resources', 'Systems')
    ui.launch_add('Add', 'Create Set')
    ui.input('Name', name_of_set)
    ui.tab('Members')
    ui.launch_modal('Add', 'Add System')
    ui.search(system_name)
    ui.check_row(system_name)
    ui.close_modal('Add')
    ui.save()
    id_of_set = SetsManager.get_collection_id(core_session, name_of_set,
                                              'Server')
    assert id_of_set, 'Set creation Failed'
    logger.info(f"Set: '{name_of_set}' created successfully")
    set_cleaner.append(id_of_set)

    # Login into Stored Account
    ui._waitUntilSettled()
    ui.switch_context(ActiveMainContentArea())
    ui.right_click_action(Div(system_name), 'Select/Request Account')
    ui.switch_context(Modal(system_name + ' Login'))
    ui.expect_disappear(LoadingMask(),
                        'Expected to find account but it did not', 30)
    ui.search(account_name)
    ui.expect(GridCell(account_name),
              'Expected to find account name but it did not.').try_click()
    ui.close_modal('Select')
    ui.switch_to_pop_up_window()
    ui.expect_disappear(LoadingMask(),
                        'Expected to login in account but it did not', 30)
    logger.info(f'Successfully logged in Account:{account_name}.')
    ui.switch_to_main_window()