Пример #1
0
 def setUpClass(cls):
     """Create Org, Lifecycle Environment, Content View, Activation key
     """
     super(RemoteExecutionTestCase, cls).setUpClass()
     cls.org = make_org()
     ssh.command(
         '''echo 'getenforce' > {0}'''.format(TEMPLATE_FILE)
     )
     cls.env = make_lifecycle_environment({
         u'organization-id': cls.org['id'],
     })
     cls.content_view = make_content_view({
         u'organization-id': cls.org['id'],
     })
     cls.activation_key = make_activation_key({
         u'lifecycle-environment-id': cls.env['id'],
         u'organization-id': cls.org['id'],
     })
     # Add subscription to Satellite Tools repo to activation key
     setup_org_for_a_rh_repo({
         u'product': PRDS['rhel'],
         u'repository-set': REPOSET['rhst7'],
         u'repository': REPOS['rhst7']['name'],
         u'organization-id': cls.org['id'],
         u'content-view-id': cls.content_view['id'],
         u'lifecycle-environment-id': cls.env['id'],
         u'activationkey-id': cls.activation_key['id'],
     })
Пример #2
0
 def setUpClass(cls):
     """Create Org, Lifecycle Environment, Content View, Activation key
     """
     super(RemoteExecutionTestCase, cls).setUpClass()
     cls.org = make_org()
     ssh.command(
         '''echo 'getenforce' > {0}'''.format(TEMPLATE_FILE)
     )
     cls.env = make_lifecycle_environment({
         u'organization-id': cls.org['id'],
     })
     cls.content_view = make_content_view({
         u'organization-id': cls.org['id'],
     })
     cls.activation_key = make_activation_key({
         u'lifecycle-environment-id': cls.env['id'],
         u'organization-id': cls.org['id'],
     })
     # Add subscription to Satellite Tools repo to activation key
     setup_org_for_a_rh_repo({
         u'product': PRDS['rhel'],
         u'repository-set': REPOSET['rhst7'],
         u'repository': REPOS['rhst7']['name'],
         u'organization-id': cls.org['id'],
         u'content-view-id': cls.content_view['id'],
         u'lifecycle-environment-id': cls.env['id'],
         u'activationkey-id': cls.activation_key['id'],
     })
Пример #3
0
    def setUpClass(cls):
        """Create Org, Lifecycle Environment, Content View, Activation key

        """
        super(KatelloAgentTestCase, cls).setUpClass()
        # Create new org, environment, CV and activation key
        KatelloAgentTestCase.org = make_org()
        KatelloAgentTestCase.env = make_lifecycle_environment({
            u'organization-id': KatelloAgentTestCase.org['id'],
        })
        KatelloAgentTestCase.content_view = make_content_view({
            u'organization-id': KatelloAgentTestCase.org['id'],
        })
        KatelloAgentTestCase.activation_key = make_activation_key({
            u'lifecycle-environment-id': KatelloAgentTestCase.env['id'],
            u'organization-id': KatelloAgentTestCase.org['id'],
        })
        # Add subscription to Satellite Tools repo to activation key
        setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': KatelloAgentTestCase.org['id'],
            u'content-view-id': KatelloAgentTestCase.content_view['id'],
            u'lifecycle-environment-id': KatelloAgentTestCase.env['id'],
            u'activationkey-id': KatelloAgentTestCase.activation_key['id'],
        })
        # Create custom repo, add subscription to activation key
        setup_org_for_a_custom_repo({
            u'url': FAKE_0_YUM_REPO,
            u'organization-id': KatelloAgentTestCase.org['id'],
            u'content-view-id': KatelloAgentTestCase.content_view['id'],
            u'lifecycle-environment-id': KatelloAgentTestCase.env['id'],
            u'activationkey-id': KatelloAgentTestCase.activation_key['id'],
        })
Пример #4
0
def katello_agent_repos(sat_with_katello_agent):
    """Create Org, Lifecycle Environment, Content View, Activation key"""
    sat = sat_with_katello_agent
    org = sat.api.Organization().create()
    lce = sat.api.LifecycleEnvironment(organization=org).create()
    cv = sat.api.ContentView(organization=org).create()
    ak = sat.api.ActivationKey(environment=lce, organization=org).create()
    setup_org_for_a_rh_repo({
        'product': constants.PRDS['rhel'],
        'repository-set': constants.REPOSET['rhst7'],
        'repository': constants.REPOS['rhst7']['name'],
        'organization-id': org.id,
        'content-view-id': cv.id,
        'lifecycle-environment-id': lce.id,
        'activationkey-id': ak.id,
    })
    # Create custom repository content
    setup_org_for_a_custom_repo({
        'url': settings.repos.yum_1.url,
        'organization-id': org.id,
        'content-view-id': cv.id,
        'lifecycle-environment-id': lce.id,
        'activationkey-id': ak.id,
    })
    return {
        'ak': ak,
        'cv': cv,
        'lce': lce,
        'org': org,
    }, sat_with_katello_agent
Пример #5
0
def katello_agent_repos(module_ak, module_cv, module_lce, module_org):
    """Create Org, Lifecycle Environment, Content View, Activation key"""
    setup_org_for_a_rh_repo({
        'product': PRDS['rhel'],
        'repository-set': REPOSET['rhst7'],
        'repository': REPOS['rhst7']['name'],
        'organization-id': module_org.id,
        'content-view-id': module_cv.id,
        'lifecycle-environment-id': module_lce.id,
        'activationkey-id': module_ak.id,
    })
    # Create custom repository content
    setup_org_for_a_custom_repo({
        'url': settings.repos.yum_1.url,
        'organization-id': module_org.id,
        'content-view-id': module_cv.id,
        'lifecycle-environment-id': module_lce.id,
        'activationkey-id': module_ak.id,
    })
    return {
        'ak': module_ak,
        'cv': module_cv,
        'lce': module_lce,
        'org': module_org,
    }
Пример #6
0
    def setUpClass(cls):
        """Create Org, Lifecycle Environment, Content View, Activation key

        """
        super(KatelloAgentTestCase, cls).setUpClass()
        # Create new org, environment, CV and activation key
        KatelloAgentTestCase.org = make_org()
        KatelloAgentTestCase.env = make_lifecycle_environment({
            u'organization-id': KatelloAgentTestCase.org['id'],
        })
        KatelloAgentTestCase.content_view = make_content_view({
            u'organization-id': KatelloAgentTestCase.org['id'],
        })
        KatelloAgentTestCase.activation_key = make_activation_key({
            u'lifecycle-environment-id': KatelloAgentTestCase.env['id'],
            u'organization-id': KatelloAgentTestCase.org['id'],
        })
        # Add subscription to Satellite Tools repo to activation key
        setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': KatelloAgentTestCase.org['id'],
            u'content-view-id': KatelloAgentTestCase.content_view['id'],
            u'lifecycle-environment-id': KatelloAgentTestCase.env['id'],
            u'activationkey-id': KatelloAgentTestCase.activation_key['id'],
        })
        # Create custom repo, add subscription to activation key
        setup_org_for_a_custom_repo({
            u'url': FAKE_0_YUM_REPO,
            u'organization-id': KatelloAgentTestCase.org['id'],
            u'content-view-id': KatelloAgentTestCase.content_view['id'],
            u'lifecycle-environment-id': KatelloAgentTestCase.env['id'],
            u'activationkey-id': KatelloAgentTestCase.activation_key['id'],
        })
Пример #7
0
 def setUpClass(cls):
     """Create Lifecycle Environment, Content View and Activation key
     """
     super(ContentHostTestCase, cls).setUpClass()
     cls.env = entities.LifecycleEnvironment(
         organization=cls.session_org).create()
     cls.content_view = entities.ContentView(
         organization=cls.session_org).create()
     cls.activation_key = entities.ActivationKey(
         environment=cls.env,
         organization=cls.session_org,
     ).create()
     setup_org_for_a_rh_repo({
         'product': PRDS['rhel'],
         'repository-set': REPOSET['rhst7'],
         'repository': REPOS['rhst7']['name'],
         'organization-id': cls.session_org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     })
     setup_org_for_a_custom_repo({
         'url': FAKE_6_YUM_REPO,
         'organization-id': cls.session_org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     })
