Esempio n. 1
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',
     })
Esempio n. 2
0
    def test_list_user_3(self):
        """@Test: List User for all variations of Surname

        @Feature: User - list

        @Steps:
        1. Create User for all Surname variations in [1] using valid
        Username, First Name, Email Address, Language, authorized by
        2. List User

        @Assert: User is listed
        """
        include_list = [gen_string("alphanumeric", 50)]
        for lastname in valid_usernames_list() + include_list:
            with self.subTest(lastname):
                user = make_user({'lastname': lastname})
                self.__assert_exists(user)
                result = UserObj.list({
                    u'search': u'lastname = {0}'.format(lastname),
                })
                # make sure user is in list result
                self.assertIn({
                    'email': user['email'],
                    'id': user['id'],
                    'login': user['login'],
                    'name': user['name'],
                }, result)
Esempio n. 3
0
    def test_positive_list_email(self):
        """List User for all variations of Email Address

        :id: 252f5583-6c34-43ae-9966-636fa0a2bb10

        :expectedresults: User is listed

        :CaseImportance: Critical
        """
        valid_emails = (
            gen_string("alpha") + "@somemail.com",
            gen_string("alphanumeric", 10) + "@somemail.com",
            gen_string("numeric") + "@somemail.com",
            gen_string("alphanumeric", 50) + "@somem.com"
        )
        for mail in valid_emails:
            with self.subTest(mail):
                user = make_user({'mail': mail})
                result = User.list({
                    u'search': u'mail = {0}'.format(mail),
                })
                # make sure user is in list result
                self.assertEqual({
                    'email': user['email'],
                    'id': user['id'],
                    'login': user['login'],
                    'name': user['name'],
                }, result[0])
Esempio n. 4
0
    def test_list_user_4(self):
        """@Test: List User for all variations of Email Address

        @Feature: User - list

        @Steps:
        1. Create User for all Email Address variations in [1] using valid
        valid Username, First Name, Surname, Language, authorized by
        2. List User

        @Assert: User is listed
        """
        for mail in (gen_string("alpha") + "@somemail.com",
                     gen_string("alphanumeric", 10) + "@somemail.com",
                     gen_string("numeric") + "@somemail.com",
                     gen_string("alphanumeric", 50) + "@somem.com"):
            with self.subTest(mail):
                user = make_user({'mail': mail})
                self.__assert_exists(user)
                result = UserObj.list({
                    u'search': u'mail = {0}'.format(mail),
                })
                # make sure user is in list result
                self.assertIn({
                    'email': user['email'],
                    'id': user['id'],
                    'login': user['login'],
                    'name': user['name'],
                }, result)
Esempio n. 5
0
    def test_bugzilla_1204667(self, test_data):
        """@Test: List User for utf-8,latin variations of Email Address

        @Feature: User - list

        @Steps:
        1. Create User with above Email Address variations in [1] using valid
        valid Username, First Name, Surname, Language, authorized by
        2. List User

        @Assert: User is listed

        @BZ: 1204667

        """
        user = make_user(test_data)
        self.__assert_exists(user)
        result = UserObj.list({
            u'search': u'mail = {0}'.format(test_data['mail']),
        })
        # make sure user is in list result
        self.assertIn(
            {
                'email': user['email'],
                'id': user['id'],
                'login': user['login'],
                'name': user['name'],
            },
            result,
        )
Esempio n. 6
0
    def test_list_user_3(self, test_data):
        """@Test: List User for all variations of Surname

        @Feature: User - list

        @Steps:
        1. Create User for all Surname variations in [1] using valid
        Username, First Name, Email Address, Language, authorized by
        2. List User

        @Assert: User is listed

        """
        user = make_user(test_data)
        self.__assert_exists(user)
        result = UserObj.list({
            u'search': u'lastname = {0}'.format(test_data['lastname']),
        })
        # make sure user is in list result
        self.assertIn(
            {
                'email': user['email'],
                'id': user['id'],
                'login': user['login'],
                'name': user['name'],
            },
            result,
        )
Esempio n. 7
0
    def test_user_remove_role_1(self, test_data):
        """@Test: Remove role to User for all variations of role names

        @Feature: User - Remove role

        @Steps:
        1. Create role and add it to the user . Try to remove the role

        @Assert: Role is removed

        @BZ: 1138553

        """
        user = make_user()
        role = make_role(test_data)
        self.__assert_exists(user)
        UserObj.add_role({
            'login': user['login'],
            'role': role['name'],
        })
        user = UserObj.info({'id': user['id']})
        self.assertIn(role['name'], user['roles'])
        UserObj.remove_role({
            'login': user['login'],
            'role': role['name'],
        })
        user = UserObj.info({'id': user['id']})
        self.assertNotIn(role['name'], user['roles'])
Esempio n. 8
0
    def test_positive_update_user_4(self):
        """@Test: Update Email Address in User

        @Feature: User - Positive Update

        @Steps:
        1. Create User
        2. Update Email Address for all variations in [1]

        @Assert: User is updated
        """
        user = make_user()
        for data in (gen_string("alpha"),
                     gen_string("alphanumeric"),
                     gen_string("numeric"),
                     '{0}+{1}'.format(gen_alphanumeric(), gen_alphanumeric()),
                     '{0}.{1}'.format(gen_alphanumeric(), gen_alphanumeric()),
                     r"!#$%&*+-/=?^`{|}~"):
            with self.subTest(data):
                email = '{0}@example.com'.format(data)
                UserObj.update({
                    'id': user['id'],
                    # escape ` to avoid bash syntax error
                    'mail': email.replace('`', r'\`'),
                })
                result = UserObj.info({'id': user['id']})
                self.assertEqual(result['email'], email)
