Exemplo n.º 1
0
def test_negative_create_with_duplicated_parameters():
    """Attempt to create multiple parameters with same key name for the
    same subnet

    :id: aa69bdcc-e833-41e4-8f72-7139bdd64daa

    :steps:

        1. Create Subnet with all the details
        2. Create Multiple parameters having duplicate key names

    :expectedresults:

        1. The subnet parameters should not be created with duplicate
            names
        2. An error for duplicate parameter should be thrown

    :CaseImportance: Low
    """
    subnet = entities.Subnet().create()
    entities.Parameter(name='duplicateParameter', subnet=subnet.id).create()
    with pytest.raises(HTTPError) as context:
        entities.Parameter(name='duplicateParameter',
                           subnet=subnet.id).create()
    assert re.search("Name has already been taken",
                     context.value.response.text)
Exemplo n.º 2
0
def test_positive_create_with_inherited_params(module_org, module_location):
    """Create a new Host in organization and location with parameters

    :BZ: 1287223

    :id: 5e17e968-7fe2-4e5b-90ca-ae66f4e5307a

    :customerscenario: true

    :expectedresults: Host has inherited parameters from organization and
        location as well as global parameters

    :CaseImportance: High
    """
    org_param = entities.Parameter(organization=module_org).create()
    loc_param = entities.Parameter(location=module_location).create()
    host = entities.Host(location=module_location, organization=module_org).create()
    # get global parameters
    glob_param_list = {(param.name, param.value) for param in entities.CommonParameter().search()}
    # if there are no global parameters, create one
    if len(glob_param_list) == 0:
        param_name = gen_string('alpha')
        param_global_value = gen_string('numeric')
        entities.CommonParameter(name=param_name, value=param_global_value).create()
        glob_param_list = {
            (param.name, param.value) for param in entities.CommonParameter().search()
        }
    assert len(host.all_parameters) == 2 + len(glob_param_list)
    innerited_params = {(org_param.name, org_param.value), (loc_param.name, loc_param.value)}
    expected_params = innerited_params.union(glob_param_list)
    assert expected_params == {(param['name'], param['value']) for param in host.all_parameters}
Exemplo n.º 3
0
    def test_negative_create_with_duplicated_parameters(self):
        """Attempt to create multiple parameters with same key name for the
        same subnet

        :id: aa69bdcc-e833-41e4-8f72-7139bdd64daa

        :steps:

            1. Create Subnet with all the details
            2. Create Multiple parameters having duplicate key names

        :expectedresults:

            1. The subnet parameters should not be created with duplicate
                names
            2. An error for duplicate parameter should be thrown
        """
        subnet = entities.Subnet().create()
        entities.Parameter(
            name='duplicateParameter', subnet=subnet.id
        ).create()
        with self.assertRaises(HTTPError) as context:
            entities.Parameter(
                name='duplicateParameter', subnet=subnet.id
            ).create()
        self.assertRegexpMatches(
            context.exception.response.text,
            "Name has already been taken"
        )
Exemplo n.º 4
0
    def test_positive_create_with_parameter_and_valid_separator(self):
        """Subnet parameters can be created with name with valid separators

        :id: d1e2d75a-a1e8-4767-93f1-0bb1b75e10a0

        :steps:
            1. Create Subnet with all the details
            2. Create subnet parameter having key with name separated
                by valid separators(e.g fwd slash) and value

        :expectedresults: The parameter with name separated by valid
            separators should be saved in subnet
        """
        subnet = entities.Subnet().create()
        valid_separators = [',', '/', '-', '|']
        valid_names = []
        for separator in valid_separators:
            valid_names.append(
                '{}'.format(separator).join(generate_strings_list())
            )
        value = gen_string('utf8')
        for name in valid_names:
            with self.subTest(name):
                subnet_param = entities.Parameter(
                    name=name,
                    subnet=subnet.id,
                    value=value
                ).create()
                self.assertEqual(subnet_param.name, name)
                self.assertEqual(subnet_param.value, value)
