Example #1
0
    def test_positive_update_org(self):
        """Update environment organization with new value

        :id: 2c40caf9-95a0-4b87-bd97-0a4448746052

        :expectedresults: Environment Update finished and new organization is
            assigned


        :CaseImportance: Critical
        """
        old_org = make_org()
        new_org = make_org()
        env_name = gen_string('alphanumeric', 10)
        env = make_environment({
            'name': env_name,
            'organization-ids': old_org['id'],
        })
        self.assertIn(old_org['name'], env['organizations'])
        Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        env = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], env['organizations'])
        self.assertNotIn(old_org['name'], env['organizations'])
Example #2
0
    def test_update_organization(self):
        """@Test: Update environment organization with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new organization is assigned

        """
        try:
            old_org = make_org()
            new_org = make_org()
            env_name = gen_string('alphanumeric', 10)
            make_environment({
                'name': env_name,
                'organization-ids': old_org['id'],
            })
        except CLIFactoryError as err:
            self.fail(err)
        result = Environment.info({'name': env_name})
        self.assertIn(old_org['name'], result.stdout['organizations'])

        result = Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        self.assertEqual(result.return_code, 0)

        result = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], result.stdout['organizations'])
        self.assertNotIn(old_org['name'], result.stdout['organizations'])
Example #3
0
    def test_positive_update_org_loc(self):
        """Create a filter and assign it to another organization and location.

         @id: 9bb59109-9701-4ef3-95c6-81f387d372da

         @Assert: Filter is created and assigned to new org and loc.
         """
        org = make_org()
        loc = make_location()
        filter_ = make_filter({
            'role-id': self.role['id'],
            'permissions': self.perms,
            'organization-ids': org['id'],
            'location-ids': loc['id']
        })
        # Update org and loc
        new_org = make_org()
        new_loc = make_location()
        Filter.update({
            'id': filter_['id'],
            'permissions': self.perms,
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id']
        })
        filter_ = Filter.info({'id': filter_['id']})
        # We expect here only one organization and location
        self.assertEqual(filter_['organizations'][0], new_org['name'])
        self.assertEqual(filter_['locations'][0], new_loc['name'])
Example #4
0
    def test_repositoryset_enable_by_label(self):
        """@Test: Enable repo from reposet by org label, reposet and product
        names

        @Feature: Repository-set

        @Assert: Repository was enabled

        """
        org = make_org()
        manifest = manifests.clone()
        upload_file(manifest, remote_file=manifest)
        Subscription.upload({
            u'file': manifest,
            u'organization-id': org['id'],
        })
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'name': REPOSET['rhva6'],
            u'organization-label': org['label'],
            u'product': PRDS['rhel'],
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'name': REPOSET['rhva6'],
            u'organization-label': org['label'],
            u'product': PRDS['rhel'],
        })
        enabled = [
            repo['enabled']
            for repo
            in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'true')
Example #5
0
    def setUpClass(cls):  # noqa
        """Create a shared organization for all tests to avoid generating
        hundreds of organizations

        """
        CLITestCase.setUpClass()
        cls.org = make_org(cached=True)
