コード例 #1
0
    def test_positive_delete_scap_policy_with_id(self):
        """Delete the scap policy with id as parameter

        :id: db9d925f-c730-4299-ad8e-5aaa08895f6e

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "delete" as sub-command.
            3. Pass id as parameter.

        :expectedresults: The scap policy is deleted successfully.
        """
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy(
            {
                'name': name,
                'deploy-by': 'ansible',
                'scap-content-id': self.scap_id_rhel7,
                'scap-content-profile-id': self.scap_profile_id_rhel7,
                'period': OSCAP_PERIOD['weekly'].lower(),
                'weekday': OSCAP_WEEKDAY['friday'].lower(),
            }
        )
        assert scap_policy['name'] == name
        Scappolicy.delete({'id': scap_policy['id']})
        with pytest.raises(CLIReturnCodeError):
            Scappolicy.info({'id': scap_policy['id']})
コード例 #2
0
ファイル: test_oscap.py プロジェクト: BlackSmith/robottelo
    def test_positive_delete_scap_policy_with_id(self):
        """Delete the scap policy with id as parameter

        :id: db9d925f-c730-4299-ad8e-5aaa08895f6e

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "delete" as sub-command.
            3. Pass id as parameter.

        :expectedresults: The scap policy is deleted successfully.
        """
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name': name,
            'scap-content-id': self.scap_id_rhel6,
            'scap-content-profile-id': self.scap_profile_id_rhel6,
            'period': OSCAP_PERIOD['weekly'].lower(),
            'weekday': OSCAP_WEEKDAY['friday'].lower(),
        })
        self.assertEqual(scap_policy['name'], name)
        Scappolicy.delete({'id': scap_policy['id']})
        with self.assertRaises(CLIReturnCodeError):
            Scappolicy.info({'id': scap_policy['id']})
コード例 #3
0
    def test_positive_scap_policy_end_to_end(self):
        """List all scap policies and read info using id, name

        :id: d14ab43e-c7a9-4eee-b61c-420b07ca1da9

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "list" as sub-command.
            3. Execute "policy" command with "info" as sub-command.
            4. Pass ID as the parameter.
            5. Pass name as the parameter.

        :expectedresults: The policies are listed successfully and information is displayed.
        """
        for deploy in ['manual', 'puppet', 'ansible']:
            with self.subTest(deploy):
                hostgroup = make_hostgroup()
                name = gen_string('alphanumeric')
                scap_policy = make_scap_policy({
                    'name':
                    name,
                    'deploy-by':
                    deploy,
                    'scap-content-id':
                    self.scap_id_rhel7,
                    'scap-content-profile-id':
                    self.scap_profile_id_rhel7,
                    'period':
                    OSCAP_PERIOD['weekly'].lower(),
                    'weekday':
                    OSCAP_WEEKDAY['friday'].lower(),
                    'hostgroups':
                    hostgroup['name'],
                })
                result = Scappolicy.list()
                assert name in [policy['name'] for policy in result]
                assert Scappolicy.info({'id': scap_policy['id']
                                        })['id'] == scap_policy['id']
                assert Scappolicy.info({'name':
                                        scap_policy['name']})['name'] == name

                Scappolicy.update({
                    'id': scap_policy['id'],
                    'period': OSCAP_PERIOD['monthly'].lower(),
                    'day-of-month': 15,
                })
                scap_info = Scappolicy.info({'name': name})
                assert scap_info['period'] == OSCAP_PERIOD['monthly'].lower()
                assert scap_info['day-of-month'] == '15'
                Scappolicy.delete({'id': scap_policy['id']})
                with pytest.raises(CLIReturnCodeError):
                    Scappolicy.info({'id': scap_policy['id']})