Esempio n. 9
0
    def test_positive_create_with_email_utf8_latin(self):
        """List User for utf-8,latin variations of Email Address

        :id: 3d865df5-2e28-44fb-add8-c79a18db2f95

        :expectedresults: User is listed

        :BZ: 1204667

        :CaseImportance: Critical
        """
        valid_mails = (
            gen_string("latin1") + "@somemail.com",
            gen_string("utf8") + "@somemail.com"
        )
        for mail in valid_mails:
            with self.subTest(mail):
                user = make_user({'mail': mail})
                result = User.list({
                    u'search': u'mail = {0}'.format(mail),
                })
                # make sure user is in list result
                self.assertIn({
                    'email': user['email'],
                    'id': user['id'],
                    'login': user['login'],
                    'name': user['name'],
                }, result)
Esempio n. 10
0
    def test_user_remove_role_1(self):
        """@Test: Remove role to User for all variations of role names

        @Feature: User - Remove role

        @Steps:
        1. Create role and add it to the user . Try to remove the role

        @Assert: Role is removed

        @BZ: 1138553
        """
        user = make_user()
        include_list = [gen_string("alphanumeric", 100)]
        for role_name in valid_usernames_list() + include_list:
            with self.subTest(role_name):
                make_role({'name': role_name})
                self.__assert_exists(user)
                UserObj.add_role({
                    'login': user['login'],
                    'role': role_name,
                })
                user = UserObj.info({'id': user['id']})
                self.assertIn(role_name, user['roles'])
                UserObj.remove_role({
                    'login': user['login'],
                    'role': role_name,
                })
                user = UserObj.info({'id': user['id']})
                self.assertNotIn(role_name, user['roles'])
Esempio n. 11
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'])
Esempio n. 12
0
    def test_bugzilla_1204667(self):
        """@Test: List User for utf-8,latin variations of Email Address

        @Feature: User - list

        @Steps:
        1. Create User with above Email Address variations in [1] using valid
        valid Username, First Name, Surname, Language, authorized by
        2. List User

        @Assert: User is listed

        @BZ: 1204667
        """
        for mail in (gen_string("latin1") + "@somemail.com",
                     gen_string("utf8") + "@somemail.com"):
            with self.subTest(mail):
                user = make_user({'mail': mail})
                self.__assert_exists(user)
                result = UserObj.list({
                    u'search': u'mail = {0}'.format(mail),
                })
                # make sure user is in list result
                self.assertIn({
                    'email': user['email'],
                    'id': user['id'],
                    'login': user['login'],
                    'name': user['name'],
                }, result)
