Exemplo n.º 1
0
    def test_positive_hypervisor_id_option(self, default_org, form_data,
                                           virtwho_config):
        """Verify hypervisor_id option by hammer virt-who-config update"

        :id: 082a0eec-f024-4605-b876-a8959cf68e0c

        :expectedresults: hypervisor_id option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        values = ['uuid', 'hostname']
        for value in values:
            VirtWhoConfig.update({
                'id': virtwho_config['id'],
                'hypervisor-id': value
            })
            result = VirtWhoConfig.info({'id': virtwho_config['id']})
            assert result['connection']['hypervisor-id'] == value
            config_file = get_configure_file(virtwho_config['id'])
            command = get_configure_command(virtwho_config['id'],
                                            default_org.name)
            deploy_configure_by_command(command,
                                        form_data['hypervisor-type'],
                                        org=default_org.label)
            assert get_configure_option('hypervisor_id', config_file) == value
        VirtWhoConfig.delete({'name': virtwho_config['name']})
        assert not VirtWhoConfig.exists(search=('name', form_data['name']))
Exemplo n.º 2
0
    def test_positive_proxy_option(self, form_data, virtwho_config):
        """Verify http_proxy option by hammer virt-who-config update"

        :id: 409d108e-e814-482b-93ed-09db89d21dda

        :expectedresults: http_proxy and no_proxy option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium

        :BZ: 1902199
        """
        # Check the https proxy option, update it via http proxy name
        https_proxy_url, https_proxy_name, https_proxy_id = create_http_proxy()
        no_proxy = 'test.satellite.com'
        VirtWhoConfig.update(
            {'id': virtwho_config['id'], 'http-proxy': https_proxy_name, 'no-proxy': no_proxy}
        )
        result = VirtWhoConfig.info({'id': virtwho_config['id']})
        assert result['http-proxy']['http-proxy-name'] == https_proxy_name
        assert result['connection']['ignore-proxy'] == no_proxy
        command = get_configure_command(virtwho_config['id'])
        deploy_configure_by_command(command, form_data['hypervisor-type'])
        assert get_configure_option('https_proxy', VIRTWHO_SYSCONFIG) == https_proxy_url
        assert get_configure_option('NO_PROXY', VIRTWHO_SYSCONFIG) == no_proxy

        # Check the http proxy option, update it via http proxy id
        http_proxy_url, http_proxy_name, http_proxy_id = create_http_proxy(type='http')
        VirtWhoConfig.update({'id': virtwho_config['id'], 'http-proxy-id': http_proxy_id})
        deploy_configure_by_command(command, form_data['hypervisor-type'])
        assert get_configure_option('http_proxy', VIRTWHO_SYSCONFIG) == http_proxy_url

        VirtWhoConfig.delete({'name': virtwho_config['name']})
        assert not VirtWhoConfig.exists(search=('name', form_data['name']))
Exemplo n.º 3
0
    def test_positive_interval_option(self, form_data, virtwho_config):
        """ Verify interval option by hammer virt-who-config update"

        :id: 5d558bca-534c-4bd4-b401-a0c362033c57

        :expectedresults: interval option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        options = {
            '60': '3600',
            '120': '7200',
            '240': '14400',
            '480': '28800',
            '720': '43200',
            '1440': '86400',
            '2880': '172800',
            '4320': '259200',
        }
        for key, value in sorted(options.items(),
                                 key=lambda item: int(item[0])):
            VirtWhoConfig.update({'id': virtwho_config['id'], 'interval': key})
            command = get_configure_command(virtwho_config['id'])
            deploy_configure_by_command(command, form_data['hypervisor-type'])
            assert get_configure_option('VIRTWHO_INTERVAL',
                                        VIRTWHO_SYSCONFIG) == value
        VirtWhoConfig.delete({'name': virtwho_config['name']})
        assert not VirtWhoConfig.exists(search=('name', form_data['name']))
Exemplo n.º 4
0
    def test_positive_proxy_option(self, form_data, virtwho_config):
        """ Verify http_proxy option by hammer virt-who-config update"

        :id: 409d108e-e814-482b-93ed-09db89d21dda

        :expectedresults: http_proxy and no_proxy option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        http_proxy = 'test.example.com:3128'
        no_proxy = 'test.satellite.com'
        VirtWhoConfig.update({
            'id': virtwho_config['id'],
            'proxy': http_proxy,
            'no-proxy': no_proxy
        })
        result = VirtWhoConfig.info({'id': virtwho_config['id']})
        assert result['connection']['http-proxy'] == http_proxy
        assert result['connection']['ignore-proxy'] == no_proxy
        command = get_configure_command(virtwho_config['id'])
        deploy_configure_by_command(command, form_data['hypervisor-type'])
        assert get_configure_option('http_proxy',
                                    VIRTWHO_SYSCONFIG) == http_proxy
        assert get_configure_option('NO_PROXY', VIRTWHO_SYSCONFIG) == no_proxy
        VirtWhoConfig.delete({'name': virtwho_config['name']})
        assert not VirtWhoConfig.exists(search=('name', form_data['name']))
Exemplo n.º 5
0
    def test_positive_hypervisor_id_option(self, form_data, virtwho_config):
        """Verify hypervisor_id option by hammer virt-who-config update"

        :id: 551cfc6c-71cd-40e7-9997-a7c85db02c1f

        :expectedresults: hypervisor_id option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        values = ['uuid', 'hostname']
        for value in values:
            VirtWhoConfig.update({
                'id': virtwho_config['id'],
                'hypervisor-id': value
            })
            result = VirtWhoConfig.info({'id': virtwho_config['id']})
            assert result['connection']['hypervisor-id'] == value
            config_file = get_configure_file(virtwho_config['id'])
            command = get_configure_command(virtwho_config['id'])
            deploy_configure_by_command(command, form_data['hypervisor-type'])
            assert get_configure_option('hypervisor_id', config_file) == value
        VirtWhoConfig.delete({'name': virtwho_config['name']})
        assert not VirtWhoConfig.exists(search=('name', form_data['name']))