コード例 #4
0
ファイル: test_oscap.py プロジェクト: BlackSmith/robottelo
    def test_positive_info_scap_policy_with_id(self):
        """View info of policy with id as parameter

        :id: d309000b-777e-4cfb-bf6c-7f02ab130b9d

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "info" as sub-command.
            3. Pass ID as the parameter.

        :expectedresults: The information is displayed.
        """
        scap_policy = make_scap_policy({
            'scap-content-id': self.scap_id_rhel6,
            'scap-content-profile-id': self.scap_profile_id_rhel6,
            'period': OSCAP_PERIOD['weekly'].lower(),
            'weekday': OSCAP_WEEKDAY['friday'].lower()
        })
        result = Scappolicy.info({'id': scap_policy['id']})
        self.assertEqual(result['id'], scap_policy['id'])
コード例 #5
0
ファイル: test_oscap.py プロジェクト: BlackSmith/robottelo
    def test_positive_info_scap_policy_with_name(self):
        """View info of policy with name as parameter

        :id: eece98b2-3e6a-4ac0-b742-913482343e9d

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "info" as sub-command.
            3. Pass name as the parameter.

        :expectedresults: The information is displayed.
        """
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name': name,
            'scap-content-id': self.scap_id_rhel6,
            'scap-content-profile-id': self.scap_profile_id_rhel6,
            'period': OSCAP_PERIOD['weekly'].lower(),
            'weekday': OSCAP_WEEKDAY['friday'].lower()
        })
        result = Scappolicy.info({'name': scap_policy['name']})
        self.assertEqual(result['name'], name)
コード例 #6
0
ファイル: test_oscap.py プロジェクト: renzon/robottelo
    def test_positive_info_scap_policy_with_name(self):
        """View info of policy with name as parameter

        :id: eece98b2-3e6a-4ac0-b742-913482343e9d

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "info" as sub-command.
            3. Pass name as the parameter.

        :expectedresults: The information is displayed.
        """
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name':
            name,
            'scap-content-id':
            self.scap_id_rhel6,
            'scap-content-profile-id':
            self.scap_profile_id_rhel6,
            'period':
            OSCAP_PERIOD['weekly'].lower(),
            'weekday':
            OSCAP_WEEKDAY['friday'].lower()
        })
        result = Scappolicy.info({'name': scap_policy['name']})
        self.assertEqual(result['name'], name)
コード例 #7
0
ファイル: test_oscap.py プロジェクト: renzon/robottelo
    def test_positive_info_scap_policy_with_id(self):
        """View info of policy with id as parameter

        :id: d309000b-777e-4cfb-bf6c-7f02ab130b9d

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "info" as sub-command.
            3. Pass ID as the parameter.

        :expectedresults: The information is displayed.
        """
        scap_policy = make_scap_policy({
            'scap-content-id':
            self.scap_id_rhel6,
            'scap-content-profile-id':
            self.scap_profile_id_rhel6,
            'period':
            OSCAP_PERIOD['weekly'].lower(),
            'weekday':
            OSCAP_WEEKDAY['friday'].lower()
        })
        result = Scappolicy.info({'id': scap_policy['id']})
        self.assertEqual(result['id'], scap_policy['id'])
コード例 #8
0
    def test_positive_info_scap_policy_with_name(self):
        """View info of policy with name as parameter

        :id: eece98b2-3e6a-4ac0-b742-913482343e9d

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "info" as sub-command.
            3. Pass name as the parameter.

        :expectedresults: The information is displayed.
        """
        for deploy in ['puppet', 'ansible', 'manual']:
            name = gen_string('alphanumeric')
            with self.subTest(deploy):
                scap_policy = make_scap_policy(
                    {
                        'name': name,
                        'deploy-by': deploy,
                        'scap-content-id': self.scap_id_rhel7,
                        'scap-content-profile-id': self.scap_profile_id_rhel7,
                        'period': OSCAP_PERIOD['weekly'].lower(),
                        'weekday': OSCAP_WEEKDAY['friday'].lower(),
                    }
                )
                assert scap_policy['deployment-option'] == deploy
                assert Scappolicy.info({'name': scap_policy['name']})['name'] == name