Exemplo n.º 5
0
    def test_positive_add_parameter(self):
        """Parameters can be created in subnet

        :id: c1dae6f4-45b1-45db-8529-d7918e41a99b

        :steps:

            1. Create Subnet with all the details
            2. Create subnet parameter with single key and single value

        :expectedresults: The parameter should be created in subnet

        :CaseImportance: Medium
        """
        subnet = entities.Subnet().create()
        for name in generate_strings_list():
            with self.subTest(name):
                value = gen_string('utf8')
                subnet_param = entities.Parameter(
                    subnet=subnet.id,
                    name=name,
                    value=value
                ).create()
                self.assertEqual(subnet_param.name, name)
                self.assertEqual(subnet_param.value, value)
Exemplo n.º 6
0
def test_negative_create_with_parameter_and_invalid_separator(name):
    """Subnet parameters can not be created with name with invalid
    separators

    :id: 08d10b75-a0db-4a11-a915-965a2a207d16

    :parametrized: yes

    :steps:

        1. Create Subnet with all the details
        2. Create subnet parameter having key with name separated by
            invalid separators(e.g spaces) and value

    :expectedresults:

        1. The parameter with name separated by invalid separators
            should not be saved in subnet
        2. An error for invalid name should be thrown.

    :CaseImportance: Low
    """
    subnet = entities.Subnet().create()
    with pytest.raises(HTTPError):
        entities.Parameter(name=name, subnet=subnet.id).create()
Exemplo n.º 7
0
def module_org():
    org = entities.Organization().create()
    # adding remote_execution_connect_by_ip=Yes at org level
    entities.Parameter(name='remote_execution_connect_by_ip',
                       value='Yes',
                       organization=org.id).create()
    return org
Exemplo n.º 8
0
    def test_negative_update_parameter(self):
        """Subnet parameter can not be updated with invalid names

        :id: fcdbad13-ad96-4152-8e20-e023d61a2853

        :steps:

            1. Create valid subnet with valid parameter
            2. Update above subnet parameter with some invalid
                name. e.g name with spaces

        :expectedresults:

            1. The parameter should not be updated with invalid name
            2. An error for invalid name should be thrown
        """
        subnet = entities.Subnet().create()
        sub_param = entities.Parameter(
            name=gen_string('utf8'),
            subnet=subnet.id,
            value=gen_string('utf8')
        ).create()
        invalid_values = invalid_values_list() + ['name with space']
        for new_name in invalid_values:
            with self.subTest(new_name):
                with self.assertRaises(HTTPError):
                    sub_param.name = new_name
                    sub_param.update(['name'])
Exemplo n.º 9
0
    def test_positive_add_parameter_with_values_and_separator(self):
        """Subnet parameters can be created with values separated by comma

        :id: b3de6f96-7c39-4c44-b91c-a6d141f5dd6a

        :steps:

            1. Create Subnet with all the details
            2. Create subnet parameter having single key and values
                separated with comma

        :expectedresults: The parameter with values separated by comma should
            be saved in subnet
        """
        subnet = entities.Subnet().create()
        name = gen_string('alpha')
        values = ', '.join(generate_strings_list())
        with self.subTest(name):
            subnet_param = entities.Parameter(
                name=name,
                subnet=subnet.id,
                value=values
            ).create()
            self.assertEqual(subnet_param.name, name)
            self.assertEqual(subnet_param.value, values)
Exemplo n.º 10
0
def test_negative_update_parameter(new_name):
    """Subnet parameter can not be updated with invalid names

    :id: fcdbad13-ad96-4152-8e20-e023d61a2853

    :parametrized: yes

    :steps:

        1. Create valid subnet with valid parameter
        2. Update above subnet parameter with some invalid
            name. e.g name with spaces

    :expectedresults:

        1. The parameter should not be updated with invalid name
        2. An error for invalid name should be thrown

    :CaseImportance: Medium
    """
    subnet = entities.Subnet().create()
    sub_param = entities.Parameter(name=gen_string('utf8'),
                                   subnet=subnet.id,
                                   value=gen_string('utf8')).create()
    with pytest.raises(HTTPError):
        sub_param.name = new_name
        sub_param.update(['name'])
