Ejemplo n.º 1
0
def test_delete_parent_domain_no_effect_child_domain(core_session,
                                                     domain_setup):
    """
      TC:C2216 Delete parent domain no effect child domain.
      :param core_session: Returns API session.
      :param domain_setup: fixture for creating domain.

    """
    # Creating a parent domain.
    parent_domain_id, domain_info = domain_setup

    # Create a child domain.
    child_domain_name = f"{'R1F1C1'}{guid()}"
    new_child_domain_id, add_child_domain_success = ResourceManager.add_child_domain(
        core_session,
        child_domain_name,
        description='test_child_domain',
        parent_id=parent_domain_id)
    assert add_child_domain_success, f'Failed to create child domain:API response result:{new_child_domain_id}'
    logger.info(f"Successfully created child domain:{new_child_domain_id}")

    # Trying to delete parent domain without deleting a child,expecting a failure.
    failed_del_domain_result, failed_del_domain_success = ResourceManager.del_domain(
        core_session, parent_domain_id)

    assert failed_del_domain_success is False, f'Could able to delete parent domain:API response ' \
                                               f'result: {failed_del_domain_result} '
    logger.info(
        f"Could not able to delete parent domain without deleting a child:{failed_del_domain_result}"
    )

    # Trying to delete child domain expecting child domain deleted successfully.
    child_del_domain_result, child_del_domain_success = ResourceManager.del_domain(
        core_session, new_child_domain_id)

    assert child_del_domain_success, f'Fail to delete child  domain:API response ' \
                                     f'result: {child_del_domain_result} '
    logger.info(
        f"Successfully deleted child  domain: {child_del_domain_result}")
def test_domain_action_try_to_delete_parent_domain(core_session, domain_setup,
                                                   cleanup_resources,
                                                   core_admin_ui):
    """
      TC:C2112 Check domain's "Actions" when try to delete the parent domain"".
      :param core_session: Returns API session.
      :param domain_setup: Fixture for domain creation.
      :param cleanup_resources: cleaner for domain.
      :param core_admin_ui: Return browser session.

    """

    # Creating a parent domain.
    parent_domain_id, domain_info = domain_setup
    parent_domain_name = domain_info[0]

    # Create a child domain.
    child_domain_name = f"{'child'}{guid()}"
    domain_cleanup_list = cleanup_resources[1]
    new_child_domain_id, add_child_domain_success = ResourceManager.add_child_domain(
        core_session,
        child_domain_name,
        description='test_child_domain',
        parent_id=parent_domain_id)
    assert add_child_domain_success, f'Failed to create child domain:API response result:{new_child_domain_id}'
    logger.info(
        f"Successfully created child domain:API response result: {new_child_domain_id}"
    )
    domain_cleanup_list.append(new_child_domain_id)

    # Trying to delete parent domain without deleting a child,expecting a failure.
    failed_del_domain_result, failed_del_domain_success = ResourceManager.del_domain(
        core_session, parent_domain_id)

    assert failed_del_domain_success is False, f'Could able to delete domain:API response ' \
                                               f'result: {failed_del_domain_result} '
    logger.info(
        f"Successfully found error message Unable to delete the domain."
        f"Domain has child domains {failed_del_domain_result}")

    # UI Launch
    ui = core_admin_ui
    ui.navigate('Resources', 'Domains')
    ui.switch_context(RenderedTab('Domains'))
    ui.check_span(parent_domain_name)
    ui.check_span(child_domain_name)
    ui.check_actions(["Set Administrative Account", "Add To Set"])
    logger.info(
        'Successfully find "Set Administrative Account" & "Add To Set" in Actions Menu.'
    )
def test_delete_domain(core_session, domain_config_data):
    """

                 Delete Domain

       """
    conf = domain_config_data
    name = conf['pas_bat_scenario1_infrastructure_data'][0]
    domain_name = name['Domain_name2']
    if domain_name in name.values():
        domain_id = RedrockController.get_domain_id_by_name(
            core_session, domain_name)
        del_domain = ResourceManager.del_domain(core_session, domain_id)
        assert del_domain, f'Failed to delete domain {domain_id}'
        logger.info(f"Domain deleted successfully {domain_id}")
    else:
        logger.info(f"Domain Name {domain_name} does not exist!")