コード例 #9
0
    def test_positive_info_scap_policy_with_id(self):
        """View info of policy with id as parameter

        :id: d309000b-777e-4cfb-bf6c-7f02ab130b9d

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "info" as sub-command.
            3. Pass ID as the parameter.

        :expectedresults: The information is displayed.
        """
        for deploy in ['puppet', 'ansible', 'manual']:
            with self.subTest(deploy):
                scap_policy = make_scap_policy(
                    {
                        'scap-content-id': self.scap_id_rhel7,
                        'deploy-by': deploy,
                        'scap-content-profile-id': self.scap_profile_id_rhel7,
                        'period': OSCAP_PERIOD['weekly'].lower(),
                        'weekday': OSCAP_WEEKDAY['friday'].lower(),
                    }
                )
                assert scap_policy['deployment-option'] == deploy
                assert Scappolicy.info({'id': scap_policy['id']})['id'] == scap_policy['id']
コード例 #10
0
ファイル: test_host.py プロジェクト: jhutar/robottelo
def test_positive_assign_compliance_policy(session, scap_policy):
    """Ensure host compliance Policy can be assigned.

    :id: 323661a4-e849-4cc2-aa39-4b4a5fe2abed

    :expectedresults: Host Assign Compliance Policy action is working as
        expected.

    :CaseLevel: Integration
    """
    host = entities.Host().create()
    org = host.organization.read()
    loc = host.location.read()
    # add host organization and location to scap policy
    scap_policy = Scappolicy.info(
        {'id': scap_policy['id']}, output_format='json')
    organization_ids = [
        policy_org['id']
        for policy_org in scap_policy.get('organizations', [])
    ]
    organization_ids.append(org.id)
    location_ids = [
        policy_loc['id']
        for policy_loc in scap_policy.get('locations', [])
    ]

    location_ids.append(loc.id)
    Scappolicy.update({
        'id': scap_policy['id'],
        'organization-ids': organization_ids,
        'location-ids': location_ids
    })
    with session:
        session.organization.select(org_name=org.name)
        session.location.select(loc_name=loc.name)
        assert not session.host.search(
            'compliance_policy = {0}'.format(scap_policy['name']))
        assert session.host.search(host.name)[0]['Name'] == host.name
        session.host.apply_action(
            'Assign Compliance Policy',
            [host.name],
            {
                'policy': scap_policy['name'],
            }
        )
        assert (session.host.search(
            'compliance_policy = {0}'.format(scap_policy['name']))[0]['Name']
            ==
            host.name)
コード例 #11
0
def test_positive_assign_compliance_policy(session, scap_policy):
    """Ensure host compliance Policy can be assigned.

    :id: 323661a4-e849-4cc2-aa39-4b4a5fe2abed

    :expectedresults: Host Assign Compliance Policy action is working as
        expected.

    :CaseLevel: Integration
    """
    host = entities.Host().create()
    org = host.organization.read()
    loc = host.location.read()
    # add host organization and location to scap policy
    scap_policy = Scappolicy.info(
        {'id': scap_policy['id']}, output_format='json')
    organization_ids = [
        policy_org['id']
        for policy_org in scap_policy.get('organizations', [])
    ]
    organization_ids.append(org.id)
    location_ids = [
        policy_loc['id']
        for policy_loc in scap_policy.get('locations', [])
    ]

    location_ids.append(loc.id)
    Scappolicy.update({
        'id': scap_policy['id'],
        'organization-ids': organization_ids,
        'location-ids': location_ids
    })
    with session:
        session.organization.select(org_name=org.name)
        session.location.select(loc_name=loc.name)
        assert not session.host.search(
            'compliance_policy = {0}'.format(scap_policy['name']))
        assert session.host.search(host.name)[0]['Name'] == host.name
        session.host.apply_action(
            'Assign Compliance Policy',
            [host.name],
            {
                'policy': scap_policy['name'],
            }
        )
        assert (session.host.search(
            'compliance_policy = {0}'.format(scap_policy['name']))[0]['Name']
            ==
            host.name)
