def test_positive_create_with_space(self):
        """Create tailoring files with space in name

        :id: 4b6a608b-b032-4d03-b67a-a9dce194e1ce

        :setup: tailoring file

        :steps:

            1. Navigate to Tailoring files menu
            2. Upload a valid tailoring file
            3. Give it a name with space

        :expectedresults: Tailoring file will be added to satellite

        :CaseImportance: Critical
        """
        with Session(self) as session:
            tailoring_name = gen_string('alpha') + ' ' + gen_string('alpha')
            make_oscap_tailoringfile(
                session,
                name=tailoring_name,
                tailoring_path=self.tailoring_path,
                tailoring_loc=self.loc_name,
                tailoring_org=self.org_name,
            )
            self.assertIsNotNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element not found")
    def test_positive_delete_tailoring_file(self):
        """ Delete tailoring file

        :id: 359bade3-fff1-4aac-b4de-491190407507

        :setup: tailoring file

        :steps:

            1. Upload a tailoring file
            2. Delete the created tailoring file

        :expectedresults: Tailoring file should be deleted

        :CaseImportance: Critical
        """
        tailoring_name = gen_string('alpha')
        with Session(self) as session:
            make_oscap_tailoringfile(
                session,
                name=tailoring_name,
                tailoring_path=self.tailoring_path,
                tailoring_loc=self.loc_name,
                tailoring_org=self.org_name,
            )
            self.assertIsNotNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element not found")
            self.oscaptailoringfile.delete(
                tailoring_name, dropdown_present=True)
            self.assertIsNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element found")
    def test_positive_create(self):
        """Create new Tailoring Files using different values types as name

        :id: d6ae6b33-5af3-4b55-8ad4-6fa8e67e40f5

        :setup: Oscap enabled on capsule and scap tailoring file

        :steps:

            1. Navigate to Tailoring files menu
            2. Upload a valid tailoring file
            3. Give it a valid name

        :expectedresults: Tailoring file will be added to satellite

        :CaseImportance: Critical
        """
        with Session(self) as session:
            for tailoring_file_name in valid_data_list():
                with self.subTest(tailoring_file_name):
                    make_oscap_tailoringfile(
                        session,
                        name=tailoring_file_name,
                        tailoring_path=self.tailoring_path,
                        tailoring_loc=self.loc_name,
                        tailoring_org=self.org_name,
                    )
                    self.assertIsNotNone(
                        self.oscaptailoringfile.search(tailoring_file_name),
                        msg="Tailoring file name element not found")
    def test_positive_create_with_space(self):
        """Create tailoring files with space in name

        :id: 4b6a608b-b032-4d03-b67a-a9dce194e1ce

        :setup: tailoring file

        :steps:

            1. Navigate to Tailoring files menu
            2. Upload a valid tailoring file
            3. Give it a name with space

        :expectedresults: Tailoring file will be added to satellite

        :CaseImportance: Critical
        """
        with Session(self) as session:
            tailoring_name = gen_string('alpha') + ' ' + gen_string('alpha')
            make_oscap_tailoringfile(
                session,
                name=tailoring_name,
                tailoring_path=self.tailoring_path,
                tailoring_loc=self.loc_name,
                tailoring_org=self.org_name,
            )
            self.assertIsNotNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element not found")
    def test_negative_create_with_invalid_file(self):
        """Create Tailoring files with invalid file

        :id: 310200e6-b5d9-460e-866a-a7864c134d76

        :setup: invalid tailoring file

        :steps:

            1. Navigate to Tailoring files menu
            2. With valid name ,upload  invalid tailoring file

        :expectedresults: Tailoring file will not be added to satellite

        :CaseImportance: Critical
        """
        invalid_file = SNIPPET_DATA_FILE
        tailoring_name = gen_string('alpha')
        with Session(self) as session:
            make_oscap_tailoringfile(
                session,
                name=tailoring_name,
                tailoring_path=invalid_file,
                tailoring_loc=self.loc_name,
                tailoring_org=self.org_name,
            )
            self.assertIsNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element is found")
    def test_positive_create(self):
        """Create new Tailoring Files using different values types as name

        :id: d6ae6b33-5af3-4b55-8ad4-6fa8e67e40f5

        :setup: Oscap enabled on capsule and scap tailoring file

        :steps:

            1. Navigate to Tailoring files menu
            2. Upload a valid tailoring file
            3. Give it a valid name

        :expectedresults: Tailoring file will be added to satellite

        :CaseImportance: Critical
        """
        with Session(self) as session:
            for tailoring_file_name in valid_data_list():
                with self.subTest(tailoring_file_name):
                    make_oscap_tailoringfile(
                        session,
                        name=tailoring_file_name,
                        tailoring_path=self.tailoring_path,
                        tailoring_loc=self.loc_name,
                        tailoring_org=self.org_name,
                    )
                    self.assertIsNotNone(
                        self.oscaptailoringfile.search(tailoring_file_name),
                        msg="Tailoring file name element not found")
    def test_negative_create_with_invalid_file(self):
        """Create Tailoring files with invalid file

        :id: 310200e6-b5d9-460e-866a-a7864c134d76

        :setup: invalid tailoring file

        :steps:

            1. Navigate to Tailoring files menu
            2. With valid name ,upload  invalid tailoring file

        :expectedresults: Tailoring file will not be added to satellite

        :CaseImportance: Critical
        """
        invalid_file = SNIPPET_DATA_FILE
        tailoring_name = gen_string('alpha')
        with Session(self) as session:
            make_oscap_tailoringfile(
                session,
                name=tailoring_name,
                tailoring_path=invalid_file,
                tailoring_loc=self.loc_name,
                tailoring_org=self.org_name,
            )
            self.assertIsNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element is found")
