예제 #1
0
def test_add_un_manage_account_activity(core_session, pas_setup):
    """
     :param core_session: Authenticated Centrify Session.
    :param pas_setup: Fixture for adding a system and an account associated with it.
    TC: C2534 - Add Windows system with un managed account
    trying to validate the add un manage Account Activity log's
                Steps:
                1. Try to add a system with un managed account
                    -Assert Failure
                2. Try to check in the activity of system
                    -Assert Failure
    """
    user_name = core_session.get_user().get_login_name()
    sys_id, acc_id, sys_info = pas_setup
    logger.info(f"System: {sys_info[0]} successfully added with UUID: {sys_id} and account: {sys_info[4]} "
                f"with UUID: {acc_id} associated with it.")
    checkflag = True
    counter = 0
    row = None
    while checkflag is True:
        if counter != 5:
            row = ResourceManager.get_system_activity(core_session, sys_id)
            if row is not None:
                break
        checkflag = False
        counter += 1
    reports = []
    for system_activity in row:
        if system_activity['Detail'].__contains__("added local"):
            reports.append(system_activity["Detail"])
    created_date_json = str(row[0]['When'])
    ResourceManager.get_date(created_date_json)
    assert f'{user_name} added local account "{sys_info[4]}" for "{sys_info[0]}"({sys_info[1]}) ' \
        f'with credential type Password ' in reports[0], "Account Not Added"
    logger.info(f"account activity list:{row}")
def test_import_system_and_health_check(core_session, pas_windows_setup):
    """
    C1554 : Import system and check health
    :param core_session: Authenticated Centrify Session.
    :param pas_windows_setup:
    """
    system_id, account_id, sys_info, connector_id, user_password = pas_windows_setup()
    system_details = RedrockController.get_computer_with_ID(core_session, system_id)

    system_counter = 1
    while system_counter < 60:
        if system_details['HealthStatus'] == 'OK' and system_details['LastHealthCheck']:
            break
        system_counter += 1
    ResourceManager.get_date(system_details['LastHealthCheck'])
    assert system_details['HealthStatus'] == 'OK', "System not reachable because connector is not up."
    logger.info(f"System is reachable successfully: {system_details}")

    account_counter = 1
    account_details = None
    while account_counter < 60:
        account_details = ResourceManager.get_account_information(core_session, account_id)
        if account_details[0]['VaultAccount']['Row']['Healthy'] == 'OK' and \
                account_details[0]['VaultAccount']['Row']['LastHealthCheck']:
            break
        account_counter += 1
    ResourceManager.get_date(account_details[0]['VaultAccount']['Row']['LastHealthCheck'])
    assert account_details[0]['VaultAccount']['Row']['Healthy'] == 'OK', \
        "System not reachable because connector is not up."
    logger.info(f"Account is reachable successfully: {account_details}")
def test_system_health_check(core_session, pas_windows_setup):
    """
    C1553 : Add System
    :param core_session: Authenticated Centrify Session.
    :param pas_windows_setup: Creates system with account
    """
    sys_info = pas_windows_setup()
    system_details = RedrockController.get_computer_with_ID(core_session, sys_info[0])
    ResourceManager.get_date(system_details['LastHealthCheck'])
    assert system_details['HealthStatus'] == 'OK', "Remote System is not reachable either system is down or system " \
                                                   "could not configured properly. "
    logger.info(f"System is reachable successfully: {system_details}")
def test_linux_system_health_check(core_session, setup_pas_system_for_unix):
    """
    C1556 : Linux system health check
    :param core_session: Authenticated Centrify Session.
    :param setup_pas_system_for_unix: create one system and return details associated to it.
    """
    system_info = setup_pas_system_for_unix
    system_details = RedrockController.get_computer_with_ID(
        core_session, system_info[0])
    ResourceManager.get_date(system_details['LastHealthCheck'])
    assert system_details['HealthStatus'] == 'OK', "Remote System is not reachable either system is down or system " \
                                                   "could not configured properly. "
    logger.info(f"Remote System is reachable successfully: {system_details}")