コード例 #12
0
    def test_positive_update_scap_policy_with_hostgroup(self, scap_content):
        """Update scap policy by addition of hostgroup

        :id: 21b9b82b-7c6c-4944-bc2f-67631e1d4086

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy and hostgroup.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "update" as sub-command.
            3. Pass hostgoups as the parameter.

        :expectedresults: The scap policy is updated.
        """
        hostgroup = make_hostgroup()
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name':
            name,
            'deploy-by':
            'puppet',
            'scap-content-id':
            scap_content["scap_id"],
            'scap-content-profile-id':
            scap_content["scap_profile_id"],
            'period':
            OSCAP_PERIOD['weekly'].lower(),
            'weekday':
            OSCAP_WEEKDAY['friday'].lower(),
            'hostgroups':
            hostgroup['name'],
        })
        assert scap_policy['hostgroups'][0] == hostgroup['name']
        assert scap_policy['deployment-option'] == 'puppet'
        new_hostgroup = make_hostgroup()
        Scappolicy.update({
            'id': scap_policy['id'],
            'deploy-by': 'ansible',
            'hostgroups': new_hostgroup['name']
        })
        scap_info = Scappolicy.info({'name': name})
        assert scap_info['hostgroups'][0] == new_hostgroup['name']
        # Assert if the deployment is updated
        assert scap_info['deployment-option'] == 'ansible'
コード例 #13
0
    def test_positive_update_scap_policy_with_content(self):
        """Update the scap policy by updating the scap content
        associated with the policy

        :id: 3c9df098-9ff8-4f48-a9a0-2ba21a8e48e0

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "update" as sub-command.
            3. Pass scap-content-id as parameter.

        :expectedresults: The scap policy is updated.
        """
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name':
            name,
            'deploy-by':
            'puppet',
            'scap-content-id':
            self.scap_id_rhel6,
            'scap-content-profile-id':
            self.scap_profile_id_rhel6,
            'period':
            OSCAP_PERIOD['weekly'].lower(),
            'weekday':
            OSCAP_WEEKDAY['friday'].lower(),
        })
        self.assertEqual(scap_policy['scap-content-id'], self.scap_id_rhel6)
        scap_id, scap_profile_id = self.fetch_scap_and_profile_id(
            OSCAP_DEFAULT_CONTENT['rhel_firefox'], OSCAP_PROFILE['firefox'])
        Scappolicy.update({
            'name': name,
            'scap-content-id': scap_id,
            'scap-content-profile-id': scap_profile_id,
        })
        scap_info = Scappolicy.info({'name': name})
        self.assertEqual(scap_info['scap-content-id'], scap_id)
        self.assertEqual(scap_info['scap-content-profile-id'],
                         scap_profile_id[0])
コード例 #14
0
    def test_positive_update_scap_policy_with_tailoringfiles_name(self):
        """Update the scap policy by updating the scap tailoring file name
        associated with the policy

        :id: a2403170-51df-4561-9a58-820f77a5e048

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "update" as sub-command.
            3. Pass tailoring-file as parameter.

        :expectedresults: The scap policy is updated.
        """
        _, file_name = os.path.split(settings.oscap.tailoring_path)
        ssh.upload_file(local_file=settings.oscap.tailoring_path,
                        remote_file="/tmp/{0}".format(file_name))
        tailoring_file = make_tailoringfile(
            {'scap-file': '/tmp/{0}'.format(file_name)})
        tailor_profile_id = tailoring_file['tailoring-file-profiles'][0]['id']
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name':
            name,
            'deploy-by':
            'ansible',
            'scap-content-id':
            self.scap_id_rhel6,
            'scap-content-profile-id':
            self.scap_profile_id_rhel6,
            'period':
            OSCAP_PERIOD['weekly'].lower(),
            'weekday':
            OSCAP_WEEKDAY['friday'].lower(),
        })
        self.assertEqual(scap_policy['scap-content-id'], self.scap_id_rhel6)
        Scappolicy.update({
            'name': name,
            'tailoring-file': tailoring_file['name'],
            'tailoring-file-profile-id': tailor_profile_id
        })
        scap_info = Scappolicy.info({'name': name})
        self.assertEqual(scap_info['tailoring-file-id'], tailoring_file['id'])
        self.assertEqual(scap_info['tailoring-file-profile-id'],
                         tailor_profile_id)
