def test_v2v_infra_map_special_chars(request, appliance, source_provider, provider, soft_assert):
    """
    Test infra map with special characters

    Polarion:
        assignee: ytale
        initialEstimate: 1/2h
        caseimportance: low
        caseposneg: positive
        testtype: functional
        startsin: 5.10
        casecomponent: V2V
        testSteps:
            1. Add source and target provider
            2. Create infra map with special characters
    """
    map_collection = appliance.collections.v2v_infra_mappings
    map_data = infra_mapping_default_data(source_provider, provider)
    map_data["name"] = fauxfactory.gen_special(length=4)
    mapping = map_collection.create(**map_data)

    @request.addfinalizer
    def _cleanup():
        map_collection.delete(mapping)
    view = navigate_to(map_collection, "All")
    soft_assert(mapping.name in view.infra_mapping_list.read())
    view.infra_mapping_list.delete_mapping(mapping.name)
    view.wait_displayed()
    try:
        assert mapping.name not in view.infra_mapping_list.read()
    except NoSuchElementException:
        # meaning there was only one mapping that is deleted, list is empty
        pass
def test_v2v_infra_map_special_chars(request, appliance, source_provider,
                                     provider, soft_assert):
    """
    Test infra map with special characters

    Polarion:
        assignee: sshveta
        initialEstimate: 1/2h
        caseimportance: low
        caseposneg: positive
        testtype: functional
        startsin: 5.10
        casecomponent: V2V
        testSteps:
            1. Add source and target provider
            2. Create infra map with special characters
    """
    map_collection = appliance.collections.v2v_infra_mappings
    map_data = infra_mapping_default_data(source_provider, provider)
    map_data["name"] = fauxfactory.gen_special(length=4)
    mapping = map_collection.create(**map_data)

    @request.addfinalizer
    def _cleanup():
        map_collection.delete(mapping)

    view = navigate_to(map_collection, "All")
    soft_assert(mapping.name in view.infra_mapping_list.read())
    view.infra_mapping_list.delete_mapping(mapping.name)
    view.wait_displayed()
    try:
        assert mapping.name not in view.infra_mapping_list.read()
    except NoSuchElementException:
        # meaning there was only one mapping that is deleted, list is empty
        pass
def test_v2v_mapping_with_special_chars(appliance, v2v_providers, form_data_single_datastore,
                                        soft_assert):
    """
    Polarion:
        assignee: kkulkarn
        casecomponent: V2V
        initialEstimate: 1/4h
        subcomponent: RHV
        upstream: yes
    """
    # Test mapping can be created with non-alphanumeric name e.g '!@#$%^&*()_+)=-,./,''[][]]':
    infrastructure_mapping_collection = appliance.collections.v2v_mappings
    form_data_single_datastore['general']['name'] = fauxfactory.gen_special(length=10)
    mapping = infrastructure_mapping_collection.create(form_data_single_datastore)
    view = navigate_to(infrastructure_mapping_collection, 'All')
    soft_assert(mapping.name in view.infra_mapping_list.read())
    mapping_list = view.infra_mapping_list
    mapping_list.delete_mapping(mapping.name)
    view.browser.refresh()
    view.wait_displayed()
    try:
        assert mapping.name not in view.infra_mapping_list.read()
    except NoSuchElementException:
        # meaning there was only one mapping that is deleted, list is empty
        pass
def test_v2v_mapping_with_special_chars(appliance, v2v_providers,
                                        form_data_single_datastore,
                                        soft_assert):
    """
    Polarion:
        assignee: kkulkarn
        casecomponent: V2V
        initialEstimate: 1/4h
        subcomponent: RHV
        upstream: yes
    """
    # Test mapping can be created with non-alphanumeric name e.g '!@#$%^&*()_+)=-,./,''[][]]':
    infrastructure_mapping_collection = appliance.collections.v2v_mappings
    form_data_single_datastore['general']['name'] = fauxfactory.gen_special(
        length=10)
    mapping = infrastructure_mapping_collection.create(
        form_data_single_datastore)
    view = navigate_to(infrastructure_mapping_collection, 'All')
    soft_assert(mapping.name in view.infra_mapping_list.read())
    mapping_list = view.infra_mapping_list
    mapping_list.delete_mapping(mapping.name)
    view.browser.refresh()
    view.wait_displayed()
    try:
        assert mapping.name not in view.infra_mapping_list.read()
    except NoSuchElementException:
        # meaning there was only one mapping that is deleted, list is empty
        pass
