def test_positive_delete_scap_policy_with_name(self): """Delete the scap policy with name as parameter :id: 6c167e7b-cbdd-4059-808c-04c686ba9fe8 :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 name 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({'name': name}) with self.assertRaises(CLIReturnCodeError): Scapcontent.info({'name': scap_policy['name']})
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']})
def test_positive_delete_scap_policy_with_name(self): """Delete the scap policy with name as parameter :id: 6c167e7b-cbdd-4059-808c-04c686ba9fe8 :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 name as parameter. :expectedresults: The scap policy is deleted successfully. """ name = gen_string('alphanumeric') scap_policy = make_scap_policy( { 'name': name, 'deploy-by': 'puppet', '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({'name': name}) with pytest.raises(CLIReturnCodeError): Scapcontent.info({'name': scap_policy['name']})
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']})
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']})