コード例 #15
0
    def test_positive_update_scap_policy_period(self, scap_content):
        """Update scap policy by updating the period strategy
        from monthly to weekly

        :id: 4892bc3c-d886-49b4-a5b1-250d96b7e278

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "update" as sub-command.
            3. Pass period as parameter and weekday as parameter.

        :expectedresults: The scap policy is updated.
        """
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name':
            name,
            'deploy-by':
            'puppet',
            'scap-content-id':
            scap_content["scap_id"],
            'scap-content-profile-id':
            scap_content["scap_profile_id"],
            'period':
            OSCAP_PERIOD['weekly'].lower(),
            'weekday':
            OSCAP_WEEKDAY['friday'].lower(),
        })
        assert scap_policy['period'] == OSCAP_PERIOD['weekly'].lower()
        Scappolicy.update({
            'id': scap_policy['id'],
            'period': OSCAP_PERIOD['monthly'].lower(),
            'day-of-month': 15,
        })
        scap_info = Scappolicy.info({'name': name})
        assert scap_info['period'] == OSCAP_PERIOD['monthly'].lower()
        assert scap_info['day-of-month'] == '15'
コード例 #16
0
ファイル: test_oscap.py プロジェクト: BlackSmith/robottelo
    def test_positive_update_scap_policy_with_content(self):
        """Update the scap policy by updating the scap content
        associated with the policy

        :id: 3c9df098-9ff8-4f48-a9a0-2ba21a8e48e0

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "update" as sub-command.
            3. Pass scap-content-id as parameter.

        :expectedresults: The scap policy is updated.
        """
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name': name,
            'scap-content-id': self.scap_id_rhel6,
            'scap-content-profile-id': self.scap_profile_id_rhel6,
            'period': OSCAP_PERIOD['weekly'].lower(),
            'weekday': OSCAP_WEEKDAY['friday'].lower(),
        })
        self.assertEqual(scap_policy['scap-content-id'], self.scap_id_rhel6)
        scap_id, scap_profile_id = self.fetch_scap_and_profile_id(
                OSCAP_DEFAULT_CONTENT['rhel_firefox'],
                OSCAP_PROFILE['firefox']
        )

        Scappolicy.update({
            'name': name,
            'scap-content-id': scap_id,
            'scap-content-profile-id': scap_profile_id,
        })
        scap_info = Scappolicy.info({'name': name})
        self.assertEqual(scap_info['scap-content-id'], scap_id)
        self.assertEqual(scap_info['scap-content-profile-id'],
                         scap_profile_id[0])
コード例 #17
0
ファイル: test_oscap.py プロジェクト: BlackSmith/robottelo
    def test_positive_update_scap_policy_with_tailoringfiles_id(self):
        """Update the scap policy by updating the scap tailoring file id
        associated with the policy

        :id: 91a25e0b-d5d2-49d8-a3cd-1f3836ac323c

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "update" as sub-command.
            3. Pass tailoring-file-id as parameter.

        :expectedresults: The scap policy is updated.
        """
        _, file_name = os.path.split(settings.oscap.tailoring_path)
        ssh.upload_file(
            local_file=settings.oscap.tailoring_path,
            remote_file="/tmp/{0}".format(file_name)
        )
        tailoring_file = make_tailoringfile({
            'scap-file': '/tmp/{0}'.format(file_name)
        })
        tailor_profile_id = tailoring_file['tailoring-file-profiles'][0]['id']
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name': name,
            'scap-content-id': self.scap_id_rhel6,
            'scap-content-profile-id': self.scap_profile_id_rhel6,
            'period': OSCAP_PERIOD['weekly'].lower(),
            'weekday': OSCAP_WEEKDAY['friday'].lower(),
        })
        self.assertEqual(scap_policy['scap-content-id'], self.scap_id_rhel6)
        Scappolicy.update({
            'name': name,
            'tailoring-file-id': tailoring_file['id'],
            'tailoring-file-profile-id': tailor_profile_id
        })
        scap_info = Scappolicy.info({'name': name})
        self.assertEqual(scap_info['tailoring-file-id'], tailoring_file['id'])
        self.assertEqual(scap_info['tailoring-file-profile-id'],
                         tailor_profile_id)