Exemplo n.º 6
0
    def test_positive_debug_option(self, form_data, virtwho_config):
        """ Verify debug option by hammer virt-who-config update"

        :id: c98bc518-828c-49ba-a644-542db3190263

        :expectedresults: debug option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        assert virtwho_config['name'] == form_data['name']
        new_name = gen_string('alphanumeric')
        VirtWhoConfig.update({
            'id': virtwho_config['id'],
            'new-name': new_name
        })
        virt_who_instance_name = VirtWhoConfig.info(
            {'id': virtwho_config['id']})['general-information']['name']
        assert virt_who_instance_name == new_name
        options = {'true': '1', 'false': '0', 'yes': '1', 'no': '0'}
        for key, value in sorted(options.items(), key=lambda item: item[0]):
            VirtWhoConfig.update({'id': virtwho_config['id'], 'debug': key})
            command = get_configure_command(virtwho_config['id'])
            deploy_configure_by_command(command, form_data['hypervisor-type'])
            assert get_configure_option('VIRTWHO_DEBUG',
                                        VIRTWHO_SYSCONFIG), value
        VirtWhoConfig.delete({'name': new_name})
        assert not VirtWhoConfig.exists(search=('name', new_name))
Exemplo n.º 7
0
    def test_positive_proxy_option(self, form_data, virtwho_config):
        """ Verify http_proxy option by "PUT

        /foreman_virt_who_configure/api/v2/configs/:id""

        :id: e1b00b46-d5e6-40d5-a955-a45a75a5cfad

        :expectedresults: http_proxy and no_proxy option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        command = get_configure_command(virtwho_config.id)
        deploy_configure_by_command(command, form_data['hypervisor_type'])
        assert get_configure_option('NO_PROXY', VIRTWHO_SYSCONFIG) == '*'
        proxy = 'test.example.com:3128'
        no_proxy = 'test.satellite.com'
        virtwho_config.proxy = proxy
        virtwho_config.no_proxy = no_proxy
        virtwho_config.update(['proxy', 'no_proxy'])
        command = get_configure_command(virtwho_config.id)
        deploy_configure_by_command(command, form_data['hypervisor_type'])
        assert get_configure_option('http_proxy', VIRTWHO_SYSCONFIG) == proxy
        assert get_configure_option('NO_PROXY', VIRTWHO_SYSCONFIG) == no_proxy
        virtwho_config.delete()
        assert not entities.VirtWhoConfig().search(
            query={'search': f"name={form_data['name']}"})
Exemplo n.º 8
0
    def test_positive_configure_organization_list(self, form_data,
                                                  virtwho_config):
        """ Verify "GET /foreman_virt_who_configure/

        api/v2/organizations/:organization_id/configs"

        :id: 7434a875-e96a-40bd-9652-83d0805997a5

        :expectedresults: Config can be searched in org list

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        command = get_configure_command(virtwho_config.id)
        deploy_configure_by_command(command)
        search_result = virtwho_config.get_organization_configs(
            data={'per_page': 1000})
        assert [
            item for item in search_result['results']
            if item['name'] == form_data['name']
        ]
        virtwho_config.delete()
        assert not entities.VirtWhoConfig().search(
            query={'search': f"name={form_data['name']}"})
Exemplo n.º 9
0
    def test_positive_foreman_packages_protection(self, default_org, form_data,
                                                  virtwho_config):
        """foreman-protector should allow virt-who to be installed

        :id: 635ef99b-c5a3-4ac4-a0f1-09f7036d116e

        :expectedresults:
            virt-who packages can be installed
            the virt-who plugin can be deployed successfully

        :CaseLevel: Integration

        :customerscenario: true

        :CaseImportance: Medium

        :BZ: 1783987
        """
        virtwho_package_locked()
        command = get_configure_command(virtwho_config['id'], default_org.name)
        deploy_configure_by_command(command,
                                    form_data['hypervisor-type'],
                                    org=default_org.label)
        virt_who_instance = VirtWhoConfig.info(
            {'id': virtwho_config['id']})['general-information']['status']
        assert virt_who_instance == 'OK'
        VirtWhoConfig.delete({'name': virtwho_config['name']})
        assert not VirtWhoConfig.exists(search=('name', form_data['name']))
Exemplo n.º 10
0
    def test_positive_rhsm_option(self, default_org, form_data, virtwho_config,
                                  default_sat):
        """Verify rhsm options in the configure file"

        :id: b5b93d4d-e780-41c0-9eaa-2407cc1dcc9b

        :expectedresults:
            rhsm_hostname, rhsm_prefix are ecpected
            rhsm_username is not a login account

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        config_file = get_configure_file(virtwho_config['id'])
        command = get_configure_command(virtwho_config['id'], default_org.name)
        deploy_configure_by_command(command,
                                    form_data['hypervisor-type'],
                                    org=default_org.label)
        rhsm_username = get_configure_option('rhsm_username', config_file)
        assert not User.exists(search=('login', rhsm_username))
        assert get_configure_option('rhsm_hostname',
                                    config_file) == default_sat.hostname
        assert get_configure_option('rhsm_prefix', config_file) == '/rhsm'
        VirtWhoConfig.delete({'name': virtwho_config['name']})
        assert not VirtWhoConfig.exists(search=('name', form_data['name']))