Exemplo n.º 11
0
    def test_negative_create_with_parameter_and_invalid_separator(self):
        """Subnet parameters can not be created with name with invalid
        separators

        :id: 08d10b75-a0db-4a11-a915-965a2a207d16

        :steps:

            1. Create Subnet with all the details
            2. Create subnet parameter having key with name separated by
                invalid separators(e.g spaces) and value

        :expectedresults:

            1. The parameter with name separated by invalid separators
                should not be saved in subnet
            2. An error for invalid name should be thrown.
        """
        subnet = entities.Subnet().create()
        invalid_values = invalid_values_list() + ['name with space']
        for name in invalid_values:
            with self.subTest(name):
                with self.assertRaises(HTTPError):
                    entities.Parameter(
                        name=name,
                        subnet=subnet.id
                    ).create()
Exemplo n.º 12
0
def _org():
    org = entities.Organization().create()
    # adding remote_execution_connect_by_ip=Yes at org level
    entities.Parameter(name='remote_execution_connect_by_ip',
                       value='Yes',
                       organization=org.id).create()
    upload_manifest_locked(org.id)
    return org
Exemplo n.º 13
0
    def test_positive_delete_subnet_parameter(self):
        """Subnet parameter can be deleted

        :id: 972b66ec-d506-4fcb-9786-c62f2f79ac1a

        :steps:

            1. Create valid subnet with valid parameter
            2. Delete the above subnet parameter

        :expectedresults: The parameter should be deleted from subnet
        """
        subnet = entities.Subnet().create()
        sub_param = entities.Parameter(subnet=subnet.id).create()
        sub_param.delete()
        with self.assertRaises(HTTPError):
            sub_param.read()
Exemplo n.º 14
0
def test_positive_add_parameter(name):
    """Parameters can be created in subnet

    :id: c1dae6f4-45b1-45db-8529-d7918e41a99b

    :parametrized: yes

    :steps:

        1. Create Subnet with all the details
        2. Create subnet parameter with single key and single value

    :expectedresults: The parameter should be created in subnet

    :CaseImportance: Medium
    """
    subnet = entities.Subnet().create()
    value = gen_string('utf8')
    subnet_param = entities.Parameter(subnet=subnet.id, name=name,
                                      value=value).create()
    assert subnet_param.name == name
    assert subnet_param.value == value
Exemplo n.º 15
0
    def test_positive_list_parameters(self):
        """Satellite lists all the subnet parameters

        :id: ce86d531-bf6b-45a9-81e3-67e1b3398f76

        :steps:

            1. Create subnet with all the details
            2. Add two parameters in subnet
            3. List parameters of subnet

        :expectedresults: The satellite should display all the subnet
            parameters
        """
        parameter = {'name': gen_string('alpha'), 'value': gen_string('alpha')}
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()
        org_subnet = entities.Subnet(
            location=[loc],
            organization=[org],
            ipam='DHCP',
            vlanid=gen_string('numeric', 3),
            subnet_parameters_attributes=[parameter],
        ).create()
        self.assertEqual(org_subnet.subnet_parameters_attributes[0]['name'],
                         parameter['name'])
        self.assertEqual(org_subnet.subnet_parameters_attributes[0]['value'],
                         parameter['value'])
        sub_param = entities.Parameter(name=gen_string('alpha'),
                                       subnet=org_subnet.id,
                                       value=gen_string('alpha')).create()
        org_subnet = entities.Subnet(id=org_subnet.id).read()
        params_list = {
            param['name']: param['value']
            for param in org_subnet.subnet_parameters_attributes
            if param['name'] == sub_param.name
        }
        self.assertEqual(params_list[sub_param.name], sub_param.value)
Exemplo n.º 16
0
def test_positive_create_with_parameter_and_valid_separator(separator):
    """Subnet parameters can be created with name with valid separators

    :id: d1e2d75a-a1e8-4767-93f1-0bb1b75e10a0

    :parametrized: yes

    :steps:
        1. Create Subnet with all the details
        2. Create subnet parameter having key with name separated
            by valid separators(e.g fwd slash) and value

    :expectedresults: The parameter with name separated by valid
        separators should be saved in subnet

    :CaseImportance: Low
    """
    name = f'{separator}'.join(generate_strings_list())
    subnet = entities.Subnet().create()
    value = gen_string('utf8')
    subnet_param = entities.Parameter(name=name, subnet=subnet.id,
                                      value=value).create()
    assert subnet_param.name == name
    assert subnet_param.value == value