예제 #5
0
def test_manage_to_un_managed(core_session, pas_setup):
    """
     :param core_session: Authenticated Centrify Session.
    :param pas_setup: Fixture for adding a system and an account associated with it.
    TC: C2545 Change managed account to un managed account
    trying to Validate account activity log's
                Steps:
                1. Try to add a system with managed account
                    -Assert Failure
                2. Try to check manage account updated to un manage account
                    -Assert Failure
    """
    user_name = core_session.get_user().get_login_name()
    sys_id, acc_id, sys_info = pas_setup
    logger.info(f"System: {sys_info[0]} successfully added with UUID: {sys_id} and account: {sys_info[4]} "
                f"with UUID: {acc_id} associated with it.")
    success, response = ResourceManager.update_account(core_session, acc_id, sys_info[4], host=sys_id,
                                                       ismanaged=False)
    assert success, f'Updating account failed. API response: {response}'
    logger.info(f'account updated successfully: {response}')
    checkflag = True
    counter = 0
    row = None
    while checkflag is True:
        if counter != 5:
            row = ResourceManager.get_system_activity(core_session, sys_id)
            if row is not None:
                break
        checkflag = False
        counter += 1
    reports = []
    for system_activity in row:
        if system_activity['Detail'].__contains__("updated local"):
            reports.append(system_activity["Detail"])
    created_date_json = str(row[0]['When'])
    ResourceManager.get_date(created_date_json)
    assert f'{user_name} updated local account "{sys_info[4]}" for "{sys_info[0]}"({sys_info[1]}) ' \
           f'with credential type Password ' in reports[0], "Account Not Added"
    logger.info(f"account activity list:{row}")
def test_Change_Account_managed(core_session, pas_config, remote_users_qty1,
                                detect_proxy):
    """
    :param core_session:  Authenticated Centrify Session.
    :param pas_config: fixture reading data from resources_data.yaml file.
    TC: C2544 - Change Account to be a managed account and verify password changed in 5 minutes
    trying to validate the added manage Account password Activity log's
            Steps:
                1. Try to add a system along with an manage account
                    -Assert Failure
                2. Try to check in the account password is rotated
                    -Assert Failure
                3. Try to validate account activity log's
    """
    user = core_session.get_user()
    user_name = user.get_login_name()

    sys_name = f"Automatedsystem{guid()}"
    res_data = pas_config
    user = remote_users_qty1
    sys_result, status = ResourceManager.add_system(
        core_session, sys_name,
        res_data['Windows_infrastructure_data']['FQDN'], 'Windows', "Rdp")
    assert status, f"failed to add system"

    success, response = ResourceManager.update_system(
        core_session,
        sys_result,
        sys_name,
        res_data['Windows_infrastructure_data']['FQDN'],
        'Windows',
        managementmode='RpcOverTcp')
    assert success, f"failed to change the management mode:API response result:{response}"
    logger.info(f"Successfully updated the system:{response}")

    account_id, status = ResourceManager.add_account(core_session, user[0],
                                                     'Hello123', sys_result)
    assert status, f'failed to add account'

    success, response = ResourceManager.update_account(core_session,
                                                       account_id,
                                                       user[0],
                                                       host=sys_result,
                                                       ismanaged=True)
    assert success, f'Updating account failed. API response: {response}'

    server_id = ResourceManager.wait_for_server_to_exist_return_id(
        core_session, sys_name)
    acc_id = ResourceManager.wait_for_account_to_exist_return_id(
        core_session, user[0])
    assert server_id == sys_result, "Server was not created"
    assert acc_id == account_id, "Account was not created"

    res, success = ResourceManager.rotate_password(core_session, account_id)
    assert success, f"Failed to add account in the portal: {res}"

    checkout_password, response = ResourceManager.check_out_password(
        core_session, 1, accountid=account_id)

    assert checkout_password[
        'Password'] != 'Hello123', f'Checkout Password Failed. API response: {response}'
    row = ResourceManager.get_system_activity(core_session, sys_result)
    checkout_activity = row[0]['Detail']
    created_date_json = str(row[0]['When'])
    ResourceManager.get_date(created_date_json)
    assert f'{user_name} checked out local account "{user[0]}" password for system "{sys_name}"' \
           f'({res_data["Windows_infrastructure_data"]["FQDN"]})' == checkout_activity, "No system activity data "
    logger.info(f"account activity list:{row}")