Exemplo n.º 11
0
    def test_positive_configure_organization_list(self, form_data,
                                                  virtwho_config):
        """ Verify "GET /foreman_virt_who_configure/

        api/v2/organizations/:organization_id/configs"

        :id: 5bf34bef-bf68-4557-978d-419bd4df0ba1

        :expectedresults: Config can be searched in org list

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        command = get_configure_command(virtwho_config.id)
        deploy_configure_by_command(command, form_data['hypervisor_type'])
        search_result = virtwho_config.get_organization_configs(
            data={'per_page': 1000})
        assert [
            item for item in search_result['results']
            if item['name'] == form_data['name']
        ]
        virtwho_config.delete()
        assert not entities.VirtWhoConfig().search(
            query={'search': f"name={form_data['name']}"})
Exemplo n.º 12
0
    def test_positive_interval_option(self, form_data, virtwho_config):
        """ Verify interval option by "PUT

        /foreman_virt_who_configure/api/v2/configs/:id"

        :id: 65f4138b-ca8f-4f1e-805c-1a331b951be5

        :expectedresults: interval option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        options = {
            '60': '3600',
            '120': '7200',
            '240': '14400',
            '480': '28800',
            '720': '43200',
            '1440': '86400',
            '2880': '172800',
            '4320': '259200',
        }
        for key, value in sorted(options.items(),
                                 key=lambda item: int(item[0])):
            virtwho_config.interval = key
            virtwho_config.update(['interval'])
            command = get_configure_command(virtwho_config.id)
            deploy_configure_by_command(command, form_data['hypervisor_type'])
            assert get_configure_option('VIRTWHO_INTERVAL',
                                        VIRTWHO_SYSCONFIG) == value
        virtwho_config.delete()
        assert not entities.VirtWhoConfig().search(
            query={'search': f"name={form_data['name']}"})
Exemplo n.º 13
0
    def test_positive_hypervisor_id_option(self, form_data, virtwho_config):
        """ Verify hypervisor_id option by "PUT

        /foreman_virt_who_configure/api/v2/configs/:id"

        :id: 9aa17bbc-e417-473a-831c-4d87781f41d8

        :expectedresults: hypervisor_id option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        values = ['uuid', 'hostname']
        if settings.virtwho.hypervisor_type in ('esx', 'rhevm'):
            values.append('hwuuid')
        for value in values:
            virtwho_config.hypervisor_id = value
            virtwho_config.update(['hypervisor_id'])
            config_file = get_configure_file(virtwho_config.id)
            command = get_configure_command(virtwho_config.id)
            deploy_configure_by_command(command)
            assert get_configure_option('hypervisor_id', config_file) == value
        virtwho_config.delete()
        assert not entities.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"})
Exemplo n.º 14
0
    def test_positive_hypervisor_id_option(self, default_org, session, form_data):
        """Verify Hypervisor ID dropdown options.

        :id: 09826cc0-aa49-4355-8980-8097511eb7d7

        :expectedresults:
            hypervisor_id can be changed in virt-who-config-{}.conf if the
            dropdown option is selected to uuid/hwuuid/hostname.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        name = gen_string('alpha')
        form_data['name'] = name
        with session:
            session.virtwho_configure.create(form_data)
            config_id = get_configure_id(name)
            config_command = get_configure_command(config_id, default_org.name)
            config_file = get_configure_file(config_id)
            values = ['uuid', 'hostname']
            for value in values:
                session.virtwho_configure.edit(name, {'hypervisor_id': value})
                results = session.virtwho_configure.read(name)
                assert results['overview']['hypervisor_id'] == value
                deploy_configure_by_command(
                    config_command, form_data['hypervisor_type'], org=default_org.label
                )
                assert get_configure_option('hypervisor_id', config_file) == value
            session.virtwho_configure.delete(name)
            assert not session.virtwho_configure.search(name)