Пример #8
0
    def test_positive_get_diff_for_cv_envs(self):
        """Generate a difference in errata between a set of environments
        for a content view

        :id: 96732506-4a89-408c-8d7e-f30c8d469769

        :Setup:

            1. Errata synced on satellite server.
            2. Multiple environments present.

        :Steps: GET /katello/api/compare

        :expectedresults: Difference in errata between a set of environments
            for a content view is retrieved.

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(environment=env,
                                                organization=org).create()
        setup_org_for_a_rh_repo(
            {
                'product': PRDS['rhel'],
                'repository-set': REPOSET['rhst7'],
                'repository': REPOS['rhst7']['name'],
                'organization-id': org.id,
                'content-view-id': content_view.id,
                'lifecycle-environment-id': env.id,
                'activationkey-id': activation_key.id,
            },
            force_use_cdn=True,
        )
        setup_org_for_a_custom_repo({
            'url': CUSTOM_REPO_URL,
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        new_env = entities.LifecycleEnvironment(organization=org,
                                                prior=env).create()
        cvvs = content_view.read().version[-2:]
        promote(cvvs[-1], new_env.id)
        result = entities.Errata().compare(
            data={
                'content_view_version_ids': [cvv.id for cvv in cvvs],
                'per_page': 9999
            })
        cvv2_only_errata = next(
            errata for errata in result['results']
            if errata['errata_id'] == CUSTOM_REPO_ERRATA_ID)
        self.assertEqual([cvvs[-1].id], cvv2_only_errata['comparison'])
        both_cvvs_errata = next(errata for errata in result['results']
                                if errata['errata_id'] == REAL_0_ERRATA_ID)
        self.assertEqual({cvv.id
                          for cvv in cvvs},
                         set(both_cvvs_errata['comparison']))
Пример #9
0
 def setUpClass(cls):
     """Create Lifecycle Environment, Content View and Activation key
     """
     super(ContentHostTestCase, cls).setUpClass()
     cls.env = entities.LifecycleEnvironment(
         organization=cls.session_org).create()
     cls.content_view = entities.ContentView(
         organization=cls.session_org).create()
     cls.activation_key = entities.ActivationKey(
         environment=cls.env,
         organization=cls.session_org,
     ).create()
     setup_org_for_a_rh_repo({
         'product': PRDS['rhel'],
         'repository-set': REPOSET['rhst7'],
         'repository': REPOS['rhst7']['name'],
         'organization-id': cls.session_org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     })
     setup_org_for_a_custom_repo({
         'url': FAKE_6_YUM_REPO,
         'organization-id': cls.session_org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     })
Пример #10
0
 def setUpClass(cls):
     """Set up single org with subscription to 1 RH and 1 custom products to
     reuse in tests
     """
     super(ErrataTestCase, cls).setUpClass()
     cls.env = entities.LifecycleEnvironment(
         organization=cls.session_org).create()
     cls.content_view = entities.ContentView(
         organization=cls.session_org).create()
     cls.activation_key = entities.ActivationKey(
         environment=cls.env,
         organization=cls.session_org,
     ).create()
     setup_org_for_a_rh_repo({
         'product': PRDS['rhel'],
         'repository-set': REPOSET['rhst7'],
         'repository': REPOS['rhst7']['name'],
         'organization-id': cls.session_org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     })
     cls.custom_entitites = setup_org_for_a_custom_repo({
         'url':
         CUSTOM_REPO_URL,
         'organization-id':
         cls.session_org.id,
         'content-view-id':
         cls.content_view.id,
         'lifecycle-environment-id':
         cls.env.id,
         'activationkey-id':
         cls.activation_key.id,
     })
Пример #11
0
 def setUpClass(cls):
     """Create Org, Lifecycle Environment, Content View, Activation key"""
     super(ErrataTestCase, cls).setUpClass()
     cls.org = entities.Organization().create()
     cls.env = entities.LifecycleEnvironment(
         organization=cls.org).create()
     cls.content_view = entities.ContentView(
         organization=cls.org).create()
     cls.activation_key = entities.ActivationKey(
         environment=cls.env,
         organization=cls.org,
     ).create()
     setup_org_for_a_rh_repo({
         'product': PRDS['rhel'],
         'repository-set': REPOSET['rhst7'],
         'repository': REPOS['rhst7']['name'],
         'organization-id': cls.org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     }, force_manifest_upload=True)
     cls.custom_entities = setup_org_for_a_custom_repo({
         'url': FAKE_9_YUM_REPO,
         'organization-id': cls.org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     })
Пример #12
0
 def setUpClass(cls):
     """Set up single org with subscription to 1 RH and 1 custom products to
     reuse in tests
     """
     super(ErrataTestCase, cls).setUpClass()
     cls.env = entities.LifecycleEnvironment(
         organization=cls.session_org).create()
     cls.content_view = entities.ContentView(
         organization=cls.session_org).create()
     cls.activation_key = entities.ActivationKey(
         environment=cls.env,
         organization=cls.session_org,
     ).create()
     setup_org_for_a_rh_repo({
         'product': PRDS['rhel'],
         'repository-set': REPOSET['rhst7'],
         'repository': REPOS['rhst7']['name'],
         'organization-id': cls.session_org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     })
     cls.custom_entitites = setup_org_for_a_custom_repo({
         'url': CUSTOM_REPO_URL,
         'organization-id': cls.session_org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     })
Пример #13
0
 def setUpClass(cls):
     """Create Org, Lifecycle Environment, Content View, Activation key"""
     super(ErrataTestCase, cls).setUpClass()
     cls.org = entities.Organization().create()
     cls.env = entities.LifecycleEnvironment(organization=cls.org).create()
     cls.content_view = entities.ContentView(organization=cls.org).create()
     cls.activation_key = entities.ActivationKey(
         environment=cls.env, organization=cls.org).create()
     setup_org_for_a_rh_repo(
         {
             'product': PRDS['rhel'],
             'repository-set': REPOSET['rhst7'],
             'repository': REPOS['rhst7']['name'],
             'organization-id': cls.org.id,
             'content-view-id': cls.content_view.id,
             'lifecycle-environment-id': cls.env.id,
             'activationkey-id': cls.activation_key.id,
         },
         force_manifest_upload=True,
     )
     cls.custom_entities = setup_org_for_a_custom_repo({
         'url':
         FAKE_9_YUM_REPO,
         'organization-id':
         cls.org.id,
         'content-view-id':
         cls.content_view.id,
         'lifecycle-environment-id':
         cls.env.id,
         'activationkey-id':
         cls.activation_key.id,
     })
Пример #14
0
    def test_positive_content_host_subscription_status(self):
        """Check if the Content Host Subscription Status is working in the
        Dashboard UI

        :id: ce0d7b0c-ae6a-4361-8173-e50f6381194a

        :Steps:

            1. Register Content Host and subscribe it
            2. Navigate Monitor -> Dashboard
            3. Review the Content Host Subscription Status
            4. Click each link:

                a. Invalid Subscriptions
                b. Partial Subscriptions
                c. Valid Subscriptions

        :expectedresults: The widget is updated with all details for Valid,
            Invalid and Partial Subscriptions

        :CaseLevel: Integration
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        # Using cdn repo as we need a rh repo (no matter are we in cdn or
        # downstream) for subscription status to be ok
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        }, force_use_cdn=True)
        with VirtualMachine(distro=DISTRO_RHEL7) as client:
            client.install_katello_ca()
            client.register_contenthost(
                org.label, activation_key.name)
            self.assertTrue(client.subscribed)
            client.enable_repo(REPOS['rhst7']['id'])
            client.install_katello_agent()
            with Session(self.browser) as session:
                set_context(session, org=org.name)
                self.assertTrue(self.dashboard.validate_chss_navigation(
                    'Invalid', u'subscription_status = invalid'))
                self.assertIsNotNone(self.dashboard.wait_until_element(
                    common_locators['kt_search_no_results']))
                self.assertTrue(self.dashboard.validate_chss_navigation(
                    'Partial', u'subscription_status = partial'))
                self.assertIsNotNone(self.dashboard.wait_until_element(
                    common_locators['kt_search_no_results']))
                self.assertTrue(self.dashboard.validate_chss_navigation(
                    'Valid', u'subscription_status = valid', client.hostname))
Пример #15
0
    def test_positive_content_host_subscription_status(self):
        """Check if the Content Host Subscription Status is working in the
        Dashboard UI

        :id: ce0d7b0c-ae6a-4361-8173-e50f6381194a

        :Steps:

            1. Register Content Host and subscribe it
            2. Navigate Monitor -> Dashboard
            3. Review the Content Host Subscription Status
            4. Click each link:

                a. Invalid Subscriptions
                b. Partial Subscriptions
                c. Valid Subscriptions

        :expectedresults: The widget is updated with all details for Valid,
            Invalid and Partial Subscriptions

        :CaseLevel: Integration
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': 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(
                org.label, activation_key.name)
            self.assertEqual(result.return_code, 0)
            client.enable_repo(REPOS['rhst7']['id'])
            client.install_katello_agent()
            with Session(self.browser) as session:
                set_context(session, org=org.name)
                self.assertTrue(self.dashboard.validate_chss_navigation(
                    'Invalid', u'subscription_status=invalid'))
                self.assertIsNotNone(self.dashboard.wait_until_element(
                    common_locators['kt_search_no_results']))
                self.assertTrue(self.dashboard.validate_chss_navigation(
                    'Partial', u'subscription_status=partial'))
                self.assertIsNotNone(self.dashboard.wait_until_element(
                    common_locators['kt_search_no_results']))
                self.assertTrue(self.dashboard.validate_chss_navigation(
                    'Valid', u'subscription_status=valid', client.hostname))
Пример #16
0
    def test_positive_filter_by_envs(self):
        """Filter applicable errata for a content host by current and
        Library environments

        :id: f41bfcc2-39ee-4ae1-a71f-d2c9288875be

        :Setup:

            1. Make sure multiple environments are present.
            2. One of Content host's previous environment has additional
               errata.

        :Steps: GET /katello/api/errata

        :expectedresults: The errata for the content host is filtered by
            current and Library environments.

        :CaseLevel: System

        :BZ: 1682940
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        new_cv = entities.ContentView(organization=org).create()
        new_repo = entities.Repository(
            product=entities.Product(organization=org).create(),
            url=CUSTOM_REPO_URL,
        ).create()
        self.assertEqual(new_repo.sync()['result'], 'success')
        new_cv = new_cv.read()
        new_cv.repository.append(new_repo)
        new_cv = new_cv.update(['repository'])
        new_cv.publish()
        library_env = entities.LifecycleEnvironment(
            name='Library',
            organization=org,
        ).search()[0]
        errata_library = entities.Errata(environment=library_env).search(
            query={'per_page': 1000})
        errata_env = entities.Errata(environment=env).search(
            query={'per_page': 1000})
        self.assertGreater(len(errata_library), len(errata_env))