示例#8
0
    def test_positive_delete_tailoring_file(self):
        """ Delete tailoring file

        :id: 359bade3-fff1-4aac-b4de-491190407507

        :setup: tailoring file

        :steps:

            1. Upload a tailoring file
            2. Delete the created tailoring file

        :expectedresults: Tailoring file should be deleted

        :CaseImportance: Critical
        """
        tailoring_name = gen_string('alpha')
        with Session(self) as session:
            make_oscap_tailoringfile(
                session,
                name=tailoring_name,
                tailoring_path=self.tailoring_path,
                tailoring_loc=self.loc_name,
                tailoring_org=self.org_name,
            )
            self.assertIsNotNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element not found")
            self.oscaptailoringfile.delete(tailoring_name,
                                           dropdown_present=True)
            self.assertIsNone(self.oscaptailoringfile.search(tailoring_name),
                              msg="Tailoring file name element found")
    def test_positive_associate_tailoring_file_with_scap(self):
        """ Associate a Tailoring file with it’s scap content

        :id: 33e7b8ca-2e5f-4886-91b7-1a8763059d14

        :setup: scap content and tailoring file

        :steps:

            1. Create a valid scap content
            2. Upload a vaild tailoring file
            3. Associate scap content with it’s tailoring file

        :expectedresults: Association should be successful

        :CaseImportance: Critical
        """
        tailoring_name = gen_string('alpha')
        content_name = OSCAP_DEFAULT_CONTENT['rhel7_content']
        Scapcontent.update({
            'title': content_name,
            'organizations': self.org_name})
        policy_name = gen_string('alpha')
        with Session(self) as session:
            session.nav.go_to_select_org(self.org_name)
            make_oscap_tailoringfile(
                session,
                name=tailoring_name,
                tailoring_path=self.tailoring_path,
                tailoring_loc=self.loc_name,
            )
            self.assertIsNotNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element not found")
            self.assertIsNotNone(
                self.oscapcontent.search(content_name))
            make_oscappolicy(
                session,
                content=content_name,
                name=policy_name,
                period=OSCAP_PERIOD['weekly'],
                profile=OSCAP_PROFILE['common'],
                tailoring=tailoring_name,
                tailoring_profile=OSCAP_PROFILE['tailoring_rhel7'],
                period_value=OSCAP_WEEKDAY['friday'],
            )
            self.assertIsNotNone(
                self.oscappolicy.search(policy_name),
                msg="scap policy name element not found")