コード例 #18
0
    def test_positive_update_scap_policy_with_tailoringfiles_name(self):
        """Update the scap policy by updating the scap tailoring file name
        associated with the policy

        :id: a2403170-51df-4561-9a58-820f77a5e048

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "update" as sub-command.
            3. Pass tailoring-file as parameter.

        :expectedresults: The scap policy is updated.
        """
        tailoring_file = make_tailoringfile(
            {'scap-file': self.tailoring_file_path})
        tailor_profile_id = tailoring_file['tailoring-file-profiles'][0]['id']
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name':
            name,
            'deploy-by':
            'ansible',
            'scap-content-id':
            self.scap_id_rhel7,
            'scap-content-profile-id':
            self.scap_profile_id_rhel7,
            'period':
            OSCAP_PERIOD['weekly'].lower(),
            'weekday':
            OSCAP_WEEKDAY['friday'].lower(),
        })
        assert scap_policy['scap-content-id'] == self.scap_id_rhel7
        Scappolicy.update({
            'name': name,
            'tailoring-file': tailoring_file['name'],
            'tailoring-file-profile-id': tailor_profile_id
        })
        scap_info = Scappolicy.info({'name': name})
        assert scap_info['tailoring-file-id'] == tailoring_file['id']
        assert scap_info['tailoring-file-profile-id'] == tailor_profile_id
コード例 #19
0
ファイル: test_oscap.py プロジェクト: BlackSmith/robottelo
    def test_positive_update_scap_policy_period(self):
        """Update scap policy by updating the period strategy
        from monthly to weekly

        :id: 4892bc3c-d886-49b4-a5b1-250d96b7e278

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "update" as sub-command.
            3. Pass period as parameter and weekday as parameter.

        :expectedresults: The scap policy is updated.
        """
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name': name,
            'scap-content-id': self.scap_id_rhel6,
            'scap-content-profile-id': self.scap_profile_id_rhel6,
            'period': OSCAP_PERIOD['weekly'].lower(),
            'weekday': OSCAP_WEEKDAY['friday'].lower(),
        })
        self.assertEqual(scap_policy['period'], OSCAP_PERIOD['weekly'].lower())
        Scappolicy.update({
            'id': scap_policy['id'],
            'period': OSCAP_PERIOD['monthly'].lower(),
            'day-of-month': 15
        })
        scap_info = Scappolicy.info({'name': name})
        self.assertEqual(scap_info['period'], OSCAP_PERIOD['monthly'].lower())
        self.assertEqual(scap_info['day-of-month'], '15')
コード例 #20
0
ファイル: test_oscap.py プロジェクト: BlackSmith/robottelo
    def test_positive_update_scap_policy_with_hostgroup(self):
        """Update scap policy by addition of hostgroup

        :id: 21b9b82b-7c6c-4944-bc2f-67631e1d4086

        :setup:

            1. Oscap should be enabled.
            2. Oscap-cli hammer plugin installed.
            3. Atleast 1 policy and hostgroup.

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "update" as sub-command.
            3. Pass hostgoups as the parameter.

        :expectedresults: The scap policy is updated.
        """
        hostgroup = make_hostgroup()
        name = gen_string('alphanumeric')
        scap_policy = make_scap_policy({
            'name': name,
            'scap-content-id': self.scap_id_rhel6,
            'scap-content-profile-id': self.scap_profile_id_rhel6,
            'period': OSCAP_PERIOD['weekly'].lower(),
            'weekday': OSCAP_WEEKDAY['friday'].lower(),
            'hostgroups': hostgroup['name']
        })
        self.assertEqual(scap_policy['hostgroups'][0], hostgroup['name'])
        new_hostgroup = make_hostgroup()
        Scappolicy.update({
            'id': scap_policy['id'],
            'hostgroups': new_hostgroup['name']
        })
        scap_info = Scappolicy.info({'name': name})
        self.assertEqual(scap_info['hostgroups'][0], new_hostgroup['name'])
