def test_positive_update_name(self): """Create new content view filter and assign it to existing content view by id. Try to update that filter using different value types as a name :id: 70ba8916-5898-4911-9de8-21d2e0fb3df9 :expectedresults: Content view filter updated successfully and has proper and expected name :CaseLevel: Integration :CaseImportance: Critical """ cvf_name = gen_string('utf8') cvf = make_content_view_filter({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'organization-id': self.org['id'], 'type': 'rpm', }) for new_name in valid_data_list(): with self.subTest(new_name): ContentView.filter.update({ 'content-view-id': self.content_view['id'], 'id': cvf['filter-id'], 'new-name': new_name, }) cvf = ContentView.filter.info({ 'content-view-id': self.content_view['id'], 'name': new_name, }) self.assertEqual(cvf['name'], new_name) cvf_name = new_name # updating cvf name for next iteration
def test_positive_update_name(self): """Create new content view filter and assign it to existing content view by id. Try to update that filter using different value types as a name @id: 70ba8916-5898-4911-9de8-21d2e0fb3df9 @Assert: Content view filter updated successfully and has proper and expected name @CaseLevel: Integration """ cvf_name = gen_string('utf8') cvf = make_content_view_filter({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'organization-id': self.org['id'], 'type': 'rpm', }) for new_name in valid_data_list(): with self.subTest(new_name): ContentView.filter.update({ 'content-view-id': self.content_view['id'], 'id': cvf['filter-id'], 'new-name': new_name, }) cvf = ContentView.filter.info({ 'content-view-id': self.content_view['id'], 'name': new_name, }) self.assertEqual(cvf['name'], new_name) cvf_name = new_name # updating cvf name for next iteration
def test_positive_errata_status_installable_param(self): """Filter errata for specific content view and verify that host that was registered using that content view has different states in correspondence to filtered errata and `errata status installable` settings flag value :id: ed94cf34-b8b9-4411-8edc-5e210ea6af4f :Steps: 1. Prepare setup: Create Lifecycle Environment, Content View, Activation Key and all necessary repos 2. Register Content Host using created data 3. Create necessary Content View Filter and Rule for repository errata 4. Publish and Promote Content View to a new version and remove old ones. 5. Go to created Host page and check its properties 6. Change 'errata status installable' flag in the settings and check host properties once more :expectedresults: Check that 'errata status installable' flag works as intended :BZ: 1368254 :CaseLevel: System """ env = entities.LifecycleEnvironment( organization=self.session_org).create() content_view = entities.ContentView( organization=self.session_org).create() activation_key = entities.ActivationKey( environment=env, organization=self.session_org, ).create() setup_org_for_a_rh_repo({ 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], 'repository': REPOS['rhst7']['name'], 'organization-id': self.session_org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }, force_manifest_upload=True) custom_entitites = setup_org_for_a_custom_repo({ 'url': CUSTOM_REPO_URL, 'organization-id': self.session_org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }) with VirtualMachine(distro=DISTRO_RHEL7) as client: client.install_katello_ca() client.register_contenthost( self.session_org.label, activation_key.name, ) self.assertTrue(client.subscribed) client.enable_repo(REPOS['rhst7']['id']) client.install_katello_agent() client.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE)) # Adding content view filter and content view filter rule to # exclude errata that we are going to track cvf = make_content_view_filter({ u'content-view-id': content_view.id, u'inclusion': 'false', u'organization-id': self.session_org.id, u'repository-ids': custom_entitites['repository-id'], u'type': 'erratum', }) make_content_view_filter_rule({ u'content-view-id': content_view.id, u'content-view-filter-id': cvf['filter-id'], u'errata-id': CUSTOM_REPO_ERRATA_ID, }) ContentView.publish({u'id': content_view.id}) cvv = ContentView.info({u'id': content_view.id})['versions'][-1] ContentView.version_promote({ u'id': cvv['id'], u'organization-id': self.session_org.id, u'to-lifecycle-environment-id': env.id, }) # Remove old cv versions to have unambiguous one for testing cvvs = ContentView.info({u'id': content_view.id})['versions'] self.assertGreater(len(cvvs), 1) for i in range(len(cvvs)-1): ContentView.version_delete({u'id': cvvs[i]['id']}) with Session(self) as session: edit_param( session, tab_locator=tab_locators['settings.tab_content'], param_name='errata_status_installable', param_value='Yes', ) expected_dict = { 'Status': 'OK', 'Errata': 'All errata applied', 'Subscription': 'Fully entitled', } actual_dict = self.hosts.get_host_properties( client.hostname, expected_dict.keys()) self.assertEqual(expected_dict, actual_dict) edit_param( session, tab_locator=tab_locators['settings.tab_content'], param_name='errata_status_installable', param_value='No', ) expected_dict = { 'Status': 'Error', 'Errata': 'Security errata applicable', 'Subscription': 'Fully entitled', } actual_dict = self.hosts.get_host_properties( client.hostname, expected_dict.keys()) self.assertEqual(expected_dict, actual_dict)
def test_positive_errata_status_installable_param(self): """Filter errata for specific content view and verify that host that was registered using that content view has different states in correspondence to filtered errata and `errata status installable` settings flag value :id: ed94cf34-b8b9-4411-8edc-5e210ea6af4f :Steps: 1. Prepare setup: Create Lifecycle Environment, Content View, Activation Key and all necessary repos 2. Register Content Host using created data 3. Create necessary Content View Filter and Rule for repository errata 4. Publish and Promote Content View to a new version and remove old ones. 5. Go to created Host page and check its properties 6. Change 'errata status installable' flag in the settings and check host properties once more :expectedresults: Check that 'errata status installable' flag works as intended :BZ: 1368254 :CaseLevel: System """ env = entities.LifecycleEnvironment( organization=self.session_org).create() content_view = entities.ContentView( organization=self.session_org).create() activation_key = entities.ActivationKey( environment=env, organization=self.session_org, ).create() setup_org_for_a_rh_repo({ 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], 'repository': REPOS['rhst7']['name'], 'organization-id': self.session_org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }) custom_entitites = setup_org_for_a_custom_repo({ 'url': CUSTOM_REPO_URL, 'organization-id': self.session_org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }) with VirtualMachine(distro=DISTRO_RHEL7) as client: client.install_katello_ca() result = client.register_contenthost( self.session_org.label, activation_key.name, ) self.assertEqual(result.return_code, 0) client.enable_repo(REPOS['rhst7']['id']) client.install_katello_agent() client.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE)) # Adding content view filter and content view filter rule to # exclude errata that we are going to track cvf = make_content_view_filter({ u'content-view-id': content_view.id, u'inclusion': 'false', u'organization-id': self.session_org.id, u'repository-ids': custom_entitites['repository-id'], u'type': 'erratum', }) make_content_view_filter_rule({ u'content-view-id': content_view.id, u'content-view-filter-id': cvf['filter-id'], u'errata-id': CUSTOM_REPO_ERRATA_ID, }) ContentView.publish({u'id': content_view.id}) cvv = ContentView.info({u'id': content_view.id})['versions'][-1] ContentView.version_promote({ u'id': cvv['id'], u'organization-id': self.session_org.id, u'to-lifecycle-environment-id': env.id, }) # Remove old cv versions to have unambiguous one for testing cvvs = ContentView.info({u'id': content_view.id})['versions'] self.assertGreater(len(cvvs), 1) for i in range(len(cvvs) - 1): ContentView.version_delete({u'id': cvvs[i]['id']}) with Session(self.browser) as session: edit_param( session, tab_locator=tab_locators['settings.tab_katello'], param_name='errata_status_installable', param_value='true', ) expected_dict = { 'Status': 'OK', 'Errata': 'All errata applied', 'Subscription': 'Fully entitled', } actual_dict = self.hosts.get_host_properties( client.hostname, expected_dict.keys()) self.assertEqual(expected_dict, actual_dict) edit_param( session, tab_locator=tab_locators['settings.tab_katello'], param_name='errata_status_installable', param_value='false', ) expected_dict = { 'Status': 'Error', 'Errata': 'Security errata applicable', 'Subscription': 'Fully entitled', } actual_dict = self.hosts.get_host_properties( client.hostname, expected_dict.keys()) self.assertEqual(expected_dict, actual_dict)
def test_host_errata_search_commands(request, module_org, module_cv, module_lce, host_collection, errata_hosts): """View a list of affected hosts for security (RHSA) and bugfix (RHBA) errata, filtered with errata status and applicable flags. Applicability is calculated using the Library, but Installability is calculated using the attached CV, and is subject to the CV's own filtering. :id: 07757a77-7ab4-4020-99af-2beceb023266 :Setup: Errata synced on satellite server, custom package installed on errata hosts. :Steps: 1. host list --search 'errata_status = errata_needed' 2. host list --search 'errata_status = security_needed' 3. host list --search 'applicable_errata = <bugfix_advisory>' 4. host list --search 'applicable_errata = <security_advisory>' 5. host list --search 'applicable_rpms = <bugfix_package>' 6. host list --search 'applicable_rpms = <security_package>' 7. Create filter & rule to hide RPM (applicable vs. installable test) 8. Repeat steps 3 and 5, but 5 expects host name not found. :expectedresults: The hosts are correctly listed for security and bugfix advisories. """ # note time for later wait_for_tasks include 2 mins margin of safety. timestamp = (datetime.utcnow() - timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M') errata = REPO_WITH_ERRATA['errata'] # Update package on first host so that the security advisory doesn't apply. result = errata_hosts[0].execute( f'yum update -y {errata[0]["new_package"]}') assert result.status == 0, 'Failed to install rpm' # Update package on second host so that the bugfix advisory doesn't apply. result = errata_hosts[1].execute( f'yum update -y {errata[1]["new_package"]}') assert result.status == 0, 'Failed to install rpm' # Wait for upload profile event (in case Satellite system slow) host = entities.Host().search( query={'search': f'name={errata_hosts[0].hostname}'}) wait_for_tasks( search_query=('label = Actions::Katello::Host::UploadProfiles' f' and resource_id = {host[0].id}' f' and started_at >= "{timestamp}"'), search_rate=15, max_tries=10, ) # Step 1: Search for hosts that require bugfix advisories result = Host.list({ 'search': 'errata_status = errata_needed', 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, }) result = [item['name'] for item in result] assert errata_hosts[0].hostname in result assert errata_hosts[1].hostname not in result # Step 2: Search for hosts that require security advisories result = Host.list({ 'search': 'errata_status = security_needed', 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, }) result = [item['name'] for item in result] assert errata_hosts[0].hostname not in result assert errata_hosts[1].hostname in result # Step 3: Search for hosts that require the specified bugfix advisory result = Host.list({ 'search': f'applicable_errata = {errata[1]["id"]}', 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, }) result = [item['name'] for item in result] assert errata_hosts[0].hostname in result assert errata_hosts[1].hostname not in result # Step 4: Search for hosts that require the specified security advisory result = Host.list({ 'search': f'applicable_errata = {errata[0]["id"]}', 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, }) result = [item['name'] for item in result] assert errata_hosts[0].hostname not in result assert errata_hosts[1].hostname in result # Step 5: Search for hosts that require the specified bugfix package result = Host.list({ 'search': f'applicable_rpms = {errata[1]["new_package"]}', 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, }) result = [item['name'] for item in result] assert errata_hosts[0].hostname in result assert errata_hosts[1].hostname not in result # Step 6: Search for hosts that require the specified security package result = Host.list({ 'search': f'applicable_rpms = {errata[0]["new_package"]}', 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, }) result = [item['name'] for item in result] assert errata_hosts[0].hostname not in result assert errata_hosts[1].hostname in result # Step 7: Apply filter and rule to CV to hide RPM, thus making erratum not installable # Make RPM exclude filter cv_filter = make_content_view_filter({ 'content-view-id': module_cv.id, 'name': 'erratum_search_test', 'description': 'Hide the installable errata', 'organization-id': module_org.id, 'type': 'rpm', 'inclusion': 'false', }) @request.addfinalizer def cleanup(): cv_filter_cleanup(cv_filter['filter-id'], module_cv, module_org, module_lce) # Make rule to exclude the specified bugfix package make_content_view_filter_rule({ 'content-view-id': module_cv.id, 'content-view-filter-id': cv_filter['filter-id'], 'name': errata[1]['package_name'], }) # Publish and promote a new version with the filter cv_publish_promote(module_cv, module_org, module_lce) # Step 8: Run tests again. Applicable should still be true, installable should now be false. # Search for hosts that require the bugfix package. result = Host.list({ 'search': f'applicable_rpms = {errata[1]["new_package"]}', 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, }) result = [item['name'] for item in result] assert errata_hosts[0].hostname in result assert errata_hosts[1].hostname not in result # Search for hosts that require the specified bugfix advisory. result = Host.list({ 'search': f'installable_errata = {errata[1]["id"]}', 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, }) result = [item['name'] for item in result] assert errata_hosts[0].hostname not in result assert errata_hosts[1].hostname not in result
def test_positive_list_affected_chosts_by_erratum_restrict_flag( request, module_org, module_cv, module_lce, errata_hosts): """View a list of affected content hosts for an erratum filtered with restrict flags. Applicability is calculated using the Library, so that search must not limit to CV or LCE. Installability is calculated using the attached CV, subject to the CV's own filtering, so that search must limit to CV and LCE. :id: 594acd48-892c-499e-b0cb-6506cea7cd64 :Setup: Errata synced on satellite server, custom package installed on errata hosts. :Steps: 1. erratum list --erratum-id=<erratum_id> --organization-id=<org_id> --errata-restrict-installable=1 2. erratum list --erratum-id=<erratum_id> --organization-id=<org_id> --errata-restrict-installable=0 3. erratum list --erratum-id=<erratum_id> --organization-id=<org_id> --errata-restrict-applicable=1 4. erratum list --erratum-id=<erratum_id> --organization-id=<org_id> --errata-restrict-applicable=0 :expectedresults: List of affected content hosts for an erratum is displayed filtered with corresponding restrict flags. :CaseAutomation: Automated """ # Uninstall package so that only the first errata applies. for host in errata_hosts: host.execute( f'yum erase -y {REPO_WITH_ERRATA["errata"][1]["package_name"]}') # Create list of uninstallable errata. errata = REPO_WITH_ERRATA['errata'][0] uninstallable = REPO_WITH_ERRATA['errata_ids'].copy() uninstallable.remove(errata['id']) # Check search for only installable errata param = { 'errata-restrict-installable': 1, 'content-view-id': module_cv.id, 'lifecycle-environment-id': module_lce.id, 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, } errata_ids = get_errata_ids(param) assert errata[ 'id'] in errata_ids, 'Errata not found in list of installable errata' assert not set(uninstallable) & set(errata_ids), 'Unexpected errata found' # Check search of errata is not affected by installable=0 restrict flag param = { 'errata-restrict-installable': 0, 'content-view-id': module_cv.id, 'lifecycle-environment-id': module_lce.id, 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, } errata_ids = get_errata_ids(param) assert set(REPO_WITH_ERRATA['errata_ids']).issubset( errata_ids), 'Errata not found in list of installable errata' # Check list of applicable errata param = { 'errata-restrict-applicable': 1, 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, } errata_ids = get_errata_ids(param) assert errata[ 'id'] in errata_ids, 'Errata not found in list of applicable errata' # Check search of errata is not affected by applicable=0 restrict flag param = { 'errata-restrict-applicable': 0, 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, } errata_ids = get_errata_ids(param) assert set(REPO_WITH_ERRATA['errata_ids']).issubset( errata_ids), 'Errata not found in list of applicable errata' # Apply a filter and rule to the CV to hide the RPM, thus making erratum not installable # Make RPM exclude filter cv_filter = make_content_view_filter({ 'content-view-id': module_cv.id, 'name': 'erratum_restrict_test', 'description': 'Hide the installable errata', 'organization-id': module_org.id, 'type': 'rpm', 'inclusion': 'false', }) @request.addfinalizer def cleanup(): cv_filter_cleanup(cv_filter['filter-id'], module_cv, module_org, module_lce) # Make rule to hide the RPM that creates the need for the installable erratum make_content_view_filter_rule({ 'content-view-id': module_cv.id, 'content-view-filter-id': cv_filter['filter-id'], 'name': errata['package_name'], }) # Publish and promote a new version with the filter cv_publish_promote(module_cv, module_org, module_lce) # Check that the installable erratum is no longer present in the list param = { 'errata-restrict-installable': 0, 'content-view-id': module_cv.id, 'lifecycle-environment-id': module_lce.id, 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, } errata_ids = get_errata_ids(param) assert errata[ 'id'] not in errata_ids, 'Errata not found in list of installable errata' # Check errata still applicable param = { 'errata-restrict-applicable': 1, 'organization-id': module_org.id, 'per-page': PER_PAGE_LARGE, } errata_ids = get_errata_ids(param) assert errata[ 'id'] in errata_ids, 'Errata not found in list of applicable errata'