示例#10
0
    def test_positive_associate_tailoring_file_with_scap(self):
        """ Associate a Tailoring file with it’s scap content

        :id: 33e7b8ca-2e5f-4886-91b7-1a8763059d14

        :setup: scap content and tailoring file

        :steps:

            1. Create a valid scap content
            2. Upload a vaild tailoring file
            3. Associate scap content with it’s tailoring file

        :expectedresults: Association should be successful

        :CaseImportance: Critical
        """
        tailoring_name = gen_string('alpha')
        content_name = OSCAP_DEFAULT_CONTENT['rhel7_content']
        Scapcontent.update({
            'title': content_name,
            'organizations': self.org_name
        })
        policy_name = gen_string('alpha')
        with Session(self) as session:
            session.nav.go_to_select_org(self.org_name)
            make_oscap_tailoringfile(
                session,
                name=tailoring_name,
                tailoring_path=self.tailoring_path,
                tailoring_loc=self.loc_name,
            )
            self.assertIsNotNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element not found")
            self.assertIsNotNone(self.oscapcontent.search(content_name))
            make_oscappolicy(
                session,
                content=content_name,
                name=policy_name,
                period=OSCAP_PERIOD['weekly'],
                profile=OSCAP_PROFILE['common'],
                tailoring=tailoring_name,
                tailoring_profile=OSCAP_PROFILE['tailoring_rhel7'],
                period_value=OSCAP_WEEKDAY['friday'],
            )
            self.assertIsNotNone(self.oscappolicy.search(policy_name),
                                 msg="scap policy name element not found")
    def test_negative_associate_tailoring_file_with_different_scap(self):
        """ Associate a tailoring file with different scap content

        :id: 5b166dd4-5e9c-4c35-b2fb-fd35d75d51f5

        :setup: scap content and tailoring file

        :steps:

            1. Create a valid scap content
            2. Upload a Mutually exclusive tailoring file
            3. Associate the scap content with tailoring file

        :expectedresults: Association should give some warning

        :CaseImportance: Critical
        """
        tailoring_name = gen_string('alpha')
        content_name = OSCAP_DEFAULT_CONTENT['rhel_firefox']
        policy_name = gen_string('alpha')
        with Session(self) as session:
            make_oscap_tailoringfile(
                session,
                name=tailoring_name,
                tailoring_path=self.tailoring_path,
                tailoring_loc=self.loc_name,
                tailoring_org=self.org_name,
            )
            self.assertIsNotNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element not found")
            self.assertIsNotNone(
                self.oscapcontent.search(content_name))
            make_oscappolicy(
                session,
                content=content_name,
                name=policy_name,
                period=OSCAP_PERIOD['weekly'],
                profile=OSCAP_PROFILE['common'],
                tailoring=tailoring_name,
                tailoring_profile=OSCAP_PROFILE['tailoring_rhel7'],
                period_value=OSCAP_WEEKDAY['friday'],
            )
            self.assertIsNone(
                self.oscappolicy.search(policy_name),
                msg="scap policy name element found")
示例#12
0
    def test_negative_associate_tailoring_file_with_different_scap(self):
        """ Associate a tailoring file with different scap content

        :id: 5b166dd4-5e9c-4c35-b2fb-fd35d75d51f5

        :setup: scap content and tailoring file

        :steps:

            1. Create a valid scap content
            2. Upload a Mutually exclusive tailoring file
            3. Associate the scap content with tailoring file

        :expectedresults: Association should give some warning

        :CaseImportance: Critical
        """
        tailoring_name = gen_string('alpha')
        content_name = OSCAP_DEFAULT_CONTENT['rhel_firefox']
        policy_name = gen_string('alpha')
        with Session(self) as session:
            make_oscap_tailoringfile(
                session,
                name=tailoring_name,
                tailoring_path=self.tailoring_path,
                tailoring_loc=self.loc_name,
                tailoring_org=self.org_name,
            )
            self.assertIsNotNone(
                self.oscaptailoringfile.search(tailoring_name),
                msg="Tailoring file name element not found")
            self.assertIsNotNone(self.oscapcontent.search(content_name))
            make_oscappolicy(
                session,
                content=content_name,
                name=policy_name,
                period=OSCAP_PERIOD['weekly'],
                profile=OSCAP_PROFILE['common'],
                tailoring=tailoring_name,
                tailoring_profile=OSCAP_PROFILE['tailoring_rhel7'],
                period_value=OSCAP_WEEKDAY['friday'],
            )
            self.assertIsNone(self.oscappolicy.search(policy_name),
                              msg="scap policy name element found")
