def test_positive_delete_by_policy_name(self): """Create OpenScap Policy. @Feature: OpenScap Policy - Positive Create. @Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. 4. Delete the openscap Policy. @Assert: Whether deleting Policy for OpenScap is successful. """ content_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone(self.oscapcontent.search(content_name)) for policy_name in valid_data_list(): with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['rhccp'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone(self.oscappolicy.search(policy_name)) self.oscappolicy.delete(policy_name)
def test_negative_create_with_invalid_name(self): """Create OpenScap Policy with negative values. @id: dfebf26b-194f-473d-b5a6-9061c520f57e @Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. @Assert: Creating Policy for OpenScap is not successful. @BZ: 1293296 """ content_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) for policy_name in invalid_values_list(interface='ui'): with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNone(self.oscappolicy.search(policy_name))
def test_negative_create_with_invalid_name(self): """Create OpenScap Policy with negative values. @Feature: OpenScap Policy - Negative Create. @Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. @Assert: Creating Policy for OpenScap is not successful. @BZ: 1293296 """ content_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone(self.oscapcontent.search(content_name)) for policy_name in invalid_values_list(interface='ui'): with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['rhccp'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNone(self.oscappolicy.search(policy_name))
def test_positive_create_with_policy_name(self): """Create OpenScap Policy. @id: cdf2bc8c-ce60-4d49-b4e9-9acbf1192bc2 @Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. @Assert: Whether creating Policy for OpenScap is successful. """ content_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) for policy_name in valid_data_list(): with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone( self.oscappolicy.search(policy_name))
def test_positive_create_with_policy_name(self): """Create OpenScap Policy. :id: cdf2bc8c-ce60-4d49-b4e9-9acbf1192bc2 :Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. :expectedresults: Whether creating Policy for OpenScap is successful. :CaseImportance: Critical """ content_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone(self.oscapcontent.search(content_name)) for policy_name in valid_data_list(): with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone(self.oscappolicy.search(policy_name))
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_positive_update(self): """Update OpenScap Policy. :id: 58392782-ab25-4c12-aebc-adf23c5d9d43 :Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. 4. Update openscap policy with valid values. :expectedresults: Updating Policy for OpenScap is successful. :CaseImportance: Critical """ content_name = gen_string('alpha') policy_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone( self.oscappolicy.search(policy_name)) for new_policy_name in valid_data_list(): with self.subTest(new_policy_name): self.oscappolicy.update( name=policy_name, new_name=new_policy_name, content=content_name, profile=OSCAP_PROFILE['esp'], period=OSCAP_PERIOD['weekly'], period_value=OSCAP_WEEKDAY['sunday'], ) self.assertIsNotNone( self.oscappolicy.search(new_policy_name)) policy_name = new_policy_name
def test_positive_update(self): """Update OpenScap Policy. :id: 58392782-ab25-4c12-aebc-adf23c5d9d43 :Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. 4. Update openscap policy with valid values. :expectedresults: Updating Policy for OpenScap is successful. :CaseImportance: Critical """ content_name = gen_string('alpha') policy_name = gen_string('alpha') with Session(self) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone( self.oscappolicy.search(policy_name)) for new_policy_name in valid_data_list(): with self.subTest(new_policy_name): self.oscappolicy.update( name=policy_name, new_name=new_policy_name, content=content_name, profile=OSCAP_PROFILE['esp'], period=OSCAP_PERIOD['weekly'], period_value=OSCAP_WEEKDAY['sunday'], ) self.assertIsNotNone( self.oscappolicy.search(new_policy_name)) policy_name = new_policy_name
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_positive_update(self): """Update OpenScap Policy. @Feature: OpenScap Policy - Positive Update. @Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. 4. Update openscap policy with valid values. @Assert: Updating Policy for OpenScap is successful. """ content_name = gen_string('alpha') policy_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['rhccp'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone( self.oscappolicy.search(policy_name)) for new_policy_name in invalid_values_list(interface='ui'): with self.subTest(new_policy_name): self.oscappolicy.update( name=policy_name, new_name=new_policy_name, content=content_name, profile=OSCAP_PROFILE['usgcb'], period=OSCAP_PERIOD['weekly'], period_value=OSCAP_WEEKDAY['sunday'], ) self.assertIsNotNone( self.oscappolicy.search(new_policy_name)) policy_name = new_policy_name
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")
def test_positive_update(self): """Update OpenScap Policy. @Feature: OpenScap Policy - Positive Update. @Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. 4. Update openscap policy with valid values. @Assert: Updating Policy for OpenScap is successful. """ content_name = gen_string('alpha') policy_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone(self.oscapcontent.search(content_name)) make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['rhccp'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone(self.oscappolicy.search(policy_name)) for new_policy_name in invalid_values_list(interface='ui'): with self.subTest(new_policy_name): self.oscappolicy.update( name=policy_name, new_name=new_policy_name, content=content_name, profile=OSCAP_PROFILE['usgcb'], period=OSCAP_PERIOD['weekly'], period_value=OSCAP_WEEKDAY['sunday'], ) self.assertIsNotNone( self.oscappolicy.search(new_policy_name)) policy_name = new_policy_name
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")
def test_positive_create_with_space_policy_name(self): """Create OpenScap Policy with a space in its name. :id: a45ec231-0ca9-4719-9239-eef0355822dc :Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide openscap policy name with space in it. 4. Provide all other the appropriate parameters. :expectedresults: Creation of Policy with a space in its name is successful. :BZ: 1292622 :CaseImportance: Critical """ content_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) policy_name = "Test policy" with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone( self.oscappolicy.search(policy_name))
def test_positive_create_with_space_policy_name(self): """Create OpenScap Policy with a space in its name. :id: a45ec231-0ca9-4719-9239-eef0355822dc :Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide openscap policy name with space in it. 4. Provide all other the appropriate parameters. :expectedresults: Creation of Policy with a space in its name is successful. :BZ: 1292622 :CaseImportance: Critical """ content_name = gen_string('alpha') with Session(self) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) policy_name = "Test policy" with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone( self.oscappolicy.search(policy_name))
def test_positive_delete_by_policy_name(self): """Create OpenScap Policy. :id: 7497aad0-1e2f-426e-928d-72e430a0e853 :Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. 4. Delete the openscap Policy. :expectedresults: Whether deleting Policy for OpenScap is successful. :CaseImportance: Critical """ content_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) for policy_name in valid_data_list(): with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone( self.oscappolicy.search(policy_name)) self.oscappolicy.delete(policy_name, dropdown_present=True)
def test_positive_delete_by_policy_name(self): """Create OpenScap Policy. :id: 7497aad0-1e2f-426e-928d-72e430a0e853 :Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. 4. Delete the openscap Policy. :expectedresults: Whether deleting Policy for OpenScap is successful. :CaseImportance: Critical """ content_name = gen_string('alpha') with Session(self) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) for policy_name in valid_data_list(): with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone( self.oscappolicy.search(policy_name)) self.oscappolicy.delete(policy_name, dropdown_present=True)
def test_negative_create_with_invalid_name(self): """Create OpenScap Policy with negative values. :id: dfebf26b-194f-473d-b5a6-9061c520f57e :Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. :expectedresults: Creating Policy for OpenScap is not successful. :BZ: 1293296 :CaseImportance: Critical """ content_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) for policy_name in invalid_values_list(interface='ui'): with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNone(self.oscappolicy.search(policy_name))
def test_positive_delete_by_policy_name(self): """Create OpenScap Policy. @Feature: OpenScap Policy - Positive Create. @Steps: 1. Create an openscap content. 2. Create an openscap Policy. 3. Provide all the appropriate parameters. 4. Delete the openscap Policy. @Assert: Whether deleting Policy for OpenScap is successful. """ content_name = gen_string('alpha') with Session(self.browser) as session: make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) for policy_name in valid_data_list(): with self.subTest(policy_name): make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['rhccp'], period_value=OSCAP_WEEKDAY['friday'], ) self.assertIsNotNone( self.oscappolicy.search(policy_name)) self.oscappolicy.delete(policy_name)
def test_positive_check_dashboard(self): """Create OpenScap Policy which is connected to the host. That policy dashboard should be rendered and correctly display information about the host :id: 3c1575cb-f290-4d99-bb86-61b9ca6a62eb :customerscenario: true :Steps: 1. Create new host group 2. Create new host using host group from step 1 3. Create an openscap content. 4. Create an openscap Policy using host group from step 1 :expectedresults: Policy dashboard rendered properly and has necessary data :BZ: 1424936 :CaseLevel: Integration :CaseImportance: Critical """ content_name = gen_string('alpha') policy_name = gen_string('alpha') org = entities.Organization().create() lce = entities.LifecycleEnvironment(organization=org).create() content_view = entities.ContentView(organization=org).create() content_view.publish() content_view = content_view.read() promote(content_view.version[0], environment_id=lce.id) loc = entities.Location(organization=[org]).create() hostgroup = entities.HostGroup( location=[loc], organization=[org], ).create() entities.Host( hostgroup=hostgroup, location=loc, organization=org, content_facet_attributes={ 'content_view_id': content_view.id, 'lifecycle_environment_id': lce.id, }, ).create() with Session(self) as session: set_context(session, org=ANY_CONTEXT['org']) make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone(self.oscapcontent.search(content_name)) make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], org=org.name, loc=loc.name, host_group=hostgroup.name, ) self.oscappolicy.search_and_click(policy_name) self.assertEqual(self.dashboard.get_total_hosts_count(), 1) self.assertEqual( self.oscappolicy.wait_until_element( locators['dashboard.hcc.hosts_percentage'] % 'Not audited').text, '100%')
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)))
def test_positive_upload_to_satellite(self): """Perform end to end oscap test and upload reports. @Feature: Oscap End to End. @Assert: Oscap reports from rhel6 and rhel7 clients should be uploaded to satellite6 and be searchable. """ rhel6_repo = settings.rhel6_repo rhel7_repo = settings.rhel7_repo rhel6_content = OSCAP_DEFAULT_CONTENT["rhel6_content"] rhel7_content = OSCAP_DEFAULT_CONTENT["rhel7_content"] sat6_hostname = settings.server.hostname hgrp6_name = gen_string("alpha") hgrp7_name = gen_string("alpha") policy_values = [ {"content": rhel6_content, "hgrp": hgrp6_name, "policy": gen_string("alpha")}, {"content": rhel7_content, "hgrp": hgrp7_name, "policy": gen_string("alpha")}, ] vm_values = [ {"distro": "rhel67", "hgrp": hgrp6_name, "rhel_repo": rhel6_repo}, {"distro": "rhel71", "hgrp": hgrp7_name, "rhel_repo": rhel7_repo}, ] with Session(self.browser) as session: set_context(session, org=ANY_CONTEXT["org"]) # Creates oscap content for both rhel6 and rhel7 for content in [rhel6_content, rhel7_content]: session.nav.go_to_oscap_content() self.oscapcontent.update(content, content_org=self.org_name) set_context(session, org=self.org_name) # Creates host_group for both rhel6 and rhel7 for host_group in [hgrp6_name, hgrp7_name]: make_hostgroup( session, content_source=sat6_hostname, name=host_group, puppet_ca=sat6_hostname, puppet_master=sat6_hostname, ) # Creates oscap_policy for both rhel6 and rhel7. for value in policy_values: make_oscappolicy( session, content=value["content"], host_group=value["hgrp"], name=value["policy"], period=OSCAP_PERIOD["weekly"], profile=OSCAP_PROFILE["rhccp"], period_value=OSCAP_WEEKDAY["friday"], ) # Creates two vm's each for rhel6 and rhel7, runs # openscap scan and uploads report to satellite6. for value in vm_values: with VirtualMachine(distro=value["distro"]) as vm: host = vm.hostname vm.install_katello_ca() vm.register_contenthost(self.ak_name, self.org_name) vm.configure_puppet(value["rhel_repo"]) session.nav.go_to_hosts() set_context(session, org=ANY_CONTEXT["org"]) self.hosts.update_host_bulkactions(host=host, org=self.org_name) self.hosts.update( name=host, parameters_list=[ ["Host", "Lifecycle Environment", self.env_name], ["Host", "Content View", self.cv_name], ["Host", "Host Group", value["hgrp"]], ["Host", "Reset Puppet Environment", True], ], ) session.nav.go_to_hosts() # 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) # BZ 1259188 , required till CH and Hosts unification. # We need to re-register because of above bug and FE vm.register_contenthost(self.ak_name, self.org_name) # Runs the actual oscap scan on the vm/clients and # uploads report to Internal Capsule. vm.execute_foreman_scap_client() # Runs the below command on Internal capsule to upload # content to Satellite6 and thus make reports visible # on UI. ssh.command(u"smart-proxy-openscap-send") # Assert whether oscap reports are uploaded to # Satellite6. session.nav.go_to_reports() self.assertTrue(self.oscapreports.search(host))
def test_oscap_reports(self): """@Test: Perform end to end oscap test. @Feature: Oscap End to End. @Assert: Oscap reports from rhel6 and rhel7 clients should be uploaded to satellite6 and be searchable. """ rhel6_repo = settings.rhel6_repo rhel7_repo = settings.rhel7_repo rhel6_content = OSCAP_DEFAULT_CONTENT['rhel6_content'] rhel7_content = OSCAP_DEFAULT_CONTENT['rhel7_content'] sat6_hostname = settings.server.hostname hgrp6_name = gen_string('alpha') hgrp7_name = gen_string('alpha') policy_values = [ { 'content': rhel6_content, 'hgrp': hgrp6_name, 'policy': gen_string('alpha'), }, { 'content': rhel7_content, 'hgrp': hgrp7_name, 'policy': gen_string('alpha'), }, ] vm_values = [ { 'distro': 'rhel67', 'hgrp': hgrp6_name, 'rhel_repo': rhel6_repo, }, { 'distro': 'rhel71', 'hgrp': hgrp7_name, 'rhel_repo': rhel7_repo, }, ] with Session(self.browser) as session: self.puppetclasses.import_scap_client_puppet_classes() set_context(session, org=ANY_CONTEXT['org']) # Creates oscap content for both rhel6 and rhel7 for content in [rhel6_content, rhel7_content]: session.nav.go_to_oscap_content() self.oscapcontent.update(content, content_org=self.org_name) set_context(session, org=self.org_name) # Creates host_group for both rhel6 and rhel7 for host_group in [hgrp6_name, hgrp7_name]: make_hostgroup( session, content_source=sat6_hostname, name=host_group, puppet_ca=sat6_hostname, puppet_master=sat6_hostname, ) # Creates oscap_policy for both rhel6 and rhel7. for value in policy_values: make_oscappolicy( session, content=value['content'], host_group=value['hgrp'], name=value['policy'], period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['rhccp'], period_value=OSCAP_WEEKDAY['friday'], ) # Creates two vm's each for rhel6 and rhel7, runs # openscap scan and uploads report to satellite6. for value in vm_values: with VirtualMachine(distro=value['distro']) as vm: host = vm.hostname vm.install_katello_ca() vm.register_contenthost(self.ak_name, self.org_name) vm.configure_puppet(value['rhel_repo']) session.nav.go_to_hosts() set_context(session, org=ANY_CONTEXT['org']) self.hosts.update_host_bulkactions( host=host, org=self.org_name ) self.hosts.update( cv=self.cv_name, host_group=value['hgrp'], lifecycle_env=self.env_name, name=host, reset_puppetenv=True, ) session.nav.go_to_hosts() # 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) # BZ 1259188 , required till CH and Hosts unification. # We need to re-register because of above bug and FE vm.register_contenthost(self.ak_name, self.org_name) # Runs the actual oscap scan on the vm/clients and # uploads report to Internal Capsule. vm.execute_foreman_scap_client() # Runs the below command on Internal capsule to upload # content to Satellite6 and thus make reports visible # on UI. ssh.command(u'smart-proxy-openscap-send') # Assert whether oscap reports are uploaded to # Satellite6. session.nav.go_to_reports() self.assertTrue(self.oscapreports.search(host))
def test_positive_push_updated_content(self): """Perform end to end oscap test, and push the updated scap content after first run. :id: 7eb75ca5-2ea1-434e-bb43-1223fa4d8e9f :expectedresults: Satellite should push updated content to Clients and satellite should get updated reports :CaseLevel: System """ if settings.rhel7_repo is None: self.skipTest('Missing configuration for rhel7_repo') rhel7_repo = settings.rhel7_repo rhel7_content = OSCAP_DEFAULT_CONTENT['rhel7_content'] content_update = OSCAP_DEFAULT_CONTENT['rhel_firefox'] hgrp7_name = gen_string('alpha') policy_values = { 'content': rhel7_content, 'hgrp': hgrp7_name, 'policy': gen_string('alpha'), } vm_values = { 'distro': DISTRO_RHEL7, 'hgrp': hgrp7_name, 'rhel_repo': rhel7_repo, } with Session(self) as session: set_context(session, org=ANY_CONTEXT['org']) # Creates oscap content for rhel7 session.nav.go_to_oscap_content() self.oscapcontent.update(rhel7_content, content_org=self.config_env['org_name']) self.oscapcontent.update(content_update, content_org=self.config_env['org_name']) set_context(session, 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'], ) # Creates oscap_policy for both rhel6 and 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'], ) # Creates two vm's each for rhel6 and rhel7, runs # openscap scan and uploads report to satellite6. with VirtualMachine(distro=vm_values.get('distro')) as vm: host = vm.hostname vm.install_katello_ca() vm.register_contenthost(self.config_env['org_name'], self.config_env['ak_name']) self.assertTrue(vm.subscribed) vm.configure_puppet(vm_values.get('rhel_repo')) self.hosts.update( name=vm._target_image, domain_name=vm._domain, parameters_list=[ [ 'Host', 'Lifecycle Environment', self.config_env['env_name'] ], ['Host', 'Content View', self.config_env['cv_name']], ['Host', 'Host Group', vm_values.get('hgrp')], ['Host', 'Reset Puppet Environment', True], ], ) # 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 content_path') 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(host)) self.oscappolicy.update( name=policy_values.get('policy'), new_name=gen_string('alpha'), content=OSCAP_DEFAULT_CONTENT['rhel_firefox'], profile=OSCAP_PROFILE['firefox'], period=OSCAP_PERIOD['weekly'], period_value=OSCAP_WEEKDAY['friday'], ) self.oscapreports.delete(host, really=True) for _ in range(2): vm.run(u'puppet agent -t 2> /dev/null') updated_result = vm.run( u'cat /etc/foreman_scap_client/config.yaml' '| grep content_path') self.assertIsNot(result, updated_result) self.assertEqual(updated_result.return_code, 0) # Runs the actual oscap scan on the vm/clients and # uploads report to Internal Capsule. vm.execute_foreman_scap_client() self.assertTrue(self.oscapreports.search(host))
def test_positive_upload_to_satellite(self): """Perform end to end oscap test and upload reports. @Feature: Oscap End to End. @Assert: Oscap reports from rhel6 and rhel7 clients should be uploaded to satellite6 and be searchable. """ rhel6_repo = settings.rhel6_repo rhel7_repo = settings.rhel7_repo rhel6_content = OSCAP_DEFAULT_CONTENT['rhel6_content'] rhel7_content = OSCAP_DEFAULT_CONTENT['rhel7_content'] sat6_hostname = settings.server.hostname hgrp6_name = gen_string('alpha') hgrp7_name = gen_string('alpha') policy_values = [ { 'content': rhel6_content, 'hgrp': hgrp6_name, 'policy': gen_string('alpha'), }, { 'content': rhel7_content, 'hgrp': hgrp7_name, 'policy': gen_string('alpha'), }, ] vm_values = [ { 'distro': 'rhel67', 'hgrp': hgrp6_name, 'rhel_repo': rhel6_repo, }, { 'distro': 'rhel71', 'hgrp': hgrp7_name, 'rhel_repo': rhel7_repo, }, ] with Session(self.browser) as session: set_context(session, org=ANY_CONTEXT['org']) # Creates oscap content for both rhel6 and rhel7 for content in [rhel6_content, rhel7_content]: session.nav.go_to_oscap_content() self.oscapcontent.update(content, content_org=self.org_name) set_context(session, org=self.org_name) # Creates host_group for both rhel6 and rhel7 for host_group in [hgrp6_name, hgrp7_name]: make_hostgroup( session, content_source=sat6_hostname, name=host_group, puppet_ca=sat6_hostname, puppet_master=sat6_hostname, ) # Creates oscap_policy for both rhel6 and rhel7. for value in policy_values: make_oscappolicy( session, content=value['content'], host_group=value['hgrp'], name=value['policy'], period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['rhccp'], period_value=OSCAP_WEEKDAY['friday'], ) # Creates two vm's each for rhel6 and rhel7, runs # openscap scan and uploads report to satellite6. for value in vm_values: with VirtualMachine(distro=value['distro']) as vm: host = vm.hostname vm.install_katello_ca() vm.register_contenthost(self.ak_name, self.org_name) vm.configure_puppet(value['rhel_repo']) session.nav.go_to_hosts() set_context(session, org=ANY_CONTEXT['org']) self.hosts.update_host_bulkactions(host=host, org=self.org_name) self.hosts.update( name=host, parameters_list=[ ['Host', 'Lifecycle Environment', self.env_name], ['Host', 'Content View', self.cv_name], ['Host', 'Host Group', value['hgrp']], ['Host', 'Reset Puppet Environment', True], ], ) session.nav.go_to_hosts() # 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) # BZ 1259188 , required till CH and Hosts unification. # We need to re-register because of above bug and FE vm.register_contenthost(self.ak_name, self.org_name) # Runs the actual oscap scan on the vm/clients and # uploads report to Internal Capsule. vm.execute_foreman_scap_client() # Runs the below command on Internal capsule to upload # content to Satellite6 and thus make reports visible # on UI. ssh.command(u'smart-proxy-openscap-send') # Assert whether oscap reports are uploaded to # Satellite6. session.nav.go_to_reports() self.assertTrue(self.oscapreports.search(host))
def test_positive_upload_to_satellite(self): """Perform end to end oscap test and upload reports. :id: 17a0978d-64f9-44ad-8303-1f54ada08602 :expectedresults: Oscap reports from rhel6 and rhel7 clients should be uploaded to satellite6 and be searchable. :CaseLevel: System """ if settings.rhel6_repo is None: self.skipTest('Missing configuration for rhel6_repo') rhel6_repo = settings.rhel6_repo if settings.rhel7_repo is None: self.skipTest('Missing configuration for rhel7_repo') rhel7_repo = settings.rhel7_repo rhel6_content = OSCAP_DEFAULT_CONTENT['rhel6_content'] rhel7_content = OSCAP_DEFAULT_CONTENT['rhel7_content'] hgrp6_name = gen_string('alpha') hgrp7_name = gen_string('alpha') policy_values = [ { 'content': rhel6_content, 'hgrp': hgrp6_name, 'policy': gen_string('alpha'), }, { 'content': rhel7_content, 'hgrp': hgrp7_name, 'policy': gen_string('alpha'), }, ] vm_values = [ { 'distro': DISTRO_RHEL6, 'hgrp': hgrp6_name, 'rhel_repo': rhel6_repo, }, { 'distro': DISTRO_RHEL7, 'hgrp': hgrp7_name, 'rhel_repo': rhel7_repo, }, ] with Session(self) as session: set_context(session, org=ANY_CONTEXT['org']) # Creates oscap content for both rhel6 and rhel7 for content in [rhel6_content, rhel7_content]: session.nav.go_to_oscap_content() self.oscapcontent.update( content, content_org=self.config_env['org_name']) set_context(session, org=self.config_env['org_name']) # Creates host_group for both rhel6 and rhel7 for host_group in [hgrp6_name, hgrp7_name]: make_hostgroup( session, content_source=self.config_env['sat6_hostname'], name=host_group, puppet_ca=self.config_env['sat6_hostname'], puppet_master=self.config_env['sat6_hostname'], ) # Creates oscap_policy for both rhel6 and rhel7. for value in policy_values: make_oscappolicy( session, content=value['content'], host_group=value['hgrp'], name=value['policy'], period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['common'], period_value=OSCAP_WEEKDAY['friday'], ) # Creates two vm's each for rhel6 and rhel7, runs # openscap scan and uploads report to satellite6. for value in vm_values: with VirtualMachine(distro=value['distro']) as vm: host = vm.hostname vm.install_katello_ca() vm.register_contenthost(self.config_env['org_name'], self.config_env['ak_name']) self.assertTrue(vm.subscribed) vm.configure_puppet(value['rhel_repo']) self.hosts.update( name=vm._target_image, domain_name=vm._domain, parameters_list=[ [ 'Host', 'Lifecycle Environment', self.config_env['env_name'] ], [ 'Host', 'Content View', self.config_env['cv_name'] ], ['Host', 'Host Group', value['hgrp']], ['Host', 'Reset Puppet Environment', True], ], ) session.nav.go_to_hosts() # 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(host))
def test_positive_push_updated_content(self): """Perform end to end oscap test, and push the updated scap content after first run. :id: 7eb75ca5-2ea1-434e-bb43-1223fa4d8e9f :expectedresults: Satellite should push updated content to Clients and satellite should get updated reports :CaseLevel: System """ if settings.rhel7_repo is None: self.skipTest('Missing configuration for rhel7_repo') rhel7_repo = settings.rhel7_repo rhel7_content = OSCAP_DEFAULT_CONTENT['rhel7_content'] content_update = OSCAP_DEFAULT_CONTENT['rhel_firefox'] hgrp7_name = gen_string('alpha') policy_values = { 'content': rhel7_content, 'hgrp': hgrp7_name, 'policy': gen_string('alpha'), } vm_values = { 'distro': DISTRO_RHEL7, 'hgrp': hgrp7_name, 'rhel_repo': rhel7_repo, } with Session(self) as session: set_context(session, org=ANY_CONTEXT['org']) # Creates oscap content for rhel7 session.nav.go_to_oscap_content() self.oscapcontent.update( rhel7_content, content_org=self.config_env['org_name'] ) self.oscapcontent.update( content_update, content_org=self.config_env['org_name'] ) set_context(session, 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'], ) # Creates oscap_policy for both rhel6 and 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'], ) # Creates two vm's each for rhel6 and rhel7, runs # openscap scan and uploads report to satellite6. with VirtualMachine(distro=vm_values.get('distro')) as vm: host = vm.hostname vm.install_katello_ca() vm.register_contenthost( self.config_env['org_name'], self.config_env['ak_name'] ) self.assertTrue(vm.subscribed) vm.configure_puppet(vm_values.get('rhel_repo')) self.hosts.update( name=vm._target_image, domain_name=vm._domain, parameters_list=[ ['Host', 'Lifecycle Environment', self.config_env['env_name']], ['Host', 'Content View', self.config_env['cv_name']], ['Host', 'Host Group', vm_values.get('hgrp')], ['Host', 'Reset Puppet Environment', True], ], ) # 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 content_path' ) 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(host)) self.oscappolicy.update( name=policy_values.get('policy'), new_name=gen_string('alpha'), content=OSCAP_DEFAULT_CONTENT['rhel_firefox'], profile=OSCAP_PROFILE['firefox'], period=OSCAP_PERIOD['weekly'], period_value=OSCAP_WEEKDAY['friday'], ) self.oscapreports.delete(host, really=True) for _ in range(2): vm.run(u'puppet agent -t 2> /dev/null') updated_result = vm.run( u'cat /etc/foreman_scap_client/config.yaml' '| grep content_path' ) self.assertIsNot(result, updated_result) self.assertEqual(updated_result.return_code, 0) # Runs the actual oscap scan on the vm/clients and # uploads report to Internal Capsule. vm.execute_foreman_scap_client() self.assertTrue(self.oscapreports.search(host))
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)))
def test_positive_check_dashboard(self): """Create OpenScap Policy which is connected to the host. That policy dashboard should be rendered and correctly display information about the host :id: 3c1575cb-f290-4d99-bb86-61b9ca6a62eb :Steps: 1. Create new host group 2. Create new host using host group from step 1 3. Create an openscap content. 4. Create an openscap Policy using host group from step 1 :expectedresults: Policy dashboard rendered properly and has necessary data :BZ: 1424936 :CaseLevel: Integration :CaseImportance: Critical """ content_name = gen_string('alpha') policy_name = gen_string('alpha') org = entities.Organization().create() lce = entities.LifecycleEnvironment(organization=org).create() content_view = entities.ContentView(organization=org).create() content_view.publish() content_view = content_view.read() promote(content_view.version[0], environment_id=lce.id) loc = entities.Location(organization=[org]).create() hostgroup = entities.HostGroup( location=[loc], organization=[org], ).create() entities.Host( hostgroup=hostgroup, location=loc, organization=org, content_facet_attributes={ 'content_view_id': content_view.id, 'lifecycle_environment_id': lce.id, }, ).create() with Session(self) as session: set_context(session, org=ANY_CONTEXT['org']) make_oscapcontent( session, name=content_name, content_path=self.content_path, ) self.assertIsNotNone( self.oscapcontent.search(content_name)) make_oscappolicy( session, content=content_name, name=policy_name, period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['c2s_rhel6'], period_value=OSCAP_WEEKDAY['friday'], org=org.name, loc=loc.name, host_group=hostgroup.name, ) self.oscappolicy.search_and_click(policy_name) self.assertEqual(self.dashboard.get_total_hosts_count(), 1) self.assertEqual( self.oscappolicy.wait_until_element( locators[ 'dashboard.hcc.hosts_percentage' ] % 'Not audited').text, '100%' )
def test_positive_upload_to_satellite(self): """Perform end to end oscap test and upload reports. :id: 17a0978d-64f9-44ad-8303-1f54ada08602 :expectedresults: Oscap reports from rhel6 and rhel7 clients should be uploaded to satellite6 and be searchable. :CaseLevel: System """ if settings.rhel6_repo is None: self.skipTest('Missing configuration for rhel6_repo') rhel6_repo = settings.rhel6_repo if settings.rhel7_repo is None: self.skipTest('Missing configuration for rhel7_repo') rhel7_repo = settings.rhel7_repo rhel6_content = OSCAP_DEFAULT_CONTENT['rhel6_content'] rhel7_content = OSCAP_DEFAULT_CONTENT['rhel7_content'] hgrp6_name = gen_string('alpha') hgrp7_name = gen_string('alpha') policy_values = [ { 'content': rhel6_content, 'hgrp': hgrp6_name, 'policy': gen_string('alpha'), }, { 'content': rhel7_content, 'hgrp': hgrp7_name, 'policy': gen_string('alpha'), }, ] vm_values = [ { 'distro': DISTRO_RHEL6, 'hgrp': hgrp6_name, 'rhel_repo': rhel6_repo, }, { 'distro': DISTRO_RHEL7, 'hgrp': hgrp7_name, 'rhel_repo': rhel7_repo, }, ] with Session(self) as session: set_context(session, org=ANY_CONTEXT['org']) # Creates oscap content for both rhel6 and rhel7 for content in [rhel6_content, rhel7_content]: session.nav.go_to_oscap_content() self.oscapcontent.update( content, content_org=self.config_env['org_name'] ) set_context(session, org=self.config_env['org_name']) # Creates host_group for both rhel6 and rhel7 for host_group in [hgrp6_name, hgrp7_name]: make_hostgroup( session, content_source=self.config_env['sat6_hostname'], name=host_group, puppet_ca=self.config_env['sat6_hostname'], puppet_master=self.config_env['sat6_hostname'], ) # Creates oscap_policy for both rhel6 and rhel7. for value in policy_values: make_oscappolicy( session, content=value['content'], host_group=value['hgrp'], name=value['policy'], period=OSCAP_PERIOD['weekly'], profile=OSCAP_PROFILE['common'], period_value=OSCAP_WEEKDAY['friday'], ) # Creates two vm's each for rhel6 and rhel7, runs # openscap scan and uploads report to satellite6. for value in vm_values: with VirtualMachine(distro=value['distro']) as vm: host = vm.hostname vm.install_katello_ca() vm.register_contenthost( self.config_env['org_name'], self.config_env['ak_name'] ) self.assertTrue(vm.subscribed) vm.configure_puppet(value['rhel_repo']) self.hosts.update( name=vm._target_image, domain_name=vm._domain, parameters_list=[ ['Host', 'Lifecycle Environment', self.config_env['env_name']], ['Host', 'Content View', self.config_env['cv_name']], ['Host', 'Host Group', value['hgrp']], ['Host', 'Reset Puppet Environment', True], ], ) session.nav.go_to_hosts() # 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(host))