Пример #17
0
    def test_positive_filter_by_envs(self):
        """Filter applicable errata for a content host by current and
        Library environments

        @id: f41bfcc2-39ee-4ae1-a71f-d2c9288875be

        @Setup:

        1. Make sure multiple environments are present.
        2. One of Content host's previous environment has additional errata.

        @Steps:

        1. GET /katello/api/errata

        @Assert: The errata for the content host is filtered by current and
        Library environments.

        @CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(
            organization=org).create()
        content_view = entities.ContentView(
            organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        new_cv = entities.ContentView(organization=org).create()
        new_repo = entities.Repository(
            product=entities.Product(organization=org).create(),
            url=CUSTOM_REPO_URL,
        ).create()
        self.assertEqual(new_repo.sync()['result'], 'success')
        new_cv = new_cv.read()
        new_cv.repository.append(new_repo)
        new_cv = new_cv.update(['repository'])
        new_cv.publish()
        library_env = entities.LifecycleEnvironment(
            name='Library',
            organization=org,
        ).search()[0]
        errata_library = entities.Errata(environment=library_env).search()
        errata_env = entities.Errata(environment=env).search()
        self.assertGreater(len(errata_library), len(errata_env))
Пример #18
0
    def setUp(self):
        """Create VM, subscribe it to satellite-tools repo, install katello-ca
        and katello-agent packages

        """
        super(TestCHKatelloAgent, self).setUp()

        # Create new org, environment, CV and activation key
        if TestCHKatelloAgent.org is None:
            TestCHKatelloAgent.org = make_org()
        if TestCHKatelloAgent.env is None:
            TestCHKatelloAgent.env = make_lifecycle_environment({
                u'organization-id': TestCHKatelloAgent.org['id'],
            })
        if TestCHKatelloAgent.cv is None:
            TestCHKatelloAgent.cv = make_content_view({
                u'organization-id': TestCHKatelloAgent.org['id'],
            })
        if TestCHKatelloAgent.activation_key is None:
            TestCHKatelloAgent.activation_key = make_activation_key({
                u'lifecycle-environment-id': TestCHKatelloAgent.env['id'],
                u'organization-id': TestCHKatelloAgent.org['id'],
            })
        # Add subscription to Satellite Tools repo to activation key
        if not TestCHKatelloAgent.org_is_set_up:
            setup_org_for_a_rh_repo({
                u'product': PRDS['rhel'],
                u'repository-set': REPOSET['rhst7'],
                u'repository': REPOS['rhst7']['name'],
                u'organization-id': TestCHKatelloAgent.org['id'],
                u'content-view-id': TestCHKatelloAgent.cv['id'],
                u'lifecycle-environment-id': TestCHKatelloAgent.env['id'],
                u'activationkey-id': TestCHKatelloAgent.activation_key['id'],
            })
            TestCHKatelloAgent.org_is_set_up = True

        # Create VM and register content host
        self.vm = VirtualMachine(distro='rhel71')
        self.vm.create()
        self.vm.install_katello_cert()
        # Create custom repo, add subscription to activation key
        setup_org_for_a_custom_repo({
            u'url': FAKE_0_YUM_REPO,
            u'organization-id': TestCHKatelloAgent.org['id'],
            u'content-view-id': TestCHKatelloAgent.cv['id'],
            u'lifecycle-environment-id': TestCHKatelloAgent.env['id'],
            u'activationkey-id': TestCHKatelloAgent.activation_key['id'],
        })
        # Register content host, install katello-agent
        self.vm.register_contenthost(
            TestCHKatelloAgent.activation_key['name'],
            TestCHKatelloAgent.org['label']
        )
        self.vm.enable_repo(REPOS['rhst7']['id'])
        self.vm.install_katello_agent()
Пример #19
0
def rh_repo(module_org, module_lce, module_cv, module_ak_cv_lce):
    """Add a subscription for the Satellite Tools repo to activation key."""
    setup_org_for_a_rh_repo(
        {
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': module_org.id,
            'content-view-id': module_cv.id,
            'lifecycle-environment-id': module_lce.id,
            'activationkey-id': module_ak_cv_lce.id,
        },
        force_manifest_upload=True,
    )
Пример #20
0
    def test_positive_add_redhat_product(self):
        """Test that RH product can be associated to Activation Keys

        :id: 7b15de8e-edde-41aa-937b-ad6aa529891a

        :expectedresults: RH products are successfully associated to Activation
            key

        :CaseLevel: System
        """
        org = make_org()
        # Using CDN as we need this repo to be RH one no matter are we in
        # downstream or cdn
        result = setup_org_for_a_rh_repo(
            {
                u'product': PRDS['rhel'],
                u'repository-set': REPOSET['rhst7'],
                u'repository': REPOS['rhst7']['name'],
                u'organization-id': org['id'],
            },
            force_use_cdn=True)
        content = ActivationKey.product_content({
            u'id':
            result['activationkey-id'],
            u'organization-id':
            org['id'],
        })
        self.assertEqual(content[0]['name'], REPOSET['rhst7'])
Пример #21
0
 def setUpClass(cls):
     """Set up single org with subscription to 1 RH and 1 custom products to
     reuse in tests
     """
     super(ErrataTestCase, cls).setUpClass()
     cls.env = entities.LifecycleEnvironment(
         organization=cls.session_org).create()
     cls.content_view = entities.ContentView(
         organization=cls.session_org).create()
     cls.activation_key = entities.ActivationKey(
         environment=cls.env,
         organization=cls.session_org,
     ).create()
     setup_org_for_a_rh_repo(
         {
             'product': PRDS['rhel'],
             'repository-set': REPOSET['rhst7'],
             'repository': REPOS['rhst7']['name'],
             'organization-id': cls.session_org.id,
             'content-view-id': cls.content_view.id,
             'lifecycle-environment-id': cls.env.id,
             'activationkey-id': cls.activation_key.id,
         },
         force_manifest_upload=True)
     cls.custom_entitites = setup_org_for_a_custom_repo({
         'url':
         CUSTOM_REPO_URL,
         'organization-id':
         cls.session_org.id,
         'content-view-id':
         cls.content_view.id,
         'lifecycle-environment-id':
         cls.env.id,
         'activationkey-id':
         cls.activation_key.id,
     })
     rhva_repo = enable_rhrepo_and_fetchid(
         basearch=DEFAULT_ARCHITECTURE,
         org_id=cls.session_org.id,
         product=PRDS['rhel'],
         repo=REPOS['rhva6']['name'],
         reposet=REPOSET['rhva6'],
         releasever=DEFAULT_RELEASE_VERSION,
     )
     assert entities.Repository(id=rhva_repo).sync()['result'] == 'success'
     cls.rhva_errata_id = REAL_4_ERRATA_ID
     cls.rhva_errata_cves = REAL_4_ERRATA_CVES
Пример #22
0
    def test_positive_re_register_host(self):
        """Re-register a host which was un-registered earlier from content-host

        @id: 898695dc-36ff-45b8-85be-6734e6a232d6

        @steps:
        1.  Re-register a host which was unregistered before
        2.  View host under content hosts
        3.  View host under 'All hosts'

        @assert: A single entry of host should appear at both places on
        re-registering

        @CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            vm.install_katello_ca()
            result = vm.register_contenthost(org.label, activation_key.name)
            self.assertEqual(result.return_code, 0)
            with Session(self.browser) as session:
                session.nav.go_to_select_org(org.name)
                self.contenthost.unregister(vm.hostname)
                self.contenthost.validate_subscription_status(
                    vm.hostname, False)
                result = vm.register_contenthost(org.label,
                                                 activation_key.name)
                self.assertEqual(result.return_code, 0)
                self.contenthost.validate_subscription_status(
                    vm.hostname, True)
                self.assertIsNotNone(self.contenthost.search(vm.hostname))
                self.assertIsNotNone(self.hosts.search(vm.hostname))
Пример #23
0
    def test_positive_re_register_host(self):
        """Re-register a host which was un-registered earlier from content-host

        @id: 898695dc-36ff-45b8-85be-6734e6a232d6

        @steps:
        1.  Re-register a host which was unregistered before
        2.  View host under content hosts
        3.  View host under 'All hosts'

        @assert: A single entry of host should appear at both places on
        re-registering

        @CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            vm.install_katello_ca()
            result = vm.register_contenthost(org.label, activation_key.name)
            self.assertEqual(result.return_code, 0)
            with Session(self.browser) as session:
                session.nav.go_to_select_org(org.name)
                self.contenthost.unregister(vm.hostname)
                self.contenthost.validate_subscription_status(
                    vm.hostname, False)
                result = vm.register_contenthost(
                    org.label, activation_key.name)
                self.assertEqual(result.return_code, 0)
                self.contenthost.validate_subscription_status(
                    vm.hostname, True)
                self.assertIsNotNone(self.contenthost.search(vm.hostname))
                self.assertIsNotNone(self.hosts.search(vm.hostname))
Пример #24
0
 def setUpClass(cls):
     """Create Org, Lifecycle Environment, Content View, Activation key"""
     super(HostCollectionPackageManagementTest, cls).setUpClass()
     cls.env = entities.LifecycleEnvironment(
         organization=cls.session_org).create()
     cls.content_view = entities.ContentView(
         organization=cls.session_org).create()
     cls.activation_key = entities.ActivationKey(
         environment=cls.env,
         organization=cls.session_org,
     ).create()
     rh_tools_content_data = setup_org_for_a_rh_repo({
         'product':
         PRDS['rhel'],
         'repository-set':
         REPOSET['rhst7'],
         'repository':
         REPOS['rhst7']['name'],
         'organization-id':
         cls.session_org.id,
         'content-view-id':
         cls.content_view.id,
         'lifecycle-environment-id':
         cls.env.id,
         'activationkey-id':
         cls.activation_key.id,
     })
     custom_content_data = [
         setup_org_for_a_custom_repo({
             'url':
             url,
             'organization-id':
             cls.session_org.id,
             'content-view-id':
             cls.content_view.id,
             'lifecycle-environment-id':
             cls.env.id,
             'activationkey-id':
             cls.activation_key.id,
         }) for url in [FAKE_1_YUM_REPO, FAKE_6_YUM_REPO]
     ]
     cls.rh_sat_tools_custom_product = None
     cls.rh_sat_tools_custom_repository = None
     if not settings.cdn and settings.sattools_repo['rhel7']:
         # RH sat tools repository was added as custom product and repo
         cls.rh_sat_tools_custom_product = entities.Product(
             id=rh_tools_content_data['product-id']).read()
         cls.rh_sat_tools_custom_repository = entities.Repository(
             id=rh_tools_content_data['repository-id']).read()
     cls.custom_products = [
         entities.Product(id=content_data['product-id']).read()
         for content_data in custom_content_data
     ]
     cls.custom_repositories = [
         entities.Repository(id=content_data['repository-id']).read()
         for content_data in custom_content_data
     ]
Пример #25
0
    def test_positive_unregister_content_host(self):
        """Unregister a host from content-hosts page

        :id: a7d8a081-b0f2-4944-a8dc-5527cb6ab914

        :steps:
            1.  Un-register a host from content-host page
            2.  View host under content hosts
            3.  View host under 'All hosts'

        :expectedresults: Hosts un-registered from content-host should appear
            in both sides of UI

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            vm.install_katello_ca()
            vm.register_contenthost(org.label, activation_key.name)
            self.assertTrue(vm.subscribed)
            with Session(self) as session:
                session.nav.go_to_select_org(org.name)
                self.contenthost.unregister(vm.hostname)
                self.contenthost.validate_subscription_status(
                    vm.hostname, False)
                self.assertIsNotNone(self.contenthost.search(vm.hostname))
                self.assertIsNotNone(self.hosts.search(vm.hostname))