Exemplo n.º 15
0
    def test_positive_delete_configure(self, session, form_data):
        """Verify when a config is deleted the associated user is deleted.

        :id: 0e66dcf6-dc64-4fb2-b8a9-518f5adfa800

        :steps:
            1. Create a virt-who configuration and deploy it to a
               virt-who server.
            2. Delete the configuration on the Satellite.

        :expectedresults:
            1. Verify the virt-who server can no longer connect to the
               Satellite.

        """
        name = gen_string('alpha')
        form_data['name'] = name
        with session:
            session.virtwho_configure.create(form_data)
            config_id = get_configure_id(name)
            config_command = get_configure_command(config_id)
            deploy_configure_by_command(config_command, form_data['hypervisor_type'])
            assert session.virtwho_configure.search(name)[0]['Status'] == 'ok'
            session.virtwho_configure.delete(name)
            assert not session.virtwho_configure.search(name)
            restart_virtwho_service()
            assert get_virtwho_status() == 'logerror'
Exemplo n.º 16
0
    def test_positive_hypervisor_id_option(self, form_data, virtwho_config):
        """Verify hypervisor_id option by hammer virt-who-config update"

        :id: d8428508-3149-4558-8173-4386db5e3760

        :expectedresults: hypervisor_id option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        # esx and rhevm support hwuuid option
        values = ['uuid', 'hostname', 'hwuuid']
        for value in values:
            VirtWhoConfig.update({
                'id': virtwho_config['id'],
                'hypervisor-id': value
            })
            result = VirtWhoConfig.info({'id': virtwho_config['id']})
            assert result['connection']['hypervisor-id'] == value
            config_file = get_configure_file(virtwho_config['id'])
            command = get_configure_command(virtwho_config['id'])
            deploy_configure_by_command(command, form_data['hypervisor-type'])
            assert get_configure_option('hypervisor_id', config_file) == value
        VirtWhoConfig.delete({'name': virtwho_config['name']})
        assert not VirtWhoConfig.exists(search=('name', form_data['name']))
Exemplo n.º 17
0
    def test_positive_hypervisor_id_option(self, session, form_data):
        """Verify Hypervisor ID dropdown options.

        :id: cc494bd9-51d9-452a-bfa9-5cdcafef5197

        :expectedresults:
            hypervisor_id can be changed in virt-who-config-{}.conf if the
            dropdown option is selected to uuid/hwuuid/hostname.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        name = gen_string('alpha')
        form_data['name'] = name
        with session:
            session.virtwho_configure.create(form_data)
            config_id = get_configure_id(name)
            config_command = get_configure_command(config_id)
            config_file = get_configure_file(config_id)
            # esx and rhevm support hwuuid option
            values = ['uuid', 'hostname', 'hwuuid']
            for value in values:
                session.virtwho_configure.edit(name, {'hypervisor_id': value})
                results = session.virtwho_configure.read(name)
                assert results['overview']['hypervisor_id'] == value
                deploy_configure_by_command(config_command, form_data['hypervisor_type'])
                assert get_configure_option('hypervisor_id', config_file) == value
            session.virtwho_configure.delete(name)
            assert not session.virtwho_configure.search(name)
Exemplo n.º 18
0
    def test_positive_hypervisor_id_option(self, form_data, virtwho_config):
        """ Verify hypervisor_id option by "PUT

        /foreman_virt_who_configure/api/v2/configs/:id"

        :id: f232547f-c4b2-41bc-ab8d-e7579a49ab69

        :expectedresults: hypervisor_id option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        # esx and rhevm support hwuuid option
        values = ['uuid', 'hostname', 'hwuuid']
        for value in values:
            virtwho_config.hypervisor_id = value
            virtwho_config.update(['hypervisor_id'])
            config_file = get_configure_file(virtwho_config.id)
            command = get_configure_command(virtwho_config.id)
            deploy_configure_by_command(command, form_data['hypervisor_type'])
            assert get_configure_option('hypervisor_id', config_file) == value
        virtwho_config.delete()
        assert not entities.VirtWhoConfig().search(
            query={'search': f"name={form_data['name']}"})
Exemplo n.º 19
0
    def test_positive_virtwho_manager_role(self, session, test_name,
                                           form_data):
        """Verify the virt-who manager role can TRULY work.

        :id: a72023fb-7b23-4582-9adc-c5227dc7859c

        :expectedresults:
            Virt-who Manager Role granting all permissions to manage virt-who configurations,
            user needs this role to create, delete or update configurations.
        """
        username = gen_string('alpha')
        password = gen_string('alpha')
        config_name = gen_string('alpha')
        with session:
            # Create an user
            session.user.create({
                'user.login': username,
                'user.mail': valid_emails_list()[0],
                'user.auth': 'INTERNAL',
                'user.password': password,
                'user.confirm': password,
            })
            # Create a virt-who config plugin
            form_data['name'] = config_name
            session.virtwho_configure.create(form_data)
            values = session.virtwho_configure.read(config_name)
            command = values['deploy']['command']
            deploy_configure_by_command(command, form_data['hypervisor_type'])
            assert session.virtwho_configure.search(
                config_name)[0]['Status'] == 'ok'
            # Check the permissioin of Virt-who Manager
            session.user.update(
                username, {'roles.resources.assigned': ['Virt-who Manager']})
            user = session.user.read(username)
            assert user['roles']['resources']['assigned'] == [
                'Virt-who Manager'
            ]
            with Session(test_name, username, password) as newsession:
                # create_virt_who_config
                new_virt_who_name = gen_string('alpha')
                form_data['name'] = new_virt_who_name
                newsession.virtwho_configure.create(form_data)
                # view_virt_who_config
                values = newsession.virtwho_configure.read(new_virt_who_name)
                command = values['deploy']['command']
                deploy_configure_by_command(command,
                                            form_data['hypervisor_type'])
                assert newsession.virtwho_configure.search(
                    new_virt_who_name)[0]['Status'] == 'ok'
                # edit_virt_who_config
                modify_name = gen_string('alpha')
                newsession.virtwho_configure.edit(new_virt_who_name,
                                                  {'name': modify_name})
                newsession.virtwho_configure.search(modify_name)
                # destroy_virt_who_config
                newsession.virtwho_configure.delete(modify_name)
                assert not newsession.virtwho_configure.search(modify_name)
            # Delete the created user
            session.user.delete(username)
            assert not session.user.search(username)
Exemplo n.º 20
0
    def test_positive_debug_option(self, session, form_data):
        """Verify debug checkbox and the value changes of VIRTWHO_DEBUG

        :id: adb435c4-d02b-47b6-89f5-dce9a4ff7939

        :expectedresults:
            1. if debug is checked, VIRTWHO_DEBUG=1 in /etc/sysconfig/virt-who
            2. if debug is unchecked, VIRTWHO_DEBUG=0 in /etc/sysconfig/virt-who

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        name = gen_string('alpha')
        form_data['name'] = name
        with session:
            session.virtwho_configure.create(form_data)
            config_id = get_configure_id(name)
            config_command = get_configure_command(config_id)
            deploy_configure_by_command(config_command, form_data['hypervisor_type'])
            assert get_configure_option('VIRTWHO_DEBUG', VIRTWHO_SYSCONFIG) == '1'
            session.virtwho_configure.edit(name, {'debug': False})
            results = session.virtwho_configure.read(name)
            assert results['overview']['debug'] is False
            deploy_configure_by_command(config_command, form_data['hypervisor_type'])
            assert get_configure_option('VIRTWHO_DEBUG', VIRTWHO_SYSCONFIG) == '0'
            session.virtwho_configure.delete(name)
            assert not session.virtwho_configure.search(name)