Example #6
0
    def test_positive_update_with_manager_role(self):
        """Create template providing the initial name, then update its name
        with manager user role.

        :id: 28c4357a-93cb-4b01-a445-5db50435bcc0

        :expectedresults: Provisioning Template is created, and its name can
            be updated.

        :CaseImportance: Critical

        :BZ: 1277308
        """
        new_name = gen_string('alpha')
        username = gen_string('alpha')
        password = gen_string('alpha')
        org = make_org()
        loc = make_location()
        template = make_template({
            'organization-ids': org['id'], 'location-ids': loc['id']})
        # Create user with Manager role
        user = make_user({
            'login': username,
            'password': password,
            'admin': False,
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        })
        User.add_role({'id': user['id'], 'role': "Manager"})
        # Update template name with that user
        Template.with_user(username=username, password=password).update({
            'id': template['id'], 'name': new_name})
        template = Template.info({'id': template['id']})
        self.assertEqual(new_name, template['name'])
    def test_positive_remove_compresource_by_name(self):
        """Remove a compute resource from organization by its name

        @id: 1b1313a8-8326-4b33-8113-17c5cf0d4ffb

        @Assert: Compute resource is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        compute_res = make_compute_resource({
            'provider': FOREMAN_PROVIDERS['libvirt'],
            'url': u'qemu+ssh://root@{0}/system'.format(
                settings.compute_resources.libvirt_hostname
            )
        })
        Org.add_compute_resource({
            'compute-resource': compute_res['name'],
            'name': org['name'],
        })
        Org.remove_compute_resource({
            'compute-resource': compute_res['name'],
            'name': org['name'],
        })
        org = Org.info({'name': org['name']})
        self.assertNotIn(compute_res['name'], org['compute-resources'])
    def test_positive_add_template_by_name(self):
        """Add a provisioning template to organization by its name

        @id: bd46a192-488f-4da0-bf47-1f370ae5f55c

        @Assert: Template is added to the org

        @CaseLevel: Integration
        """
        for name in valid_data_list():
            with self.subTest(name):
                org = make_org()
                template = make_template({
                    'content': gen_string('alpha'),
                    'name': name,
                })
                Org.add_config_template({
                    'config-template': template['name'],
                    'name': org['name'],
                })
                org = Org.info({'name': org['name']})
                self.assertIn(
                    u'{0} ({1})'. format(template['name'], template['type']),
                    org['templates']
                )
    def test_positive_remove_capsule_by_name(self):
        """Remove a capsule from organization by its name

        @id: f56eaf46-fef5-4b52-819f-e30e61f0ec4a

        @Assert: Capsule is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        proxy = make_proxy()
        # Add capsule and org to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
        self.addCleanup(org_cleanup, org['id'])

        Org.add_smart_proxy({
            'name': org['name'],
            'smart-proxy': proxy['name'],
        })
        Org.remove_smart_proxy({
            'name': org['name'],
            'smart-proxy': proxy['name'],
        })
        org = Org.info({'name': org['name']})
        self.assertNotIn(proxy['name'], org['smart-proxies'])
    def test_positive_remove_compresource_by_id(self):
        """Remove a compute resource from organization by its ID

        @id: 415c14ab-f879-4ed8-9ba7-8af4ada2e277

        @Assert: Compute resource is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        compute_res = make_compute_resource({
            'provider': FOREMAN_PROVIDERS['libvirt'],
            'url': u'qemu+ssh://root@{0}/system'.format(
                settings.compute_resources.libvirt_hostname
            )
        })
        Org.add_compute_resource({
            'compute-resource-id': compute_res['id'],
            'id': org['id'],
        })
        Org.remove_compute_resource({
            'compute-resource-id': compute_res['id'],
            'id': org['id'],
        })
        org = Org.info({'id': org['id']})
        self.assertNotIn(compute_res['name'], org['compute-resources'])
    def test_positive_remove_lce(self):
        """Remove a lifecycle environment from organization

        @id: bfa9198e-6078-4f10-b79a-3d7f51b835fd

        @Assert: Lifecycle environment is removed from the org

        @CaseLevel: Integration
        """
        # Create a lifecycle environment.
        org_id = make_org()['id']
        lc_env_name = make_lifecycle_environment(
            {'organization-id': org_id})['name']
        lc_env_attrs = {
            'name': lc_env_name,
            'organization-id': org_id,
        }
        # Read back information about the lifecycle environment. Verify the
        # sanity of that information.
        response = LifecycleEnvironment.list(lc_env_attrs)
        self.assertEqual(response[0]['name'], lc_env_name)
        # Delete it.
        LifecycleEnvironment.delete(lc_env_attrs)
        # We should get a zero-length response when searching for the LC env.
        response = LifecycleEnvironment.list(lc_env_attrs)
        self.assertEqual(len(response), 0)
Example #12
0
    def setUp(self):
        """Tests for Sync Plans via Hammer CLI"""

        super(TestSyncPlan, self).setUp()

        if TestSyncPlan.org is None:
            TestSyncPlan.org = make_org(cached=True)
    def test_positive_remove_capsule_by_id(self):
        """Remove a capsule from organization by its id

        @id: 71af64ec-5cbb-4dd8-ba90-652e302305ec

        @Assert: Capsule is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        proxy = make_proxy()
        # Add capsule and org to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
        self.addCleanup(org_cleanup, org['id'])

        Org.add_smart_proxy({
            'id': org['id'],
            'smart-proxy-id': proxy['id'],
        })
        Org.remove_smart_proxy({
            'id': org['id'],
            'smart-proxy-id': proxy['id'],
        })
        org = Org.info({'id': org['id']})
        self.assertNotIn(proxy['name'], org['smart-proxies'])
    def setUp(self):
        """Tests for Lifecycle Environment via Hammer CLI"""

        super(TestLifeCycleEnvironment, self).setUp()

        if TestLifeCycleEnvironment.org is None:
            TestLifeCycleEnvironment.org = make_org()