Пример #26
0
    def test_positive_unregister_content_host(self):
        """Unregister a host from content-hosts page

        :id: a7d8a081-b0f2-4944-a8dc-5527cb6ab914

        :steps:
            1.  Un-register a host from content-host page
            2.  View host under content hosts
            3.  View host under 'All hosts'

        :expectedresults: Hosts un-registered from content-host should appear
            in both sides of UI

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            vm.install_katello_ca()
            vm.register_contenthost(org.label, activation_key.name)
            self.assertTrue(vm.subscribed)
            with Session(self) as session:
                session.nav.go_to_select_org(org.name)
                self.contenthost.unregister(vm.hostname)
                self.contenthost.validate_subscription_status(
                    vm.hostname, False)
                self.assertIsNotNone(self.contenthost.search(vm.hostname))
                self.assertIsNotNone(self.hosts.search(vm.hostname))
Пример #27
0
def setup_rhst_repo():
    """Prepare Satellite tools repository for usage in specified organization"""
    org = entities.Organization().create()
    cv = entities.ContentView(organization=org).create()
    lce = entities.LifecycleEnvironment(organization=org).create()
    ak = entities.ActivationKey(
        environment=lce,
        organization=org,
    ).create()
    repo_name = 'rhst7'
    setup_org_for_a_rh_repo({
        'product': PRDS['rhel'],
        'repository-set': REPOSET[repo_name],
        'repository': REPOS[repo_name]['name'],
        'organization-id': org.id,
        'content-view-id': cv.id,
        'lifecycle-environment-id': lce.id,
        'activationkey-id': ak.id,
    })
    return {'ak': ak, 'cv': cv, 'lce': lce, 'org': org, 'repo_name': repo_name}
Пример #28
0
 def setUpClass(cls):
     """Set up single org with subscription to 1 RH and 1 custom products to
     reuse in tests
     """
     super(ErrataTestCase, cls).setUpClass()
     cls.env = entities.LifecycleEnvironment(
         organization=cls.session_org).create()
     cls.content_view = entities.ContentView(
         organization=cls.session_org).create()
     cls.activation_key = entities.ActivationKey(
         environment=cls.env,
         organization=cls.session_org,
     ).create()
     setup_org_for_a_rh_repo({
         'product': PRDS['rhel'],
         'repository-set': REPOSET['rhst7'],
         'repository': REPOS['rhst7']['name'],
         'organization-id': cls.session_org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     }, force_manifest_upload=True)
     cls.custom_entitites = setup_org_for_a_custom_repo({
         'url': CUSTOM_REPO_URL,
         'organization-id': cls.session_org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     })
     rhva_repo = enable_rhrepo_and_fetchid(
         basearch=DEFAULT_ARCHITECTURE,
         org_id=cls.session_org.id,
         product=PRDS['rhel'],
         repo=REPOS['rhva6']['name'],
         reposet=REPOSET['rhva6'],
         releasever=DEFAULT_RELEASE_VERSION,
     )
     assert entities.Repository(id=rhva_repo).sync()['result'] == 'success'
     cls.rhva_errata_id = REAL_4_ERRATA_ID
     cls.rhva_errata_cves = REAL_4_ERRATA_CVES
Пример #29
0
    def test_positive_add_redhat_and_custom_products(self):
        """Test if RH/Custom product can be associated to Activation key

        :id: 74c77426-18f5-4abb-bca9-a2135f7fcc1f

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

        :BZ: 1426386
        """
        org = make_org()
        # Using CDN as we need this repo to be RH one no matter are we in
        # downstream or cdn
        result = setup_org_for_a_rh_repo(
            {
                u'product': PRDS['rhel'],
                u'repository-set': REPOSET['rhst7'],
                u'repository': REPOS['rhst7']['name'],
                u'organization-id': org['id'],
            },
            force_use_cdn=True)
        result = setup_org_for_a_custom_repo({
            u'url':
            FAKE_0_YUM_REPO,
            u'organization-id':
            org['id'],
            u'activationkey-id':
            result['activationkey-id'],
            u'content-view-id':
            result['content-view-id'],
            u'lifecycle-environment-id':
            result['lifecycle-environment-id'],
        })
        repo = Repository.info({u'id': result['repository-id']})
        content = ActivationKey.product_content({
            u'id':
            result['activationkey-id'],
            u'organization-id':
            org['id'],
        })
        self.assertEqual(len(content), 2)
        self.assertEqual({REPOSET['rhst7'], repo['name']},
                         {pc['name']
                          for pc in content})
Пример #30
0
def rh_repo(module_org, module_lce, module_cv, activation_key):
    return setup_org_for_a_rh_repo(
        {
            'product': constants.PRDS['rhel'],
            'repository-set': constants.REPOSET['rhst7'],
            'repository': constants.REPOS['rhst7']['name'],
            'organization-id': module_org.id,
            'content-view-id': module_cv.id,
            'lifecycle-environment-id': module_lce.id,
            'activationkey-id': activation_key.id,
        },
        force_manifest_upload=True,
    )
Пример #31
0
    def test_positive_delete_content_host(self):
        """Unregister and delete a host from content-hosts page

        @id: 3c75c1e6-85e3-49e6-a10e-6052a0db2b7f

        @steps:
        1.  Un-register and delete a host from content-host page
        2.  View host under content hosts
        3.  View host under 'All hosts'

        @assert: Hosts un-registered from content-host should disappear from
        both sides of UI

        @CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            vm.install_katello_ca()
            result = vm.register_contenthost(org.label, activation_key.name)
            self.assertEqual(result.return_code, 0)
            with Session(self.browser) as session:
                session.nav.go_to_select_org(org.name)
                self.contenthost.delete(vm.hostname)
                self.assertIsNone(self.hosts.search(vm.hostname))
Пример #32
0
    def test_positive_delete_content_host(self):
        """Unregister and delete a host from content-hosts page

        @id: 3c75c1e6-85e3-49e6-a10e-6052a0db2b7f

        @steps:
        1.  Un-register and delete a host from content-host page
        2.  View host under content hosts
        3.  View host under 'All hosts'

        @assert: Hosts un-registered from content-host should disappear from
        both sides of UI

        @CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            vm.install_katello_ca()
            result = vm.register_contenthost(org.label, activation_key.name)
            self.assertEqual(result.return_code, 0)
            with Session(self.browser) as session:
                session.nav.go_to_select_org(org.name)
                self.contenthost.delete(vm.hostname)
                self.assertIsNone(self.hosts.search(vm.hostname))
Пример #33
0
    def test_positive_register_host_via_ak(self):
        """Register a pre-installed host via rhsm using activation-key

        :id: b42a1a13-49ef-418e-bb66-12ed71cf3038

        :steps:
            1.  Register a host via rhsm using activation-key
            2.  View host under content hosts
            3.  View host under 'All Hosts'

        :expectedresults: Hosts registered via activation key appears under
            'All hosts' as well as under content-hosts

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            vm.install_katello_ca()
            vm.register_contenthost(org.label, activation_key.name)
            self.assertTrue(vm.subscribed)
            with Session(self) as session:
                session.nav.go_to_select_org(org.name)
                self.assertIsNotNone(self.hosts.search(vm.hostname))
                self.assertIsNotNone(self.contenthost.search(vm.hostname))