示例#13
0
    def test_positive_oscap_run_with_tailoring_file_and_capsule(self):
        """ End-to-End Oscap run with tailoring files and default capsule

        :id: 346946ad-4f62-400e-9390-81817006048c

        :setup: scap content, scap policy, tailoring file, host group

        :steps:

            1. Create a valid scap content
            2. Upload a valid tailoring file
            3. Create a scap policy
            4. Associate scap content with it's tailoring file
            5. Associate the policy with a hostgroup
            6. Provision a host using the hostgroup
            7. Puppet should configure and fetch the scap content
               and tailoring file

        :expectedresults: ARF report should be sent to satellite reflecting
                         the changes done via tailoring files

        :CaseImportance: Critical
        """
        if settings.rhel7_repo is None:
            self.skipTest('Missing configuration for rhel7_repo')
        rhel7_repo = settings.rhel7_repo
        hgrp7_name = gen_string('alpha')
        policy_values = {
            'content': self.rhel7_content,
            'hgrp': hgrp7_name,
            'policy': gen_string('alpha'),
        }
        vm_values = {
            'distro': DISTRO_RHEL7,
            'hgrp': hgrp7_name,
            'rhel_repo': rhel7_repo,
        }
        tailoring_file_name = gen_string('alpha')
        tailoring_path = get_data_file(settings.oscap.tailoring_path)
        with Session(self) as session:
            session.nav.go_to_select_org(self.config_env['org_name'])
            # Creates host_group for rhel7
            make_hostgroup(
                session,
                content_source=self.config_env['sat6_hostname'],
                name=hgrp7_name,
                puppet_ca=self.config_env['sat6_hostname'],
                puppet_master=self.config_env['sat6_hostname'],
            )
            make_oscap_tailoringfile(
                session,
                name=tailoring_file_name,
                tailoring_path=tailoring_path,
            )
            self.assertIsNotNone(
                self.oscaptailoringfile.search(tailoring_file_name))
            # Creates oscap_policy for rhel7.
            make_oscappolicy(
                session,
                content=policy_values.get('content'),
                host_group=policy_values.get('hgrp'),
                name=policy_values.get('policy'),
                period=OSCAP_PERIOD['weekly'],
                profile=OSCAP_PROFILE['common'],
                period_value=OSCAP_WEEKDAY['friday'],
                tailoring=tailoring_file_name,
                tailoring_profile=OSCAP_PROFILE['tailoring_rhel7']
            )
            distro_os = vm_values.get('distro')
            with VirtualMachine(distro=distro_os) as vm:
                host_name, _, host_domain = vm.hostname.partition('.')
                vm.install_katello_ca()
                vm.register_contenthost(
                    self.config_env['org_name'],
                    self.config_env['ak_name'].get(distro_os)
                )
                self.assertTrue(vm.subscribed)
                vm.configure_puppet(rhel7_repo)
                self.hosts.update(
                    name=host_name,
                    domain_name=host_domain,
                    parameters_list=[
                        ['Host', 'Host Group', vm_values.get('hgrp')],
                        ['Host', 'Lifecycle Environment',
                            self.config_env['env_name']],
                        ['Host', 'Content View', self.config_env['cv_name']],
                        ['Host', 'Reset Puppet Environment', True],
                        ['Host', 'Openscap Capsule',
                            self.config_env['sat6_hostname']],
                    ],
                )
                self.hosts.update_host_bulkactions(
                    ['{0}'.format(vm.hostname.lower())],
                    action='Assign Compliance Policy',
                    parameters_list=[
                        {'policy': policy_values.get('policy')}],
                )
                # Run "puppet agent -t" twice so that it detects it's,
                # satellite6 and fetch katello SSL certs.
                for _ in range(2):
                    vm.run(u'puppet agent -t 2> /dev/null')
                result = vm.run(
                    u'cat /etc/foreman_scap_client/config.yaml'
                    '| grep profile'
                )
                self.assertEqual(result.return_code, 0)
                # Runs the actual oscap scan on the vm/clients and
                # uploads report to Internal Capsule.
                vm.execute_foreman_scap_client()
                # Assert whether oscap reports are uploaded to
                # Satellite6.
                self.assertTrue(self.oscapreports.search(
                    '{0}'.format(vm.hostname)))