Example #15
0
    def setUp(self):
        """Tests for Sync Plans via Hammer CLI"""

        super(SyncPlanTestCase, self).setUp()

        if SyncPlanTestCase.org is None:
            SyncPlanTestCase.org = make_org(cached=True)
    def test_positive_remove_template_by_id(self):
        """Remove a provisioning template from organization by its ID

        @id: 8f3e05c2-6c0d-48a6-a311-41ad032b7977

        @Assert: Template is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        template = make_template({'content': gen_string('alpha')})
        # Add config-template
        Org.add_config_template({
            'config-template-id': template['id'],
            'id': org['id'],
        })
        result = Org.info({'id': org['id']})
        self.assertIn(
            u'{0} ({1})'. format(template['name'], template['type']),
            result['templates'],
        )
        # Remove config-template
        Org.remove_config_template({
            'config-template-id': template['id'],
            'id': org['id'],
        })
        result = Org.info({'id': org['id']})
        self.assertNotIn(
            u'{0} ({1})'. format(template['name'], template['type']),
            result['templates'],
        )
 def setUpClass(cls):
     """Create Directory for all CV Sync Tests in /tmp"""
     super(ContentViewSync, cls).setUpClass()
     cls.exporting_org = make_org()
     cls.exporting_prod = gen_string('alpha')
     product = make_product({
         'organization-id': cls.exporting_org['id'],
         'name': cls.exporting_prod
     })
     cls.exporting_repo = gen_string('alpha')
     repo = make_repository({
         'name': cls.exporting_repo,
         'download-policy': 'immediate',
         'product-id': product['id']
     })
     Repository.synchronize({'id': repo['id']})
     cls.exporting_cv = gen_string('alpha')
     content_view = make_content_view({
         'name': cls.exporting_cv,
         'organization-id': cls.exporting_org['id']
     })
     ContentView.add_repository({
         'id': content_view['id'],
         'organization-id': cls.exporting_org['id'],
         'repository-id': repo['id']
     })
     ContentView.publish({u'id': content_view['id']})
     content_view = ContentView.info({u'id': content_view['id']})
     cls.exporting_cvv_id = content_view['versions'][0]['id']
Example #18
0
    def test_positive_update_parameter(self):
        """Update a parameter associated with organization

        @id: 4a7ed165-a0c5-4ba6-833a-5a1b3ee47ace

        @Assert: Parameter is updated
        """
        param_name = gen_string('alpha')
        param_new_value = gen_string('alpha')
        org = make_org()
        # Create parameter
        Org.set_parameter({
            'name': param_name,
            'value': gen_string('alpha'),
            'organization': org['name'],
        })
        result = Org.info({'id': org['id']})
        self.assertEqual(len(result['parameters']), 1)
        Org.set_parameter({
            'name': param_name,
            'value': param_new_value,
            'organization': org['name'],
        })
        result = Org.info({'id': org['id']})
        self.assertEqual(len(result['parameters']), 1)
        self.assertEqual(
            param_new_value, result['parameters'][param_name.lower()])
 def setUpClass(cls):
     """Tests for Content Host via Hammer CLI"""
     super(ContentHostTestCase, cls).setUpClass()
     ContentHostTestCase.NEW_ORG = make_org(cached=True)
     ContentHostTestCase.NEW_LIFECYCLE = make_lifecycle_environment(
         {u'organization-id': ContentHostTestCase.NEW_ORG['id']},
         cached=True
     )
     ContentHostTestCase.LIBRARY = LifecycleEnvironment.info({
         u'organization-id': ContentHostTestCase.NEW_ORG['id'],
         u'name': u'Library',
     })
     ContentHostTestCase.DEFAULT_CV = ContentView.info({
         u'organization-id': ContentHostTestCase.NEW_ORG['id'],
         u'name': u'Default Organization View',
     })
     ContentHostTestCase.NEW_CV = make_content_view({
         u'organization-id': ContentHostTestCase.NEW_ORG['id'],
     })
     cv_id = ContentHostTestCase.NEW_CV['id']
     ContentView.publish({u'id': cv_id})
     version_id = ContentView.version_list({
         u'content-view-id': cv_id,
     })[0]['id']
     ContentView.version_promote({
         u'id': version_id,
         u'to-lifecycle-environment-id': ContentHostTestCase.NEW_LIFECYCLE[
             'id'
         ],
         u'organization-id': ContentHostTestCase.NEW_ORG['id']
     })
     ContentHostTestCase.PROMOTED_CV = ContentHostTestCase.NEW_CV
Example #20
0
    def test_positive_update_org_loc(self):
        """Update org and location of selected discovery rule

        :id: 26da79aa-30e5-4052-98ae-141de071a68a

        :expectedresults: Rule was updated and with given org & location.

        :BZ: 1377990

        :CaseLevel: Integration
        """
        new_org = make_org()
        new_loc = make_location()
        new_hostgroup = make_hostgroup({
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id'],
        })
        rule = self._make_discoveryrule()
        DiscoveryRule.update({
            'id': rule['id'],
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id'],
            'hostgroup-id': new_hostgroup['id'],
        })
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertIn(new_org['name'], rule['organizations'])
        self.assertIn(new_loc['name'], rule['locations'])
Example #21
0
 def setUpClass(cls):
     """Tests for discovery rules via Hammer CLI"""
     super(DiscoveryRuleRoleTestCase, cls).setUpClass()
     cls.org = make_org()
     cls.loc = make_location()
     cls.hostgroup = make_hostgroup({
         u'organization-ids': cls.org['id'],
         u'location-ids': cls.loc['id'],
     })
     cls.password = gen_alphanumeric()
     cls.user = make_user({
         'organization-ids': cls.org['id'],
         'location-ids': cls.loc['id'],
         'password': cls.password,
     })
     cls.user['password'] = cls.password
     User.add_role({
         'login': cls.user['login'],
         'role': 'Discovery Manager',
     })
     cls.user_reader = make_user({
         'organization-ids': cls.org['id'],
         'location-ids': cls.loc['id'],
         'password': cls.password,
     })
     cls.user_reader['password'] = cls.password
     User.add_role({
         'login': cls.user_reader['login'],
         'role': 'Discovery Reader',
     })
    def setUp(self):
        """Tests for Lifecycle Environment via Hammer CLI"""

        super(LifeCycleEnvironmentTestCase, self).setUp()

        if LifeCycleEnvironmentTestCase.org is None:
            LifeCycleEnvironmentTestCase.org = make_org()
Example #23
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'],
        })
Example #24
0
    def test_positive_add_subscription_by_id(self):
        """Test that subscription can be added to activation key

        :id: b884be1c-b35d-440a-9a9d-c854c83e10a7

        :Steps:

            1. Create Activation key
            2. Upload manifest and add subscription
            3. Associate the activation key to subscription

        :expectedresults: Subscription successfully added to activation key

        :BZ: 1463685

        :CaseLevel: Integration
        """
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        org_id = make_org()['id']
        ackey_id = self._make_activation_key({'organization-id': org_id})['id']
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': org_id,
        })
        subs_id = Subscription.list(
            {'organization-id': org_id},
            per_page=False
        )
        result = ActivationKey.add_subscription({
            u'id': ackey_id,
            u'subscription-id': subs_id[0]['id'],
        })
        self.assertIn('Subscription added to activation key', result)
    def test_positive_enable_by_label(self):
        """Enable repo from reposet by org label, reposet and product
        names

        @id: 5230c1cd-fed7-40ac-8445-bac4f9c5ee68

        @Assert: Repository was enabled
        """
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            u'organization-id': org['id'],
        })
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'name': REPOSET['rhva6'],
            u'organization-label': org['label'],
            u'product': PRDS['rhel'],
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'name': REPOSET['rhva6'],
            u'organization-label': org['label'],
            u'product': PRDS['rhel'],
        })
        enabled = [
            repo['enabled']
            for repo
            in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'true')
Example #26
0
 def setUpClass(cls):
     """Create a shared organization for all tests to avoid generating
     hundreds of organizations
     """
     super(TestGPGKey, cls).setUpClass()
     # pylint: disable=unexpected-keyword-arg
     cls.org = make_org(cached=True)
    def setUp(self):
        """Tests for Host Collections via Hammer CLI"""
        super(HostCollectionTestCase, self).setUp()

        if HostCollectionTestCase.org is None:
            HostCollectionTestCase.org = make_org(cached=True)
        if HostCollectionTestCase.new_lifecycle is None:
            HostCollectionTestCase.new_lifecycle = make_lifecycle_environment(
                {u"organization-id": HostCollectionTestCase.org["id"]}, cached=True
            )
        if HostCollectionTestCase.library is None:
            HostCollectionTestCase.library = LifecycleEnvironment.info(
                {u"organization-id": HostCollectionTestCase.org["id"], u"name": ENVIRONMENT}
            )
        if HostCollectionTestCase.default_cv is None:
            HostCollectionTestCase.default_cv = ContentView.info(
                {u"organization-id": HostCollectionTestCase.org["id"], u"name": DEFAULT_CV}
            )
        if HostCollectionTestCase.new_cv is None:
            HostCollectionTestCase.new_cv = make_content_view({u"organization-id": HostCollectionTestCase.org["id"]})
            HostCollectionTestCase.promoted_cv = None
            cv_id = HostCollectionTestCase.new_cv["id"]
            ContentView.publish({u"id": cv_id})
            result = ContentView.version_list({u"content-view-id": cv_id})
            version_id = result[0]["id"]
            ContentView.version_promote(
                {
                    u"id": version_id,
                    u"organization-id": HostCollectionTestCase.org["id"],
                    u"to-lifecycle-environment-id": (HostCollectionTestCase.new_lifecycle["id"]),
                }
            )
            HostCollectionTestCase.promoted_cv = HostCollectionTestCase.new_cv
    def test_positive_enable_by_name(self):
        """Enable repo from reposet by names of reposet, org and product

        :id: a78537bd-b88d-4f00-8901-e7944e5de729

        :expectedresults: Repository was enabled

        :CaseImportance: Critical
        """
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            u'organization-id': org['id'],
        })
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'name': REPOSET['rhva6'],
            u'organization': org['name'],
            u'product': PRDS['rhel'],
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'name': REPOSET['rhva6'],
            u'organization': org['name'],
            u'product': PRDS['rhel'],
        })
        enabled = [
            repo['enabled']
            for repo
            in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'true')
    def set_importing_org(self, product, repo, cv):
        """Sets same CV, product and repository in importing organization as
        exporting organization

        :param str product: The product name same as exporting product
        :param str repo: The repo name same as exporting repo
        :param str cv: The cv name same as exporting cv
        """
        self.importing_org = make_org()
        importing_prod = make_product({
            'organization-id': self.importing_org['id'],
            'name': product
        })
        importing_repo = make_repository({
            'name': repo,
            'download-policy': 'immediate',
            'product-id': importing_prod['id']
        })
        self.importing_cv = make_content_view({
            'name': cv,
            'organization-id': self.importing_org['id']
        })
        ContentView.add_repository({
            'id': self.importing_cv['id'],
            'organization-id': self.importing_org['id'],
            'repository-id': importing_repo['id']
        })
Example #30
0
    def setUp(self):
        """Tests for Lifecycle Environment via Hammer CLI"""

        super(ProductTestCase, self).setUp()

        if ProductTestCase.org is None:
            ProductTestCase.org = make_org(cached=True)
Example #31
0
    def test_positive_info_by_name(self):
        """Get org information by its name

        :id: cf971026-26a4-428f-b560-bb14e5324207

        :expectedresults: Organization is created and info can be obtained by
            its name graciously

        :CaseImportance: Critical
        """
        org = make_org()
        result = Org.info({'name': org['name']})
        self.assertEqual(org['id'], result['id'])
Example #32
0
    def test_positive_create_with_org(self):
        """Check if hostgroup with organization can be created

        :id: 780d4b93-f35a-4c5b-a645-4053aed4c37b

        :expectedresults: Hostgroup is created and has new organization
            assigned

        :CaseLevel: Integration
        """
        org = make_org()
        hostgroup = make_hostgroup({'organization-ids': org['id']})
        self.assertIn(org['name'], hostgroup['organizations'])
 def setUpClass(cls):
     super(EC2ComputeResourceTestCase, cls).setUpClass()
     cls.org = make_org()
     cls.loc = make_location()
     Org.add_location({'id': cls.org['id'], 'location-id': cls.loc['id']})
     cls.aws_access_key = settings.ec2.access_key
     cls.aws_secret_key = settings.ec2.secret_key
     cls.aws_region = settings.ec2.region
     cls.aws_image = settings.ec2.image
     cls.aws_availability_zone = settings.ec2.availability_zone
     cls.aws_subnet = settings.ec2.subnet
     cls.aws_security_groups = settings.ec2.security_groups
     cls.aws_managed_ip = settings.ec2.managed_ip
Example #34
0
    def test_positive_create_with_organization_by_id(self):
        """Check if medium with organization can be created

        :id: 631bb6ed-e42b-482a-83f0-f6ce0f20729a

        :expectedresults: Medium is created and has new organization assigned


        :CaseImportance: Critical
        """
        org = make_org()
        medium = make_medium({'organization-ids': org['id']})
        self.assertIn(org['name'], medium['organizations'])
 def setUpClass(cls):
     """Create an organization which can be re-used in tests."""
     super(RemoteExecutionTestCase, cls).setUpClass()
     cls.organization = make_org()
     ssh.command('''echo 'getenforce' > {0}'''.format(TEMPLATE_FILE))
     cls.client = VirtualMachine(distro=DISTRO_RHEL7)
     cls.client.create()
     cls.client.install_katello_ca()
     cls.client.register_contenthost(cls.organization['label'],
                                     lce='Library')
     cls.client.enable_repo(REPOS['rhst7']['id'])
     cls.client.install_katello_agent()
     add_remote_execution_ssh_key(cls.client.hostname)
Example #36
0
    def test_positive_create_with_name(self):
        """Create organization with valid name only

        :id: 35840da7-668e-4f78-990a-738aa688d586

        :expectedresults: organization is created and has appropriate name

        :CaseImportance: Critical
        """
        for name in valid_org_names_list():
            with self.subTest(name):
                org = make_org({'name': name})
                self.assertEqual(org['name'], name)
Example #37
0
    def test_negative_update_name(self):
        """Create organization then fail to update its name

        :id: 582d41b8-370d-45ed-9b7b-8096608e1324

        :expectedresults: organization name is not updated

        """
        org = make_org()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Org.update({'id': org['id'], 'new-name': new_name})
Example #38
0
    def test_positive_create_with_org(self):
        """Check if domain with organization can be created

        :id: f4dfef1b-9b2a-49b8-ade5-031da29e7f6a

        :expectedresults: Domain is created and has new organization assigned


        :CaseImportance: Critical
        """
        org = make_org()
        domain = make_domain({'organization-ids': org['id']})
        self.assertIn(org['name'], domain['organizations'])
Example #39
0
    def test_positive_search_by_label(self):
        """Can search for an organization by name

        @feature: Organization

        @assert: organization is created and can be searched by label
        """
        for name in valid_org_names_list():
            with self.subTest(name):
                org = make_org({'name': name})
                # Can we find the new object?
                result = Org.exists(search=('label', org['label']))
                self.assertEqual(org['name'], result['name'])
Example #40
0
    def test_positive_add_compresource_by_id(self):
        """Add a compute resource to organization by its ID

        @id: 355e20c5-ec04-49f7-a0ae-0864a3fe0f3f

        @Assert: Compute Resource is added to the org

        @CaseLevel: Integration
        """
        compute_res = make_compute_resource()
        org = make_org({'compute-resource-ids': compute_res['id']})
        self.assertEqual(len(org['compute-resources']), 1)
        self.assertEqual(org['compute-resources'][0], compute_res['name'])
Example #41
0
    def test_positive_create_with_orgs(self):
        """Create User associated to multiple Organizations

        @Feature: User - Positive Create

        @Assert: User is created
        """
        orgs_amount = random.randint(3, 5)
        orgs = [make_org() for _ in range(orgs_amount)]
        user = make_user({'organization-ids': [org['id'] for org in orgs]})
        self.assertEqual(len(user['organizations']), orgs_amount)
        for org in orgs:
            self.assertIn(org['name'], user['organizations'])
Example #42
0
    def test_positive_info_by_label(self):
        """Get org information by its label

        :id: 02328b67-5d24-4873-b716-113eee3ff67b

        :expectedresults: Organization is created and info can be obtained by
            its label graciously

        :CaseImportance: Critical
        """
        org = make_org()
        result = Org.info({'label': org['label']})
        self.assertEqual(org['id'], result['id'])
Example #43
0
    def test_positive_search_by_name(self):
        """Can search for an organization by name

        @id: 4279972b-180d-40ce-944f-47a1940af25d

        @assert: organization is created and can be searched by name
        """
        for name in valid_org_names_list():
            with self.subTest(name):
                org = make_org({'name': name})
                # Can we find the new object?
                result = Org.exists(search=('name', org['name']))
                self.assertEqual(org['name'], result['name'])
Example #44
0
    def test_positive_create_with_org(self):
        """Check if Template with Organization can be created

        @Feature: Template - Create

        @Assert: Template is created and new Organization has been assigned
        """
        new_org = make_org()
        new_template = make_template({
            'name': gen_string('alpha'),
            'organization-ids': new_org['id'],
        })
        self.assertIn(new_org['name'], new_template['organizations'])
Example #45
0
    def test_positive_list(self):
        """Check if Org can be listed

        :id: bdd26bb3-e3d2-4a5c-8be7-fb12c1114ccc

        :expectedresults: Org is listed

        :CaseImportance: Critical
        """
        org = make_org()
        result_list = Org.list({'search': 'name=%s' % org['name']})
        self.assertTrue(len(result_list) > 0)
        self.assertEqual(result_list[0]['name'], org['name'])
Example #46
0
def test_product_list_with_default_settings(module_org, default_sat):
    """Listing product of an organization apart from default organization using hammer
     does not return output if a defaults settings are applied on org.

    :id: d5c5edac-b19c-4277-92fe-28d9b9fa43ef

    :BZ: 1745575

    :customerscenario: true

    :expectedresults: product/reporsitory list should work as expected.

    """
    org_id = str(module_org.id)
    default_product_name = gen_string('alpha')
    non_default_product_name = gen_string('alpha')
    non_default_org = make_org()
    default_product = make_product({'name': default_product_name, 'organization-id': org_id})
    non_default_product = make_product(
        {'name': non_default_product_name, 'organization-id': non_default_org['id']}
    )
    for product in default_product, non_default_product:
        make_repository(
            {
                'organization-id': org_id,
                'product-id': product['id'],
                'url': settings.repos.yum_0.url,
            },
        )

    Defaults.add({'param-name': 'organization_id', 'param-value': org_id})
    result = default_sat.cli.Defaults.list(per_page=False)
    assert any([res['value'] == org_id for res in result if res['parameter'] == 'organization_id'])

    try:
        # Verify --organization-id is not required to pass if defaults are set
        result = default_sat.cli.Product.list()
        assert any([res['name'] == default_product_name for res in result])
        result = default_sat.cli.Repository.list()
        assert any([res['product'] == default_product_name for res in result])

        # verify that defaults setting should not affect other entities
        product_list = Product.list({'organization-id': non_default_org['id']})
        assert non_default_product_name == product_list[0]['name']
        repository_list = Repository.list({'organization-id': non_default_org['id']})
        assert non_default_product_name == repository_list[0]['product']

    finally:
        Defaults.delete({'param-name': 'organization_id'})
        result = default_sat.cli.Defaults.list(per_page=False)
        assert not [res for res in result if res['parameter'] == 'organization_id']
Example #47
0
    def test_positive_CRD(self):
        """Create organization with valid name, label and description

        :id: 35840da7-668e-4f78-990a-738aa688d586

        :expectedresults: organization is created with attributes

        :CaseImportance: Critical

        create read
        """
        # Create
        name = valid_org_names_list()[0]
        label = valid_labels_list()[0]
        desc = valid_data_list()[0]
        org = make_org({'name': name, 'label': label, 'description': desc})
        self.assertEqual(org['name'], name)
        self.assertEqual(org['label'], label)
        self.assertEqual(org['description'], desc)

        # List
        result = Org.list({'search': 'name=%s' % org['name']})
        self.assertTrue(len(result), 1)
        self.assertEqual(result[0]['name'], org['name'])

        # Search scoped
        for query in [
                'label = {}'.format(label),
                'description ~ {}'.format(desc[:-5]),
                'name ^ "{}"'.format(org['name']),
        ]:
            result = Org.list({'search': query})
            self.assertTrue(len(result), 1)
            self.assertEqual(result[0]['name'], org['name'])

        # Search by name and label
        result = Org.exists(search=('name', org['name']))
        self.assertEqual(org['name'], result['name'])
        result = Org.exists(search=('label', org['label']))
        self.assertEqual(org['name'], result['name'])

        # Info by name and label
        result = Org.info({'label': org['label']})
        self.assertEqual(org['id'], result['id'])
        result = Org.info({'name': org['name']})
        self.assertEqual(org['id'], result['id'])

        # Delete
        Org.delete({'id': org['id']})
        with self.assertRaises(CLIReturnCodeError):
            Org.info({'id': org['id']})
Example #48
0
    def setUp(self):
        """Create a directory for export, configure permissions and satellite
        settings
        """
        super(RepositoryExportTestCase, self).setUp()

        if not RepositoryExportTestCase.is_set_up:
            RepositoryExportTestCase.export_dir = gen_string('alphanumeric')

            # Create a new 'export' directory on the Satellite system
            result = ssh.command('mkdir /mnt/{0}'.format(self.export_dir))
            self.assertEqual(result.return_code, 0)

            result = ssh.command(
                'chown foreman.foreman /mnt/{0}'.format(self.export_dir))
            self.assertEqual(result.return_code, 0)

            result = ssh.command(
                'ls -Z /mnt/ | grep {0}'.format(self.export_dir))
            self.assertEqual(result.return_code, 0)
            self.assertGreaterEqual(len(result.stdout), 1)
            self.assertIn('unconfined_u:object_r:mnt_t:s0', result.stdout[0])

            # Fix SELinux policy for new directory
            result = ssh.command(
                'semanage fcontext -a -t foreman_var_run_t "/mnt/{0}(/.*)?"'
                .format(self.export_dir)
            )
            self.assertEqual(result.return_code, 0)

            result = ssh.command(
                'restorecon -Rv /mnt/{0}'.format(self.export_dir))
            self.assertEqual(result.return_code, 0)

            # Assert that we have the correct policy
            result = ssh.command(
                'ls -Z /mnt/ | grep {0}'.format(self.export_dir))
            self.assertEqual(result.return_code, 0)
            self.assertGreaterEqual(len(result.stdout), 1)
            self.assertIn(
                'unconfined_u:object_r:foreman_var_run_t:s0', result.stdout[0])

            # Update the 'pulp_export_destination' settings to new directory
            Settings.set({
                'name': 'pulp_export_destination',
                'value': '/mnt/{0}'.format(self.export_dir),
            })
            # Create an organization to reuse in tests
            RepositoryExportTestCase.org = make_org()

            RepositoryExportTestCase.is_set_up = True
Example #49
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'],
        })
Example #50
0
    def test_positive_update_org_loc(self):
        """Create a filter and assign it to another organization and location.

        :id: 9bb59109-9701-4ef3-95c6-81f387d372da

        :expectedresults: Filter is created and assigned to new org and loc.

        :BZ: 1401469

        :CaseImportance: Critical
        """
        org = make_org()
        loc = make_location()
        filter_ = make_filter(
            {
                'role-id': self.role['id'],
                'permissions': self.perms,
                'organization-ids': org['id'],
                'location-ids': loc['id'],
                'override': 1,
            }
        )
        # Update org and loc
        new_org = make_org()
        new_loc = make_location()
        Filter.update(
            {
                'id': filter_['id'],
                'permissions': self.perms,
                'organization-ids': new_org['id'],
                'location-ids': new_loc['id'],
                'override': 1,
            }
        )
        filter_ = Filter.info({'id': filter_['id']})
        # We expect here only one organization and location
        self.assertEqual(filter_['organizations'][0], new_org['name'])
        self.assertEqual(filter_['locations'][0], new_loc['name'])
Example #51
0
    def test_positive_create_with_orgs_and_update(self):
        """Create User associated to multiple Organizations, update them

        :id: f537296c-a8a8-45ef-8996-c1d32b8f64de

        :expectedresults: User is created with orgs, orgs are updated

        :CaseLevel: Integration
        """
        orgs_amount = 2
        orgs = [make_org() for _ in range(orgs_amount)]
        user = make_user({'organization-ids': [org['id'] for org in orgs]})
        assert len(user['organizations']) == orgs_amount
        for org in orgs:
            assert org['name'] in user['organizations']
        orgs = [make_org() for _ in range(orgs_amount)]
        User.update({
            'id': user['id'],
            'organization-ids': [org['id'] for org in orgs]
        })
        user = User.info({'id': user['id']})
        for org in orgs:
            assert org['name'] in user['organizations']
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test.
     """
     super(SmartClassParametersTestCase, cls).setUpClass()
     cls.puppet_modules = [
         {
             'author': 'robottelo',
             'name': 'cli_test_classparameters'
         },
     ]
     cls.org = make_org()
     cls.loc = make_location()
     cv = publish_puppet_module(cls.puppet_modules, CUSTOM_PUPPET_REPO,
                                cls.org['id'])
     cls.env = Environment.list(
         {'search': u'content_view="{0}"'.format(cv['name'])})[0]
     Environment.update({
         'name': cls.env['name'],
         'organization-ids': cls.org['id'],
         'location-ids': cls.loc['id'],
     })
     cls.puppet_class = Puppet.info({
         'name': cls.puppet_modules[0]['name'],
         'environment': cls.env['name'],
     })
     cls.sc_params_list = SmartClassParameter.list({
         'environment':
         cls.env['name'],
         'search':
         u'puppetclass="{0}"'.format(cls.puppet_class['name'])
     })
     cls.sc_params_ids_list = [
         sc_param['id'] for sc_param in cls.sc_params_list
     ]
     cls.host = entities.Host(
         organization=cls.org['id'],
         location=cls.loc['id'],
         environment=cls.env['name'],
     ).create()
     cls.host.add_puppetclass(
         data={'puppetclass_id': cls.puppet_class['id']})
     cls.hostgroup = make_hostgroup({
         'environment-id':
         cls.env['id'],
         'puppet-class-ids':
         cls.puppet_class['id']
     })
 def setUpClass(cls):
     """Init single organization, product and repository for all tests"""
     super().setUpClass()
     cls.org = make_org()
     cls.product = make_product_wait({'organization-id': cls.org['id']})
     cls.content_view = make_content_view(
         {'organization-id': cls.org['id']})
     for _ in range(2):
         cls.repo = make_repository({'product-id': cls.product['id']})
         Repository.synchronize({'id': cls.repo['id']})
         ContentView.add_repository({
             'id': cls.content_view['id'],
             'repository-id': cls.repo['id']
         })