Example #5
0
def test_migration_special_char_name(request, appliance, v2v_providers,
                                     host_creds, conversion_tags,
                                     form_data_vm_obj_single_datastore):
    """Tests migration where name of migration plan is comprised of special non-alphanumeric
       characters, such as '@#$(&#@('."""
    infrastructure_mapping_collection = appliance.collections.v2v_mappings
    mapping = infrastructure_mapping_collection.create(
        form_data_vm_obj_single_datastore.form_data)

    @request.addfinalizer
    def _cleanup():
        infrastructure_mapping_collection.delete(mapping)

    migration_plan_collection = appliance.collections.v2v_plans
    # fauxfactory.gen_special() used here to create special character string e.g. #$@#@
    migration_plan = migration_plan_collection.create(
        name="{}".format(fauxfactory.gen_special()),
        description="desc_{}".format(fauxfactory.gen_alphanumeric()),
        infra_map=mapping.name,
        vm_list=form_data_vm_obj_single_datastore.vm_list,
        start_migration=True)

    # explicit wait for spinner of in-progress status card
    view = appliance.browser.create_view(
        navigator.get_class(migration_plan_collection, 'All').VIEW.pick())
    wait_for(func=view.progress_card.is_plan_started,
             func_args=[migration_plan.name],
             message="migration plan is starting, be patient please",
             delay=5,
             num_sec=150,
             handle_exception=True)

    # wait until plan is in progress
    wait_for(func=view.plan_in_progress,
             func_args=[migration_plan.name],
             message="migration plan is in progress, be patient please",
             delay=5,
             num_sec=1800)

    view.switch_to("Completed Plans")
    view.wait_displayed()
    migration_plan_collection.find_completed_plan(migration_plan)
    logger.info(
        "For plan %s, migration status after completion: %s, total time elapsed: %s",
        migration_plan.name,
        view.migration_plans_completed_list.get_vm_count_in_plan(
            migration_plan.name),
        view.migration_plans_completed_list.get_clock(migration_plan.name))
    # validate MAC address matches between source and target VMs
    assert view.migration_plans_completed_list.is_plan_succeeded(
        migration_plan.name)
    src_vm = form_data_vm_obj_single_datastore.vm_list[0]
    migrated_vm = get_migrated_vm_obj(src_vm, v2v_providers.rhv_provider)
    assert src_vm.mac_address == migrated_vm.mac_address
def test_migration_special_char_name(request, appliance, v2v_providers, host_creds, conversion_tags,
                                    form_data_vm_obj_single_datastore):
    """Tests migration where name of migration plan is comprised of special non-alphanumeric
       characters, such as '@#$(&#@('.

    Polarion:
        assignee: kkulkarn
        casecomponent: V2V
        initialEstimate: 1/2h
        subcomponent: RHV
        upstream: yes
    """
    infrastructure_mapping_collection = appliance.collections.v2v_mappings
    mapping = infrastructure_mapping_collection.create(form_data_vm_obj_single_datastore.form_data)

    @request.addfinalizer
    def _cleanup():
        infrastructure_mapping_collection.delete(mapping)

    migration_plan_collection = appliance.collections.v2v_plans
    # fauxfactory.gen_special() used here to create special character string e.g. #$@#@
    migration_plan = migration_plan_collection.create(
        name="{}".format(fauxfactory.gen_special()), description="desc_{}"
        .format(fauxfactory.gen_alphanumeric()), infra_map=mapping.name,
        vm_list=form_data_vm_obj_single_datastore.vm_list, start_migration=True)

    # explicit wait for spinner of in-progress status card
    view = appliance.browser.create_view(
        navigator.get_class(migration_plan_collection, 'All').VIEW.pick())
    wait_for(func=view.progress_card.is_plan_started, func_args=[migration_plan.name],
        message="migration plan is starting, be patient please", delay=5, num_sec=150,
        handle_exception=True, fail_cond=False)

    # wait until plan is in progress
    wait_for(func=view.plan_in_progress, func_args=[migration_plan.name],
        message="migration plan is in progress, be patient please",
        delay=5, num_sec=1800)

    view.switch_to("Completed Plans")
    view.wait_displayed()
    migration_plan_collection.find_completed_plan(migration_plan)
    logger.info("For plan %s, migration status after completion: %s, total time elapsed: %s",
        migration_plan.name, view.migration_plans_completed_list.get_vm_count_in_plan(
            migration_plan.name), view.migration_plans_completed_list.get_clock(
            migration_plan.name))
    # validate MAC address matches between source and target VMs
    assert view.migration_plans_completed_list.is_plan_succeeded(migration_plan.name)
    src_vm = form_data_vm_obj_single_datastore.vm_list[0]
    migrated_vm = get_migrated_vm_obj(src_vm, v2v_providers.rhv_provider)
    assert src_vm.mac_address == migrated_vm.mac_address