Exemplo n.º 17
0
def test_module_stream_actions_on_content_host(session, vm_module_streams):
    """Check remote execution for module streams actions e.g. install, remove, disable
    works on content host. Verify that correct stream module stream
    get installed/removed.

    :id: 684e467e-b41c-4b95-8450-001abe85abe0

    :expectedresults: Remote execution for module actions should succeed.

    :CaseLevel: System
    """
    stream_version = "5.21"
    run_remote_command_on_content_host('dnf -y upload-profile',
                                       vm_module_streams)
    with session:
        entities.Parameter(name='remote_execution_connect_by_ip',
                           value='Yes',
                           host=vm_module_streams.hostname)
        # install Module Stream
        result = session.contenthost.execute_module_stream_action(
            vm_module_streams.hostname,
            action_type="Install",
            module_name=FAKE_2_CUSTOM_PACKAGE_NAME,
            stream_version=stream_version)
        assert result['overview']['hosts_table'][0]['Status'] == 'success'
        module_stream = session.contenthost.search_module_stream(
            vm_module_streams.hostname,
            FAKE_2_CUSTOM_PACKAGE_NAME,
            status='Installed',
            stream_version=stream_version)
        assert module_stream[0]['Name'] == FAKE_2_CUSTOM_PACKAGE_NAME
        assert module_stream[0]['Stream'] == stream_version
        assert 'Enabled' and 'Installed' in module_stream[0]['Status']

        # remove Module Stream
        result = session.contenthost.execute_module_stream_action(
            vm_module_streams.hostname,
            action_type="Remove",
            module_name=FAKE_2_CUSTOM_PACKAGE_NAME,
            stream_version=stream_version)
        assert result['overview']['hosts_table'][0]['Status'] == 'success'
        assert not session.contenthost.search_module_stream(
            vm_module_streams.hostname,
            FAKE_2_CUSTOM_PACKAGE_NAME,
            status='Installed',
            stream_version=stream_version)
        module_stream = session.contenthost.search_module_stream(
            vm_module_streams.hostname,
            FAKE_2_CUSTOM_PACKAGE_NAME,
            status='Enabled',
            stream_version=stream_version)
        assert module_stream[0]['Name'] == FAKE_2_CUSTOM_PACKAGE_NAME
        assert module_stream[0]['Stream'] == stream_version
        assert module_stream[0]['Status'] == "Enabled"

        # disable Module Stream
        result = session.contenthost.execute_module_stream_action(
            vm_module_streams.hostname,
            action_type='Disable',
            module_name=FAKE_2_CUSTOM_PACKAGE_NAME,
            stream_version=stream_version)
        assert result['overview']['hosts_table'][0]['Status'] == 'success'
        module_stream = session.contenthost.search_module_stream(
            vm_module_streams.hostname,
            FAKE_2_CUSTOM_PACKAGE_NAME,
            status='Disabled',
            stream_version=stream_version)
        assert module_stream[0]['Name'] == FAKE_2_CUSTOM_PACKAGE_NAME
        assert module_stream[0]['Stream'] == stream_version
        assert module_stream[0]['Status'] == "Disabled"

        # reset Module Stream
        result = session.contenthost.execute_module_stream_action(
            vm_module_streams.hostname,
            action_type='Reset',
            module_name=FAKE_2_CUSTOM_PACKAGE_NAME,
            stream_version=stream_version)
        assert result['overview']['hosts_table'][0]['Status'] == 'success'
        assert not session.contenthost.search_module_stream(
            vm_module_streams.hostname,
            FAKE_2_CUSTOM_PACKAGE_NAME,
            status='Disabled',
            stream_version=stream_version)
        module_stream = session.contenthost.search_module_stream(
            vm_module_streams.hostname,
            FAKE_2_CUSTOM_PACKAGE_NAME,
            status='Unknown',
            stream_version=stream_version)
        assert module_stream[0]['Name'] == FAKE_2_CUSTOM_PACKAGE_NAME
        assert module_stream[0]['Stream'] == stream_version
        assert module_stream[0]['Status'] == ""