def test_checkout_password(core_session, pas_config, cleanup_resources,
                           cleanup_accounts, remote_users_qty1):
    """TC C2554 - Checkout password for a windows managed account from Accounts page
     trying to Checkout password for a windows managed account from Accounts page
        Steps:
           Pre: Create system with 1 manage account hand
              1. Try to Checkout password for an account
                  -Assert Failure
              2. Try to check my password checkouts in workspace
                  -Assert Failure
    """
    system_list = cleanup_resources[0]
    accounts_list = cleanup_accounts[0]
    # Getting system details.
    sys_name = f'{"Win-2012"}{guid()}'
    user_password = '******'
    sys_details = pas_config
    add_user_in_target_system = remote_users_qty1
    fdqn = sys_details['Windows_infrastructure_data']['FQDN']
    # Adding system.
    add_sys_result, add_sys_success = ResourceManager.add_system(
        core_session, sys_name, fdqn, 'Windows', "Rdp")
    assert add_sys_success, f"failed to add system:API response result:{add_sys_result}"
    logger.info(f"Successfully added system:{add_sys_result}")
    system_list.append(add_sys_result)

    success, response = ResourceManager.update_system(
        core_session,
        add_sys_result,
        sys_name,
        fdqn,
        'Windows',
        managementmode='RpcOverTcp')
    assert success, f"failed to change the management mode:API response result:{response}"
    logger.info(f"Successfully updated the system:{add_sys_result}")

    # Adding account in portal.
    acc_result, acc_success = ResourceManager.add_account(
        core_session,
        add_user_in_target_system[0],
        password=user_password,
        host=add_sys_result,
        ismanaged=True)
    assert acc_success, f"Failed to add account in the portal: {acc_result}"
    logger.info(
        f"Successfully added account {add_user_in_target_system[0]} in the portal"
    )

    server_id = ResourceManager.wait_for_server_to_exist_return_id(
        core_session, sys_name)
    acc_id = ResourceManager.wait_for_account_to_exist_return_id(
        core_session, add_user_in_target_system[0])
    assert server_id == add_sys_result, "Server was not created"
    assert acc_id == acc_result, "Account was not created"

    res, success = ResourceManager.rotate_password(core_session, acc_result)
    assert success, f"Failed to add account in the portal: {res}"

    password_checkout_result, password_checkout_success = \
        ResourceManager.check_out_password(core_session, 1, accountid=acc_result)
    assert password_checkout_result['Password'] != user_password, \
        f"expected password equal to actual password: {password_checkout_result}"
    logger.info(
        f"password successfully checkout Account password: {password_checkout_result}"
    )
    my_password_checkout = RedrockController.get_total_checkouts(core_session)
    created_date_json = str(my_password_checkout[0]['LoanDate'])
    ResourceManager.get_date(created_date_json)
    check_out_details = []
    for i in my_password_checkout:
        if i['Summary'] in f'{add_user_in_target_system[0]} ({sys_name})':
            check_out_details.append(i['Summary'])
    assert check_out_details[0] == f'{add_user_in_target_system[0]} ({sys_name})',\
        "fail to checkout password from workspace"
    logger.info(
        f"password successfully checkout Account password::{my_password_checkout}"
    )
    accounts_list.append(acc_result)
    password_check_in_result, password_check_in_success = ResourceManager.check_in_password(
        core_session, coid=password_checkout_result['COID'])
    assert password_check_in_success, f"password check-in Failed. API response result: {password_check_in_result}"
    logger.info(
        f"password successfully check in for account: {add_user_in_target_system[0]}"
    )