示例#14
0
    def test_positive_oscap_run_with_tailoring_file_and_capsule(self):
        """ End-to-End Oscap run with tailoring files and default capsule

        :id: 346946ad-4f62-400e-9390-81817006048c

        :setup: scap content, scap policy, tailoring file, host group

        :steps:

            1. Create a valid scap content
            2. Upload a valid tailoring file
            3. Create a scap policy
            4. Associate scap content with it's tailoring file
            5. Associate the policy with a hostgroup
            6. Provision a host using the hostgroup
            7. Puppet should configure and fetch the scap content
               and tailoring file

        :expectedresults: ARF report should be sent to satellite reflecting
                         the changes done via tailoring files

        :CaseImportance: Critical
        """
        if settings.rhel7_repo is None:
            self.skipTest('Missing configuration for rhel7_repo')
        rhel7_repo = settings.rhel7_repo
        hgrp7_name = gen_string('alpha')
        policy_values = {
            'content': self.rhel7_content,
            'hgrp': hgrp7_name,
            'policy': gen_string('alpha'),
        }
        vm_values = {
            'distro': DISTRO_RHEL7,
            'hgrp': hgrp7_name,
            'rhel_repo': rhel7_repo,
        }
        tailoring_file_name = gen_string('alpha')
        tailoring_path = get_data_file(settings.oscap.tailoring_path)
        with Session(self) as session:
            session.nav.go_to_select_org(self.config_env['org_name'])
            # Creates host_group for rhel7
            make_hostgroup(
                session,
                content_source=self.config_env['sat6_hostname'],
                name=hgrp7_name,
                puppet_ca=self.config_env['sat6_hostname'],
                puppet_master=self.config_env['sat6_hostname'],
            )
            make_oscap_tailoringfile(
                session,
                name=tailoring_file_name,
                tailoring_path=tailoring_path,
            )
            self.assertIsNotNone(
                self.oscaptailoringfile.search(tailoring_file_name))
            # Creates oscap_policy for rhel7.
            make_oscappolicy(
                session,
                content=policy_values.get('content'),
                host_group=policy_values.get('hgrp'),
                name=policy_values.get('policy'),
                period=OSCAP_PERIOD['weekly'],
                profile=OSCAP_PROFILE['common'],
                period_value=OSCAP_WEEKDAY['friday'],
                tailoring=tailoring_file_name,
                tailoring_profile=OSCAP_PROFILE['tailoring_rhel7'])
            distro_os = vm_values.get('distro')
            with VirtualMachine(distro=distro_os) as vm:
                host_name, _, host_domain = vm.hostname.partition('.')
                vm.install_katello_ca()
                vm.register_contenthost(
                    self.config_env['org_name'],
                    self.config_env['ak_name'].get(distro_os))
                self.assertTrue(vm.subscribed)
                vm.configure_puppet(rhel7_repo)
                self.hosts.update(
                    name=host_name,
                    domain_name=host_domain,
                    parameters_list=[
                        ['Host', 'Host Group',
                         vm_values.get('hgrp')],
                        [
                            'Host', 'Lifecycle Environment',
                            self.config_env['env_name']
                        ],
                        ['Host', 'Content View', self.config_env['cv_name']],
                        ['Host', 'Reset Puppet Environment', True],
                        [
                            'Host', 'Openscap Capsule',
                            self.config_env['sat6_hostname']
                        ],
                    ],
                )
                self.hosts.update_host_bulkactions(
                    ['{0}'.format(vm.hostname.lower())],
                    action='Assign Compliance Policy',
                    parameters_list=[{
                        'policy': policy_values.get('policy')
                    }],
                )
                # Run "puppet agent -t" twice so that it detects it's,
                # satellite6 and fetch katello SSL certs.
                for _ in range(2):
                    vm.run(u'puppet agent -t 2> /dev/null')
                result = vm.run(u'cat /etc/foreman_scap_client/config.yaml'
                                '| grep profile')
                self.assertEqual(result.return_code, 0)
                # Runs the actual oscap scan on the vm/clients and
                # uploads report to Internal Capsule.
                vm.execute_foreman_scap_client()
                # Assert whether oscap reports are uploaded to
                # Satellite6.
                self.assertTrue(
                    self.oscapreports.search('{0}'.format(vm.hostname)))