Example #54
0
    def test_positive_create_with_defaut_org(self):
        """Check if user with default organization can be created

        @id: cc692b6f-2519-429b-8ecb-c4bb51ed3544

        @Assert: User is created and has new default organization assigned
        """
        org = make_org()
        user = make_user({
            'default-organization-id': org['id'],
            'organization-ids': org['id'],
        })
        self.assertIn(org['name'], user['organizations'])
        self.assertEqual(org['name'], user['default-organization'])
Example #55
0
 def setUpClass(cls):
     """Import a parametrized puppet class.
     """
     super(PuppetClassTestCase, cls).setUpClass()
     cls.puppet_modules = [{'author': 'robottelo', 'name': 'generic_1'}]
     cls.org = make_org()
     cv = publish_puppet_module(cls.puppet_modules, CUSTOM_PUPPET_REPO,
                                cls.org['id'])
     cls.env = Environment.list(
         {'search': 'content_view="{0}"'.format(cv['name'])})[0]
     cls.puppet = Puppet.info({
         'name': cls.puppet_modules[0]['name'],
         'environment': cls.env['name']
     })
Example #56
0
    def test_positive_create_with_defaut_org(self):
        """Check if user with default organization can be created

        :id: cc692b6f-2519-429b-8ecb-c4bb51ed3544

        :expectedresults: User is created and has new default organization
            assigned

        :CaseImportance: Critical
        """
        org = make_org()
        user = make_user({'default-organization-id': org['id'], 'organization-ids': org['id']})
        self.assertIn(org['name'], user['organizations'])
        self.assertEqual(org['name'], user['default-organization'])
    def test_positive_update_org(self):
        """Update environment organization with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new organization is assigned

        """
        old_org = make_org()
        new_org = make_org()
        env_name = gen_string('alphanumeric', 10)
        env = make_environment({
            'name': env_name,
            'organization-ids': old_org['id'],
        })
        self.assertIn(old_org['name'], env['organizations'])
        Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        env = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], env['organizations'])
        self.assertNotIn(old_org['name'], env['organizations'])
