def test_positive_create_after_refresh(function_org): """Upload a manifest,refresh it and upload a new manifest to an other organization. :id: 1869bbb6-c31b-49a9-bc92-402a90071a11 :customerscenario: true :expectedresults: the manifest is uploaded successfully to other org :BZ: 1393442 :CaseImportance: Critical """ org_sub = entities.Subscription(organization=function_org) new_org = entities.Organization().create() new_org_sub = entities.Subscription(organization=new_org) upload_manifest(function_org.id, manifests.original_manifest().content) try: org_sub.refresh_manifest(data={'organization_id': function_org.id}) assert org_sub.search() upload_manifest(new_org.id, manifests.clone().content) assert new_org_sub.search() finally: org_sub.delete_manifest(data={'organization_id': function_org.id})
def test_positive_promote_with_rh_content(session): """Attempt to promote a content view containing RH content :id: 82f71639-3580-49fd-bd5a-8dba568b98d1 :setup: Multiple environments for an org; RH content synced :expectedresults: Content view can be promoted :CaseLevel: System """ cv_name = gen_string('alpha') version = 'Version 1.0' rh_repo = { 'name': REPOS['rhst7']['name'], 'product': PRDS['rhel'], 'reposet': REPOSET['rhst7'], 'basearch': 'x86_64', 'releasever': None, } org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) enable_sync_redhat_repo(rh_repo, org.id) lce = entities.LifecycleEnvironment(organization=org).create() with session: session.organization.select(org.name) session.contentview.create({'name': cv_name}) assert session.contentview.search(cv_name)[0]['Name'] == cv_name session.contentview.add_yum_repo(cv_name, rh_repo['name']) result = session.contentview.publish(cv_name) assert result['Version'] == version result = session.contentview.promote(cv_name, version, lce.name) assert 'Promoted to {}'.format(lce.name) in result['Status']
def test_positive_add_rh_content(session): """Add Red Hat content to a content view :id: c370fd79-0c0d-4685-99cb-848556c786c1 :setup: Sync RH content :expectedresults: RH Content can be seen in a view :CaseLevel: Integration """ cv_name = gen_string('alpha') rh_repo = { 'name': REPOS['rhst7']['name'], 'product': PRDS['rhel'], 'reposet': REPOSET['rhst7'], 'basearch': 'x86_64', 'releasever': None } # Create new org to import manifest org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) enable_sync_redhat_repo(rh_repo, org.id) with session: # Create content-view session.organization.select(org.name) session.contentview.create({'name': cv_name}) assert session.contentview.search(cv_name)[0]['Name'] == cv_name session.contentview.add_yum_repo(cv_name, rh_repo['name']) cv = session.contentview.read(cv_name) assert (cv['repositories']['resources']['assigned'][0]['Name'] == rh_repo['name'])
def setUpClass(cls): # noqa super(RHAITestCase, cls).setUpClass() # Create a new organization with prefix 'insights' org = entities.Organization(name="insights_{0}".format(gen_string("alpha", 6))).create() # Upload manifest with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) # Create activation key using default CV and library environment activation_key = entities.ActivationKey( auto_attach=True, content_view=org.default_content_view.id, environment=org.library.id, name=gen_string("alpha"), organization=org, ).create() # Walk through the list of subscriptions. # Find the "Red Hat Employee Subscription" and attach it to the # recently-created activation key. for subs in entities.Subscription(organization=org).search(): if subs.read_json()["product_name"] == DEFAULT_SUBSCRIPTION_NAME: # 'quantity' must be 1, not subscription['quantity']. Greater # values produce this error: "RuntimeError: Error: Only pools # with multi-entitlement product subscriptions can be added to # the activation key with a quantity greater than one." activation_key.add_subscriptions(data={"quantity": 1, "subscription_id": subs.id}) break cls.org_label = org.label cls.ak_name = activation_key.name cls.org_name = org.name
def test_positive_add_rh_and_custom_products(session): """Test that RH/Custom product can be associated to Activation keys :id: 3d8876fa-1412-47ca-a7a4-bce2e8baf3bc :Steps: 1. Create Activation key 2. Associate RH product(s) to Activation Key 3. Associate custom product(s) to Activation Key :expectedresults: RH/Custom product is successfully associated to Activation key :CaseLevel: Integration """ name = gen_string('alpha') rh_repo = { 'name': REPOS['rhva6']['name'], 'product': PRDS['rhel'], 'reposet': REPOSET['rhva6'], 'basearch': DEFAULT_ARCHITECTURE, 'releasever': DEFAULT_RELEASE_VERSION, } custom_product_name = gen_string('alpha') repo_name = gen_string('alpha') org = entities.Organization().create() product = entities.Product(name=custom_product_name, organization=org).create() repo = entities.Repository(name=repo_name, product=product).create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) rhel_repo_id = enable_rhrepo_and_fetchid( basearch=rh_repo['basearch'], org_id=org.id, product=rh_repo['product'], repo=rh_repo['name'], reposet=rh_repo['reposet'], releasever=rh_repo['releasever'], ) for repo_id in [rhel_repo_id, repo.id]: entities.Repository(id=repo_id).sync() with session: session.organization.select(org.name) session.activationkey.create({ 'name': name, 'lce': { ENVIRONMENT: True }, 'content_view': DEFAULT_CV }) assert session.activationkey.search(name)[0]['Name'] == name for subscription in (DEFAULT_SUBSCRIPTION_NAME, custom_product_name): session.activationkey.add_subscription(name, subscription) ak = session.activationkey.read(name, widget_names='subscriptions') subscriptions = [ subscription['Repository Name'] for subscription in ak['subscriptions']['resources']['assigned'] ] assert {DEFAULT_SUBSCRIPTION_NAME, custom_product_name} == set(subscriptions)
def test_positive_publish_with_rh_content(session): """Attempt to publish a content view containing RH content :id: bd24dc13-b6c4-4a9b-acb2-cd6df30f436c :setup: RH content synced :expectedresults: Content view can be published :CaseLevel: System """ cv_name = gen_string('alpha') version = 'Version 1.0' rh_repo = { 'name': REPOS['rhst7']['name'], 'product': PRDS['rhel'], 'reposet': REPOSET['rhst7'], 'basearch': 'x86_64', 'releasever': None, } org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) enable_sync_redhat_repo(rh_repo, org.id) with session: session.organization.select(org.name) session.contentview.create({'name': cv_name}) assert session.contentview.search(cv_name)[0]['Name'] == cv_name session.contentview.add_yum_repo(cv_name, rh_repo['name']) result = session.contentview.publish(cv_name) assert result['Version'] == version cv = session.contentview.read(cv_name) assert cv['versions']['table'][0]['Version'] == version
def test_verify_bugzilla_1225588(self): """Create Organization with valid values and upload manifest. Then try to delete that organization. @feature: Organization Positive Delete Test. @assert: Organization is deleted successfully. """ org_name = gen_string('alphanumeric') org = entities.Organization(name=org_name).create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) with Session(self.browser) as session: make_lifecycle_environment(session, org_name, name='DEV') make_lifecycle_environment(session, org_name, name='QE', prior='DEV') # Org cannot be deleted when selected, # So switching to Default Org and then deleting. session.nav.go_to_select_org('Default Organization') self.org.delete(org_name) for _ in range(10): status = self.org.search(org_name) if status is None: break self.assertIsNone(status)
def test_verify_bugzilla_1225588(self): """Create Organization with valid values and upload manifest. Then try to delete that organization. :id: 851c8557-a406-4a70-9c8b-94bcf0482f8d :expectedresults: Organization is deleted successfully. :CaseLevel: Integration :CaseImportance: Critical """ org_name = gen_string('alphanumeric') org = entities.Organization(name=org_name).create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) with Session(self.browser) as session: make_lifecycle_environment(session, org_name, name='DEV') make_lifecycle_environment(session, org_name, name='QE', prior='DEV') # Org cannot be deleted when selected, # So switching to Default Org and then deleting. session.nav.go_to_select_org('Default Organization') self.org.delete(org_name, dropdown_present=True) for _ in range(10): status = self.org.search(org_name) if status is None: break self.assertIsNone(status)
def setup_content(): org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) rh_repo_id = enable_rhrepo_and_fetchid( basearch='x86_64', org_id=org.id, product=PRDS['rhel'], repo=REPOS['rhst7']['name'], reposet=REPOSET['rhst7'], releasever=None, ) rh_repo = entities.Repository(id=rh_repo_id).read() rh_repo.sync() custom_repo = entities.Repository( product=entities.Product(organization=org).create(), ).create() custom_repo.sync() lce = entities.LifecycleEnvironment(organization=org).create() cv = entities.ContentView( organization=org, repository=[rh_repo_id, custom_repo.id], ).create() cv.publish() cvv = cv.read().version[0].read() promote(cvv, lce.id) ak = entities.ActivationKey( content_view=cv, max_hosts=100, organization=org, environment=lce, auto_attach=True ).create() subscription = entities.Subscription(organization=org).search( query={'search': f'name="{DEFAULT_SUBSCRIPTION_NAME}"'} )[0] ak.add_subscriptions(data={'quantity': 1, 'subscription_id': subscription.id}) return ak, org
def test_positive_filter_product_list(self): """Filter products based on param 'custom/redhat_only' :id: e61fb63a-4552-4915-b13d-23ab80138249 :expectedresults: Able to list the products based on defined filter. :CaseLevel: Integration :BZ: 1667129 """ product = entities.Product(organization=self.org.id).create() # Manifest upload to create RH Product with manifests.clone() as manifest: upload_manifest(self.org.id, manifest.content) custom_products = entities.Product(organization=self.org.id).search( query={'custom': True}) rh_products = entities.Product(organization=self.org.id).search( query={ 'redhat_only': True, 'per_page': 1000 }) assert len(custom_products) == 1 assert product.name == custom_products[0].name assert 'Red Hat Beta' not in (prod.name for prod in custom_products) assert len(rh_products) > 1 assert 'Red Hat Beta' in (prod.name for prod in rh_products) assert product.name not in (prod.name for prod in rh_products)
def test_positive_add_rh_content(session): """Add Red Hat content to a content view :id: c370fd79-0c0d-4685-99cb-848556c786c1 :setup: Sync RH content :expectedresults: RH Content can be seen in a view :CaseLevel: Integration """ cv_name = gen_string('alpha') rh_repo = { 'name': REPOS['rhst7']['name'], 'product': PRDS['rhel'], 'reposet': REPOSET['rhst7'], 'basearch': 'x86_64', 'releasever': None } # Create new org to import manifest org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) enable_sync_redhat_repo(rh_repo, org.id) with session: # Create content-view session.organization.select(org.name) session.contentview.create({'name': cv_name}) assert session.contentview.search(cv_name)[0]['Name'] == cv_name session.contentview.add_yum_repo(cv_name, rh_repo['name']) cv = session.contentview.read(cv_name) assert ( cv['repositories']['resources']['assigned'][0]['Name'] == rh_repo['name'] )
def test_positive_reposet_disable(self): """Disable repo from reposet @id: 60a102df-099e-4325-8924-2a31e5f738ba @Assert: Repository was disabled """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) product = entities.Product( name=PRDS['rhel'], organization=org, ).search()[0] reposet = entities.RepositorySet( name=REPOSET['rhva6'], product=product, ).search()[0] reposet.enable(data={'basearch': 'x86_64', 'releasever': '6Server'}) reposet.disable(data={'basearch': 'x86_64', 'releasever': '6Server'}) repositories = reposet.available_repositories()['results'] self.assertFalse([ repo['enabled'] for repo in repositories if (repo['substitutions']['basearch'] == 'x86_64' and repo['substitutions']['releasever'] == '6Server') ][0])
def test_verify_bugzilla_1259248(self): """Create organization with valid manifest. Download debug certificate for that organization and refresh added manifest for few times in a row :id: 1fcd7cd1-8ba1-434f-b9fb-c4e920046eb4 :expectedresults: Scenario passed successfully :CaseLevel: Integration :CaseImportance: Critical """ org = entities.Organization().create() sub = entities.Subscription(organization=org) with manifests.original_manifest() as manifest: upload_manifest(org.id, manifest.content) try: with Session(self) as session: for _ in range(3): self.assertIsNotNone(org.download_debug_certificate()) session.nav.go_to_select_org(org.name) session.nav.go_to_red_hat_subscriptions() self.subscriptions.refresh() self.assertIsNone(session.nav.wait_until_element( common_locators['notif.error'], timeout=5)) self.assertTrue(session.nav.wait_until_element( common_locators['alert.success'], timeout=180)) finally: sub.delete_manifest(data={'organization_id': org.id})
def test_verify_bugzilla_1225588(self): """Create Organization with valid values and upload manifest. Then try to delete that organization. :id: 851c8557-a406-4a70-9c8b-94bcf0482f8d :expectedresults: Organization is deleted successfully. :CaseLevel: Integration :CaseImportance: Critical """ org_name = gen_string('alphanumeric') org = entities.Organization(name=org_name).create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) with Session(self) as session: make_lifecycle_environment(session, org_name, name='DEV') make_lifecycle_environment( session, org_name, name='QE', prior='DEV' ) # Org cannot be deleted when selected, # So switching to Default Org and then deleting. session.nav.go_to_select_org('Default Organization') self.org.delete(org_name, dropdown_present=True) for _ in range(10): status = self.org.search(org_name) if status is None: break self.assertIsNone(status)
def test_positive_current_subscription_totals(self): """Check if the Current Subscriptions Totals widget is working in the Dashboard UI :id: 6d0f56ff-7007-4cdb-96f3-d9e8b6cc1701 :Steps: 1. Make sure sat6 has some active subscriptions 2. Navigate to Monitor -> Dashboard 3. Review the Current Subscription Total widget :expectedresults: The widget displays all the active subscriptions and expired subscriptions details :CaseImportance: Critical """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) with Session(self.browser) as session: set_context(session, org=org.name) self.assertGreaterEqual(self.dashboard.get_cst_subs_count( 'Active Subscriptions'), 1) self.assertEqual(self.dashboard.get_cst_subs_count( 'Subscriptions Expiring in 120 Days'), 0) self.assertEqual(self.dashboard.get_cst_subs_count( 'Recently Expired Subscriptions'), 0)
def test_positive_expired_SCA_cert_handling(module_org, rhel7_contenthost, default_sat): """Verify that a content host with an expired SCA cert can re-register successfully :id: 27bca6b8-dd9c-4977-81d2-319588ee59b3 :steps: 1. Import an SCA-enabled manifest 2. Register a content host to the Default Organization View using an activation key 3. Unregister the content host 4. Enable and synchronize a repository 5. Re-register the host using the same activation key as in step 3 above :expectedresults: the host is re-registered successfully and its SCA entitlement certificate is refreshed :CustomerScenario: true :Assignee: dsynk :BZ: 1949353 :parametrized: yes :CaseImportance: High """ with manifests.clone(name='golden_ticket') as manifest: upload_manifest(module_org.id, manifest.content) ak = entities.ActivationKey( content_view=module_org.default_content_view, max_hosts=100, organization=module_org, environment=entities.LifecycleEnvironment(id=module_org.library.id), auto_attach=True, ).create() # registering the content host with no content enabled/synced in the org # should create a client SCA cert with no content rhel7_contenthost.install_katello_ca(default_sat) rhel7_contenthost.register_contenthost(org=module_org.label, activation_key=ak.name) assert rhel7_contenthost.subscribed rhel7_contenthost.unregister() # syncing content with the content host unregistered should invalidate # the previous client SCA cert rh_repo_id = enable_rhrepo_and_fetchid( basearch='x86_64', org_id=module_org.id, product=PRDS['rhel'], repo=REPOS['rhst7']['name'], reposet=REPOSET['rhst7'], releasever=None, ) rh_repo = entities.Repository(id=rh_repo_id).read() rh_repo.sync() # re-registering the host should test whether Candlepin gracefully handles # registration of a host with an expired SCA cert rhel7_contenthost.register_contenthost(module_org.label, ak.name) assert rhel7_contenthost.subscribed
def test_verify_bugzilla_1259248(self): """Create organization with valid manifest. Download debug certificate for that organization and refresh added manifest for few times in a row :id: 1fcd7cd1-8ba1-434f-b9fb-c4e920046eb4 :expectedresults: Scenario passed successfully :CaseLevel: Integration :CaseImportance: Critical """ org = entities.Organization().create() sub = entities.Subscription(organization=org) with manifests.original_manifest() as manifest: upload_manifest(org.id, manifest.content) try: with Session(self.browser) as session: for _ in range(3): self.assertIsNotNone(org.download_debug_certificate()) session.nav.go_to_select_org(org.name) session.nav.go_to_red_hat_subscriptions() self.subscriptions.refresh() self.assertIsNone( session.nav.wait_until_element( common_locators['notif.error'], timeout=5)) self.assertTrue( session.nav.wait_until_element( common_locators['alert.success'], timeout=180)) finally: sub.delete_manifest(data={'organization_id': org.id})
def test_positive_reposet_enable(self): """Enable repo from reposet @id: dedcecf7-613a-4e85-a3af-92fb57e2b0a1 @Assert: Repository was enabled """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) product = entities.Product( name=PRDS['rhel'], organization=org, ).search()[0] reposet = entities.RepositorySet( name=REPOSET['rhva6'], product=product, ).search()[0] reposet.enable(data={'basearch': 'x86_64', 'releasever': '6Server'}) repositories = reposet.available_repositories()['results'] self.assertTrue([ repo['enabled'] for repo in repositories if (repo['substitutions']['basearch'] == 'x86_64' and repo['substitutions']['releasever'] == '6Server') ][0])
def test_verify_bugzilla_1259248(self): """Create organization with valid manifest. Download debug certificate for that organization and refresh added manifest for few times in a row @feature: Organizations. @assert: Scenario passed successfully """ org = entities.Organization().create() sub = entities.Subscription(organization=org) with manifests.original_manifest() as manifest: upload_manifest(org.id, manifest.content) try: with Session(self.browser) as session: for _ in range(3): self.assertIsNotNone(org.download_debug_certificate()) session.nav.go_to_select_org(org.name) session.nav.go_to_red_hat_subscriptions() self.subscriptions.refresh() self.assertIsNone(session.nav.wait_until_element( common_locators['notif.error'], timeout=5)) self.assertTrue(session.nav.wait_until_element( common_locators['alert.success'], timeout=180)) finally: sub.delete_manifest(data={'organization_id': org.id})
def test_positive_update_rh_product(session): """Update Content View in an Activation key :id: 9b0ac209-45de-4cc4-97e8-e191f3f37239 :Steps: 1. Create an activation key 2. Update the content view with another content view which has RH products :expectedresults: Activation key is updated :CaseLevel: Integration """ name = gen_string('alpha') env1_name = gen_string('alpha') env2_name = gen_string('alpha') cv1_name = gen_string('alpha') cv2_name = gen_string('alpha') rh_repo1 = { 'name': REPOS['rhva6']['name'], 'product': PRDS['rhel'], 'reposet': REPOSET['rhva6'], 'basearch': DEFAULT_ARCHITECTURE, 'releasever': DEFAULT_RELEASE_VERSION, } rh_repo2 = { 'name': ('Red Hat Enterprise Virtualization Agents for RHEL 6 ' 'Server RPMs i386 6Server'), 'product': PRDS['rhel'], 'reposet': REPOSET['rhva6'], 'basearch': 'i386', 'releasever': DEFAULT_RELEASE_VERSION, } org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) repo1_id = enable_sync_redhat_repo(rh_repo1, org.id) cv_publish_promote(cv1_name, env1_name, repo1_id, org.id) repo2_id = enable_sync_redhat_repo(rh_repo2, org.id) cv_publish_promote(cv2_name, env2_name, repo2_id, org.id) with session: session.organization.select(org.name) session.activationkey.create({ 'name': name, 'lce': {env1_name: True}, 'content_view': cv1_name, }) assert session.activationkey.search(name)[0]['Name'] == name ak = session.activationkey.read(name) assert ak['details']['content_view'] == cv1_name if bz_bug_is_open(1597639): assert session.activationkey.search(name)[0]['Name'] == name session.activationkey.update(name, {'details': { 'lce': {env2_name: True}, 'content_view': cv2_name, }}) ak = session.activationkey.read(name) assert ak['details']['content_view'] == cv2_name
def test_verify_bugzilla_1225588(self): """Create Organization with valid values and upload manifest. Then try to delete that organization. @feature: Organization Positive Delete Test. @assert: Organization is deleted successfully. """ org_name = gen_string('alphanumeric') org = entities.Organization(name=org_name).create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) with Session(self.browser) as session: make_lifecycle_environment(session, org_name, name='DEV') make_lifecycle_environment( session, org_name, name='QE', prior='DEV' ) # Org cannot be deleted when selected, # So switching to Default Org and then deleting. session.nav.go_to_select_org('Default Organization') self.org.delete(org_name) for _ in range(10): status = self.org.search(org_name) if status is None: break self.assertIsNone(status)
def test_positive_reposet_disable(self): """@Test: Disable repo from reposet @Feature: Repository-set @Assert: Repository was disabled """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) product = entities.Product( name=PRDS['rhel'], organization=org, ).search()[0] reposet = entities.RepositorySet( name=REPOSET['rhva6'], product=product, ).search()[0] reposet.enable(data={'basearch': 'x86_64', 'releasever': '6Server'}) reposet.disable(data={'basearch': 'x86_64', 'releasever': '6Server'}) repositories = reposet.available_repositories()['results'] self.assertFalse([ repo['enabled'] for repo in repositories if (repo['substitutions']['basearch'] == 'x86_64' and repo['substitutions']['releasever'] == '6Server') ][0])
def golden_ticket_host_setup(): org = entities.Organization().create() with manifests.clone(name='golden_ticket') as manifest: upload_manifest(org.id, manifest.content) rh_repo_id = enable_rhrepo_and_fetchid( basearch='x86_64', org_id=org.id, product=PRDS['rhel'], repo=REPOS['rhst7']['name'], reposet=REPOSET['rhst7'], releasever=None, ) rh_repo = entities.Repository(id=rh_repo_id).read() rh_repo.sync() custom_product = entities.Product(organization=org).create() custom_repo = entities.Repository( name=gen_string('alphanumeric').upper(), product=custom_product ).create() custom_repo.sync() ak = entities.ActivationKey( content_view=org.default_content_view, max_hosts=100, organization=org, environment=entities.LifecycleEnvironment(id=org.library.id), auto_attach=True, ).create() subscription = entities.Subscription(organization=org).search( query={'search': f'name="{DEFAULT_SUBSCRIPTION_NAME}"'} )[0] ak.add_subscriptions(data={'quantity': 1, 'subscription_id': subscription.id}) return org, ak
def golden_ticket_host_setup(): org = entities.Organization().create() with manifests.clone(name='golden_ticket') as manifest: upload_manifest(org.id, manifest.content) rh_repo_id = enable_rhrepo_and_fetchid( basearch='x86_64', org_id=org.id, product=PRDS['rhel'], repo=REPOS['rhst7']['name'], reposet=REPOSET['rhst7'], releasever=None, ) rh_repo = entities.Repository(id=rh_repo_id).read() rh_repo.sync() custom_product = entities.Product(organization=org).create() custom_repo = entities.Repository(name=gen_string('alphanumeric').upper(), product=custom_product).create() custom_repo.sync() ak = entities.ActivationKey( content_view=org.default_content_view, max_hosts=100, organization=org, environment=entities.LifecycleEnvironment(id=org.library.id), auto_attach=True, ).create() return org, ak
def _create_rh_rhel_tools_repos(self, org_id): """ Upload manifest, enable RHEL7 and tools repos and sync them :param: int org_id: Organization ID :return: nailgun.entities.Repository: repository """ from_version = settings.upgrade.from_version repo_name = 'rhst7_{}'.format(str(from_version).replace('.', '')) rh_rhel = { 'name': REPOS['rhel7']['name'], 'product': REPOS['rhel7']['product'], 'reposet': REPOS['rhel7']['reposet'], 'basearch': REPOS['rhel7']['arch'], 'releasever': '7Server', } rh_tools = { 'name': REPOS[repo_name]['name'], 'product': REPOS[repo_name]['product'], 'reposet': REPOS[repo_name]['reposet'], 'basearch': DEFAULT_ARCHITECTURE, 'releasever': '7Server', } with manifests.clone() as manifest: upload_manifest(org_id, manifest.content) repo1_id = enable_sync_redhat_repo(rh_rhel, org_id, timeout=3500) repo2_id = enable_sync_redhat_repo(rh_tools, org_id, timeout=3500) return [ entities.Repository(id=repo_id) for repo_id in [repo1_id, repo2_id] ]
def test_positive_reposet_enable(self): """Enable repo from reposet :id: dedcecf7-613a-4e85-a3af-92fb57e2b0a1 :expectedresults: Repository was enabled :CaseImportance: Critical """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) product = entities.Product( name=PRDS['rhel'], organization=org, ).search()[0] reposet = entities.RepositorySet( name=REPOSET['rhva6'], product=product, ).search()[0] reposet.enable(data={'basearch': 'x86_64', 'releasever': '6Server'}) repositories = reposet.available_repositories()['results'] self.assertTrue([ repo['enabled'] for repo in repositories if (repo['substitutions']['basearch'] == 'x86_64' and repo['substitutions']['releasever'] == '6Server') ][0])
def test_positive_delete_bz1225588(self, org_name): """@test: Create Organization with valid values and upload manifest. Then try to delete that organization. @feature: Organization Positive Delete Test. @assert: Organization is deleted successfully. """ org = entities.Organization(name=org_name).create() with open(manifests.clone(), 'rb') as manifest: upload_manifest(org.id, manifest) with Session(self.browser) as session: make_lifecycle_environment(session, org_name, name='DEV') make_lifecycle_environment( session, org_name, name='QE', prior='DEV' ) # Org cannot be deleted when selected, # So switching to Default Org and then deleting. session.nav.go_to_select_org('Default Organization') self.org.remove(org_name) session.nav.go_to_dashboard() status = self.org.search(org_name) # Check for at least ten times that org is deleted due #1225588 for _ in range(10): status = self.org.search(org_name) if status is None: break self.assertIsNone(status)
def test_positive_reposet_disable(self): """Disable repo from reposet :id: 60a102df-099e-4325-8924-2a31e5f738ba :expectedresults: Repository was disabled :CaseImportance: Critical """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) product = entities.Product( name=PRDS['rhel'], organization=org, ).search()[0] reposet = entities.RepositorySet( name=REPOSET['rhva6'], product=product, ).search()[0] reposet.enable(data={'basearch': 'x86_64', 'releasever': '6Server'}) reposet.disable(data={'basearch': 'x86_64', 'releasever': '6Server'}) repositories = reposet.available_repositories()['results'] self.assertFalse([ repo['enabled'] for repo in repositories if (repo['substitutions']['basearch'] == 'x86_64' and repo['substitutions']['releasever'] == '6Server') ][0])
def test_positive_sync_rh_ostree_repo(self): """Sync CDN based ostree repository . @id: 4d28fff0-5fda-4eee-aa0c-c5af02c31de5 @Steps: 1. Import a valid manifest 2. Enable the OStree repo and sync it @Assert: ostree repo should be synced successfully from CDN @CaseLevel: Integration """ repos = self.sync.create_repos_tree(ATOMIC_HOST_TREE) org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) with Session(self.browser) as session: session.nav.go_to_select_org(org.name) session.nav.go_to_red_hat_repositories() self.sync.enable_rh_repos(repos, repo_tab=REPO_TAB['ostree']) session.nav.go_to_sync_status() self.assertTrue(self.sync.sync_noversion_rh_repos( PRDS['rhah'], [REPOS['rhaht']['name']] ))
def setup_to_create_cv(self, repo_name=None, repo_url=None, repo_type=None, rh_repo=None, org_id=None): """Create product/repo and sync it""" if not rh_repo: repo_name = repo_name or gen_string('alpha') # Creates new custom product via API's product = entities.Product( organization=org_id or self.organization ).create() # Creates new custom repository via API's repo_id = entities.Repository( name=repo_name, url=(repo_url or FAKE_1_YUM_REPO), content_type=(repo_type or REPO_TYPE['yum']), product=product, ).create().id elif rh_repo: # Uploads the manifest and returns the result. with open(manifests.clone(), 'rb') as manifest: upload_manifest(org_id, manifest) # Enables the RedHat repo and fetches it's Id. repo_id = enable_rhrepo_and_fetchid( basearch=rh_repo['basearch'], org_id=str(org_id), # OrgId is passed as data in API hence str product=rh_repo['product'], repo=rh_repo['name'], reposet=rh_repo['reposet'], releasever=rh_repo['releasever'], ) # Sync repository entities.Repository(id=repo_id).sync()
def test_positive_generate_subscriptions_report_json(session, module_org, module_loc): """Use provided Subscriptions report, generate JSON :id: b44d4cd8-a88e-47cf-9993-0bb871ac2c96 :expectedresults: The Subscriptions report is generated in JSON :CaseLevel: Integration :CaseImportance: Medium """ # make sure we have some subscriptions with manifests.clone() as manifest: upload_manifest(module_org.id, manifest.content) # generate Subscriptions report with session: file_path = session.reporttemplate.generate( "Subscriptions", values={'output_format': 'JSON'}) with open(file_path) as json_file: data = json.load(json_file) subscription_cnt = len( entities.Subscription(organization=module_org).search()) assert subscription_cnt > 0 assert len(data) >= subscription_cnt keys_expected = [ 'Available', 'Contract number', 'ID', 'Name', 'Quantity', 'SKU' ] for subscription in data: assert sorted(list(subscription.keys())) == keys_expected
def test_positive_candlepin_events_processed_by_STOMP(self): """Verify that Candlepin events are being read and processed by attaching subscriptions, validating host subscriptions status, and viewing processed and failed Candlepin events :id: efd20ffd-8f98-4536-abb6-d080f9d23169 :steps: 1. Add subscriptions to content host 2. Verify subscription status is invalid at <your-satellite-url>/api/v2/hosts 3. Import a Manifest 4. Attach subs to content host 5. Verify subscription status is valid 6. Check ping api for processed and failed events /katello/api/v2/ping :expectedresults: Candlepin events are being read and processed correctly without any failures :BZ: #1826515 :CaseImportance: High """ org = entities.Organization().create() repo = entities.Repository(product=entities.Product( organization=org).create()).create() repo.sync() ak = entities.ActivationKey( content_view=org.default_content_view, max_hosts=100, organization=org, environment=entities.LifecycleEnvironment(id=org.library.id), auto_attach=True, ).create() with VirtualMachine(distro=DISTRO_RHEL7) as vm: vm.install_katello_ca() vm.register_contenthost(org.name, ak.name) host = entities.Host().search( query={'search': f'name={vm.hostname}'}) host_id = host[0].id host_content = entities.Host(id=host_id).read_json() assert host_content["subscription_status"] == 2 with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) subscription = entities.Subscription(organization=org).search( query={'search': f'name="{DEFAULT_SUBSCRIPTION_NAME}"'})[0] entities.HostSubscription(host=host_id).add_subscriptions(data={ 'subscriptions': [{ 'id': subscription.cp_id, 'quantity': 1 }] }) host_content = entities.Host(id=host_id).read_json() assert host_content["subscription_status"] == 0 response = entities.Ping().search_json( )["services"]["candlepin_events"] assert response["status"] == "ok" assert "0 Failed" in response["message"]
def test_positive_candlepin_events_processed_by_stomp(rhel7_contenthost, function_org, default_sat): """Verify that Candlepin events are being read and processed by attaching subscriptions, validating host subscriptions status, and viewing processed and failed Candlepin events :id: efd20ffd-8f98-4536-abb6-d080f9d23169 :steps: 1. Add subscriptions to content host 2. Verify subscription status is invalid at <your-satellite-url>/api/v2/hosts 3. Import a Manifest 4. Attach subs to content host 5. Verify subscription status is valid 6. Check ping api for processed and failed events /katello/api/v2/ping :expectedresults: Candlepin events are being read and processed correctly without any failures :BZ: 1826515 :parametrized: yes :CaseImportance: High """ repo = entities.Repository(product=entities.Product( organization=function_org).create()).create() repo.sync() ak = entities.ActivationKey( content_view=function_org.default_content_view, max_hosts=100, organization=function_org, environment=entities.LifecycleEnvironment(id=function_org.library.id), auto_attach=True, ).create() rhel7_contenthost.install_katello_ca(default_sat) rhel7_contenthost.register_contenthost(function_org.name, ak.name) host = entities.Host().search( query={'search': f'name={rhel7_contenthost.hostname}'}) host_id = host[0].id host_content = entities.Host(id=host_id).read_json() assert host_content['subscription_status'] == 2 with manifests.clone() as manifest: upload_manifest(function_org.id, manifest.content) subscription = entities.Subscription(organization=function_org).search( query={'search': f'name="{DEFAULT_SUBSCRIPTION_NAME}"'})[0] entities.HostSubscription(host=host_id).add_subscriptions( data={'subscriptions': [{ 'id': subscription.cp_id, 'quantity': 1 }]}) host_content = entities.Host(id=host_id).read_json() assert host_content['subscription_status'] == 0 response = entities.Ping().search_json()['services']['candlepin_events'] assert response['status'] == 'ok' assert '0 Failed' in response['message']
def test_positive_create_composite(session): # Note: puppet repos cannot/should not be used in this test # It shouldn't work - and that is tested in a different case. # Individual modules from a puppet repo, however, are a valid # variation. """Create a composite content views :id: 550f1970-5cbd-4571-bb7b-17e97639b715 :setup: sync multiple content source/types (RH, custom, etc.) :expectedresults: Composite content views are created :CaseLevel: System """ puppet_module = 'httpd' cv_name1 = gen_string('alpha') cv_name2 = gen_string('alpha') composite_name = gen_string('alpha') rh_repo = { 'name': REPOS['rhst7']['name'], 'product': PRDS['rhel'], 'reposet': REPOSET['rhst7'], 'basearch': 'x86_64', 'releasever': None, } # Create new org to import manifest org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) enable_sync_redhat_repo(rh_repo, org.id) create_sync_custom_repo( org.id, repo_url=FAKE_0_PUPPET_REPO, repo_type=REPO_TYPE['puppet']) with session: session.organization.select(org.name) # Create content views for cv_name in (cv_name1, cv_name2): session.contentview.create({'name': cv_name}) assert session.contentview.search(cv_name)[0]['Name'] == cv_name session.contentview.add_puppet_module(cv_name1, puppet_module) cv1 = session.contentview.read(cv_name1) assert cv1['puppet_modules']['table'][0]['Name'] == puppet_module session.contentview.publish(cv_name1) # fixme: drop next line after airgun#63 is solved session.contentview.search(cv_name2) session.contentview.add_yum_repo(cv_name2, rh_repo['name']) session.contentview.publish(cv_name2) session.contentview.create({ 'name': composite_name, 'composite_view': True, }) for cv_name in (cv_name1, cv_name2): session.contentview.add_cv(composite_name, cv_name) composite_cv = session.contentview.read(composite_name) assert {cv_name1, cv_name2} == set([ cv['Name'] for cv in composite_cv['content_views']['resources']['assigned'] ])
def test_positive_create_composite(session): # Note: puppet repos cannot/should not be used in this test # It shouldn't work - and that is tested in a different case. # Individual modules from a puppet repo, however, are a valid # variation. """Create a composite content views :id: 550f1970-5cbd-4571-bb7b-17e97639b715 :setup: sync multiple content source/types (RH, custom, etc.) :expectedresults: Composite content views are created :CaseLevel: System """ puppet_module = 'httpd' cv_name1 = gen_string('alpha') cv_name2 = gen_string('alpha') composite_name = gen_string('alpha') rh_repo = { 'name': REPOS['rhst7']['name'], 'product': PRDS['rhel'], 'reposet': REPOSET['rhst7'], 'basearch': 'x86_64', 'releasever': None, } # Create new org to import manifest org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) enable_sync_redhat_repo(rh_repo, org.id) create_sync_custom_repo(org.id, repo_url=FAKE_0_PUPPET_REPO, repo_type=REPO_TYPE['puppet']) with session: session.organization.select(org.name) # Create content views for cv_name in (cv_name1, cv_name2): session.contentview.create({'name': cv_name}) assert session.contentview.search(cv_name)[0]['Name'] == cv_name session.contentview.add_puppet_module(cv_name1, puppet_module) cv1 = session.contentview.read(cv_name1) assert cv1['puppet_modules']['table'][0]['Name'] == puppet_module session.contentview.publish(cv_name1) session.contentview.add_yum_repo(cv_name2, rh_repo['name']) session.contentview.publish(cv_name2) session.contentview.create({ 'name': composite_name, 'composite_view': True, }) for cv_name in (cv_name1, cv_name2): session.contentview.add_cv(composite_name, cv_name) composite_cv = session.contentview.read(composite_name) assert {cv_name1, cv_name2} == set([ cv['Name'] for cv in composite_cv['content_views']['resources']['assigned'] ])
def module_org(): org_name = f'insights_{gen_string("alpha", 6)}' org = nailgun.entities.Organization(name=org_name).create() nailgun.entities.Parameter(name='remote_execution_connect_by_ip', value='Yes', organization=org.id).create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) yield org
def test_positive_candlepin_events_processed_by_STOMP(session, rhel7_contenthost, target_sat): """Verify that Candlepin events are being read and processed by attaching subscriptions, validating host subscriptions status, and viewing processed and failed Candlepin events :id: 9510fd1c-2efb-4132-8665-9a72273cd1af :steps: 1. Register Content Host without subscriptions attached 2. Verify subscriptions status is red "invalid" 3. Import a Manifest 4. Attach subs to content host 5. Verify subscription status is green "valid" 6. Check for processed and failed Candlepin events :expectedresults: Candlepin events are being read and processed correctly without any failures :BZ: 1826515 :parametrized: yes :CaseImportance: High """ org = entities.Organization().create() repo = entities.Repository(product=entities.Product( organization=org).create()).create() repo.sync() ak = entities.ActivationKey( content_view=org.default_content_view, max_hosts=100, organization=org, environment=entities.LifecycleEnvironment(id=org.library.id), ).create() rhel7_contenthost.install_katello_ca(target_sat) rhel7_contenthost.register_contenthost(org.name, ak.name) with session: session.organization.select(org_name=org.name) host = session.contenthost.read(rhel7_contenthost.hostname, widget_names='details')['details'] assert 'Unentitled' in host['subscription_status'] with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) session.contenthost.add_subscription(rhel7_contenthost.hostname, DEFAULT_SUBSCRIPTION_NAME) session.browser.refresh() updated_sub_status = session.contenthost.read( rhel7_contenthost.hostname, widget_names='details')['details']['subscription_status'] assert 'Fully entitled' in updated_sub_status response = entities.Ping().search_json( )['services']['candlepin_events'] assert response['status'] == 'ok' assert '0 Failed' in response['message']
def setup_content_rhel6(): """Setup content fot rhel6 content host Using `Red Hat Enterprise Virtualization Agents for RHEL 6 Server (RPMs)` from manifest, SATTOOLS_REPO for host-tools and yum_9 repo as custom repo. :return: Activation Key, Organization, subscription list """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) rh_repo_id_rhva = enable_rhrepo_and_fetchid( basearch='x86_64', org_id=org.id, product=constants.PRDS['rhel'], repo=constants.REPOS['rhva6']['name'], reposet=constants.REPOSET['rhva6'], releasever=constants.DEFAULT_RELEASE_VERSION, ) rh_repo = entities.Repository(id=rh_repo_id_rhva).read() rh_repo.sync() host_tools_product = entities.Product(organization=org).create() host_tools_repo = entities.Repository( product=host_tools_product, ).create() host_tools_repo.url = settings.repos.SATTOOLS_REPO.RHEL6 host_tools_repo = host_tools_repo.update(['url']) host_tools_repo.sync() custom_product = entities.Product(organization=org).create() custom_repo = entities.Repository( product=custom_product, ).create() custom_repo.url = CUSTOM_REPO_URL custom_repo = custom_repo.update(['url']) custom_repo.sync() lce = entities.LifecycleEnvironment(organization=org).create() cv = entities.ContentView( organization=org, repository=[rh_repo_id_rhva, host_tools_repo.id, custom_repo.id], ).create() cv.publish() cvv = cv.read().version[0].read() promote(cvv, lce.id) ak = entities.ActivationKey(content_view=cv, organization=org, environment=lce).create() sub_list = [DEFAULT_SUBSCRIPTION_NAME, host_tools_product.name, custom_product.name] for sub_name in sub_list: subscription = entities.Subscription(organization=org).search( query={'search': f'name="{sub_name}"'} )[0] ak.add_subscriptions(data={'subscription_id': subscription.id}) return ak, org, sub_list
def test_positive_create(self): """Upload a manifest. @id: 6faf9d96-9b45-4bdc-afa9-ec3fbae83d41 @Assert: Manifest is uploaded successfully """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content)
def test_positive_create(self): """Upload a manifest. @Assert: Manifest is uploaded successfully @Feature: Subscriptions """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content)
def test_positive_create(self): """@Test: Upload a manifest. @Assert: Manifest is uploaded successfully @Feature: Subscriptions """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content)
def setUpClass(cls): """Creates the pre-requisites for the Incremental updates that used in all test""" super(IncrementalUpdateTestCase, cls).setUpClass() # Create a new Organization cls.org = Organization(name=gen_alpha()).create() # Create two lifecycle environments - DEV, QE cls.dev_lce = LifecycleEnvironment( name='DEV', organization=cls.org ).create() cls.qe_lce = LifecycleEnvironment( name='QE', prior=cls.dev_lce, organization=cls.org ).create() # Upload manifest with manifests.clone() as manifest: upload_manifest(cls.org.id, manifest.content) # Enable repositories - RHE Virtualization Agents and rhel6 sat6tools rhva_6_repo_id = enable_rhrepo_and_fetchid( basearch=DEFAULT_ARCHITECTURE, org_id=cls.org.id, product=PRDS['rhel'], repo=REPOS['rhva6']['name'], reposet=REPOSET['rhva6'], releasever=DEFAULT_RELEASE_VERSION, ) rhel6_sat6tools_repo_id = enable_rhrepo_and_fetchid( basearch=DEFAULT_ARCHITECTURE, org_id=cls.org.id, product=PRDS['rhel'], repo=REPOS['rhst6']['name'], reposet=REPOSET['rhst6'], releasever=None, ) # Read the repositories cls.rhva_6_repo = Repository(id=rhva_6_repo_id).read() cls.rhel6_sat6tools_repo = Repository( id=rhel6_sat6tools_repo_id ).read() # Sync the enabled repositories try: cls.old_task_timeout = entity_mixins.TASK_TIMEOUT # Update timeout to 15 minutes to finish sync entity_mixins.TASK_TIMEOUT = 900 for repo in [cls.rhva_6_repo, cls.rhel6_sat6tools_repo]: assert Repository(id=repo.id).sync()['result'] == u'success' finally: entity_mixins.TASK_TIMEOUT = cls.old_task_timeout
def test_positive_create(self): """Upload a manifest. :id: 6faf9d96-9b45-4bdc-afa9-ec3fbae83d41 :expectedresults: Manifest is uploaded successfully :CaseImportance: Critical """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content)
def test_delete_manifest(self): """@Test: Check if deleting a manifest removes it from Activation key @Feature: Activation key - Manifest @Steps: 1. Create Activation key 2. Associate a manifest to the Activation Key 3. Delete the manifest @Assert: Deleting a manifest removes it from the Activation key """ # Upload manifest org = entities.Organization().create() sub = entities.Subscription(organization=org) with open(manifests.clone(), 'rb') as manifest: upload_manifest(org.id, manifest) # Create activation key activation_key = entities.ActivationKey( organization=org, ).create() # Associate a manifest to the activation key for subs in sub.search(): if subs.read_json()['product_name'] == DEFAULT_SUBSCRIPTION_NAME: activation_key.add_subscriptions(data={ 'quantity': 1, 'subscription_id': subs.id, }) break with Session(self.browser) as session: session.nav.go_to_select_org(org.name) # Verify subscription is assigned to activation key self.navigator.go_to_activation_keys() self.assertIsNotNone( self.activationkey.search_key_subscriptions( activation_key.name, DEFAULT_SUBSCRIPTION_NAME ) ) # Delete the manifest self.navigator.go_to_red_hat_subscriptions() self.subscriptions.delete() self.assertIsNotNone(self.subscriptions.wait_until_element( common_locators['alert.success'])) # Verify the subscription was removed from the activation key self.navigator.go_to_activation_keys() self.assertIsNone( self.activationkey.search_key_subscriptions( activation_key.name, DEFAULT_SUBSCRIPTION_NAME ) )
def test_positive_delete_manifest(self): """Check if deleting a manifest removes it from Activation key @id: 512d8e41-b937-451e-a9c6-840457d3d7d4 @Steps: 1. Create Activation key 2. Associate a manifest to the Activation Key 3. Delete the manifest @Assert: Deleting a manifest removes it from the Activation key @CaseLevel: Integration """ # Upload manifest org = entities.Organization().create() sub = entities.Subscription(organization=org) with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) # Create activation key activation_key = entities.ActivationKey( organization=org, ).create() # Associate a manifest to the activation key for subs in sub.search(): if subs.read_json()['product_name'] == DEFAULT_SUBSCRIPTION_NAME: activation_key.add_subscriptions(data={ 'quantity': 1, 'subscription_id': subs.id, }) break with Session(self.browser) as session: session.nav.go_to_select_org(org.name) # Verify subscription is assigned to activation key self.assertIsNotNone( self.activationkey.search_key_subscriptions( activation_key.name, DEFAULT_SUBSCRIPTION_NAME ) ) # Delete the manifest self.navigator.go_to_red_hat_subscriptions() self.subscriptions.delete() self.assertIsNotNone(self.subscriptions.wait_until_element( common_locators['alert.success'], timeout=180)) # Verify the subscription was removed from the activation key self.assertIsNone( self.activationkey.search_key_subscriptions( activation_key.name, DEFAULT_SUBSCRIPTION_NAME ) )
def test_positive_fetch_product_content(self): """Associate RH & custom product with AK and fetch AK's product content :id: 424f3dfb-0112-464b-b633-e8c9bce6e0f1 :expectedresults: Both Red Hat and custom product subscriptions are assigned as Activation Key's product content :BZ: 1426386 :CaseLevel: Integration """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) rh_repo_id = enable_rhrepo_and_fetchid( basearch='x86_64', org_id=org.id, product=PRDS['rhel'], repo=REPOS['rhst7']['name'], reposet=REPOSET['rhst7'], releasever=None, ) rh_repo = entities.Repository(id=rh_repo_id).read() rh_repo.sync() custom_repo = entities.Repository( product=entities.Product(organization=org).create(), ).create() custom_repo.sync() cv = entities.ContentView( organization=org, repository=[rh_repo_id, custom_repo.id], ).create() cv.publish() ak = entities.ActivationKey(content_view=cv, organization=org).create() org_subscriptions = entities.Subscription(organization=org).search() for subscription in org_subscriptions: provided_products_ids = [ prod.id for prod in subscription.read().provided_product] if (custom_repo.product.id in provided_products_ids or rh_repo.product.id in provided_products_ids): ak.add_subscriptions(data={ 'quantity': 1, 'subscription_id': subscription.id, }) ak_subscriptions = ak.product_content()['results'] self.assertEqual( {custom_repo.product.id, rh_repo.product.id}, {subscr['product']['id'] for subscr in ak_subscriptions} )
def test_positive_delete(self): """Delete an Uploaded manifest. @id: 4c21c7c9-2b26-4a65-a304-b978d5ba34fc @Assert: Manifest is Deleted successfully """ org = entities.Organization().create() sub = entities.Subscription(organization=org) with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) self.assertGreater(len(sub.search()), 0) sub.delete_manifest(data={'organization_id': org.id}) self.assertEqual(len(sub.search()), 0)
def test_positive_delete(self): """@Test: Delete an Uploaded manifest. @Assert: Manifest is Deleted successfully @Feature: Subscriptions """ org = entities.Organization().create() sub = entities.Subscription(organization=org) with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) self.assertGreater(len(sub.search()), 0) sub.delete_manifest(data={'organization_id': org.id}) self.assertEqual(len(sub.search()), 0)
def test_negative_upload(self): """@Test: Upload the same manifest to two organizations. @Assert: The manifest is not uploaded to the second organization. @Feature: Subscriptions """ orgs = [entities.Organization().create() for _ in range(2)] with manifests.clone() as manifest: upload_manifest(orgs[0].id, manifest.content) with self.assertRaises(TaskFailedError): upload_manifest(orgs[1].id, manifest.content) self.assertEqual( len(entities.Subscription(organization=orgs[1]).search()), 0)
def setUpClass(cls): super(RHPackagesTestCase, cls).setUpClass() cls.organization = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(cls.organization.id, manifest.content) repo_id = enable_rhrepo_and_fetchid( basearch='x86_64', org_id=cls.organization.id, product=PRDS['rhel'], repo=REPOS['rhst7']['name'], reposet=REPOSET['rhst7'], releasever=None, ) entities.Repository(id=repo_id).sync()
def test_positive_fetch_product_content(session): """Associate RH & custom product with AK and fetch AK's product content :id: 4c37fb12-ea2a-404e-b7cc-a2735e8dedb6 :expectedresults: Both Red Hat and custom product subscriptions are assigned as Activation Key's product content :BZ: 1426386, 1432285 :CaseLevel: Integration """ org = entities.Organization().create() with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) rh_repo_id = enable_rhrepo_and_fetchid( basearch='x86_64', org_id=org.id, product=PRDS['rhel'], repo=REPOS['rhst7']['name'], reposet=REPOSET['rhst7'], releasever=None, ) rh_repo = entities.Repository(id=rh_repo_id).read() rh_repo.sync() custom_product = entities.Product(organization=org).create() custom_repo = entities.Repository( name=gen_string('alphanumeric').upper(), # first letter is always # uppercase on product content page, workarounding it for # successful checks product=custom_product).create() custom_repo.sync() cv = entities.ContentView( organization=org, repository=[rh_repo_id, custom_repo.id], ).create() cv.publish() ak = entities.ActivationKey(content_view=cv, organization=org).create() with session: session.organization.select(org.name) for subscription in (DEFAULT_SUBSCRIPTION_NAME, custom_product.name): session.activationkey.add_subscription(ak.name, subscription) ak = session.activationkey.read(ak.name) reposets = [ reposet['Repository Name'] for reposet in ak['repository_sets']['resources'] ] assert {custom_repo.name, REPOSET['rhst7']} == set(reposets)
def test_positive_refresh(self): """Upload a manifest and refresh it afterwards. @Assert: Manifest is refreshed successfully @Feature: Subscriptions """ org = entities.Organization().create() sub = entities.Subscription(organization=org) with manifests.original_manifest() as manifest: upload_manifest(org.id, manifest.content) try: sub.refresh_manifest(data={'organization_id': org.id}) self.assertGreater(len(sub.search()), 0) finally: sub.delete_manifest(data={'organization_id': org.id})
def test_negative_upload(self): """Upload the same manifest to two organizations. :id: 60ca078d-cfaf-402e-b0db-34d8901449fe :expectedresults: The manifest is not uploaded to the second organization. :CaseImportance: Critical """ orgs = [entities.Organization().create() for _ in range(2)] with manifests.clone() as manifest: upload_manifest(orgs[0].id, manifest.content) with self.assertRaises(TaskFailedError): upload_manifest(orgs[1].id, manifest.content) self.assertEqual( len(entities.Subscription(organization=orgs[1]).search()), 0)
def test_positive_refresh(self): """Upload a manifest and refresh it afterwards. :id: cd195db6-e81b-42cb-a28d-ec0eb8a53341 :expectedresults: Manifest is refreshed successfully :CaseImportance: Critical """ org = entities.Organization().create() sub = entities.Subscription(organization=org) with manifests.original_manifest() as manifest: upload_manifest(org.id, manifest.content) try: sub.refresh_manifest(data={'organization_id': org.id}) self.assertGreater(len(sub.search()), 0) finally: sub.delete_manifest(data={'organization_id': org.id})