def test_positive_delete_by_id(self):
        """Create lifecycle environment with valid name, prior to
        Library

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment is deleted

        """
        for name in valid_data_list():
            with self.subTest(name):
                new_lce = make_lifecycle_environment({
                    'name':
                    name,
                    'organization-id':
                    self.org['id'],
                })
                LifecycleEnvironment.delete({'id': new_lce['id']})
                with self.assertRaises(CLIReturnCodeError):
                    LifecycleEnvironment.info({
                        'id':
                        new_lce['id'],
                        'organization-id':
                        self.org['id'],
                    })
Example #2
0
    def test_positive_delete_1(self, test_data):
        """
        @Test: Create lifecycle environment with valid name, prior to Library
        @Feature: Lifecycle Environment
        @Assert: Lifecycle environment is deleted
        """

        payload = {"organization-id": self.org["label"], "name": test_data["name"]}

        new_obj = make_lifecycle_environment(payload)
        self.assertIsNotNone(new_obj, "Could not create lifecycle environment.")

        # Can we find the new object
        result = LifecycleEnvironment.info({"organization-id": self.org["label"], "id": new_obj["id"]})

        self.assertEqual(result.return_code, 0, "Could find the lifecycle environment")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here.")
        self.assertGreater(len(result.stdout), 0, "No output was returned")
        self.assertEqual(
            new_obj["name"], result.stdout["name"], "Could not find lifecycle environment '%s'" % new_obj["name"]
        )

        # Delete the lifecycle environment
        result = LifecycleEnvironment.delete({"id": new_obj["id"]})

        self.assertEqual(result.return_code, 0, "Could find the lifecycle environment")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here.")

        # Can we find the object
        result = LifecycleEnvironment.info({"organization-id": self.org["label"], "id": new_obj["id"]})

        self.assertGreater(result.return_code, 0, "Should not find the lifecycle environment")
        self.assertGreater(len(result.stderr), 0, "There should be an error here")
Example #3
0
    def test_positive_delete_by_id(self):
        """Create lifecycle environment with valid name, prior to
        Library

        :id: 76989039-5389-4136-9f7c-220eb38f157b

        :expectedresults: Lifecycle environment is deleted


        :CaseImportance: Critical
        """
        for name in valid_data_list():
            with self.subTest(name):
                new_lce = make_lifecycle_environment({
                    'name':
                    name,
                    'organization-id':
                    self.org['id']
                })
                LifecycleEnvironment.delete({'id': new_lce['id']})
                with self.assertRaises(CLIReturnCodeError):
                    LifecycleEnvironment.info({
                        'id': new_lce['id'],
                        'organization-id': self.org['id']
                    })
def test_positive_lce_crud(module_org):
    """CRUD test case for lifecycle environment for name, description, label, registry name pattern,
    and unauthenticated pull

    :id: 6b0fbf4f-528c-4983-bc3f-e81ccb7438fd

    :expectedresults: Lifecycle environment is created, read, updated, and deleted successfull

    :CaseImportance: High
    """
    name = gen_string('alpha')
    new_name = gen_string('alpha')
    desc = gen_string('alpha')
    new_desc = gen_string('alpha')
    label = gen_string('alpha')
    org_name = module_org.name
    registry_name_pattern = (
        "{}-<%= organization.label %>/<%= repository.docker_upstream_name %>"
    ).format(gen_string('alpha', 5))

    # create
    lce = make_lifecycle_environment({
        'organization': org_name,
        'organization-id': module_org.id,
        'name': name,
        'label': label,
        'description': desc,
    })

    assert lce['prior-lifecycle-environment'] == ENVIRONMENT
    assert lce['name'] == name
    assert lce['description'] == desc
    assert lce['label'] == label
    assert lce['organization'] == org_name

    # update
    LifecycleEnvironment.update({
        'id': lce['id'],
        'new-name': new_name,
        'description': new_desc,
        'registry-unauthenticated-pull': 'true',
        'registry-name-pattern': registry_name_pattern,
    })
    lce = LifecycleEnvironment.info({
        'id': lce['id'],
        'organization-id': module_org.id
    })
    assert lce['name'] == new_name
    assert lce['registry-name-pattern'] == registry_name_pattern
    assert lce['unauthenticated-pull'] == 'true'

    # delete
    LifecycleEnvironment.delete({'id': lce['id']})
    with pytest.raises(CLIReturnCodeError):
        LifecycleEnvironment.info({
            'id': lce['id'],
            'organization-id': module_org.id
        })