Exemplo n.º 21
0
    def test_positive_hypervisor_id_option(self, default_org, form_data, virtwho_config):
        """Verify hypervisor_id option by "PUT

        /foreman_virt_who_configure/api/v2/configs/:id"

        :id: 37a08451-2add-4c5c-bab6-ebe002a746f1

        :expectedresults: hypervisor_id option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        values = ['uuid', 'hostname']
        for value in values:
            virtwho_config.hypervisor_id = value
            virtwho_config.update(['hypervisor_id'])
            config_file = get_configure_file(virtwho_config.id)
            command = get_configure_command(virtwho_config.id, default_org.name)
            deploy_configure_by_command(
                command, form_data['hypervisor_type'], org=default_org.label
            )
            assert get_configure_option('hypervisor_id', config_file) == value
        virtwho_config.delete()
        assert not entities.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"})
Exemplo n.º 22
0
    def test_positive_proxy_option(self, session, form_data):
        """Verify 'HTTP Proxy' and 'Ignore Proxy' options.

        :id: 6659d577-0135-4bf0-81af-14b930011536

        :expectedresults:
            http_proxy ad NO_PROXY will be setting in /etc/sysconfig/virt-who.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        name = gen_string('alpha')
        form_data['name'] = name
        with session:
            session.virtwho_configure.create(form_data)
            config_id = get_configure_id(name)
            config_command = get_configure_command(config_id)
            http_proxy = 'test.example.com:3128'
            no_proxy = 'test.satellite.com'
            session.virtwho_configure.edit(name, {'proxy': http_proxy, 'no_proxy': no_proxy})
            results = session.virtwho_configure.read(name)
            assert results['overview']['proxy'] == http_proxy
            assert results['overview']['no_proxy'] == no_proxy
            deploy_configure_by_command(config_command, form_data['hypervisor_type'])
            assert get_configure_option('http_proxy', VIRTWHO_SYSCONFIG) == http_proxy
            assert get_configure_option('NO_PROXY', VIRTWHO_SYSCONFIG) == no_proxy
            session.virtwho_configure.delete(name)
            assert not session.virtwho_configure.search(name)