Example #7
0
def test_special_string():
    """Assert that only punctuation strings are returned."""
    VALID_CHARS = string.punctuation
    special_str = gen_special()
    for char in special_str:
        assert char in VALID_CHARS
def test_regex_dialog_disabled_validation(appliance, catalog, request):
    """
    Bugzilla:
        1721814
    Polarion:
        assignee: nansari
        casecomponent: Services
        initialEstimate: 1/16h
        startsin: 5.11
        testSteps:
            1. Create a dialog. Set regex_validation in text box ->  ^[0-9]*$
            2. Save the dialog
            3. Edit the dialog and disable the validation button of text box
            4. Use the dialog in a catalog
            5. Navigate to catalog order page
            6. Input anything except the format " ^[0-9]*$ "
        expectedResults:
            1.
            2.
            3.
            4.
            5.
            6. It shouldn't gives the validation error
    """
    service_dialog = appliance.collections.service_dialogs
    element_data = {
        "element_information": {
            "ele_label": fauxfactory.gen_alphanumeric(15, start="ele_label_"),
            "ele_name": fauxfactory.gen_alphanumeric(15, start="ele_name_"),
            "ele_desc": fauxfactory.gen_alphanumeric(15, start="ele_desc_"),
            "choose_type": "Text Box",
        },
        "options": {
            "validation_switch": True,
            "validation": "^[0-9]*$"
        },
    }
    sd = service_dialog.create(
        label=fauxfactory.gen_alphanumeric(start="dialog_"),
        description="my dialog")
    tab = sd.tabs.create(tab_label=fauxfactory.gen_alphanumeric(start="tab_"),
                         tab_desc="my tab desc")
    box = tab.boxes.create(
        box_label=fauxfactory.gen_alphanumeric(start="box_"),
        box_desc="my box desc")
    box.elements.create(element_data=[element_data])

    navigate_to(sd, "Edit")
    view = appliance.browser.create_view(EditElementView)
    label = element_data["element_information"]["ele_label"]
    view.element.edit_element(label)
    view.options.click()
    assert view.options.validation_switch.fill(False)
    view.ele_save_button.click()
    view.save_button.click()

    catalog_item = appliance.collections.catalog_items.create(
        appliance.collections.catalog_items.GENERIC,
        name=fauxfactory.gen_alphanumeric(15, start="cat_item_"),
        description="my catalog",
        display_in=True,
        catalog=catalog,
        dialog=sd)

    @request.addfinalizer
    def _cleanup():
        if catalog_item.exists:
            catalog_item.delete()
        sd.delete_if_exists()

    ele_name = element_data["element_information"]["ele_name"]
    service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog,
                                       catalog_item.name)
    view = navigate_to(service_catalogs, 'Order')

    input_data_list = [
        fauxfactory.gen_alpha(length=3),
        fauxfactory.gen_number(),
        fauxfactory.gen_special(length=5),
        fauxfactory.gen_alphanumeric(length=5)
    ]

    msg = f"""Entered text should match the format: {element_data["options"]["validation"]}"""

    for input_data in input_data_list:
        logger.info('Entering input data: %s ' % input_data)
        view.fields(ele_name).fill(input_data)
        element = view.fields(ele_name).input
        assert element.warning != msg
        assert view.submit_button.is_enabled