Example #5
0
    def test_positive_delete_1(self, test_data):
        """@Test: Create lifecycle environment with valid name, prior to Library

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment is deleted

        """

        payload = {
            'organization-id': self.org['id'],
            'name': test_data['name'],
        }

        new_obj = make_lifecycle_environment(payload)
        self.assertIsNotNone(new_obj,
                             "Could not create lifecycle environment.")

        # Can we find the new object
        result = LifecycleEnvironment.info({
            'organization-id': self.org['id'],
            'id': new_obj['id'],
        })

        self.assertEqual(result.return_code, 0,
                         "Could find the lifecycle environment")
        self.assertEqual(len(result.stderr), 0,
                         "There should not be an error here.")
        self.assertGreater(len(result.stdout), 0, "No output was returned")
        self.assertEqual(
            new_obj['name'], result.stdout['name'],
            "Could not find lifecycle environment \'%s\'" % new_obj['name'])

        # Delete the lifecycle environment
        result = LifecycleEnvironment.delete({'id': new_obj['id']})

        self.assertEqual(result.return_code, 0,
                         "Could find the lifecycle environment")
        self.assertEqual(len(result.stderr), 0,
                         "There should not be an error here.")

        # Can we find the object
        result = LifecycleEnvironment.info({
            'organization-id': self.org['id'],
            'id': new_obj['id'],
        })

        self.assertGreater(result.return_code, 0,
                           "Should not find the lifecycle environment")
        self.assertGreater(len(result.stderr), 0,
                           "There should be an error here")
    def test_positive_delete_by_id(self):
        """Create lifecycle environment with valid name, prior to
        Library

        @id: 76989039-5389-4136-9f7c-220eb38f157b

        @Assert: Lifecycle environment is deleted

        """
        for name in valid_data_list():
            with self.subTest(name):
                new_lce = make_lifecycle_environment({"name": name, "organization-id": self.org["id"]})
                LifecycleEnvironment.delete({"id": new_lce["id"]})
                with self.assertRaises(CLIReturnCodeError):
                    LifecycleEnvironment.info({"id": new_lce["id"], "organization-id": self.org["id"]})
    def test_positive_update_1(self, test_data):
        """@Test: Create lifecycle environment then update its name

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment name is updated

        """

        payload = {
            'organization-id': self.org['id'],
        }

        new_obj = make_lifecycle_environment(payload)

        # Update its name
        result = LifecycleEnvironment.update({
            'organization-id': self.org['id'],
            'id': new_obj['id'],
            'new-name': test_data['name'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # Fetch the object
        result = LifecycleEnvironment.info({
            'organization-id': self.org['id'],
            'id': new_obj['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertGreater(len(result.stdout), 0)
        self.assertEqual(test_data['name'], result.stdout['name'])
        self.assertNotEqual(new_obj['name'], result.stdout['name'])
    def test_positive_delete_1(self, test_data):
        """@Test: Create lifecycle environment with valid name, prior to Library

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment is deleted

        """
        new_obj = make_lifecycle_environment({
            'organization-id': self.org['id'],
            'name': test_data['name'],
        })

        # Delete the lifecycle environment
        result = LifecycleEnvironment.delete({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # Can we find the object
        result = LifecycleEnvironment.info({
            'organization-id': self.org['id'],
            'id': new_obj['id'],
        })
        self.assertGreater(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
    def test_positive_update_2(self, test_data):
        """@Test: Create lifecycle environment then update its description

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment description is updated

        """
        new_obj = make_lifecycle_environment({
            'organization-id': self.org['id'],
        })

        # Update its description
        result = LifecycleEnvironment.update({
            'description': test_data['description'],
            'id': new_obj['id'],
            'organization-id': self.org['id'],
            'prior': new_obj['prior-lifecycle-environment'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # Fetch the object
        result = LifecycleEnvironment.info({
            'id': new_obj['id'],
            'organization-id': self.org['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertGreater(len(result.stdout), 0)
        self.assertEqual(
            test_data['description'], result.stdout['description'])
        self.assertNotEqual(
            new_obj['description'], result.stdout['description'])
Example #10
0
    def test_bugzilla_1077333(self):
        """@Test: Search lifecycle environment via its name containing UTF-8 chars

        @Feature: Lifecycle Environment

        @Assert: Can get info for lifecycle by its name

        """

        payload = {
            'organization-id': self.org['id'],
            'name': gen_string('utf8', 15),
        }

        new_obj = make_lifecycle_environment(payload)
        self.assertIsNotNone(new_obj,
                             "Could not create lifecycle environment.")

        # Can we find the new object
        result = LifecycleEnvironment.info({
            'organization-id': self.org['id'],
            'name': new_obj['name'],
        })

        self.assertEqual(result.return_code, 0,
                         "Could find the lifecycle environment")
        self.assertEqual(len(result.stderr), 0,
                         "There should not be an error here.")
        self.assertGreater(len(result.stdout), 0, "No output was returned")
        self.assertEqual(
            new_obj['name'], result.stdout['name'],
            "Could not find lifecycle environment \'%s\'" % new_obj['name'])
Example #11
0
 def setup_content_view(self, org_id, lce_id=None):
     # type: (int, int) -> Tuple[Dict, Dict]
     """Setup organization content view by adding all the repositories, publishing and promoting
     to lce if needed.
     """
     if lce_id is None:
         lce = make_lifecycle_environment({'organization-id': org_id})
     else:
         lce = LifecycleEnvironment.info({
             'id': lce_id,
             'organization-id': org_id,
         })
     content_view = make_content_view({'organization-id': org_id})
     # Add repositories to content view
     for repo in self:
         repo.add_to_content_view(org_id, content_view['id'])
     # Publish the content view
     ContentView.publish({'id': content_view['id']})
     if lce['name'] != ENVIRONMENT:
         # Get the latest content view version id
         content_view_version = ContentView.info({'id': content_view['id']
                                                  })['versions'][-1]
         # Promote content view version to lifecycle environment
         ContentView.version_promote({
             'id':
             content_view_version['id'],
             'organization-id':
             org_id,
             'to-lifecycle-environment-id':
             lce['id'],
         })
     content_view = ContentView.info({'id': content_view['id']})
     return content_view, lce
Example #12
0
    def setUp(self):
        """
        Tests for Content Host via Hammer CLI
        """

        super(TestContentHost, self).setUp()

        if TestContentHost.NEW_ORG is None:
            TestContentHost.NEW_ORG = make_org()
        if TestContentHost.NEW_LIFECYCLE is None:
            TestContentHost.NEW_LIFECYCLE = make_lifecycle_environment(
                {u'organization-id': TestContentHost.NEW_ORG['id']}
            )
        if TestContentHost.LIBRARY is None:
            library_result = LifecycleEnvironment.info(
                {u'organization-id': TestContentHost.NEW_ORG['id'],
                 u'name': u'Library'}
            )
            TestContentHost.LIBRARY = library_result.stdout
        if TestContentHost.DEFAULT_CV is None:
            cv_result = ContentView.info(
                {u'organization-id': TestContentHost.NEW_ORG['id'],
                 u'name': u'Default Organization View'}
            )
            TestContentHost.DEFAULT_CV = cv_result.stdout
    def test_positive_update_name(self):
        """Create lifecycle environment then update its name

        :id: de67a44e-6c6a-430e-927b-4fa43c7c2771

        :expectedresults: Lifecycle environment name is updated


        :CaseImportance: Critical
        """
        new_lce = make_lifecycle_environment({
            'organization-id': self.org['id'],
        })
        for new_name in valid_data_list():
            with self.subTest(new_name):
                LifecycleEnvironment.update({
                    'id': new_lce['id'],
                    'new-name': new_name,
                    'organization-id': self.org['id'],
                })
                result = LifecycleEnvironment.info({
                    'id': new_lce['id'],
                    'organization-id': self.org['id'],
                })
                self.assertGreater(len(result), 0)
                self.assertEqual(result['name'], new_name)
    def test_positive_update_description(self):
        """Create lifecycle environment then update its description

        :id: 15b82949-3c3a-4942-b42b-db1de34cf5be

        :expectedresults: Lifecycle environment description is updated


        :CaseImportance: Critical
        """
        new_lce = make_lifecycle_environment({
            'organization-id': self.org['id'],
        })
        for new_desc in valid_data_list():
            with self.subTest(new_desc):
                LifecycleEnvironment.update({
                    'description': new_desc,
                    'id': new_lce['id'],
                    'organization-id': self.org['id'],
                })
                result = LifecycleEnvironment.info({
                    'id': new_lce['id'],
                    'organization-id': self.org['id'],
                })
                self.assertGreater(len(result), 0)
                self.assertEqual(result['description'], new_desc)
    def test_positive_update_description(self):
        """Create lifecycle environment then update its description

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment description is updated

        """
        new_lce = make_lifecycle_environment({
            'organization-id': self.org['id'],
        })
        for new_desc in valid_data_list():
            with self.subTest(new_desc):
                LifecycleEnvironment.update({
                    'description':
                    new_desc,
                    'id':
                    new_lce['id'],
                    'organization-id':
                    self.org['id'],
                    'prior':
                    new_lce['prior-lifecycle-environment'],
                })
                result = LifecycleEnvironment.info({
                    'id':
                    new_lce['id'],
                    'organization-id':
                    self.org['id'],
                })
                self.assertGreater(len(result), 0)
                self.assertEqual(result['description'], new_desc)
Example #16
0
    def test_positive_update_name(self):
        """Create lifecycle environment then update its name

        :id: de67a44e-6c6a-430e-927b-4fa43c7c2771

        :expectedresults: Lifecycle environment name is updated


        :CaseImportance: Critical
        """
        new_lce = make_lifecycle_environment(
            {'organization-id': self.org['id']})
        for new_name in valid_data_list():
            with self.subTest(new_name):
                LifecycleEnvironment.update({
                    'id': new_lce['id'],
                    'new-name': new_name,
                    'organization-id': self.org['id']
                })
                result = LifecycleEnvironment.info({
                    'id':
                    new_lce['id'],
                    'organization-id':
                    self.org['id']
                })
                self.assertGreater(len(result), 0)
                self.assertEqual(result['name'], new_name)
Example #17
0
    def setUp(self):
        """
        Tests for activation keys via Hammer CLI
        """

        super(TestActivationKey, self).setUp()

        if TestActivationKey.org is None:
            TestActivationKey.org = make_org()
        if TestActivationKey.env1 is None:
            TestActivationKey.env1 = make_lifecycle_environment(
                {u'organization-id': TestActivationKey.org['id']})
        if TestActivationKey.env2 is None:
            TestActivationKey.env2 = make_lifecycle_environment({
                u'organization-id':
                TestActivationKey.org['id'],
                u'prior':
                TestActivationKey.env1['label']
            })
        if TestActivationKey.product is None:
            TestActivationKey.product = make_product(
                {u'organization-id': TestActivationKey.org['id']})

        if TestActivationKey.library is None:
            TestActivationKey.library = LifecycleEnvironment.info({
                'organization-id':
                TestActivationKey.org['id'],
                'name':
                'Library'
            }).stdout
Example #18
0
    def test_positive_update_2(self, test_data):
        """
        @Test: Create lifecycle environment then update its description
        @Feature: Lifecycle Environment
        @Assert: Lifecycle environment description is updated
        """

        payload = {"organization-id": self.org["label"]}

        new_obj = make_lifecycle_environment(payload)
        self.assertIsNotNone(new_obj, "Could not create lifecycle environment.")

        # Update its description
        result = LifecycleEnvironment.update(
            {"organization-id": self.org["label"], "id": new_obj["id"], "description": test_data["description"]}
        )
        self.assertEqual(result.return_code, 0, "Could find the lifecycle environment")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here.")

        # Fetch the object
        result = LifecycleEnvironment.info({"organization-id": self.org["label"], "id": new_obj["id"]})
        self.assertEqual(result.return_code, 0, "Could find the lifecycle environment")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here.")
        self.assertGreater(len(result.stdout), 0, "No output was returned")
        self.assertEqual(test_data["description"], result.stdout["description"], "Description was not updated")
        self.assertNotEqual(
            new_obj["description"], result.stdout["description"], "Description should have been updated"
        )
    def test_positive_update_1(self):
        """@Test: Create lifecycle environment then update its name

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment name is updated

        """
        new_lce = make_lifecycle_environment({
            'organization-id': self.org['id'],
        })
        for new_name in valid_data_list():
            with self.subTest(new_name):
                LifecycleEnvironment.update({
                    'id': new_lce['id'],
                    'new-name': new_name,
                    'organization-id': self.org['id'],
                    'prior': new_lce['prior-lifecycle-environment'],
                })
                result = LifecycleEnvironment.info({
                    'id': new_lce['id'],
                    'organization-id': self.org['id'],
                })
                self.assertGreater(len(result), 0)
                self.assertEqual(result['name'], new_name)
Example #20
0
 def setup_content_view(self, org_id, lce_id=None):
     # type: (int, int) -> Tuple[Dict, Dict]
     """Setup organization content view by adding all the repositories, publishing and promoting
     to lce if needed.
     """
     if lce_id is None:
         lce = make_lifecycle_environment({'organization-id': org_id})
     else:
         lce = LifecycleEnvironment.info({
             'id': lce_id,
             'organization-id': org_id,
         })
     content_view = make_content_view({'organization-id': org_id})
     # Add repositories to content view
     for repo in self:
         repo.add_to_content_view(org_id, content_view['id'])
     # Publish the content view
     ContentView.publish({'id': content_view['id']})
     if lce['name'] != ENVIRONMENT:
         # Get the latest content view version id
         content_view_version = ContentView.info({
             'id': content_view['id']
         })['versions'][-1]
         # Promote content view version to lifecycle environment
         ContentView.version_promote({
             'id': content_view_version['id'],
             'organization-id': org_id,
             'to-lifecycle-environment-id': lce['id'],
         })
     content_view = ContentView.info({'id': content_view['id']})
     return content_view, lce
Example #21
0
    def test_positive_update_unauthenticated_pull(self):
        """Create lifecycle environment and then update registry's
        unauthenticated pull

        :id: 8b73e0b7-30c9-4211-87a4-53dc0b0f3e21

        :expectedresults: Lifecycle environment registry's unauthenticated pull
            is updated


        :CaseImportance: Critical
        """
        lce = make_lifecycle_environment({'organization-id': self.org['id']})

        LifecycleEnvironment.update({
            'registry-unauthenticated-pull': 'true',
            'id': lce['id'],
            'organization-id': self.org['id'],
        })
        result = LifecycleEnvironment.info({
            'id': lce['id'],
            'organization-id': self.org['id']
        })
        self.assertGreater(len(result), 0)
        self.assertEqual(result['unauthenticated-pull'], 'true')
Example #22
0
    def test_positive_update_registry_name_pattern(self):
        """Create lifecycle environment and then update registry name pattern

        :id: 131aaed7-d74f-4c9a-be7e-04226d48e64a

        :expectedresults: Lifecycle environment registry name pattern is updated


        :CaseImportance: Critical
        """
        lce = make_lifecycle_environment({'organization-id': self.org['id']})
        registry_name_pattern = (
            "{}-<%= organization.label %>/<%= repository.docker_upstream_name %>"
        ).format(gen_string('alpha', 5))

        LifecycleEnvironment.update({
            'registry-name-pattern': registry_name_pattern,
            'id': lce['id'],
            'organization-id': self.org['id'],
        })
        result = LifecycleEnvironment.info({
            'id': lce['id'],
            'organization-id': self.org['id']
        })
        self.assertGreater(len(result), 0)
        self.assertEqual(result['registry-name-pattern'],
                         registry_name_pattern)
Example #23
0
 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
    def test_positive_update_description(self):
        """Create lifecycle environment then update its description

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment description is updated

        """
        new_lce = make_lifecycle_environment({
            'organization-id': self.org['id'],
        })
        for new_desc in valid_data_list():
            with self.subTest(new_desc):
                LifecycleEnvironment.update({
                    'description': new_desc,
                    'id': new_lce['id'],
                    'organization-id': self.org['id'],
                    'prior': new_lce['prior-lifecycle-environment'],
                })
                result = LifecycleEnvironment.info({
                    'id': new_lce['id'],
                    'organization-id': self.org['id'],
                })
                self.assertGreater(len(result), 0)
                self.assertEqual(result['description'], new_desc)
    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 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 #27
0
    def test_positive_update_description(self):
        """Create lifecycle environment then update its description

        :id: 15b82949-3c3a-4942-b42b-db1de34cf5be

        :expectedresults: Lifecycle environment description is updated


        :CaseImportance: Critical
        """
        new_lce = make_lifecycle_environment(
            {'organization-id': self.org['id']})
        for new_desc in valid_data_list():
            with self.subTest(new_desc):
                LifecycleEnvironment.update({
                    'description': new_desc,
                    'id': new_lce['id'],
                    'organization-id': self.org['id'],
                })
                result = LifecycleEnvironment.info({
                    'id':
                    new_lce['id'],
                    'organization-id':
                    self.org['id']
                })
                self.assertGreater(len(result), 0)
                self.assertEqual(result['description'], new_desc)
Example #28
0
 def get_default_env():
     """Get default lifecycle environment"""
     return LifecycleEnvironment.info({
         'organization-id':
         ActivationKeyTestCase.org['id'],
         'name':
         'Library',
     })
Example #29
0
    def test_positive_update_1(self, test_data):
        """@Test: Create lifecycle environment then update its name

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment name is updated

        @BZ: 1095937, 1099655

        """

        payload = {
            'organization-id': self.org['id'],
            }

        new_obj = make_lifecycle_environment(payload)
        self.assertIsNotNone(
            new_obj, "Could not create lifecycle environment.")

        # Update its name
        result = LifecycleEnvironment.update(
            {
                'organization-id': self.org['id'],
                'id': new_obj['id'],
                'new-name': test_data['name'],
            }
        )
        self.assertEqual(
            result.return_code, 0, "Could find the lifecycle environment"
        )
        self.assertEqual(
            len(result.stderr), 0, "There should not be an error here.")

        # Fetch the object
        result = LifecycleEnvironment.info(
            {
                'organization-id': self.org['id'],
                'id': new_obj['id'],
            }
        )
        self.assertEqual(
            result.return_code, 0, "Could find the lifecycle environment"
        )
        self.assertEqual(
            len(result.stderr), 0, "There should not be an error here.")
        self.assertGreater(
            len(result.stdout), 0, "No output was returned"
        )
        self.assertEqual(
            test_data['name'],
            result.stdout['name'],
            "Name was not updated"
        )
        self.assertNotEqual(
            new_obj['name'],
            result.stdout['name'],
            "Name should have been updated"
        )
Example #30
0
 def setUpClass(cls):
     """Prepare some data to be used in tests"""
     super(HostCollectionTestCase, cls).setUpClass()
     cls.organization = make_org()
     cls.library = LifecycleEnvironment.info(
         {'organization-id': cls.organization['id'], 'name': ENVIRONMENT}
     )
     cls.default_cv = ContentView.info(
         {'organization-id': cls.organization['id'], 'name': DEFAULT_CV}
     )
     make_host_collection({'organization-id': cls.organization['id']})
    def test_positive_delete_by_id(self):
        """Create lifecycle environment with valid name, prior to
        Library

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment is deleted

        """
        for name in valid_data_list():
            with self.subTest(name):
                new_lce = make_lifecycle_environment({
                    'name': name,
                    'organization-id': self.org['id'],
                })
                LifecycleEnvironment.delete({'id': new_lce['id']})
                with self.assertRaises(CLIReturnCodeError):
                    LifecycleEnvironment.info({
                        'id': new_lce['id'],
                        'organization-id': self.org['id'],
                    })
Example #32
0
def _make_fake_host_helper(module_org):
    """Make a new fake host"""
    library = LifecycleEnvironment.info({'organization-id': module_org.id, 'name': ENVIRONMENT})
    default_cv = ContentView.info({'organization-id': module_org.id, 'name': DEFAULT_CV})
    return make_fake_host(
        {
            'content-view-id': default_cv['id'],
            'lifecycle-environment-id': library['id'],
            'name': gen_string('alpha', 15),
            'organization-id': module_org.id,
        }
    )
 def setUpClass(cls):
     """Prepare some data to be used in tests"""
     super(HostCollectionTestCase, cls).setUpClass()
     cls.organization = make_org()
     cls.library = LifecycleEnvironment.info({
         u'organization-id': cls.organization['id'],
         u'name': ENVIRONMENT,
     })
     cls.default_cv = ContentView.info({
         u'organization-id': cls.organization['id'],
         u'name': DEFAULT_CV
     })
    def test_positive_delete_by_id(self):
        """Create lifecycle environment with valid name, prior to
        Library

        :id: 76989039-5389-4136-9f7c-220eb38f157b

        :expectedresults: Lifecycle environment is deleted


        :CaseImportance: Critical
        """
        for name in valid_data_list():
            with self.subTest(name):
                new_lce = make_lifecycle_environment({
                    'name': name,
                    'organization-id': self.org['id'],
                })
                LifecycleEnvironment.delete({'id': new_lce['id']})
                with self.assertRaises(CLIReturnCodeError):
                    LifecycleEnvironment.info({
                        'id': new_lce['id'],
                        'organization-id': self.org['id'],
                    })
    def test_verify_bugzilla_1077333(self):
        """Search lifecycle environment via its name containing UTF-8
        chars

        @id: d15001ed-5bbf-43cf-bdd3-1e129dff14ec

        @Assert: Can get info for lifecycle by its name

        """
        test_data = {"name": gen_string("utf8", 15), "organization-id": self.org["id"]}
        # Can we find the new object
        result = LifecycleEnvironment.info(
            {"name": make_lifecycle_environment(test_data)["name"], "organization-id": self.org["id"]}
        )
        self.assertEqual(result["name"], test_data["name"])
Example #36
0
    def test_positive_create_2(self, test_data):
        """@Test: Create lifecycle environment with valid name and description,
        prior to Library

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment is created with Library as prior

        @BZ: 1099655

        """

        payload = {
            'organization-id': self.org['id'],
            'name': test_data['name'],
            'description': test_data['name'],
            }

        new_obj = make_lifecycle_environment(payload)
        self.assertIsNotNone(
            new_obj, "Could not create lifecycle environment.")

        # Can we find the new object
        result = LifecycleEnvironment.info(
            {
                'organization-id': self.org['id'],
                'id': new_obj['id'],
            }
        )

        self.assertEqual(
            result.return_code, 0, "Could find the lifecycle environment"
        )
        self.assertEqual(
            len(result.stderr), 0, "There should not be an error here.")
        self.assertGreater(
            len(result.stdout), 0, "No output was returned"
        )
        self.assertEqual(
            new_obj['name'],
            result.stdout['name'],
            "Could not find lifecycle environment \'%s\'" % new_obj['name']
        )
        self.assertEqual(
            new_obj['description'],
            result.stdout['description'],
            "Descriptions don't match"
        )
Example #37
0
    def test_positive_update_2(self, test_data):
        """@Test: Create lifecycle environment then update its description

        @Feature: Lifecycle Environment

        @Assert: Lifecycle environment description is updated

        """

        payload = {
            'organization-id': self.org['id'],
        }

        new_obj = make_lifecycle_environment(payload)
        self.assertIsNotNone(new_obj,
                             "Could not create lifecycle environment.")

        # Update its description
        result = LifecycleEnvironment.update({
            'organization-id':
            self.org['id'],
            'id':
            new_obj['id'],
            'description':
            test_data['description'],
        })
        self.assertEqual(result.return_code, 0,
                         "Could find the lifecycle environment")
        self.assertEqual(len(result.stderr), 0,
                         "There should not be an error here.")

        # Fetch the object
        result = LifecycleEnvironment.info({
            'organization-id': self.org['id'],
            'id': new_obj['id'],
        })
        self.assertEqual(result.return_code, 0,
                         "Could find the lifecycle environment")
        self.assertEqual(len(result.stderr), 0,
                         "There should not be an error here.")
        self.assertGreater(len(result.stdout), 0, "No output was returned")
        self.assertEqual(test_data['description'],
                         result.stdout['description'],
                         "Description was not updated")
        self.assertNotEqual(new_obj['description'],
                            result.stdout['description'],
                            "Description should have been updated")
    def test_positive_update_description(self):
        """Create lifecycle environment then update its description

        @id: 15b82949-3c3a-4942-b42b-db1de34cf5be

        @Assert: Lifecycle environment description is updated

        """
        new_lce = make_lifecycle_environment({"organization-id": self.org["id"]})
        for new_desc in valid_data_list():
            with self.subTest(new_desc):
                LifecycleEnvironment.update(
                    {"description": new_desc, "id": new_lce["id"], "organization-id": self.org["id"]}
                )
                result = LifecycleEnvironment.info({"id": new_lce["id"], "organization-id": self.org["id"]})
                self.assertGreater(len(result), 0)
                self.assertEqual(result["description"], new_desc)
    def test_positive_update_name(self):
        """Create lifecycle environment then update its name

        @id: de67a44e-6c6a-430e-927b-4fa43c7c2771

        @Assert: Lifecycle environment name is updated

        """
        new_lce = make_lifecycle_environment({"organization-id": self.org["id"]})
        for new_name in valid_data_list():
            with self.subTest(new_name):
                LifecycleEnvironment.update(
                    {"id": new_lce["id"], "new-name": new_name, "organization-id": self.org["id"]}
                )
                result = LifecycleEnvironment.info({"id": new_lce["id"], "organization-id": self.org["id"]})
                self.assertGreater(len(result), 0)
                self.assertEqual(result["name"], new_name)
Example #40
0
    def setUp(self):  # noqa
        """Tests for Host Collections via Hammer CLI"""

        super(TestHostCollection, self).setUp()

        if TestHostCollection.org is None:
            TestHostCollection.org = make_org(cached=True)
        if TestHostCollection.new_lifecycle is None:
            TestHostCollection.new_lifecycle = make_lifecycle_environment(
                {u'organization-id': TestHostCollection.org['id']},
                cached=True)
        if TestHostCollection.library is None:
            library_result = LifecycleEnvironment.info({
                u'organization-id':
                TestHostCollection.org['id'],
                u'name':
                u'Library'
            })
            TestHostCollection.library = library_result.stdout
        if TestHostCollection.default_cv is None:
            cv_result = ContentView.info({
                u'organization-id':
                TestHostCollection.org['id'],
                u'name':
                u'Default Organization View'
            })
            TestHostCollection.default_cv = cv_result.stdout
        if TestHostCollection.new_cv is None:
            TestHostCollection.new_cv = make_content_view(
                {u'organization-id': TestHostCollection.org['id']})
            TestHostCollection.promoted_cv = None
            cv_id = TestHostCollection.new_cv['id']
            ContentView.publish({u'id': cv_id})
            result = ContentView.version_list({u'content-view-id': cv_id})
            version_id = result.stdout[0]['id']
            promotion = ContentView.version_promote({
                u'id':
                version_id,
                u'to-lifecycle-environment-id':
                (TestHostCollection.new_lifecycle['id']),
                u'organization-id':
                TestHostCollection.org['id']
            })
            if promotion.stderr == []:
                TestHostCollection.promoted_cv = TestHostCollection.new_cv
Example #41
0
    def setUp(self):  # noqa
        """Tests for Content Host via Hammer CLI"""

        super(TestContentHost, self).setUp()

        if TestContentHost.NEW_ORG is None:
            TestContentHost.NEW_ORG = make_org(cached=True)
        if TestContentHost.NEW_LIFECYCLE is None:
            TestContentHost.NEW_LIFECYCLE = make_lifecycle_environment(
                {u'organization-id': TestContentHost.NEW_ORG['id']},
                cached=True)
        if TestContentHost.LIBRARY is None:
            library_result = LifecycleEnvironment.info({
                u'organization-id':
                TestContentHost.NEW_ORG['id'],
                u'name':
                u'Library'
            })
            TestContentHost.LIBRARY = library_result.stdout
        if TestContentHost.DEFAULT_CV is None:
            cv_result = ContentView.info({
                u'organization-id':
                TestContentHost.NEW_ORG['id'],
                u'name':
                u'Default Organization View'
            })
            TestContentHost.DEFAULT_CV = cv_result.stdout
        if TestContentHost.NEW_CV is None:
            TestContentHost.NEW_CV = make_content_view(
                {u'organization-id': TestContentHost.NEW_ORG['id']})
            TestContentHost.PROMOTED_CV = None
            cv_id = TestContentHost.NEW_CV['id']
            ContentView.publish({u'id': cv_id})
            result = ContentView.version_list({u'content-view-id': cv_id})
            version_id = result.stdout[0]['id']
            promotion = ContentView.version_promote({
                u'id':
                version_id,
                u'to-lifecycle-environment-id':
                TestContentHost.NEW_LIFECYCLE['id'],
                u'organization-id':
                TestContentHost.NEW_ORG['id']
            })
            if promotion.stderr == []:
                TestContentHost.PROMOTED_CV = TestContentHost.NEW_CV
Example #42
0
    def setUp(self):  # noqa
        """Tests for Host Collections via Hammer CLI"""
        super(TestHostCollection, self).setUp()

        if TestHostCollection.org is None:
            TestHostCollection.org = make_org(cached=True)
        if TestHostCollection.new_lifecycle is None:
            TestHostCollection.new_lifecycle = make_lifecycle_environment(
                {u'organization-id': TestHostCollection.org['id']},
                cached=True
            )
        if TestHostCollection.library is None:
            result = LifecycleEnvironment.info({
                u'organization-id': TestHostCollection.org['id'],
                u'name': u'Library',
            })
            self.assertEqual(result.return_code, 0)
            TestHostCollection.library = result.stdout
        if TestHostCollection.default_cv is None:
            result = ContentView.info(
                {u'organization-id': TestHostCollection.org['id'],
                 u'name': u'Default Organization View'}
            )
            self.assertEqual(result.return_code, 0)
            TestHostCollection.default_cv = result.stdout
        if TestHostCollection.new_cv is None:
            TestHostCollection.new_cv = make_content_view(
                {u'organization-id': TestHostCollection.org['id']}
            )
            TestHostCollection.promoted_cv = None
            cv_id = TestHostCollection.new_cv['id']
            result = ContentView.publish({u'id': cv_id})
            self.assertEqual(result.return_code, 0)
            result = ContentView.version_list({u'content-view-id': cv_id})
            self.assertEqual(result.return_code, 0)
            version_id = result.stdout[0]['id']
            result = ContentView.version_promote({
                u'id': version_id,
                u'to-lifecycle-environment-id': (
                    TestHostCollection.new_lifecycle['id']),
                u'organization-id': TestHostCollection.org['id']
            })
            self.assertEqual(result.return_code, 0)
            TestHostCollection.promoted_cv = TestHostCollection.new_cv
    def test_verify_bugzilla_1077333(self):
        """Search lifecycle environment via its name containing UTF-8
        chars

        @Feature: Lifecycle Environment

        @Assert: Can get info for lifecycle by its name

        """
        test_data = {
            'name': gen_string('utf8', 15),
            'organization-id': self.org['id'],
        }
        # Can we find the new object
        result = LifecycleEnvironment.info({
            'name': make_lifecycle_environment(test_data)['name'],
            'organization-id': self.org['id'],
        })
        self.assertEqual(result['name'], test_data['name'])
Example #44
0
    def setUp(self):  # noqa
        """Tests for Content Host via Hammer CLI"""
        super(TestContentHost, self).setUp()

        if TestContentHost.NEW_ORG is None:
            TestContentHost.NEW_ORG = make_org(cached=True)
        if TestContentHost.NEW_LIFECYCLE is None:
            TestContentHost.NEW_LIFECYCLE = make_lifecycle_environment(
                {u'organization-id': TestContentHost.NEW_ORG['id']},
                cached=True)
        if TestContentHost.LIBRARY is None:
            result = LifecycleEnvironment.info({
                u'organization-id': TestContentHost.NEW_ORG['id'],
                u'name': u'Library',
            })
            self.assertEqual(result.return_code, 0)
            TestContentHost.LIBRARY = result.stdout
        if TestContentHost.DEFAULT_CV is None:
            result = ContentView.info({
                u'organization-id': TestContentHost.NEW_ORG['id'],
                u'name': u'Default Organization View',
            })
            self.assertEqual(result.return_code, 0)
            TestContentHost.DEFAULT_CV = result.stdout
        if TestContentHost.NEW_CV is None:
            TestContentHost.NEW_CV = make_content_view({
                u'organization-id': TestContentHost.NEW_ORG['id'],
            })
            TestContentHost.PROMOTED_CV = None
            cv_id = TestContentHost.NEW_CV['id']
            result = ContentView.publish({u'id': cv_id})
            self.assertEqual(result.return_code, 0)
            result = ContentView.version_list({u'content-view-id': cv_id})
            self.assertEqual(result.return_code, 0)
            version_id = result.stdout[0]['id']
            result = ContentView.version_promote({
                u'id': version_id,
                u'to-lifecycle-environment-id': TestContentHost.NEW_LIFECYCLE[
                    'id'],
                u'organization-id': TestContentHost.NEW_ORG['id']
            })
            self.assertEqual(result.return_code, 0)
            TestContentHost.PROMOTED_CV = TestContentHost.NEW_CV
Example #45
0
    def setUp(self):
        """
        Tests for Content Host via Hammer CLI
        """

        super(TestContentHost, self).setUp()

        if TestContentHost.NEW_ORG is None:
            TestContentHost.NEW_ORG = make_org()
        if TestContentHost.NEW_LIFECYCLE is None:
            TestContentHost.NEW_LIFECYCLE = make_lifecycle_environment(
                {u'organization-id': TestContentHost.NEW_ORG['id']}
            )
        if TestContentHost.LIBRARY is None:
            library_result = LifecycleEnvironment.info(
                {u'organization-id': TestContentHost.NEW_ORG['id'],
                 u'name': u'Library'}
            )
            TestContentHost.LIBRARY = library_result.stdout
        if TestContentHost.DEFAULT_CV is None:
            cv_result = ContentView.info(
                {u'organization-id': TestContentHost.NEW_ORG['id'],
                 u'name': u'Default Organization View'}
            )
            TestContentHost.DEFAULT_CV = cv_result.stdout
        if TestContentHost.NEW_CV is None:
            TestContentHost.NEW_CV = make_content_view(
                {u'organization-id': TestContentHost.NEW_ORG['id']}
            )
            TestContentHost.PROMOTED_CV = None
            cv_id = TestContentHost.NEW_CV['id']
            ContentView.publish({u'id': cv_id})
            result = ContentView.version_list({u'content-view-id': cv_id})
            version_id = result.stdout[0]['id']
            promotion = ContentView.version_promote({
                u'id': version_id,
                u'lifecycle-environment-id': TestContentHost.NEW_LIFECYCLE[
                    'id'],
                u'organization-id': TestContentHost.NEW_ORG['id']
            })
            if promotion.stderr == []:
                TestContentHost.PROMOTED_CV = TestContentHost.NEW_CV
Example #46
0
    def setUp(self):
        """Tests for activation keys via Hammer CLI"""

        super(TestActivationKey, self).setUp()

        if TestActivationKey.org is None:
            TestActivationKey.org = make_org()
        if TestActivationKey.env1 is None:
            TestActivationKey.env1 = make_lifecycle_environment({u"organization-id": TestActivationKey.org["id"]})
        if TestActivationKey.env2 is None:
            TestActivationKey.env2 = make_lifecycle_environment(
                {u"organization-id": TestActivationKey.org["id"], u"prior": TestActivationKey.env1["label"]}
            )
        if TestActivationKey.product is None:
            TestActivationKey.product = make_product({u"organization-id": TestActivationKey.org["id"]})

        if TestActivationKey.library is None:
            TestActivationKey.library = LifecycleEnvironment.info(
                {"organization-id": TestActivationKey.org["id"], "name": "Library"}
            ).stdout
Example #47
0
    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
Example #48
0
    def test_bugzilla_1077333(self):
        """@Test: Search lifecycle environment via its name containing UTF-8 chars

        @Feature: Lifecycle Environment

        @Assert: Can get info for lifecycle by its name

        @BZ: 1077333, 1099655

        """

        payload = {
            'organization-id': self.org['id'],
            'name': generate_string('utf8', 15),
            }

        new_obj = make_lifecycle_environment(payload)
        self.assertIsNotNone(
            new_obj, "Could not create lifecycle environment.")

        # Can we find the new object
        result = LifecycleEnvironment.info(
            {
                'organization-id': self.org['id'],
                'name': new_obj['name'],
            }
        )

        self.assertEqual(
            result.return_code, 0, "Could find the lifecycle environment"
        )
        self.assertEqual(
            len(result.stderr), 0, "There should not be an error here.")
        self.assertGreater(
            len(result.stdout), 0, "No output was returned"
        )
        self.assertEqual(
            new_obj['name'],
            result.stdout['name'],
            "Could not find lifecycle environment \'%s\'" % new_obj['name']
        )
    def test_verify_bugzilla_1077333(self):
        """Search lifecycle environment via its name containing UTF-8
        chars

        :id: d15001ed-5bbf-43cf-bdd3-1e129dff14ec

        :expectedresults: Can get info for lifecycle by its name


        :CaseImportance: Critical
        """
        test_data = {
            'name': gen_string('utf8', 15),
            'organization-id': self.org['id'],
        }
        # Can we find the new object
        result = LifecycleEnvironment.info({
            'name': make_lifecycle_environment(test_data)['name'],
            'organization-id': self.org['id'],
        })
        self.assertEqual(result['name'], test_data['name'])
    def test_bugzilla_1077333(self):
        """@Test: Search lifecycle environment via its name containing UTF-8 chars

        @Feature: Lifecycle Environment

        @Assert: Can get info for lifecycle by its name

        """
        data = {
            'organization-id': self.org['id'],
            'name': gen_string('utf8', 15),
        }

        # Can we find the new object
        result = LifecycleEnvironment.info({
            'organization-id': self.org['id'],
            'name': make_lifecycle_environment(data)['name'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(result.stdout['name'], data['name'])
    def test_verify_bugzilla_1077333(self):
        """Search lifecycle environment via its name containing UTF-8
        chars

        @Feature: Lifecycle Environment

        @Assert: Can get info for lifecycle by its name

        """
        test_data = {
            'name': gen_string('utf8', 15),
            'organization-id': self.org['id'],
        }
        # Can we find the new object
        result = LifecycleEnvironment.info({
            'name':
            make_lifecycle_environment(test_data)['name'],
            'organization-id':
            self.org['id'],
        })
        self.assertEqual(result['name'], test_data['name'])
Example #52
0
    def test_verify_bugzilla_1077333(self):
        """Search lifecycle environment via its name containing UTF-8
        chars

        :id: d15001ed-5bbf-43cf-bdd3-1e129dff14ec

        :expectedresults: Can get info for lifecycle by its name


        :CaseImportance: High
        """
        test_data = {
            'name': gen_string('utf8', 15),
            'organization-id': self.org['id']
        }
        # Can we find the new object
        result = LifecycleEnvironment.info({
            'name':
            make_lifecycle_environment(test_data)['name'],
            'organization-id':
            self.org['id'],
        })
        self.assertEqual(result['name'], test_data['name'])
def test_positive_search_lce_via_UTF8(module_org):
    """Search lifecycle environment via its name containing UTF-8
    chars

    :id: d15001ed-5bbf-43cf-bdd3-1e129dff14ec

    :expectedresults: Can get info for lifecycle by its name

    :BZ: 1077333

    :CaseImportance: High
    """
    test_data = {
        'name': gen_string('utf8', 15),
        'organization-id': module_org.id
    }
    # Can we find the new object
    result = LifecycleEnvironment.info({
        'name':
        make_lifecycle_environment(test_data)['name'],
        'organization-id':
        module_org.id
    })
    assert result['name'] == test_data['name']
Example #54
0
    def virt_who_hypervisor_config(
        self,
        config_id,
        org_id=None,
        lce_id=None,
        hypervisor_hostname=None,
        configure_ssh=False,
        hypervisor_user=None,
        subscription_name=None,
        exec_one_shot=False,
        upload_manifest=True,
        extra_repos=None,
    ):
        """
        Configure virtual machine as hypervisor virt-who service

        :param int config_id: virt-who config id
        :param int org_id: the organization id
        :param int lce_id: the lifecycle environment id to use
        :param str hypervisor_hostname: the hypervisor hostname
        :param str hypervisor_user: hypervisor user that connect with the ssh key
        :param bool configure_ssh: configure the ssh key to allow host to connect to hypervisor
        :param str subscription_name: the subscription name to assign to virt-who hypervisor guests
        :param bool exec_one_shot: whether to run the virt-who one-shot command after startup
        :param bool upload_manifest: whether to upload the organization manifest
        :param list extra_repos: (Optional) repositories dict options to setup additionally.
        """
        from robottelo.cli.org import Org
        from robottelo.cli import factory as cli_factory
        from robottelo.cli.lifecycleenvironment import LifecycleEnvironment
        from robottelo.cli.subscription import Subscription
        from robottelo.cli.virt_who_config import VirtWhoConfig

        org = cli_factory.make_org() if org_id is None else Org.info(
            {'id': org_id})

        if lce_id is None:
            lce = cli_factory.make_lifecycle_environment(
                {'organization-id': org['id']})
        else:
            lce = LifecycleEnvironment.info({
                'id': lce_id,
                'organization-id': org['id']
            })
        extra_repos = extra_repos or []
        repos = [
            # Red Hat Satellite Tools
            {
                'product': constants.PRDS['rhel'],
                'repository-set': constants.REPOSET['rhst7'],
                'repository': constants.REPOS['rhst7']['name'],
                'repository-id': constants.REPOS['rhst7']['id'],
                'url': settings.sattools_repo['rhel7'],
                'cdn': bool(settings.cdn
                            or not settings.sattools_repo['rhel7']),
            }
        ]
        repos.extend(extra_repos)
        content_setup_data = cli_factory.setup_cdn_and_custom_repos_content(
            org['id'],
            lce['id'],
            repos,
            upload_manifest=upload_manifest,
            rh_subscriptions=[constants.DEFAULT_SUBSCRIPTION_NAME],
        )
        activation_key = content_setup_data['activation_key']
        content_view = content_setup_data['content_view']
        self.contenthost_setup(
            org_label=org['label'],
            activation_key=activation_key['name'],
            patch_os_release_distro=constants.DISTRO_RHEL7,
            rh_repo_ids=[
                repo['repository-id'] for repo in repos if repo['cdn']
            ],
            install_katello_agent=False,
        )
        # configure manually RHEL custom repo url as sync time is very big
        # (more than 2 hours for RHEL 7Server) and not critical in this context.
        rhel_repo_option_name = (
            f'rhel{constants.DISTROS_MAJOR_VERSION[constants.DISTRO_RHEL7]}_repo'
        )
        rhel_repo_url = getattr(settings.repos, rhel_repo_option_name, None)
        if not rhel_repo_url:
            raise ValueError(
                f'Settings option "{rhel_repo_option_name}" is whether not set or does not exist'
            )
        self.configure_rhel_repo(rhel_repo_url)
        if hypervisor_hostname and configure_ssh:
            # configure ssh access of hypervisor from self
            hypervisor_ssh_key_name = f'hypervisor-{gen_alpha().lower()}.key'
            # upload the ssh key
            self.put_ssh_key(settings.server.ssh_key, hypervisor_ssh_key_name)
            # setup the ssh config and known_hosts files
            self.update_known_hosts(self,
                                    hypervisor_ssh_key_name,
                                    hypervisor_hostname,
                                    user=hypervisor_user)

        # upload the virt-who config deployment script
        virt_who_deploy_directory = '/root/virt_who_deploy_output'
        virt_who_deploy_filename = f'{gen_alpha(length=5)}-virt-who-deploy-{config_id}'
        virt_who_deploy_file = f'{virt_who_deploy_directory}/{virt_who_deploy_filename}'
        VirtWhoConfig.fetch({'id': config_id, 'output': virt_who_deploy_file})
        # remote_copy from satellite to self
        satellite = Satellite(settings.server.hostname)
        satellite.session.remote_copy(virt_who_deploy_file, self)

        # ensure the virt-who config deploy script is executable
        result = self.run(f'chmod +x {virt_who_deploy_file}')
        if result.status != 0:
            raise CLIFactoryError(
                f'Failed to set deployment script as executable:\n{result.stderr}'
            )
        # execute the deployment script
        result = self.run(f'{virt_who_deploy_file}')
        if result.status != 0:
            raise CLIFactoryError(
                f'Deployment script failure:\n{result.stderr}')
        # after this step, we should have virt-who service installed and started
        if exec_one_shot:
            # usually to be sure that the virt-who generated the report we need
            # to force a one shot report, for this we have to stop the virt-who
            # service
            result = self.run('service virt-who stop')
            if result.status != 0:
                raise CLIFactoryError(
                    f'Failed to stop the virt-who service:\n{result.stderr}')
            result = self.run('virt-who --one-shot', timeout=900)
            if result.status != 0:
                raise CLIFactoryError(
                    f'Failed when executing virt-who --one-shot:\n{result.stderr}'
                )
            result = self.run('service virt-who start')
            if result.status != 0:
                raise CLIFactoryError(
                    f'Failed to start the virt-who service:\n{result.stderr}')
        # after this step the hypervisor as a content host should be created
        # do not confuse virt-who host with hypervisor host as they can be
        # diffrent hosts and as per this setup we have only registered the virt-who
        # host, the hypervisor host should registered after virt-who send the
        # first report when started or with one shot command
        # the virt-who hypervisor will be registered to satellite with host name
        # like "virt-who-{hypervisor_hostname}-{organization_id}"
        virt_who_hypervisor_hostname = f'virt-who-{hypervisor_hostname}-{org["id"]}'
        # find the registered virt-who hypervisor host
        org_hosts = Host.list({
            'organization-id': org['id'],
            'search': f'name={virt_who_hypervisor_hostname}'
        })
        # Note: if one shot command was executed the report is immediately
        # generated, and the server must have already registered the virt-who
        # hypervisor host
        if not org_hosts and not exec_one_shot:
            # we have to wait until the first report was sent.
            # the report is generated after the virt-who service startup, but some
            # small delay can occur.
            max_time = time.time() + 60
            while time.time() <= max_time:
                time.sleep(5)
                org_hosts = Host.list({
                    'organization-id':
                    org['id'],
                    'search':
                    f'name={virt_who_hypervisor_hostname}',
                })
                if org_hosts:
                    break

        if len(org_hosts) == 0:
            raise CLIFactoryError(
                f'Failed to find hypervisor host:\n{result.stderr}')
        virt_who_hypervisor_host = org_hosts[0]
        subscription_id = None
        if hypervisor_hostname and subscription_name:
            subscriptions = Subscription.list({'organization-id': org_id},
                                              per_page=False)
            for subscription in subscriptions:
                if subscription['name'] == subscription_name:
                    subscription_id = subscription['id']
                    Host.subscription_attach({
                        'host': virt_who_hypervisor_hostname,
                        'subscription-id': subscription_id
                    })
                    break
        return {
            'subscription_id': subscription_id,
            'subscription_name': subscription_name,
            'activation_key_id': activation_key['id'],
            'organization_id': org['id'],
            'content_view_id': content_view['id'],
            'lifecycle_environment_id': lce['id'],
            'virt_who_hypervisor_host': virt_who_hypervisor_host,
        }