Exemplo n.º 23
0
    def test_positive_debug_option(self, default_org, form_data,
                                   virtwho_config):
        """Verify debug option by "PUT

        /foreman_virt_who_configure/api/v2/configs/:id"

        :id: be395108-3944-4a04-bee4-6bac3fa03a19

        :expectedresults: debug option can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        options = {'true': '1', 'false': '0', '1': '1', '0': '0'}
        for key, value in sorted(options.items(), key=lambda item: item[0]):
            virtwho_config.debug = key
            virtwho_config.update(['debug'])
            command = get_configure_command(virtwho_config.id,
                                            default_org.name)
            deploy_configure_by_command(command,
                                        form_data['hypervisor_type'],
                                        org=default_org.label)
            assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == value
        virtwho_config.delete()
        assert not entities.VirtWhoConfig().search(
            query={'search': f"name={form_data['name']}"})
Exemplo n.º 24
0
    def test_positive_filtering_option(self, default_org, session, form_data):
        """Verify Filtering dropdown options.

        :id: e17dda14-79cd-4cd2-8f29-60970b24a905

        :expectedresults:
            1. if filtering is selected to Whitelist, 'Filter hosts' can be set.
            2. if filtering is selected to Blacklist, 'Exclude hosts' can be set.

        :CaseLevel: Integration

        :CaseImportance: Medium

        :BZ: 1735670
        """
        name = gen_string('alpha')
        form_data['name'] = name
        with session:
            session.virtwho_configure.create(form_data)
            config_id = get_configure_id(name)
            config_command = get_configure_command(config_id,
                                                   default_org.label)
            config_file = get_configure_file(config_id)
            regex = '.*redhat.com'
            whitelist = {
                'filtering': 'Whitelist',
                'filtering_content.filter_hosts': regex
            }
            blacklist = {
                'filtering': 'Blacklist',
                'filtering_content.exclude_hosts': regex
            }
            # esx support filter-host-parents and exclude-host-parents options
            whitelist['filtering_content.filter_host_parents'] = regex
            blacklist['filtering_content.exclude_host_parents'] = regex
            # Update Whitelist and check the result
            session.virtwho_configure.edit(name, whitelist)
            results = session.virtwho_configure.read(name)
            assert results['overview']['filter_hosts'] == regex
            assert results['overview']['filter_host_parents'] == regex
            deploy_configure_by_command(config_command,
                                        form_data['hypervisor_type'],
                                        org=default_org.label)
            assert regex == get_configure_option('filter_hosts', config_file)
            assert regex == get_configure_option('filter_host_parents',
                                                 config_file)
            # Update Blacklist and check the result
            session.virtwho_configure.edit(name, blacklist)
            results = session.virtwho_configure.read(name)
            assert results['overview']['exclude_hosts'] == regex
            assert results['overview']['exclude_host_parents'] == regex
            deploy_configure_by_command(config_command,
                                        form_data['hypervisor_type'],
                                        org=default_org.label)
            assert regex == get_configure_option('exclude_hosts', config_file)
            assert regex == get_configure_option('exclude_host_parents',
                                                 config_file)
            session.virtwho_configure.delete(name)
            assert not session.virtwho_configure.search(name)
Exemplo n.º 25
0
    def test_positive_virtwho_viewer_role(self, session, test_name, form_data):
        """Verify the virt-who viewer role can TRULY work.

        :id: bf3be2e4-3853-41cc-9b3e-c8677f0b8c5f

        :expectedresults:
            Virt-who Viewer Role granting permissions to see all configurations
            including their configuration scripts, which means viewers could still
            deploy the virt-who instances for existing virt-who configurations.
        """
        username = gen_string('alpha')
        password = gen_string('alpha')
        config_name = gen_string('alpha')
        with session:
            # Create an user
            session.user.create({
                'user.login': username,
                'user.mail': valid_emails_list()[0],
                'user.auth': 'INTERNAL',
                'user.password': password,
                'user.confirm': password,
            })
            # Create a virt-who config plugin
            form_data['name'] = config_name
            session.virtwho_configure.create(form_data)
            values = session.virtwho_configure.read(config_name)
            command = values['deploy']['command']
            deploy_configure_by_command(command, form_data['hypervisor_type'])
            assert session.virtwho_configure.search(
                config_name)[0]['Status'] == 'ok'
            # Check the permissioin of Virt-who Viewer
            session.user.update(
                username, {'roles.resources.assigned': ['Virt-who Viewer']})
            user = session.user.read(username)
            assert user['roles']['resources']['assigned'] == [
                'Virt-who Viewer'
            ]
            # Update the virt-who config file
            config_id = get_configure_id(config_name)
            config_file = get_configure_file(config_id)
            update_configure_option('rhsm_username', username, config_file)
            delete_configure_option('rhsm_encrypted_password', config_file)
            add_configure_option('rhsm_password', password, config_file)
            restart_virtwho_service()
            assert get_virtwho_status() == 'logerror'
            with Session(test_name, username, password) as newsession:
                create_permission = newsession.virtwho_configure.check_create_permission(
                )
                update_permission = newsession.virtwho_configure.check_update_permission(
                    config_name)
                assert create_permission['can_view']
                assert not create_permission['can_create']
                assert not update_permission['can_delete']
                assert not update_permission['can_edit']
                newsession.virtwho_configure.read(config_name)
            # Delete the created user
            session.user.delete(username)
            assert not session.user.search(username)
Exemplo n.º 26
0
    def test_positive_virtwho_reporter_role(self, default_org, session,
                                            test_name, form_data):
        """Verify the virt-who reporter role can TRULY work.

        :id: cd235ab0-d89c-464b-98d6-9d090ac40d8f

        :expectedresults:
            Virt-who Reporter Role granting minimal set of permissions for virt-who
            to upload the report, it can be used if you configure virt-who manually
            and want to use user that has locked down account.
        """
        username = gen_string('alpha')
        password = gen_string('alpha')
        config_name = gen_string('alpha')
        with session:
            # Create an user
            session.user.create({
                'user.login': username,
                'user.mail': valid_emails_list()[0],
                'user.auth': 'INTERNAL',
                'user.password': password,
                'user.confirm': password,
            })
            # Create a virt-who config plugin
            form_data['name'] = config_name
            session.virtwho_configure.create(form_data)
            values = session.virtwho_configure.read(config_name)
            command = values['deploy']['command']
            deploy_configure_by_command(command,
                                        form_data['hypervisor_type'],
                                        org=default_org.label)
            assert session.virtwho_configure.search(
                config_name)[0]['Status'] == 'ok'
            # Update the virt-who config file
            config_id = get_configure_id(config_name)
            config_file = get_configure_file(config_id)
            update_configure_option('rhsm_username', username, config_file)
            delete_configure_option('rhsm_encrypted_password', config_file)
            add_configure_option('rhsm_password', password, config_file)
            restart_virtwho_service()
            assert get_virtwho_status() == 'logerror'
            # Check the permissioin of Virt-who Reporter
            session.user.update(
                username, {'roles.resources.assigned': ['Virt-who Reporter']})
            assert session.user.search(username)[0]['Username'] == username
            user = session.user.read(username)
            assert user['roles']['resources']['assigned'] == [
                'Virt-who Reporter'
            ]
            restart_virtwho_service()
            assert get_virtwho_status() == 'running'
            with Session(test_name, username, password) as newsession:
                assert not newsession.virtwho_configure.check_create_permission(
                )['can_view']
            session.user.delete(username)
            assert not session.user.search(username)
Exemplo n.º 27
0
    def test_positive_filter_option(self, default_org, form_data,
                                    virtwho_config):
        """Verify filter option by hammer virt-who-config update"

        :id: aaf45c5e-9504-47ce-8f25-b8073c2de036

        :expectedresults: filter and filter_hosts can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        regex = '.*redhat.com'
        whitelist = {
            'id': virtwho_config['id'],
            'filtering-mode': 'whitelist',
            'whitelist': regex
        }
        blacklist = {
            'id': virtwho_config['id'],
            'filtering-mode': 'blacklist',
            'blacklist': regex
        }
        # esx support filter-host-parents and exclude-host-parents options
        whitelist['filter-host-parents'] = regex
        blacklist['exclude-host-parents'] = regex
        config_file = get_configure_file(virtwho_config['id'])
        command = get_configure_command(virtwho_config['id'], default_org.name)
        # Update Whitelist and check the result
        VirtWhoConfig.update(whitelist)
        result = VirtWhoConfig.info({'id': virtwho_config['id']})
        assert result['connection']['filtering'] == 'Whitelist'
        assert result['connection']['filtered-hosts'] == regex
        assert result['connection']['filter-host-parents'] == regex
        deploy_configure_by_command(command,
                                    form_data['hypervisor-type'],
                                    org=default_org.label)
        assert get_configure_option('filter_hosts', config_file) == regex
        assert get_configure_option('filter_host_parents',
                                    config_file) == regex
        # Update Blacklist and check the result
        VirtWhoConfig.update(blacklist)
        result = VirtWhoConfig.info({'id': virtwho_config['id']})
        assert result['connection']['filtering'] == 'Blacklist'
        assert result['connection']['excluded-hosts'] == regex
        assert result['connection']['exclude-host-parents'] == regex
        deploy_configure_by_command(command,
                                    form_data['hypervisor-type'],
                                    org=default_org.label)
        assert get_configure_option('exclude_hosts', config_file) == regex
        assert get_configure_option('exclude_host_parents',
                                    config_file) == regex
        VirtWhoConfig.delete({'name': virtwho_config['name']})
        assert not VirtWhoConfig.exists(search=('name', form_data['name']))