Example #58
0
def aws():
    aws = type('rhev', (object, ), {})()
    aws.org = make_org()
    aws.loc = make_location()
    Org.add_location({'id': aws.org['id'], 'location-id': aws.loc['id']})
    aws.aws_access_key = settings.ec2.access_key
    aws.aws_secret_key = settings.ec2.secret_key
    aws.aws_region = settings.ec2.region
    aws.aws_image = settings.ec2.image
    aws.aws_availability_zone = settings.ec2.availability_zone
    aws.aws_subnet = settings.ec2.subnet
    aws.aws_security_groups = settings.ec2.security_groups
    aws.aws_managed_ip = settings.ec2.managed_ip
    return aws
    def test_positive_create_with_org(self):
        """Check if Environment with Organization can be created

        @Feature: Environment - Create

        @Assert: Environment is created and has new Organization assigned

        """
        new_org = make_org()
        new_environment = make_environment({
            'name': gen_string('alpha'),
            'organization-ids': new_org['id'],
        })
        self.assertIn(new_org['name'], new_environment['organizations'])
Example #60
0
 def setUpClass(cls):
     """Init single organization, product and repository for all tests"""
     super(ContentViewFilterTestCase, cls).setUpClass()
     cls.org = make_org()
     cls.product = make_product({u'organization-id': cls.org['id']})
     cls.repo = make_repository({u'product-id': cls.product['id']})
     Repository.synchronize({u'id': cls.repo['id']})
     cls.content_view = make_content_view({
         u'organization-id': cls.org['id'],
     })
     ContentView.add_repository({
         u'id': cls.content_view['id'],
         u'repository-id': cls.repo['id'],
     })