Пример #34
0
    def test_positive_register_host_via_ak(self):
        """Register a pre-installed host via rhsm using activation-key

        :id: b42a1a13-49ef-418e-bb66-12ed71cf3038

        :steps:
            1.  Register a host via rhsm using activation-key
            2.  View host under content hosts
            3.  View host under 'All Hosts'

        :expectedresults: Hosts registered via activation key appears under
            'All hosts' as well as under content-hosts

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            vm.install_katello_ca()
            vm.register_contenthost(org.label, activation_key.name)
            self.assertTrue(vm.subscribed)
            with Session(self) as session:
                session.nav.go_to_select_org(org.name)
                self.assertIsNotNone(self.hosts.search(vm.hostname))
                self.assertIsNotNone(self.contenthost.search(vm.hostname))
Пример #35
0
    def setUpClass(cls):
        """Create Org, Lifecycle Environment, Content View, Activation key

        """
        super(KatelloAgentTestCase, cls).setUpClass()
        # Create new org, environment, CV and activation key
        KatelloAgentTestCase.org = make_org()
        KatelloAgentTestCase.env = make_lifecycle_environment({u"organization-id": KatelloAgentTestCase.org["id"]})
        KatelloAgentTestCase.content_view = make_content_view({u"organization-id": KatelloAgentTestCase.org["id"]})
        KatelloAgentTestCase.activation_key = make_activation_key(
            {
                u"lifecycle-environment-id": KatelloAgentTestCase.env["id"],
                u"organization-id": KatelloAgentTestCase.org["id"],
            }
        )
        # Add subscription to Satellite Tools repo to activation key
        setup_org_for_a_rh_repo(
            {
                u"product": PRDS["rhel"],
                u"repository-set": REPOSET["rhst7"],
                u"repository": REPOS["rhst7"]["name"],
                u"organization-id": KatelloAgentTestCase.org["id"],
                u"content-view-id": KatelloAgentTestCase.content_view["id"],
                u"lifecycle-environment-id": KatelloAgentTestCase.env["id"],
                u"activationkey-id": KatelloAgentTestCase.activation_key["id"],
            }
        )
        # Create custom repo, add subscription to activation key
        setup_org_for_a_custom_repo(
            {
                u"url": FAKE_0_YUM_REPO,
                u"organization-id": KatelloAgentTestCase.org["id"],
                u"content-view-id": KatelloAgentTestCase.content_view["id"],
                u"lifecycle-environment-id": KatelloAgentTestCase.env["id"],
                u"activationkey-id": KatelloAgentTestCase.activation_key["id"],
            }
        )
Пример #36
0
def test_positive_filter_by_cve(module_org, default_sat):
    """Filter errata by CVE

    :id: a921d4c2-8d3d-4462-ba6c-fbd4b898a3f2

    :Setup: Errata synced on satellite server.

    :Steps: GET /katello/api/errata

    :expectedresults: Errata is filtered by CVE.

    :CaseLevel: System
    """
    repo = default_sat.api.Repository(
        name=constants.REPOS['rhva6']['name']).search(
            query={'organization_id': module_org.id})
    if repo:
        repo = repo[0]
    else:
        result = setup_org_for_a_rh_repo({
            'product':
            constants.PRDS['rhel'],
            'repository-set':
            constants.REPOSET['rhva6'],
            'repository':
            constants.REPOS['rhva6']['name'],
            'organization-id':
            module_org.id,
            'releasever':
            constants.DEFAULT_RELEASE_VERSION,
            'basearch':
            constants.DEFAULT_ARCHITECTURE,
        })
        repo = default_sat.api.Repository(id=result['repository-id'])
    assert repo.sync()['result'] == 'success'
    erratum_list = default_sat.api.Errata(repository=repo).search(
        query={
            'order': 'cve DESC',
            'per_page': '1000'
        })
    # Most of Errata don't have any CVEs. Removing empty CVEs from results
    erratum_cves = [errata.cves for errata in erratum_list if errata.cves]
    # Verifying each errata have its CVEs sorted in DESC order
    for errata_cves in erratum_cves:
        cve_ids = [cve['cve_id'] for cve in errata_cves]
        assert cve_ids == sorted(cve_ids, reverse=True)
Пример #37
0
 def setUpClass(cls):
     """Create Org, Lifecycle Environment, Content View, Activation key"""
     super(HostCollectionPackageManagementTest, cls).setUpClass()
     cls.env = entities.LifecycleEnvironment(
         organization=cls.session_org).create()
     cls.content_view = entities.ContentView(
         organization=cls.session_org).create()
     cls.activation_key = entities.ActivationKey(
         environment=cls.env,
         organization=cls.session_org,
     ).create()
     rh_tools_content_data = setup_org_for_a_rh_repo({
         'product': PRDS['rhel'],
         'repository-set': REPOSET['rhst7'],
         'repository': REPOS['rhst7']['name'],
         'organization-id': cls.session_org.id,
         'content-view-id': cls.content_view.id,
         'lifecycle-environment-id': cls.env.id,
         'activationkey-id': cls.activation_key.id,
     })
     custom_content_data = [
         setup_org_for_a_custom_repo({
             'url': url,
             'organization-id': cls.session_org.id,
             'content-view-id': cls.content_view.id,
             'lifecycle-environment-id': cls.env.id,
             'activationkey-id': cls.activation_key.id,
         }) for url in [FAKE_1_YUM_REPO, FAKE_6_YUM_REPO]
     ]
     cls.rh_sat_tools_custom_product = None
     cls.rh_sat_tools_custom_repository = None
     if not settings.cdn and settings.sattools_repo['rhel7']:
         # RH sat tools repository was added as custom product and repo
         cls.rh_sat_tools_custom_product = entities.Product(
             id=rh_tools_content_data['product-id']).read()
         cls.rh_sat_tools_custom_repository = entities.Repository(
             id=rh_tools_content_data['repository-id']).read()
     cls.custom_products = [
         entities.Product(id=content_data['product-id']).read()
         for content_data in custom_content_data
     ]
     cls.custom_repositories = [
         entities.Repository(id=content_data['repository-id']).read()
         for content_data in custom_content_data
     ]
Пример #38
0
    def test_positive_add_redhat_product(self):
        """Test that RH product can be associated to Activation Keys

        @Feature: Activation key - Product

        @BZ: 1293585

        @Assert: RH products are successfully associated to Activation key
        """
        result = setup_org_for_a_rh_repo(
            {
                u"product": PRDS["rhel"],
                u"repository-set": REPOSET["rhst7"],
                u"repository": REPOS["rhst7"]["name"],
                u"organization-id": self.org["id"],
            }
        )
        content = ActivationKey.product_content({u"id": result["activationkey-id"], u"organization-id": self.org["id"]})
        self.assertEqual(content[0]["name"], REPOSET["rhst7"])
Пример #39
0
def test_positive_sort_by_issued_date(module_org):
    """Filter errata by issued date

    :id: 6b4a783a-a7b4-4af4-b9e6-eb2928b7f7c1

    :Setup: Errata synced on satellite server.

    :Steps: GET /katello/api/errata

    :expectedresults: Errata is sorted by issued date.

    :CaseLevel: System
    """
    repo = entities.Repository(name=constants.REPOS['rhva6']['name']).search(
        query={'organization_id': module_org.id})
    if repo:
        repo = repo[0]
    else:
        result = setup_org_for_a_rh_repo({
            'product':
            constants.PRDS['rhel'],
            'repository-set':
            constants.REPOSET['rhva6'],
            'repository':
            constants.REPOS['rhva6']['name'],
            'organization-id':
            module_org.id,
            'releasever':
            constants.DEFAULT_RELEASE_VERSION,
            'basearch':
            constants.DEFAULT_ARCHITECTURE,
            # 'content-view-id': content_view.id,
            # 'lifecycle-environment-id': env.id,
            # 'activationkey-id': activation_key.id,
        })
        repo = entities.Repository(id=result['repository-id'])
    assert repo.sync()['result'] == 'success'
    erratum_list = entities.Errata(repository=repo).search(query={
        'order': 'issued ASC',
        'per_page': '1000'
    })
    issued = [errata.issued for errata in erratum_list]
    assert issued == sorted(issued)
Пример #40
0
def test_positive_list_updated(module_org, default_sat):
    """View all errata in an Org sorted by Updated

    :id: 560d6584-70bd-4d1b-993a-cc7665a9e600

    :Setup: Errata synced on satellite server.

    :Steps: GET /katello/api/errata

    :expectedresults: Errata is filtered by Org and sorted by Updated date.

    :CaseLevel: System
    """
    repo = default_sat.api.Repository(
        name=constants.REPOS['rhva6']['name']).search(
            query={'organization_id': module_org.id})
    if repo:
        repo = repo[0]
    else:
        result = setup_org_for_a_rh_repo({
            'product':
            constants.PRDS['rhel'],
            'repository-set':
            constants.REPOSET['rhva6'],
            'repository':
            constants.REPOS['rhva6']['name'],
            'organization-id':
            module_org.id,
            'releasever':
            constants.DEFAULT_RELEASE_VERSION,
            'basearch':
            constants.DEFAULT_ARCHITECTURE,
        })
        repo = default_sat.api.Repository(id=result['repository-id'])
    assert repo.sync()['result'] == 'success'
    erratum_list = default_sat.api.Errata(repository=repo).search(
        query={
            'order': 'updated ASC',
            'per_page': '1000'
        })
    updated = [errata.updated for errata in erratum_list]
    assert updated == sorted(updated)
Пример #41
0
    def test_positive_add_redhat_and_custom_products(self):
        """Test if RH/Custom product can be associated to Activation key

        :id: 74c77426-18f5-4abb-bca9-a2135f7fcc1f

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

        :BZ: 1426386
        """
        org = make_org()
        # Using CDN as we need this repo to be RH one no matter are we in
        # downstream or cdn
        result = setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': org['id'],
        }, force_use_cdn=True)
        result = setup_org_for_a_custom_repo({
            u'url': FAKE_0_YUM_REPO,
            u'organization-id': org['id'],
            u'activationkey-id': result['activationkey-id'],
            u'content-view-id': result['content-view-id'],
            u'lifecycle-environment-id': result['lifecycle-environment-id'],
        })
        repo = Repository.info({u'id': result['repository-id']})
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': org['id'],
        })
        self.assertEqual(len(content), 2)
        self.assertEqual(
            {REPOSET['rhst7'], repo['name']}, {pc['name'] for pc in content})
Пример #42
0
    def test_positive_add_redhat_product(self):
        """Test that RH product can be associated to Activation Keys

        @id: 7b15de8e-edde-41aa-937b-ad6aa529891a

        @Assert: RH products are successfully associated to Activation key

        @CaseLevel: System
        """
        result = setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': self.org['id'],
        })
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': self.org['id'],
        })
        self.assertEqual(content[0]['name'], REPOSET['rhst7'])
    def test_positive_add_redhat_product(self):
        """Test that RH product can be associated to Activation Keys

        @Feature: Activation key - Product

        @BZ: 1293585

        @Assert: RH products are successfully associated to Activation key
        """
        result = setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': self.org['id'],
        })
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': self.org['id'],
        })
        self.assertEqual(content[0]['name'], REPOSET['rhst7'])
Пример #44
0
    def test_positive_add_redhat_product(self):
        """@Test: Test that RH product can be associated to Activation Keys

        @Feature: Activation key - Product

        @BZ: 1293585

        @Assert: RH products are successfully associated to Activation key
        """
        result = setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': self.org['id'],
        })
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': self.org['id'],
        })
        self.assertEqual(content[0]['name'], REPOSET['rhst7'])
Пример #45
0
    def test_positive_add_redhat_product(self):
        """Test that RH product can be associated to Activation Keys

        @id: 7b15de8e-edde-41aa-937b-ad6aa529891a

        @Assert: RH products are successfully associated to Activation key

        @CaseLevel: System
        """
        org = make_org()
        result = setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': org['id'],
        })
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': org['id'],
        })
        self.assertEqual(content[0]['name'], REPOSET['rhst7'])
Пример #46
0
    def test_positive_add_redhat_and_custom_products(self):
        """Test if RH/Custom product can be associated to Activation key

        @Feature: Activation key - Product

        @Steps:

        1. Create Activation key
        2. Associate RH product(s) to Activation Key
        3. Associate custom product(s) to Activation Key

        @BZ: 1293585

        @Assert: RH/Custom product is successfully associated to Activation key
        """
        result = setup_org_for_a_rh_repo(
            {
                u"product": PRDS["rhel"],
                u"repository-set": REPOSET["rhst7"],
                u"repository": REPOS["rhst7"]["name"],
                u"organization-id": self.org["id"],
            }
        )
        result = setup_org_for_a_custom_repo(
            {
                u"url": FAKE_0_YUM_REPO,
                u"organization-id": self.org["id"],
                u"activationkey-id": result["activationkey-id"],
                u"content-view-id": result["content-view-id"],
                u"lifecycle-environment-id": result["lifecycle-environment-id"],
            }
        )
        repo = Repository.info({u"id": result["repository-id"]})
        content = ActivationKey.product_content({u"id": result["activationkey-id"], u"organization-id": self.org["id"]})
        self.assertEqual(len(content), 2)
        self.assertEqual(content[0]["name"], REPOSET["rhst7"])
        self.assertEqual(content[1]["name"], repo["name"])
Пример #47
0
    def test_positive_add_redhat_and_custom_products(self):
        """Test if RH/Custom product can be associated to Activation key

        @id: 74c77426-18f5-4abb-bca9-a2135f7fcc1f

        @Steps:

        1. Create Activation key
        2. Associate RH product(s) to Activation Key
        3. Associate custom product(s) to Activation Key

        @Assert: RH/Custom product is successfully associated to Activation key

        @CaseLevel: System
        """
        org = make_org()
        result = setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': org['id'],
        })
        result = setup_org_for_a_custom_repo({
            u'url': FAKE_0_YUM_REPO,
            u'organization-id': org['id'],
            u'activationkey-id': result['activationkey-id'],
            u'content-view-id': result['content-view-id'],
            u'lifecycle-environment-id': result['lifecycle-environment-id'],
        })
        repo = Repository.info({u'id': result['repository-id']})
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': org['id'],
        })
        self.assertEqual(len(content), 2)
        self.assertEqual(
            {REPOSET['rhst7'], repo['name']}, {pc['name'] for pc in content})
Пример #48
0
    def test_positive_add_redhat_product(self):
        """Test that RH product can be associated to Activation Keys

        :id: 7b15de8e-edde-41aa-937b-ad6aa529891a

        :expectedresults: RH products are successfully associated to Activation
            key

        :CaseLevel: System
        """
        org = make_org()
        # Using CDN as we need this repo to be RH one no matter are we in
        # downstream or cdn
        result = setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': org['id'],
        }, force_use_cdn=True)
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': org['id'],
        })
        self.assertEqual(content[0]['name'], REPOSET['rhst7'])
Пример #49
0
    def test_positive_add_redhat_and_custom_products(self):
        """@Test: Test if RH/Custom product can be associated to Activation key

        @Feature: Activation key - Product

        @Steps:

        1. Create Activation key
        2. Associate RH product(s) to Activation Key
        3. Associate custom product(s) to Activation Key

        @BZ: 1293585

        @Assert: RH/Custom product is successfully associated to Activation key
        """
        result = setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': self.org['id'],
        })
        result = setup_org_for_a_custom_repo({
            u'url': FAKE_0_YUM_REPO,
            u'organization-id': self.org['id'],
            u'activationkey-id': result['activationkey-id'],
            u'content-view-id': result['content-view-id'],
            u'lifecycle-environment-id': result['lifecycle-environment-id'],
        })
        repo = Repository.info({u'id': result['repository-id']})
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': self.org['id'],
        })
        self.assertEqual(len(content), 2)
        self.assertEqual(content[0]['name'], REPOSET['rhst7'])
        self.assertEqual(content[1]['name'], repo['name'])
    def test_positive_add_redhat_and_custom_products(self):
        """Test if RH/Custom product can be associated to Activation key

        @Feature: Activation key - Product

        @Steps:

        1. Create Activation key
        2. Associate RH product(s) to Activation Key
        3. Associate custom product(s) to Activation Key

        @BZ: 1293585

        @Assert: RH/Custom product is successfully associated to Activation key
        """
        result = setup_org_for_a_rh_repo({
            u'product': PRDS['rhel'],
            u'repository-set': REPOSET['rhst7'],
            u'repository': REPOS['rhst7']['name'],
            u'organization-id': self.org['id'],
        })
        result = setup_org_for_a_custom_repo({
            u'url': FAKE_0_YUM_REPO,
            u'organization-id': self.org['id'],
            u'activationkey-id': result['activationkey-id'],
            u'content-view-id': result['content-view-id'],
            u'lifecycle-environment-id': result['lifecycle-environment-id'],
        })
        repo = Repository.info({u'id': result['repository-id']})
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': self.org['id'],
        })
        self.assertEqual(len(content), 2)
        self.assertEqual(content[0]['name'], REPOSET['rhst7'])
        self.assertEqual(content[1]['name'], repo['name'])
Пример #51
0
    def test_positive_show_count_on_chost_details_page(self):
        """Errata count on Content host Details page

        :id: 388229da-2b0b-41aa-a457-9b5ecbf3df4b

        :Setup:

            1. Errata synced on satellite server.
            2. Some content hosts are present.

        :Steps: Go to Hosts -> Content Hosts -> Select Content Host -> Details
            page.

        :expectedresults:

            1. The errata section should be displayed with Security, Bugfix,
                Enhancement types.
            2. The number should link to the errata details page, filtered  by
                type.

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(
            organization=org).create()
        content_view = entities.ContentView(
            organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst6'],
            'repository': REPOS['rhst6']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        }, force_use_cdn=True)
        setup_org_for_a_custom_repo({
            'url': CUSTOM_REPO_URL,
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        RepositorySet.enable({
            'basearch': DEFAULT_ARCHITECTURE,
            'name': REPOSET['rhva6'],
            'organization-id': org.id,
            'product': PRDS['rhel'],
            'releasever': DEFAULT_RELEASE_VERSION,
        })
        rhel_repo = Repository.info({
            'name': REPOS['rhva6']['name'],
            'organization-id': org.id,
            'product': PRDS['rhel'],
        })
        Repository.synchronize({
            'name': REPOS['rhva6']['name'],
            'organization-id': org.id,
            'product': PRDS['rhel'],
        })
        ContentView.add_repository({
            'id': content_view.id,
            'organization-id': org.id,
            'repository-id': rhel_repo['id'],
        })
        ContentView.publish({'id': content_view.id})
        cvv = ContentView.info({'id': content_view.id})['versions'][-1]
        ContentView.version_promote({
            'id': cvv['id'],
            'organization-id': org.id,
            'to-lifecycle-environment-id': env.id,
        })
        with VirtualMachine(distro=DISTRO_RHEL6) as client:
            client.install_katello_ca()
            client.register_contenthost(org.label, activation_key.name)
            self.assertTrue(client.subscribed)
            client.enable_repo(REPOS['rhst6']['id'])
            client.enable_repo(REPOS['rhva6']['id'])
            client.install_katello_agent()
            with Session(self) as session:
                session.nav.go_to_select_org(org.name)
                result = self.contenthost.fetch_errata_counts(
                    client.hostname, details_page=True)
                for errata in ('security', 'bug_fix', 'enhancement'):
                    self.assertEqual(result[errata]['value'], 0)
                if bz_bug_is_open(1484044):
                    self.assertNotIn(
                        result['security']['color'], ('red', 'yellow'))
                else:
                    self.assertEqual(result['security']['color'], 'black')
                client.run(
                    'yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE))
                result = self.contenthost.fetch_errata_counts(
                    client.hostname, details_page=True)
                self.assertEqual(result['security']['value'], 1)
                self.assertEqual(result['security']['color'], 'red')
                client.run('yum install -y {0}'.format(REAL_0_RH_PACKAGE))
                result = self.contenthost.fetch_errata_counts(
                    client.hostname, details_page=True)
                for errata in ('bug_fix', 'enhancement'):
                    self.assertEqual(result[errata]['value'], 1)
                    self.assertEqual(result[errata]['color'], 'yellow')
Пример #52
0
    def test_positive_get_applicable_for_host(self):
        """Get applicable errata ids for a host

        :id: 51d44d51-eb3f-4ee4-a1df-869629d427ac

        :Setup:
            1. Errata synced on satellite server.
            2. Some Content hosts present.

        :Steps: GET /api/v2/hosts/:id/errata

        :expectedresults: The available errata is retrieved.

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(environment=env,
                                                organization=org).create()
        setup_org_for_a_rh_repo(
            {
                'product': PRDS['rhel'],
                'repository-set': REPOSET['rhst6'],
                'repository': REPOS['rhst6']['name'],
                'organization-id': org.id,
                'content-view-id': content_view.id,
                'lifecycle-environment-id': env.id,
                'activationkey-id': activation_key.id,
            },
            force_manifest_upload=True,
        )
        setup_org_for_a_custom_repo({
            'url': CUSTOM_REPO_URL,
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        repo_id = enable_rhrepo_and_fetchid(
            basearch=DEFAULT_ARCHITECTURE,
            org_id=org.id,
            product=PRDS['rhel'],
            repo=REPOS['rhva6']['name'],
            reposet=REPOSET['rhva6'],
            releasever=DEFAULT_RELEASE_VERSION,
        )
        repo = entities.Repository(id=repo_id)
        self.assertEqual(repo.sync()['result'], 'success')
        content_view = content_view.read()
        content_view.repository.append(repo)
        content_view = content_view.update(['repository'])
        content_view.publish()
        versions = sorted(content_view.read().version, key=lambda ver: ver.id)
        cvv = versions[-1].read()
        promote(cvv, env.id)
        with VirtualMachine(distro=DISTRO_RHEL6) as client:
            client.install_katello_ca()
            client.register_contenthost(org.label, activation_key.name)
            self.assertTrue(client.subscribed)
            client.enable_repo(REPOS['rhst6']['id'])
            client.enable_repo(REPOS['rhva6']['id'])
            client.install_katello_agent()
            host = (entities.Host().search(
                query={'search': 'name={0}'.format(client.hostname)})
                    [0].read())
            erratum = self._fetch_available_errata(host, 0)
            self.assertEqual(len(erratum), 0)
            client.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE))
            erratum = self._fetch_available_errata(host, 1)
            self.assertEqual(len(erratum), 1)
            self.assertIn(CUSTOM_REPO_ERRATA_ID,
                          [errata['errata_id'] for errata in erratum])
            client.run('yum install -y {0}'.format(REAL_0_RH_PACKAGE))
            erratum = self._fetch_available_errata(host, 3)
            self.assertEqual(len(erratum), 3)
            self.assertTrue({REAL_1_ERRATA_ID, REAL_2_ERRATA_ID}.issubset(
                {errata['errata_id']
                 for errata in erratum}))
Пример #53
0
    def test_positive_get_count_for_host(self):
        """Available errata count when retrieving Host

        :id: 2f35933f-8026-414e-8f75-7f4ec048faae

        :Setup:

            1. Errata synced on satellite server.
            2. Some Content hosts present.

        :Steps: GET /api/v2/hosts

        :expectedresults: The available errata count is retrieved.

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(environment=env,
                                                organization=org).create()
        setup_org_for_a_rh_repo(
            {
                'product': PRDS['rhel'],
                'repository-set': REPOSET['rhst6'],
                'repository': REPOS['rhst6']['name'],
                'organization-id': org.id,
                'content-view-id': content_view.id,
                'lifecycle-environment-id': env.id,
                'activationkey-id': activation_key.id,
            },
            force_manifest_upload=True,
        )
        setup_org_for_a_custom_repo({
            'url': CUSTOM_REPO_URL,
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        repo_id = enable_rhrepo_and_fetchid(
            basearch=DEFAULT_ARCHITECTURE,
            org_id=org.id,
            product=PRDS['rhel'],
            repo=REPOS['rhva6']['name'],
            reposet=REPOSET['rhva6'],
            releasever=DEFAULT_RELEASE_VERSION,
        )
        repo = entities.Repository(id=repo_id)
        self.assertEqual(repo.sync()['result'], 'success')
        content_view = content_view.read()
        content_view.repository.append(repo)
        content_view = content_view.update(['repository'])
        content_view.publish()
        versions = sorted(content_view.read().version, key=lambda ver: ver.id)
        cvv = versions[-1].read()
        promote(cvv, env.id)
        with VirtualMachine(distro=DISTRO_RHEL6) as client:
            client.install_katello_ca()
            client.register_contenthost(org.label, activation_key.name)
            self.assertTrue(client.subscribed)
            client.enable_repo(REPOS['rhst6']['id'])
            client.enable_repo(REPOS['rhva6']['id'])
            client.install_katello_agent()
            host = (entities.Host().search(
                query={'search': 'name={0}'.format(client.hostname)})
                    [0].read())
            for errata in ('security', 'bugfix', 'enhancement'):
                self._validate_errata_counts(host, errata, 0)
            client.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE))
            self._validate_errata_counts(host, 'security', 1)
            client.run('yum install -y {0}'.format(REAL_0_RH_PACKAGE))
            for errata in ('bugfix', 'enhancement'):
                self._validate_errata_counts(host, errata, 1)
Пример #54
0
    def test_positive_get_diff_for_cv_envs(self):
        """Generate a difference in errata between a set of environments
        for a content view

        :id: 96732506-4a89-408c-8d7e-f30c8d469769

        :Setup:

            1. Errata synced on satellite server.
            2. Multiple environments present.

        :Steps: GET /katello/api/compare

        :expectedresults: Difference in errata between a set of environments
            for a content view is retrieved.

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(
            organization=org).create()
        content_view = entities.ContentView(
            organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        }, force_use_cdn=True)
        setup_org_for_a_custom_repo({
            'url': CUSTOM_REPO_URL,
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        new_env = entities.LifecycleEnvironment(
            organization=org,
            prior=env,
        ).create()
        cvvs = content_view.read().version[-2:]
        promote(cvvs[-1], new_env.id)
        result = entities.Errata().compare(data={
            'content_view_version_ids': [cvv.id for cvv in cvvs],
            'per_page': 9999,
        })
        cvv2_only_errata = next(
            errata for errata in result['results']
            if errata['errata_id'] == CUSTOM_REPO_ERRATA_ID
        )
        self.assertEqual([cvvs[-1].id], cvv2_only_errata['comparison'])
        both_cvvs_errata = next(
            errata for errata in result['results']
            if errata['errata_id'] == REAL_0_ERRATA_ID
        )
        self.assertEqual(
            set(cvv.id for cvv in cvvs), set(both_cvvs_errata['comparison']))
Пример #55
0
    def test_positive_get_applicable_for_host(self):
        """Get applicable errata ids for a host

        :id: 51d44d51-eb3f-4ee4-a1df-869629d427ac

        :Setup:
            1. Errata synced on satellite server.
            2. Some Content hosts present.

        :Steps: GET /api/v2/hosts/:id/errata

        :expectedresults: The available errata is retrieved.

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(
            organization=org).create()
        content_view = entities.ContentView(
            organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst6'],
            'repository': REPOS['rhst6']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        }, force_manifest_upload=True)
        setup_org_for_a_custom_repo({
            'url': CUSTOM_REPO_URL,
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        repo_id = enable_rhrepo_and_fetchid(
            basearch=DEFAULT_ARCHITECTURE,
            org_id=org.id,
            product=PRDS['rhel'],
            repo=REPOS['rhva6']['name'],
            reposet=REPOSET['rhva6'],
            releasever=DEFAULT_RELEASE_VERSION,
        )
        repo = entities.Repository(id=repo_id)
        self.assertEqual(repo.sync()['result'], 'success')
        content_view = content_view.read()
        content_view.repository.append(repo)
        content_view = content_view.update(['repository'])
        content_view.publish()
        versions = sorted(content_view.read().version, key=lambda ver: ver.id)
        cvv = versions[-1].read()
        promote(cvv, env.id)
        with VirtualMachine(distro=DISTRO_RHEL6) as client:
            client.install_katello_ca()
            client.register_contenthost(org.label, activation_key.name)
            self.assertTrue(client.subscribed)
            client.enable_repo(REPOS['rhst6']['id'])
            client.enable_repo(REPOS['rhva6']['id'])
            client.install_katello_agent()
            host = entities.Host().search(query={
                'search': 'name={0}'.format(client.hostname)})[0].read()
            erratum = self._fetch_available_errata(host, 0)
            self.assertEqual(len(erratum), 0)
            client.run(
                'yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE))
            erratum = self._fetch_available_errata(host, 1)
            self.assertEqual(len(erratum), 1)
            self.assertIn(
                CUSTOM_REPO_ERRATA_ID,
                [errata['errata_id'] for errata in erratum],
            )
            client.run('yum install -y {0}'.format(REAL_0_RH_PACKAGE))
            erratum = self._fetch_available_errata(host, 3)
            self.assertEqual(len(erratum), 3)
            self.assertTrue(
                {REAL_1_ERRATA_ID, REAL_2_ERRATA_ID}.issubset(
                    {errata['errata_id'] for errata in erratum})
            )
Пример #56
0
    def test_positive_get_count_for_host(self):
        """Available errata count when retrieving Host

        :id: 2f35933f-8026-414e-8f75-7f4ec048faae

        :Setup:

            1. Errata synced on satellite server.
            2. Some Content hosts present.

        :Steps: GET /api/v2/hosts

        :expectedresults: The available errata count is retrieved.

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(
            organization=org).create()
        content_view = entities.ContentView(
            organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst6'],
            'repository': REPOS['rhst6']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        }, force_manifest_upload=True)
        setup_org_for_a_custom_repo({
            'url': CUSTOM_REPO_URL,
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        repo_id = enable_rhrepo_and_fetchid(
            basearch=DEFAULT_ARCHITECTURE,
            org_id=org.id,
            product=PRDS['rhel'],
            repo=REPOS['rhva6']['name'],
            reposet=REPOSET['rhva6'],
            releasever=DEFAULT_RELEASE_VERSION,
        )
        repo = entities.Repository(id=repo_id)
        self.assertEqual(repo.sync()['result'], 'success')
        content_view = content_view.read()
        content_view.repository.append(repo)
        content_view = content_view.update(['repository'])
        content_view.publish()
        versions = sorted(content_view.read().version, key=lambda ver: ver.id)
        cvv = versions[-1].read()
        promote(cvv, env.id)
        with VirtualMachine(distro=DISTRO_RHEL6) as client:
            client.install_katello_ca()
            client.register_contenthost(org.label, activation_key.name)
            self.assertTrue(client.subscribed)
            client.enable_repo(REPOS['rhst6']['id'])
            client.enable_repo(REPOS['rhva6']['id'])
            client.install_katello_agent()
            host = entities.Host().search(query={
                'search': 'name={0}'.format(client.hostname)})[0].read()
            for errata in ('security', 'bugfix', 'enhancement'):
                if bz_bug_is_open(1482502):
                    self._validate_errata_counts(host, errata, None)
                else:
                    self._validate_errata_counts(host, errata, 0)
            client.run(
                'yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE))
            self._validate_errata_counts(host, 'security', 1)
            client.run('yum install -y {0}'.format(REAL_0_RH_PACKAGE))
            for errata in ('bugfix', 'enhancement'):
                self._validate_errata_counts(host, errata, 1)
Пример #57
0
    def test_positive_restore_ak_and_content_hosts_subscriptions(self):
        """Restore activation key and content hosts subscriptions

        :id: a44fdeda-9c8c-4316-85b4-a9b6b9f1ffdb

        :customerscenario: true

        :steps:
            1. Setup activation key , lifecycle environment and content view
               with RH repository
            2. Add RH subscription to activation key
            3. Setup hosts (minimum two) and subscribe them to activation key
            4. Attach RH subscription to the created content hosts
            5. export the activation key and content hosts subscriptions
            6. Delete the subscription manifest
            7. Ensure that the activation key and content hosts subscriptions
               does not exist
            8. Upload the subscription manifest
            9. Ensure the activation key and content hosts subscriptions does
               not exist
            10. Restore the activation key and content hosts subscriptions

        :expectedresults: activation key and content hosts subscriptions
            restored

        :CaseImportance: Critical
        """
        lce = make_lifecycle_environment({'organization-id': self.org['id']})
        activation_key = make_activation_key({
            'organization-id': self.org['id'],
            'lifecycle-environment-id': lce['id'],
        })
        ActivationKey.update({
            'organization-id': self.org['id'],
            'id': activation_key['id'],
            'auto-attach': 'false',
        })
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': self.org['id'],
            'lifecycle-environment-id': lce['id'],
            'activationkey-id': activation_key['id'],
        }, force_use_cdn=True)
        org_subs = Subscription.list({u'organization-id': self.org['id']})
        default_subscription_id = None
        for sub in org_subs:
            if sub['name'] == DEFAULT_SUBSCRIPTION_NAME:
                default_subscription_id = sub['id']
                break
        self.assertIsNotNone(
            default_subscription_id, msg='Default subscription not found')
        ak_subs = ActivationKey.subscriptions({
            'organization-id': self.org['id'],
            'id': activation_key['id'],
        }, output_format='json')
        self.assertIn(
            DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs])
        with VirtualMachine() as client1, VirtualMachine() as client2:
            hosts = []
            for client in [client1, client2]:
                client.install_katello_ca()
                client.register_contenthost(
                    self.org['label'], activation_key=activation_key['name'])
                self.assertTrue(client.subscribed)
                host = Host.info({'name': client.hostname})
                hosts.append(host)
                Host.subscription_attach({
                    'host-id': host['id'],
                    'subscription-id': default_subscription_id,
                })
                host_subscriptions = ActivationKey.subscriptions({
                    'organization-id': self.org['id'],
                    'id': activation_key['id'],
                    'host-id': host['id'],
                }, output_format='json')
                self.assertIn(
                    DEFAULT_SUBSCRIPTION_NAME,
                    [sub['name'] for sub in host_subscriptions]
                )
            # export the current activations and content hosts subscriptions
            ak_file_path = '/tmp/ak_{0}.csv'.format(self.org['label'])
            ch_file_path = '/tmp/content_hosts_{0}.csv'.format(
                self.org['label'])
            CSV_.activation_keys({
                'export': True,
                'file': ak_file_path,
                'organization': self.org['name'],
                'itemized-subscriptions': True,
            })
            CSV_.content_hosts({
                'export': True,
                'file': ch_file_path,
                'organization': self.org['name'],
                'itemized-subscriptions': True,
            })
            # delete the manifest
            Subscription.delete_manifest({'organization-id': self.org['id']})
            # ensure that the subscription does not exist any more
            ak_subs = ActivationKey.subscriptions({
                'organization-id': self.org['id'],
                'id': activation_key['id'],
            }, output_format='json')
            self.assertNotIn(
                DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs])
            for host in hosts:
                host_subscriptions = ActivationKey.subscriptions({
                    'organization-id': self.org['id'],
                    'id': activation_key['id'],
                    'host-id': host['id'],
                }, output_format='json')
                self.assertNotIn(
                    DEFAULT_SUBSCRIPTION_NAME,
                    [sub['name'] for sub in host_subscriptions]
                )
            # upload the manifest again
            self._upload_manifest(self.org['id'])
            # ensure that the subscription was not auto attached
            ak_subs = ActivationKey.subscriptions({
                'organization-id': self.org['id'],
                'id': activation_key['id'],
            }, output_format='json')
            self.assertNotIn(
                DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs])
            for host in hosts:
                host_subscriptions = ActivationKey.subscriptions({
                    'organization-id': self.org['id'],
                    'id': activation_key['id'],
                    'host-id': host['id'],
                }, output_format='json')
                self.assertNotIn(
                    DEFAULT_SUBSCRIPTION_NAME,
                    [sub['name'] for sub in host_subscriptions]
                )
            # restore from the saved activation key and content hosts
            # subscriptions
            CSV_.activation_keys({
                'file': ak_file_path,
                'organization': self.org['name'],
                'itemized-subscriptions': True,
            })
            CSV_.content_hosts({
                'file': ch_file_path,
                'organization': self.org['name'],
                'itemized-subscriptions': True,
            })
            # ensure that the subscriptions has been restored
            ak_subs = ActivationKey.subscriptions({
                'organization-id': self.org['id'],
                'id': activation_key['id'],
            }, output_format='json')
            self.assertIn(
                DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs])
            for host in hosts:
                host_subscriptions = ActivationKey.subscriptions({
                    'organization-id': self.org['id'],
                    'id': activation_key['id'],
                    'host-id': host['id'],
                }, output_format='json')
                self.assertIn(
                    DEFAULT_SUBSCRIPTION_NAME,
                    [sub['name'] for sub in host_subscriptions]
                )
Пример #58
0
    def test_positive_restore_content_hosts_with_modified_subscription(self):
        """Restore content hosts subscription from an exported content host csv
        file with modified subscription.

        :id: d8ac08fe-24e0-41e7-b3d8-0ca13a702a64

        :customerscenario: true

        :steps:
            1. Setup activation key , lifecycle environment and content view
               with RH tools repository
            2. Setup hosts (minimum two) and subscribe them to activation key
            3. Attach RH subscription to the created content hosts
            4. Export the organization content hosts to a csv file
            5. Create a new csv file and modify the subscription with an other
               one (the new subscription must have other data than the default
               one)
            6. Import the new csv file to organization content hosts

        :expectedresults: content hosts restored with the new subscription

        :BZ: 1296978

        :CaseImportance: Critical
        """
        lce = make_lifecycle_environment({'organization-id': self.org['id']})
        activation_key = make_activation_key({
            'organization-id': self.org['id'],
            'lifecycle-environment-id': lce['id'],
        })
        ActivationKey.update({
            'organization-id': self.org['id'],
            'id': activation_key['id'],
            'auto-attach': 'false',
        })
        # Create RH tools repository and contents, this step should upload
        # the default manifest
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': self.org['id'],
            'lifecycle-environment-id': lce['id'],
            'activationkey-id': activation_key['id'],
        }, force_use_cdn=True)
        # Export and download the organization subscriptions to prepare the new
        # subscription (The replacement of the default subscription)
        org_subs_csv_filename = 'subs_{0}.csv'.format(self.org['name'])
        org_subs_csv_remote_file_path = '/tmp/{0}'.format(
            org_subs_csv_filename)
        # export organization subscription to csv file
        CSV_.subscriptions({
            'export': True,
            'file': org_subs_csv_remote_file_path,
            'organization': self.org['name'],
        })
        # download the organization subscriptions
        org_subs_csv_local_file_path = os.path.join(
            tempfile.gettempdir(), org_subs_csv_filename)
        download_file(
            org_subs_csv_remote_file_path, org_subs_csv_local_file_path)
        _, org_subscriptions = self._read_csv_file(
            org_subs_csv_local_file_path)
        new_subscription = None
        for sub in org_subscriptions:
            if sub['Subscription Name'] == SATELLITE_SUBSCRIPTION_NAME:
                new_subscription = sub
                break
        self.assertIsNotNone(new_subscription)
        # retrieve the default subscription id
        org_subs = Subscription.list({u'organization-id': self.org['id']})
        default_subscription_id = None
        for sub in org_subs:
            if sub['name'] == DEFAULT_SUBSCRIPTION_NAME:
                default_subscription_id = sub['id']
                break
        self.assertIsNotNone(
            default_subscription_id, msg='Default subscription not found')
        # create 2 Virtual machines
        with VirtualMachine() as client1, VirtualMachine() as client2:
            hosts = []
            for client in [client1, client2]:
                client.install_katello_ca()
                client.register_contenthost(
                    self.org['label'], activation_key=activation_key['name'])
                self.assertTrue(client.subscribed)
                host = Host.info({'name': client.hostname})
                hosts.append(host)
                Host.subscription_attach({
                    'host-id': host['id'],
                    'subscription-id': default_subscription_id,
                })
                host_subscriptions = ActivationKey.subscriptions({
                    'organization-id': self.org['id'],
                    'id': activation_key['id'],
                    'host-id': host['id'],
                }, output_format='json')
                self.assertEqual(len(host_subscriptions), 1)
                self.assertEqual(
                    host_subscriptions[0]['name'], DEFAULT_SUBSCRIPTION_NAME)
            # export the content host data to csv file
            chs_export_file_name = 'chs_export_{0}.csv'.format(
                self.org['label'])
            chs_export_remote_file_path = (
                '/tmp/{0}'.format(chs_export_file_name)
            )
            CSV_.content_hosts({
                'export': True,
                'file': chs_export_remote_file_path,
                'organization': self.org['name'],
            })
            # download the csv file
            chs_export_local_file_path = os.path.join(
                tempfile.gettempdir(), chs_export_file_name)
            download_file(
                chs_export_remote_file_path, chs_export_local_file_path)
            # modify the content hosts subscription
            field_names, csv_data = self._read_csv_file(
                chs_export_local_file_path)
            # each client is represented by one row of data
            self.assertEqual(len(csv_data), 2)
            for row_data in csv_data:
                # The subscription is saved in the following format:
                # """<quantity>|<sku>|<name>|<contract>|<account>"""
                subscription_data = row_data['Subscriptions'].strip(
                    '"').split('|')
                # change the subscription SKU (looks like RH00001)
                subscription_data[1] = new_subscription['Subscription SKU']
                # change the name
                subscription_data[2] = new_subscription['Subscription Name']
                # change the contract number
                subscription_data[3] = new_subscription[
                    'Subscription Contract']
                # change the subscription account
                subscription_data[4] = new_subscription[
                    'Subscription Account']
                # modify the subscription data
                row_data['Subscriptions'] = '"{0}"'.format(
                    '|'.join(subscription_data))
            # generate a new csv file
            chs_import_file_name = 'chs_import_{0}.csv'.format(
                self.org['name'])
            chs_import_local_file_path = os.path.join(
                tempfile.gettempdir(), chs_import_file_name)
            self._write_csv_file(
                chs_import_local_file_path, field_names, csv_data)
            # upload the file
            chs_import_remote_file_path = (
                '/tmp/{0}'.format(chs_import_file_name)
            )
            upload_file(
                chs_import_local_file_path, chs_import_remote_file_path)
            # import content hosts data from csv file
            CSV_.content_hosts({
                'file': chs_import_remote_file_path,
                'organization': self.org['name'],
            })
            for host in hosts:
                host_subscriptions = ActivationKey.subscriptions({
                    'organization-id': self.org['id'],
                    'id': activation_key['id'],
                    'host-id': host['id'],
                }, output_format='json')
                self.assertEqual(len(host_subscriptions), 1)
                self.assertEqual(
                    host_subscriptions[0]['name'], SATELLITE_SUBSCRIPTION_NAME)
                self.assertEqual(
                    host_subscriptions[0]['contract'],
                    new_subscription['Subscription Contract'])
                self.assertEqual(
                    host_subscriptions[0]['account'],
                    new_subscription['Subscription Account'])
Пример #59
0
    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)