Esempio n. 13
0
    def test_positive_update_user_1(self, test_data):
        """
        @Test: Update Username in User
        @Feature: User - Positive Update
        @Steps:
        1. Create User
        2. Update User name for all variations in [1]
        @Assert: User is updated
        """

        new_obj = make_user()
        # Can we find the new object?
        result = UserObj().info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['name'], result.stdout['name'])

        # Update the user name
        result = UserObj().update({'id': new_obj['id'],
                                   'firstname': test_data['firstname']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(
            len(result.stderr), 0, "There should not be an error here")

        # Fetch the user again
        result = UserObj().info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        user_name = result.stdout['name'].split(' ')
        self.assertEqual(
            user_name[0],
            test_data['firstname'],
            "User first name was not updated"
        )
Esempio n. 14
0
    def test_positive_remove_role(self):
        """Remove role from User for all variations of role names

        @Feature: User - Remove role

        @Assert: Role is removed

        @BZ: 1138553
        """
        user = make_user()
        include_list = [gen_string("alphanumeric", 100)]
        for role_name in valid_usernames_list() + include_list:
            with self.subTest(role_name):
                make_role({'name': role_name})
                User.add_role({
                    'login': user['login'],
                    'role': role_name,
                })
                user = User.info({'id': user['id']})
                self.assertIn(role_name, user['roles'])
                User.remove_role({
                    'login': user['login'],
                    'role': role_name,
                })
                user = User.info({'id': user['id']})
                self.assertNotIn(role_name, user['roles'])
Esempio n. 15
0
    def test_positive_update_user_2(self, test_data):
        """
        @Test: Update Login in User
        @Feature: User
        @Steps:
        1. Create User
        2. Update User login for all variations in [1]
        @Assert: User login is updated
        """

        new_obj = make_user()
        # Can we find the new object?
        result = UserObj().info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['login'], result.stdout['login'])

        # Update the user login
        result = UserObj().update({'id': new_obj['id'],
                                   'login': test_data['login']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(
            len(result.stderr), 0, "There should not be an error here")

        # Fetch the user again
        result = UserObj().info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(
            result.stdout['login'],
            test_data['login'],
            "User login was not updated"
        )
Esempio n. 16
0
    def test_positive_remove_role(self):
        """Remove role from User for all variations of role names

        @id: 51b15516-da42-4149-8032-87baa93f9e56

        @Assert: Role is removed

        @BZ: 1138553

        @CaseLevel: Integration
        """
        user = make_user()
        include_list = [gen_string("alphanumeric", 100)]
        for role_name in valid_usernames_list() + include_list:
            with self.subTest(role_name):
                make_role({'name': role_name})
                User.add_role({
                    'login': user['login'],
                    'role': role_name,
                })
                user = User.info({'id': user['id']})
                self.assertIn(role_name, user['roles'])
                User.remove_role({
                    'login': user['login'],
                    'role': role_name,
                })
                user = User.info({'id': user['id']})
                self.assertNotIn(role_name, user['roles'])
Esempio n. 17
0
 def test_positive_create_user_6(self):
     """
     @Test: Create an Admin user
     @Feature: User - Positive Create
     @Assert: Admin User is created
     """
     args = make_user({'admin': '1'})
     self.__assert_exists(args)
Esempio n. 18
0
 def test_add_user(self):
     "Adds a user in an org"
     org_result = make_org()
     user_result = make_user()
     return_value = Org().add_user(
             {'name': org_result['name'], 'user-id': user_result['login']})
     self.assertTrue(return_value.return_code, 0)
     self.assertFalse(return_value.stderr)
Esempio n. 19
0
 def setUpClass(cls):
     """Creates users to be reused across tests"""
     super(HammerAuthTestCase, cls).setUpClass()
     cls.uname_admin = gen_string('alpha')
     cls.uname_viewer = gen_string('alpha')
     cls.password = gen_string('alpha')
     cls.mail = '*****@*****.**'
     make_user({
             'login': cls.uname_admin,
             'password': cls.password,
             'admin': '1',
     })
     make_user({
             'login': cls.uname_viewer,
             'password': cls.password,
     })
     User.add_role({'login': cls.uname_viewer, 'role': 'Viewer'})
Esempio n. 20
0
    def test_positive_create_admin(self):
        """Create an Admin user

        @id: 0d0384ad-d85a-492e-8630-7f48912a4fd5

        @Assert: Admin User is created
        """
        user = make_user({'admin': '1'})
        self.assertEqual(user['admin'], 'yes')
Esempio n. 21
0
    def test_positive_create_admin(self):
        """Create an Admin user

        @Feature: User - Positive Create

        @Assert: Admin User is created
        """
        user = make_user({'admin': '1'})
        self.assertEqual(user['admin'], 'yes')
Esempio n. 22
0
    def test_positive_create_with_org(self):
        """Create User associated to one Organization

        @id: 336bc067-9edd-481a-ae7a-0ff1270b2e41

        @Assert: User is created
        """
        org = make_org()
        user = make_user({'organization-ids': org['id']})
        self.assertEqual(org['name'], user['organizations'][0])
Esempio n. 23
0
    def test_positive_create_with_org(self):
        """Create User associated to one Organization

        @Feature: User - Positive Create

        @Assert: User is created
        """
        org = make_org()
        user = make_user({'organization-ids': org['id']})
        self.assertEqual(org['name'], user['organizations'][0])
Esempio n. 24
0
    def test_positive_create_with_user_id(self):
        """Create new user group using valid user attached to that group. Use
        user id as a parameter

        @Feature: Usergroup

        @Assert: User group is created successfully.
        """
        user = make_user()
        user_group = make_usergroup({'user-ids': user['id']})
        self.assertEqual(user_group['users'][0], user['login'])
Esempio n. 25
0
    def test_positive_create_admin(self):
        """Create an Admin user

        :id: 0d0384ad-d85a-492e-8630-7f48912a4fd5

        :expectedresults: Admin User is created

        :CaseImportance: Critical
        """
        user = make_user({'admin': '1'})
        self.assertEqual(user['admin'], 'yes')
Esempio n. 26
0
 def test_positive_create_user_5(self, data):
     """
     @Test: Create User for all variations of Password
     @Feature: User - Positive Create
     @Steps:
     1. Create User for all valid Password variation in [1] using valid
     Username, First Name, Surname, Email Address, Language, authorized by
     @Assert: User is created
     """
     args = make_user(data)
     self.__assert_exists(args)
Esempio n. 27
0
def _create_test_user(class_or_instance):
    """Helper function which creates test user and stores it on a class or
    instance.
    """
    class_or_instance.login = gen_string('alphanumeric', 30)
    class_or_instance.password = gen_string('alphanumeric', 30)
    class_or_instance.user = make_user({
        'login': class_or_instance.login,
        'password': class_or_instance.password,
        'admin': '1',
    })
Esempio n. 28
0
    def test_positive_create_with_surname(self):
        """Create User for all variations of Surname

        @id: 1b3d7014-6575-4cfd-b6d7-8ff2bfef587e

        @Assert: User is created
        """
        include_list = [gen_string("alphanumeric", 50)]
        for lastname in valid_usernames_list() + include_list:
            with self.subTest(lastname):
                user = make_user({'lastname': lastname})
                self.assertIn(lastname, user['name'])
Esempio n. 29
0
    def test_positive_delete_by_id(self):
        """Create an user and then delete it using its id

        @id: 7e97e177-b676-49b3-86ee-644f6f6ff30c

        @Assert: User is deleted
        """
        user = make_user()
        User.exists(search=('login', user['login']))
        User.delete({'id': user['id']})
        with self.assertRaises(CLIReturnCodeError):
            User.info({'login': user['login']})
Esempio n. 30
0
    def test_positive_create_with_org(self):
        """Create User associated to one Organization

        :id: 336bc067-9edd-481a-ae7a-0ff1270b2e41

        :expectedresults: User is created

        :CaseImportance: Critical
        """
        org = make_org()
        user = make_user({'organization-ids': org['id']})
        self.assertEqual(org['name'], user['organizations'][0])
Esempio n. 31
0
    def test_system_admin_role_end_to_end(self):
        """Test System admin role with a end to end workflow

        :id: da6b3549-d1cf-44fc-869f-08d15d407fa2

        :steps:

            1. Create a System admin role user1
            2. Login with the user1 and change global settings
                "Out of sync interval" to 31
            3. Create user2 with system admin role
            4. Login with user2 to create a Organization
            5. Clone a Org-admin role
            6. Edit the Architecture Filter and search name  =  x86_64
            7. Create a User with Cloned Org admin
            8. Login with user.

        :expectedresults:

            1. User should be assigned with System Admin role.
            2. User with sys admin role should be able to update settings
            3. User with sys admin role should be able to create users and
                assign Organizations to them.
            4. System Admin role should be able to create Organization admins
            5. User with sys admin role should be able to edit filters on roles

        :CaseLevel: System
        """
        org = make_org()
        location = make_location()
        common_pass = gen_string('alpha')
        role = Role.info({'name': 'System admin'})
        system_admin_1 = make_user({
            'password': common_pass,
            'organization-ids': org['id'],
            'location-ids': location['id'],
        })
        User.add_role({'id': system_admin_1['id'], 'role-id': role['id']})
        Settings.with_user(username=system_admin_1['login'],
                           password=common_pass).set({
                               'name': "outofsync_interval",
                               'value': "32"
                           })
        sync_time = Settings.list({'search': 'name=outofsync_interval'})[0]
        # Asserts if the setting was updated successfully
        assert '32' == sync_time['value']

        # Create another System Admin user using the first one
        system_admin = User.with_user(username=system_admin_1['login'],
                                      password=common_pass).create({
                                          'auth-source-id':
                                          1,
                                          'firstname':
                                          gen_string('alpha'),
                                          'lastname':
                                          gen_string('alpha'),
                                          'login':
                                          gen_string('alpha'),
                                          'mail':
                                          '{}@example.com'.format(
                                              gen_string('alpha')),
                                          'password':
                                          common_pass,
                                          'organizations':
                                          org['name'],
                                          'role-ids':
                                          role['id'],
                                          'locations':
                                          location['name'],
                                      })
        # Create the Org Admin user
        org_role = Role.with_user(username=system_admin['login'],
                                  password=common_pass).clone({
                                      'name':
                                      'Organization admin',
                                      'new-name':
                                      gen_string('alpha'),
                                      'organization-ids':
                                      org['id'],
                                      'location-ids':
                                      location['id'],
                                  })
        org_admin = User.with_user(username=system_admin['login'],
                                   password=common_pass).create({
                                       'auth-source-id':
                                       1,
                                       'firstname':
                                       gen_string('alpha'),
                                       'lastname':
                                       gen_string('alpha'),
                                       'login':
                                       gen_string('alpha'),
                                       'mail':
                                       '{}@example.com'.format(
                                           gen_string('alpha')),
                                       'password':
                                       common_pass,
                                       'organizations':
                                       org['name'],
                                       'role-ids':
                                       org_role['id'],
                                       'location-ids':
                                       location['id'],
                                   })
        # Assert if the cloning was successful
        assert org_role['id'] is not None
        org_role_filters = Role.filters({'id': org_role['id']})
        search_filter = None
        for arch_filter in org_role_filters:
            if arch_filter['resource-type'] == 'Architecture':
                search_filter = arch_filter
                break
        Filter.with_user(username=system_admin['login'],
                         password=common_pass).update({
                             'role-id': org_role['id'],
                             'id': arch_filter['id'],
                             'search': 'name=x86_64'
                         })
        # Asserts if the filter is updated
        assert 'name=x86_64' in Filter.info({
            'id': search_filter['id']
        }).values()
        org_admin = User.with_user(username=system_admin['login'],
                                   password=common_pass).info(
                                       {'id': org_admin['id']})
        # Asserts Created Org Admin
        assert org_role['name'] in org_admin['roles']
        assert org['name'] in org_admin['organizations']
Esempio n. 32
0
    def test_positive_generate_ansible_template(self):
        """ Report template named 'Ansible Inventory' (default name is specified in settings)
        must be present in Satellite 6.7 and later in order to provide enhanced functionality
        for Ansible Tower inventory synchronization with Satellite.

        :id: f1f7adfc-9601-4498-95c8-3e82e2b36583

        :setup:
            1. A user with minimal required permissions: 'Ansible Tower Inventory Reader' role
            2. A fake host to be checked in report output

        :steps:
            1. Check settings for default Ansible Inventory template name and ensure
               the template is present
            2. Try to render the template using the user with ATIR role
            3. Check the fake host is present in the output

        :expectedresults: Report template is present, renederable and provides output

        :CaseImportance: Medium
        """
        settings = Settings.list({'search': 'name=ansible_inventory_template'})
        assert 1 == len(settings)
        template_name = settings[0]['value']

        report_list = ReportTemplate.list()
        assert template_name in [rt['name'] for rt in report_list]

        login = gen_string('alpha').lower()
        password = gen_string('alpha').lower()
        loc = Location.info({'name': DEFAULT_LOC})
        org = Org.info({'name': DEFAULT_ORG})

        user = make_user({
            'login': login,
            'password': password,
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        })

        User.add_role({
            'login': user['login'],
            'role': 'Ansible Tower Inventory Reader'
        })

        host_name = gen_string('alpha').lower()
        host = make_fake_host({'name': host_name})

        schedule = ReportTemplate.with_user(username=user['login'],
                                            password=password).schedule(
                                                {'name': template_name})

        report_data = ReportTemplate.with_user(username=user['login'],
                                               password=password).report_data({
                                                   'id':
                                                   template_name,
                                                   'job-id':
                                                   schedule[0].split(
                                                       "Job ID: ", 1)[1]
                                               })

        assert host['name'] in [
            item.split(',')[1] for item in report_data if len(item) > 0
        ]
Esempio n. 33
0
    def test_smoke(self):
        """@Test: Check that basic content can be created

        * Create a new user with admin permissions
        * Using the new user from above:

            * Create a new organization
            * Create two new lifecycle environments
            * Create a custom product
            * Create a custom YUM repository
            * Create a custom PUPPET repository
            * Synchronize both custom repositories
            * Create a new content view
            * Associate both repositories to new content view
            * Publish content view
            * Promote content view to both lifecycles
            * Create a new libvirt compute resource
            * Create a new subnet
            * Create a new domain
            * Create a new hostgroup and associate previous entities to it

        @Feature: Smoke Test

        @Assert: All entities are created and associated.

        """
        # Create new user
        password = gen_alphanumeric()
        new_user = make_user({u'admin': u'true', u'password': password})

        # Append the password as the info command does not return it
        new_user[u'password'] = password

        # Create new org as new user
        new_org = self._create(
            new_user,
            Org,
            {u'name': gen_alphanumeric()}
        )

        # Create new lifecycle environment 1
        lifecycle1 = self._create(
            new_user,
            LifecycleEnvironment,
            {
                u'organization-id': new_org['id'],
                u'name': gen_alphanumeric(),
                u'prior': u'Library',
            }
        )

        # Create new lifecycle environment 2
        lifecycle2 = self._create(
            new_user,
            LifecycleEnvironment,
            {
                u'organization-id': new_org['id'],
                u'name': gen_alphanumeric(),
                u'prior': lifecycle1['name'],
            }
        )

        # Create a new product
        new_product = self._create(
            new_user,
            Product,
            {
                u'organization-id': new_org['id'],
                u'name': gen_alphanumeric(),
            }
        )

        # Create a YUM repository
        new_repo1 = self._create(
            new_user,
            Repository,
            {
                u'product-id': new_product['id'],
                u'name': gen_alphanumeric(),
                u'content-type': u'yum',
                u'publish-via-http': u'true',
                u'url': GOOGLE_CHROME_REPO,
            }
        )

        # Create a Puppet repository
        new_repo2 = self._create(
            new_user,
            Repository,
            {
                u'product-id': new_product['id'],
                u'name': gen_alphanumeric(),
                u'content-type': u'puppet',
                u'publish-via-http': u'true',
                u'url': FAKE_0_PUPPET_REPO,
            }
        )

        # Synchronize YUM repository
        result = Repository.with_user(
            new_user['login'],
            new_user['password']
        ).synchronize({u'id': new_repo1['id']})
        self.assertEqual(
            result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(result.stderr),
            0,
            u"Failed to synchronize YUM repo: {0}".format(result.stderr))

        # Synchronize puppet repository
        result = Repository.with_user(
            new_user['login'],
            new_user['password']
        ).synchronize({u'id': new_repo2['id']})
        self.assertEqual(
            result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(result.stderr),
            0,
            u"Failed to synchronize Puppet repo: {0}".format(result.stderr))

        # Create a Content View
        new_cv = self._create(
            new_user,
            ContentView,
            {
                u'organization-id': new_org['id'],
                u'name': gen_alphanumeric(),
            }
        )

        # Associate yum repository to content view
        result = ContentView.with_user(
            new_user['login'],
            new_user['password']
        ).add_repository({
            u'id': new_cv['id'],
            u'repository-id': new_repo1['id'],
        })
        self.assertEqual(
            result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(result.stderr),
            0,
            u"Failed to add YUM repo to content view: {0}".format(
                result.stderr))

        # Fetch puppet module
        puppet_result = PuppetModule.with_user(
            new_user['login'],
            new_user['password']
        ).list({
            u'repository-id': new_repo2['id'],
            u'per-page': False,
        })
        self.assertEqual(
            puppet_result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(puppet_result.stderr),
            0,
            u"Puppet modules list was not generated: {0}".format(
                result.stderr))

        # Associate puppet repository to content view
        result = ContentView.with_user(
            new_user['login'],
            new_user['password']
        ).puppet_module_add({
            u'content-view-id': new_cv['id'],
            u'id': puppet_result.stdout[0]['id'],
        })
        self.assertEqual(
            result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(result.stderr),
            0,
            u"Failed to add YUM repo to content view: {0}".format(
                result.stderr))

        # Publish content view
        result = ContentView.with_user(
            new_user['login'],
            new_user['password']
        ).publish({u'id': new_cv['id']})
        self.assertEqual(
            result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(result.stderr),
            0,
            u"Failed to publish content view: {0}".format(result.stderr))

        # Only after we publish version1 the info is populated.
        result = ContentView.with_user(
            new_user['login'],
            new_user['password']
        ).info({u'id': new_cv['id']})
        self.assertEqual(
            result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(result.stderr),
            0,
            u"Could not fetch content view info: {0}".format(result.stderr))

        # Let us now store the version1 id
        version1_id = result.stdout['versions'][0]['id']

        # Promote content view to first lifecycle
        result = ContentView.with_user(
            new_user['login'],
            new_user['password']
        ).version_promote({
            u'id': result.stdout['versions'][0]['id'],
            u'to-lifecycle-environment-id': lifecycle1['id'],
        })
        self.assertEqual(
            result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(result.stderr),
            0,
            u"Failed to promote content view to lifecycle '{0}': {1}".format(
                lifecycle1['name'], result.stderr))

        # Promote content view to second lifecycle
        result = ContentView.with_user(
            new_user['login'],
            new_user['password']
        ).version_promote({
            u'id': version1_id,
            u'to-lifecycle-environment-id': lifecycle2['id'],
        })
        self.assertEqual(
            result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(result.stderr),
            0,
            u"Failed to promote content view to lifecycle '{0}': {1}".format(
                lifecycle2['name'], result.stderr))

        # Create a new libvirt compute resource
        result = self._create(
            new_user,
            ComputeResource,
            {
                u'name': gen_alphanumeric(),
                u'provider': u'Libvirt',
                u'url': u'qemu+tcp://{0}:16509/system'.format(
                    conf.properties['main.server.hostname']),
            }
        )

        # Create a new subnet
        new_subnet = self._create(
            new_user,
            Subnet,
            {
                u'name': gen_alphanumeric(),
                u'network': gen_ipaddr(ip3=True),
                u'mask': u'255.255.255.0',
            }
        )

        # Create a domain
        new_domain = self._create(
            new_user,
            Domain,
            {
                u'name': gen_alphanumeric(),
            }
        )

        # Fetch Puppet environment for second lifecycle
        # (unfortunately it is not straight forward to extract this)

        # The puppet environment we want has a name like this...
        env_name = u'KT_{0}_{1}_'.format(
            #  Hyphens are replaced by underscores
            new_org['label'].replace('-', '_',),
            lifecycle2['label'].replace('-', '_')
        )
        # We fetch all the puppet environments for our organization...
        result = Environment.with_user(
            new_user['login'],
            new_user['password']
        ).list({
            u'search': u'organization="{0}"'.format(new_org['name']),
        })
        self.assertEqual(
            result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(result.stderr),
            0,
            u"Failed to fetch puppet environments: {0}".format(
                result.stderr))
        # Now look for the puppet environment that matches lifecycle2
        puppet_env = [
            env for env in result.stdout if env['name'].startswith(
                env_name)]
        self.assertEqual(
            len(puppet_env),
            1,
            u'Could not find the puppet environment: {0}'.format(env_name))

        # Create a hostgroup...
        new_hg = self._create(
            new_user,
            HostGroup,
            {
                u'name': gen_alphanumeric(),
                u'domain-id': new_domain['id'],
                u'subnet-id': new_subnet['id'],
                u'environment-id': puppet_env[0]['id'],
            }
        )
        # ...and add it to the organization
        result = Org.with_user(
            new_user['login'],
            new_user['password']
        ).add_hostgroup({
            u'id': new_org['id'],
            u'hostgroup-id': new_hg['id'],
        })
        self.assertEqual(
            result.return_code,
            0,
            u"Return code is non-zero: {0}".format(result.return_code))
        self.assertEqual(
            len(result.stderr),
            0,
            u"Failed to add hostgroup '{0}' to org '{1}': {2}".format(
                new_hg['name'], new_org['name'], result.stderr))
Esempio n. 34
0
 def setUp(self):
     """Setting up user to be used on tests"""
     super(UserWithCleanUpTestCase, self).setUp()
     self.user = make_user()
Esempio n. 35
0
    def test_negative_nonauthor_of_report_cant_download_it(self):
        """The resulting report should only be downloadable by
           the user that generated it or admin. Check.

        :id: a4bc77db-146e-4871-a42e-e93887464986

        :setup: Installed Satellite, user that can list running tasks

        :steps:

            1. hammer -u u1 -p p1 report-template schedule
            2. hammer -u u2 -p p2 report-template report-data

        :expectedresults: Report can't be downloaded. Error.

        :CaseImportance: High
        """
        uname_viewer = gen_string('alpha')
        uname_viewer2 = gen_string('alpha')
        password = gen_string('alpha')

        loc = Location.info({'name': DEFAULT_LOC})
        org = Org.info({'name': DEFAULT_ORG})

        user1 = make_user({
            'login': uname_viewer,
            'password': password,
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        })

        user2 = make_user({
            'login': uname_viewer2,
            'password': password,
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        })

        role = make_role()
        # Pick permissions by its resource type
        permissions_org = [
            permission['name'] for permission in Filter.available_permissions(
                {"search": "resource_type=Organization"})
        ]
        permissions_loc = [
            permission['name'] for permission in Filter.available_permissions(
                {"search": "resource_type=Location"})
        ]
        permissions_rt = [
            permission['name'] for permission in Filter.available_permissions(
                {"search": "resource_type=ReportTemplate"})
        ]
        permissions_pt = [
            permission['name'] for permission in Filter.available_permissions(
                {"search": "resource_type=ProvisioningTemplate"})
        ]
        permissions_jt = [
            permission['name'] for permission in Filter.available_permissions(
                {"search": "resource_type=JobTemplate"})
        ]
        # Assign filters to created role
        make_filter({'role-id': role['id'], 'permissions': permissions_org})
        make_filter({'role-id': role['id'], 'permissions': permissions_loc})
        make_filter({'role-id': role['id'], 'permissions': permissions_rt})
        make_filter({'role-id': role['id'], 'permissions': permissions_pt})
        make_filter({'role-id': role['id'], 'permissions': permissions_jt})
        User.add_role({'login': user1['login'], 'role-id': role['id']})
        User.add_role({'login': user2['login'], 'role-id': role['id']})

        name = gen_string('alpha')
        content = gen_string('alpha')

        report_template = ReportTemplate.with_user(username=user1['login'],
                                                   password=password).create({
                                                       'name':
                                                       name,
                                                       'organization-id':
                                                       org['id'],
                                                       'location-id':
                                                       loc['id'],
                                                       'file':
                                                       content
                                                   })

        schedule = ReportTemplate.with_user(username=user1['login'],
                                            password=password).schedule({
                                                'name':
                                                report_template['name']
                                            })

        report_data = ReportTemplate.with_user(username=user1['login'],
                                               password=password).report_data({
                                                   'id':
                                                   report_template['name'],
                                                   'job-id':
                                                   schedule[0].split(
                                                       "Job ID: ", 1)[1]
                                               })

        self.assertIn(content, report_data)
        with self.assertRaises(CLIReturnCodeError):
            ReportTemplate.with_user(username=user2['login'],
                                     password=password).report_data({
                                         'id':
                                         report_template['name'],
                                         'job-id':
                                         schedule[0].split("Job ID: ", 1)[1]
                                     })
Esempio n. 36
0
    def test_positive_add_and_remove_users(self):
        """Add and remove (admin) user to organization

        :id: c35b2e88-a65f-4eea-ba55-89cef59f30be

        :expectedresults: Users are added and removed from the org

        :steps:
            1. create and delete user by name
            2. create and delete user by id
            3. create and delete admin user by name
            4. create and delete admin user by id

        :bz: 1395229

        :CaseLevel: Integration
        """
        org = make_org()
        user = make_user()
        admin_user = make_user({'admin': '1'})
        self.assertEqual(admin_user['admin'], 'yes')

        # add and remove user and admin user by name
        Org.add_user({
            'name': org['name'],
            'user': user['login'],
        })
        Org.add_user({
            'name': org['name'],
            'user': admin_user['login'],
        })
        org_info = Org.info({'name': org['name']})
        self.assertIn(user['login'], org_info['users'],
                      "Failed to add user by name")
        self.assertIn(admin_user['login'], org_info['users'],
                      "Failed to add admin user by name")
        if not bz_bug_is_open(1395229):
            Org.remove_user({
                'name': org['name'],
                'user': user['login'],
            })
            Org.remove_user({
                'name': org['name'],
                'user': admin_user['login'],
            })
            org_info = Org.info({'name': org['name']})
            self.assertNotIn(user['login'], org_info['users'],
                             "Failed to remove user by name")
            self.assertNotIn(admin_user['login'], org_info['users'],
                             "Failed to remove admin user by name")

        # add and remove user and admin user by id
        Org.add_user({
            'id': org['id'],
            'user-id': user['id'],
        })
        Org.add_user({
            'id': org['id'],
            'user-id': admin_user['id'],
        })
        org_info = Org.info({'id': org['id']})
        self.assertIn(user['login'], org_info['users'],
                      "Failed to add user by id")
        self.assertIn(admin_user['login'], org_info['users'],
                      "Failed to add admin user by id")
        if not bz_bug_is_open(1395229):
            Org.remove_user({
                'id': org['id'],
                'user-id': user['id'],
            })
            Org.remove_user({
                'id': org['id'],
                'user-id': admin_user['id'],
            })
            org_info = Org.info({'id': org['id']})
            self.assertNotIn(user['login'], org_info['users'],
                             "Failed to remove user by id")
            self.assertNotIn(admin_user['login'], org_info['users'],
                             "Failed to remove admin user by id")
Esempio n. 37
0
    def test_positive_CRUD(self):
        """Create User with various parameters, updating and deleting

        :id: 2d430243-8512-46ee-8d21-7ccf0c7af807

        :expectedresults: User is created with parameters, parameters
                          are updated, user is deleted

        :CaseImportance: Critical
        """
        # create with params
        mail = random.choice(valid_emails_list())
        user_params = {
            'login': random.choice(valid_usernames_list()),
            'firstname': random.choice(valid_usernames_list()),
            'lastname': random.choice(valid_usernames_list()),
            'mail': mail.replace('"', r'\"').replace('`', r'\`'),
            'description': random.choice(list(valid_data_list().values())),
        }
        user = make_user(user_params)
        user['firstname'], user['lastname'] = user['name'].split()
        user_params.pop('mail')
        user_params['email'] = mail
        for key in user_params:
            assert user_params[key] == user[key], f'values for key "{key}" do not match'

        # list by firstname and lastname
        result = User.list({'search': 'firstname = {}'.format(user_params['firstname'])})
        # make sure user is in list result
        assert {user['id'], user['login'], user['name']} == {
            result[0]['id'],
            result[0]['login'],
            result[0]['name'],
        }
        result = User.list({'search': 'lastname = {}'.format(user_params['lastname'])})
        # make sure user is in list result
        assert {user['id'], user['login'], user['name']} == {
            result[0]['id'],
            result[0]['login'],
            result[0]['name'],
        }
        # update params
        new_mail = random.choice(valid_emails_list())
        user_params = {
            'firstname': random.choice(valid_usernames_list()),
            'lastname': random.choice(valid_usernames_list()),
            'mail': new_mail.replace('"', r'\"').replace('`', r'\`'),
            'description': random.choice(list(valid_data_list().values())),
        }
        user_params.update({'id': user['id']})
        User.update(user_params)
        user = User.info({'login': user['login']})
        user['firstname'], user['lastname'] = user['name'].split()
        user_params.pop('mail')
        user_params['email'] = new_mail
        for key in user_params:
            assert user_params[key] == user[key], f'values for key "{key}" do not match'
        # delete
        User.delete({'login': user['login']})
        with pytest.raises(CLIReturnCodeError):
            User.info({'login': user['login']})
Esempio n. 38
0
def non_admin_user():
    """create the non-admin role user for tests"""
    uname_viewer = gen_string('alpha')
    user = make_user({'login': uname_viewer, 'password': password})
    User.add_role({'login': uname_viewer, 'role': 'Viewer'})
    return user
Esempio n. 39
0
    def test_positive_end_to_end(self):
        """Perform end to end smoke tests using RH and custom repos.

        1. Create a new user with admin permissions
        2. Using the new user from above
            1. Create a new organization
            2. Clone and upload manifest
            3. Create a new lifecycle environment
            4. Create a custom product
            5. Create a custom YUM repository
            6. Create a custom PUPPET repository
            7. Enable a Red Hat repository
            8. Synchronize the three repositories
            9. Create a new content view
            10. Associate the YUM and Red Hat repositories to new content view
            11. Add a PUPPET module to new content view
            12. Publish content view
            13. Promote content view to the lifecycle environment
            14. Create a new activation key
            15. Add the products to the activation key
            16. Create a new libvirt compute resource
            17. Create a new subnet
            18. Create a new domain
            19. Create a new hostgroup and associate previous entities to it
            20. Provision a client

        :id: 8c8b3ffa-0d54-436b-8eeb-1a3542e100a8

        :expectedresults: All tests should succeed and Content should be
            successfully fetched by client.
        """
        # step 1: Create a new user with admin permissions
        password = gen_alphanumeric()
        user = make_user({'admin': 'true', 'password': password})
        user['password'] = password

        # step 2.1: Create a new organization
        org = self._create(user, Org, {'name': gen_alphanumeric()})

        # step 2.2: Clone and upload manifest
        if self.fake_manifest_is_set:
            with manifests.clone() as manifest:
                ssh.upload_file(manifest.content, manifest.filename)
            Subscription.upload({
                'file': manifest.filename,
                'organization-id': org['id']
            })

        # step 2.3: Create a new lifecycle environment
        lifecycle_environment = self._create(
            user,
            LifecycleEnvironment,
            {
                'name': gen_alphanumeric(),
                'organization-id': org['id'],
                'prior': 'Library'
            },
        )

        # step 2.4: Create a custom product
        product = self._create(user, Product, {
            'name': gen_alphanumeric(),
            'organization-id': org['id']
        })
        repositories = []

        # step 2.5: Create custom YUM repository
        yum_repo = self._create(
            user,
            Repository,
            {
                'content-type': 'yum',
                'name': gen_alphanumeric(),
                'product-id': product['id'],
                'publish-via-http': 'true',
                'url': CUSTOM_RPM_REPO,
            },
        )
        repositories.append(yum_repo)

        # step 2.6: Create custom PUPPET repository
        puppet_repo = self._create(
            user,
            Repository,
            {
                'content-type': 'puppet',
                'name': gen_alphanumeric(),
                'product-id': product['id'],
                'publish-via-http': 'true',
                'url': FAKE_0_PUPPET_REPO,
            },
        )
        repositories.append(puppet_repo)

        # step 2.7: Enable a Red Hat repository
        if self.fake_manifest_is_set:
            RepositorySet.enable({
                'basearch': 'x86_64',
                'name': REPOSET['rhva6'],
                'organization-id': org['id'],
                'product': PRDS['rhel'],
                'releasever': '6Server',
            })
            rhel_repo = Repository.info({
                'name': REPOS['rhva6']['name'],
                'organization-id': org['id'],
                'product': PRDS['rhel'],
            })
            repositories.append(rhel_repo)

        # step 2.8: Synchronize the three repositories
        for repo in repositories:
            Repository.with_user(user['login'], user['password']).synchronize(
                {'id': repo['id']})

        # step 2.9: Create content view
        content_view = self._create(user, ContentView, {
            'name': gen_alphanumeric(),
            'organization-id': org['id']
        })

        # step 2.10: Associate the YUM and Red Hat repositories to new content
        # view
        repositories.remove(puppet_repo)
        for repo in repositories:
            ContentView.add_repository({
                'id': content_view['id'],
                'organization-id': org['id'],
                'repository-id': repo['id'],
            })

        # step 2.11: Add a PUPPET module to new content view
        result = PuppetModule.with_user(user['login'], user['password']).list({
            'repository-id':
            puppet_repo['id'],
            'per-page':
            False
        })
        ContentView.with_user(user['login'],
                              user['password']).puppet_module_add({
                                  'content-view-id':
                                  content_view['id'],
                                  'id':
                                  random.choice(result)['id']
                              })

        # step 2.12: Publish content view
        ContentView.with_user(user['login'], user['password']).publish(
            {'id': content_view['id']})

        # step 2.13: Promote content view to the lifecycle environment
        content_view = ContentView.with_user(
            user['login'], user['password']).info({'id': content_view['id']})
        self.assertEqual(len(content_view['versions']), 1)
        cv_version = ContentView.with_user(
            user['login'], user['password']).version_info(
                {'id': content_view['versions'][0]['id']})
        self.assertEqual(len(cv_version['lifecycle-environments']), 1)
        ContentView.with_user(user['login'],
                              user['password']).version_promote({
                                  'id':
                                  cv_version['id'],
                                  'to-lifecycle-environment-id':
                                  lifecycle_environment['id']
                              })
        # check that content view exists in lifecycle
        content_view = ContentView.with_user(
            user['login'], user['password']).info({'id': content_view['id']})
        self.assertEqual(len(content_view['versions']), 1)
        cv_version = ContentView.with_user(
            user['login'], user['password']).version_info(
                {'id': content_view['versions'][0]['id']})
        self.assertEqual(len(cv_version['lifecycle-environments']), 2)
        self.assertEqual(cv_version['lifecycle-environments'][-1]['id'],
                         lifecycle_environment['id'])

        # step 2.14: Create a new activation key
        activation_key = self._create(
            user,
            ActivationKey,
            {
                'content-view-id': content_view['id'],
                'lifecycle-environment-id': lifecycle_environment['id'],
                'name': gen_alphanumeric(),
                'organization-id': org['id'],
            },
        )

        # step 2.15: Add the products to the activation key
        subscription_list = Subscription.with_user(
            user['login'],
            user['password']).list({'organization-id': org['id']},
                                   per_page=False)
        for subscription in subscription_list:
            if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME:
                ActivationKey.with_user(user['login'],
                                        user['password']).add_subscription({
                                            'id':
                                            activation_key['id'],
                                            'quantity':
                                            1,
                                            'subscription-id':
                                            subscription['id'],
                                        })

        # step 2.15.1: Enable product content
        if self.fake_manifest_is_set:
            ActivationKey.with_user(user['login'],
                                    user['password']).content_override({
                                        'content-label':
                                        AK_CONTENT_LABEL,
                                        'id':
                                        activation_key['id'],
                                        'organization-id':
                                        org['id'],
                                        'value':
                                        '1',
                                    })

        # BONUS: Create a content host and associate it with promoted
        # content view and last lifecycle where it exists
        content_host_name = gen_alphanumeric()
        content_host = Host.with_user(user['login'],
                                      user['password']).subscription_register({
                                          'content-view-id':
                                          content_view['id'],
                                          'lifecycle-environment-id':
                                          lifecycle_environment['id'],
                                          'name':
                                          content_host_name,
                                          'organization-id':
                                          org['id'],
                                      })

        content_host = Host.with_user(user['login'], user['password']).info(
            {'id': content_host['id']})
        # check that content view matches what we passed
        self.assertEqual(
            content_host['content-information']['content-view']['name'],
            content_view['name'])
        # check that lifecycle environment matches
        self.assertEqual(
            content_host['content-information']['lifecycle-environment']
            ['name'],
            lifecycle_environment['name'],
        )

        # step 2.16: Create a new libvirt compute resource
        self._create(
            user,
            ComputeResource,
            {
                'name':
                gen_alphanumeric(),
                'provider':
                'Libvirt',
                'url':
                'qemu+ssh://root@{}/system'.format(
                    settings.compute_resources.libvirt_hostname),
            },
        )

        # step 2.17: Create a new subnet
        subnet = self._create(
            user,
            Subnet,
            {
                'name': gen_alphanumeric(),
                'network': gen_ipaddr(ip3=True),
                'mask': '255.255.255.0',
            },
        )

        # step 2.18: Create a new domain
        domain = self._create(user, Domain, {'name': gen_alphanumeric()})

        # step 2.19: Create a new hostgroup and associate previous entities to
        # it
        host_group = self._create(
            user,
            HostGroup,
            {
                'domain-id': domain['id'],
                'name': gen_alphanumeric(),
                'subnet-id': subnet['id']
            },
        )
        HostGroup.with_user(user['login'], user['password']).update({
            'id':
            host_group['id'],
            'organization-ids':
            org['id'],
            'content-view-id':
            content_view['id'],
            'lifecycle-environment-id':
            lifecycle_environment['id'],
        })

        # step 2.20: Provision a client
        self.client_provisioning(activation_key['name'], org['label'])