Ejemplo n.º 1
0
    def test_positive_list_scap_policy(self):
        """List all scap policies

        :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.

        :expectedresults: The policies are listed successfully.
        """
        for deploy in ['puppet', 'ansible', 'manual']:
            with self.subTest(deploy):
                name = gen_string('alphanumeric')
                make_scap_policy({
                    'name': name,
                    'deploy-by': deploy,
                    '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.list()
                self.assertIn(name, [policy['name'] for policy in result])
Ejemplo n.º 2
0
    def test_positive_list_scap_policy(self):
        """List all scap policies

        :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.

        :expectedresults: The policies are listed successfully.
        """
        name = gen_string('alphanumeric')
        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.list()
        self.assertIn(name,
                      [policy['name'] for policy in result]
                      )
Ejemplo n.º 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']})