Exemplo n.º 28
0
    def test_positive_filter_option(self, form_data, virtwho_config):
        """ Verify filter option by "PUT

        /foreman_virt_who_configure/api/v2/configs/:id"

        :id: 89cc1134-69d9-4da8-9ba9-a296c17f4f16

        :expectedresults: filter and filter_hosts can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        whitelist = {'filtering_mode': '1', 'whitelist': '.*redhat.com'}
        blacklist = {'filtering_mode': '2', 'blacklist': '.*redhat.com'}
        if settings.virtwho.hypervisor_type == 'esx':
            whitelist['filter_host_parents'] = '.*redhat.com'
            blacklist['exclude_host_parents'] = '.*redhat.com'
        # Update Whitelist and check the result
        virtwho_config.filtering_mode = whitelist['filtering_mode']
        virtwho_config.whitelist = whitelist['whitelist']
        if settings.virtwho.hypervisor_type == 'esx':
            virtwho_config.filter_host_parents = whitelist[
                'filter_host_parents']
        virtwho_config.update(whitelist.keys())
        config_file = get_configure_file(virtwho_config.id)
        command = get_configure_command(virtwho_config.id)
        deploy_configure_by_command(command)
        assert get_configure_option('filter_hosts',
                                    config_file) == whitelist['whitelist']
        if settings.virtwho.hypervisor_type == 'esx':
            assert (get_configure_option(
                'filter_host_parents',
                config_file) == whitelist['filter_host_parents'])
        # Update Blacklist and check the result
        virtwho_config.filtering_mode = blacklist['filtering_mode']
        virtwho_config.blacklist = blacklist['blacklist']
        if settings.virtwho.hypervisor_type == 'esx':
            virtwho_config.exclude_host_parents = blacklist[
                'exclude_host_parents']
        virtwho_config.update(blacklist.keys())
        config_file = get_configure_file(virtwho_config.id)
        command = get_configure_command(virtwho_config.id)
        deploy_configure_by_command(command)
        assert get_configure_option('exclude_hosts',
                                    config_file) == blacklist['blacklist']
        if settings.virtwho.hypervisor_type == 'esx':
            assert (get_configure_option(
                'exclude_host_parents',
                config_file) == blacklist['exclude_host_parents'])
        virtwho_config.delete()
        assert not entities.VirtWhoConfig().search(
            query={'search': f"name={form_data['name']}"})
Exemplo n.º 29
0
    def test_positive_filter_option(self, default_org, form_data,
                                    virtwho_config):
        """Verify filter option by "PUT

        /foreman_virt_who_configure/api/v2/configs/:id"

        :id: 1f251d89-5e22-4470-be4c-0aeba84c0273

        :expectedresults: filter and filter_hosts can be updated.

        :CaseLevel: Integration

        :CaseImportance: Medium
        """
        whitelist = {'filtering_mode': '1', 'whitelist': '.*redhat.com'}
        blacklist = {'filtering_mode': '2', 'blacklist': '.*redhat.com'}
        # esx support filter-host-parents and exclude-host-parents options
        whitelist['filter_host_parents'] = '.*redhat.com'
        blacklist['exclude_host_parents'] = '.*redhat.com'
        # Update Whitelist and check the result
        virtwho_config.filtering_mode = whitelist['filtering_mode']
        virtwho_config.whitelist = whitelist['whitelist']
        virtwho_config.filter_host_parents = whitelist['filter_host_parents']
        virtwho_config.update(whitelist.keys())
        config_file = get_configure_file(virtwho_config.id)
        command = get_configure_command(virtwho_config.id, default_org.name)
        deploy_configure_by_command(command,
                                    form_data['hypervisor_type'],
                                    org=default_org.label)
        assert get_configure_option('filter_hosts',
                                    config_file) == whitelist['whitelist']
        assert (get_configure_option(
            'filter_host_parents',
            config_file) == whitelist['filter_host_parents'])
        # Update Blacklist and check the result
        virtwho_config.filtering_mode = blacklist['filtering_mode']
        virtwho_config.blacklist = blacklist['blacklist']
        virtwho_config.exclude_host_parents = blacklist['exclude_host_parents']
        virtwho_config.update(blacklist.keys())
        config_file = get_configure_file(virtwho_config.id)
        command = get_configure_command(virtwho_config.id, default_org.name)
        deploy_configure_by_command(command,
                                    form_data['hypervisor_type'],
                                    org=default_org.label)
        assert get_configure_option('exclude_hosts',
                                    config_file) == blacklist['blacklist']
        assert (get_configure_option(
            'exclude_host_parents',
            config_file) == blacklist['exclude_host_parents'])
        virtwho_config.delete()
        assert not entities.VirtWhoConfig().search(
            query={'search': f"name={form_data['name']}"})
Exemplo n.º 30
0
    def test_positive_virtwho_configs_widget(self, session, form_data):
        """Check if Virt-who Configurations Status Widget is working in the Dashboard UI

        :id: 5d61ce00-a640-4823-89d4-7b1d02b50ea6

        :Steps:

            1. Create a Virt-who Configuration
            2. Navigate Monitor -> Dashboard
            3. Review the Virt-who Configurations Status widget

        :expectedresults: The widget is updated with all details.

        :CaseLevel: Integration

        :CaseImportance: Low
        """
        org_name = gen_string('alpha')
        name = gen_string('alpha')
        form_data['name'] = name
        with session:
            session.organization.create({'name': org_name})
            session.organization.select(org_name)
            session.virtwho_configure.create(form_data)
            expected_values = [
                {'Configuration Status': 'No Reports', 'Count': '1'},
                {'Configuration Status': 'No Change', 'Count': '0'},
                {'Configuration Status': 'OK', 'Count': '0'},
                {'Configuration Status': 'Total Configurations', 'Count': '1'},
            ]
            values = session.dashboard.read('VirtWhoConfigStatus')
            assert values['config_status'] == expected_values
            assert values['latest_config'] == 'No configuration found'
            # Check the 'Status' changed after deployed the virt-who config
            config_id = get_configure_id(name)
            config_command = get_configure_command(config_id, org_name)
            deploy_configure_by_command(config_command, form_data['hypervisor_type'])
            assert session.virtwho_configure.search(name)[0]['Status'] == 'ok'
            expected_values = [
                {'Configuration Status': 'No Reports', 'Count': '0'},
                {'Configuration Status': 'No Change', 'Count': '0'},
                {'Configuration Status': 'OK', 'Count': '1'},
                {'Configuration Status': 'Total Configurations', 'Count': '1'},
            ]
            values = session.dashboard.read('VirtWhoConfigStatus')
            assert values['config_status'] == expected_values
            assert values['latest_config'] == 'No configuration found'
            session.virtwho_configure.delete(name)
            assert not session.virtwho_configure.search(name)
            session.organization.select("Default Organization")
            session.organization.delete(org_name)