コード例 #21
0
    def test_positive_associate_scap_policy_with_tailoringfiles(
            self, deploy, scap_content, tailoring_file_path):
        """Associate tailoring file by name/id to scap policy with all deployments

        :id: d0f9b244-b92d-4889-ba6a-8973ea05bf43

        :parametrized: yes

        :steps:

            1. Login to hammer shell.
            2. Execute "policy" command with "create" as sub-command.
            3. Pass valid parameters.
            4. Associate tailoring file by name/id with policy

        :expectedresults: The policy is created and associated successfully.
        """
        tailoring_file_a = make_tailoringfile(
            {'scap-file': tailoring_file_path['satellite']})
        tailoring_file_profile_a_id = tailoring_file_a[
            'tailoring-file-profiles'][0]['id']
        tailoring_file_b = make_tailoringfile(
            {'scap-file': tailoring_file_path['satellite']})
        tailoring_file_profile_b_id = tailoring_file_b[
            'tailoring-file-profiles'][0]['id']

        scap_policy = make_scap_policy({
            'scap-content-id':
            scap_content["scap_id"],
            'deploy-by':
            deploy,
            'scap-content-profile-id':
            scap_content["scap_profile_id"],
            'period':
            OSCAP_PERIOD['weekly'].lower(),
            'weekday':
            OSCAP_WEEKDAY['friday'].lower(),
            'tailoring-file':
            tailoring_file_a['name'],
            'tailoring-file-profile-id':
            tailoring_file_profile_a_id,
        })
        assert scap_policy['deployment-option'] == deploy
        assert scap_policy['tailoring-file-id'] == tailoring_file_a['id']
        assert scap_policy[
            'tailoring-file-profile-id'] == tailoring_file_profile_a_id

        Scappolicy.update({
            'name':
            scap_policy['name'],
            'tailoring-file':
            tailoring_file_b['name'],
            'tailoring-file-profile-id':
            tailoring_file_profile_b_id,
        })
        scap_info = Scappolicy.info({'name': scap_policy['name']})
        assert scap_info['tailoring-file-id'] == tailoring_file_b['id']
        assert scap_info[
            'tailoring-file-profile-id'] == tailoring_file_profile_b_id

        Scappolicy.delete({'name': scap_policy['name']})
        with pytest.raises(CLIReturnCodeError):
            Scapcontent.info({'name': scap_policy['name']})

        scap_policy = make_scap_policy({
            'scap-content-id':
            scap_content["scap_id"],
            'deploy-by':
            deploy,
            'scap-content-profile-id':
            scap_content["scap_profile_id"],
            'period':
            OSCAP_PERIOD['weekly'].lower(),
            'weekday':
            OSCAP_WEEKDAY['friday'].lower(),
            'tailoring-file-id':
            tailoring_file_a['id'],
            'tailoring-file-profile-id':
            tailoring_file_profile_a_id,
        })
        assert scap_policy['deployment-option'] == deploy
        assert scap_policy['tailoring-file-id'] == tailoring_file_a['id']
        assert scap_policy[
            'tailoring-file-profile-id'] == tailoring_file_profile_a_id

        Scappolicy.update({
            'id':
            scap_policy['id'],
            'tailoring-file-id':
            tailoring_file_b['id'],
            'tailoring-file-profile-id':
            tailoring_file_profile_b_id,
        })
        scap_info = Scappolicy.info({'id': scap_policy['id']})
        assert scap_info['tailoring-file-id'] == tailoring_file_b['id']
        assert scap_info[
            'tailoring-file-profile-id'] == tailoring_file_profile_b_id

        Scappolicy.delete({'id': scap_policy['id']})
        with pytest.raises(CLIReturnCodeError):
            Scapcontent.info({'name': scap_policy['name']})