示例#1
0
    def test_positive_automate_bz1426957(self):
        """Verify role is properly reflected on AD user.

        :id: 1c1209a6-5bb8-489c-a151-bb2fce4dbbfc

        :expectedresults: Roles from usergroup is applied on AD user successfully.

        :CaseLevel: Integration

        :BZ: 1426957, 1667704
        """
        ext_user_group = make_usergroup_external(
            {
                'auth-source-id': self.auth['server']['id'],
                'user-group-id': self.user_group['id'],
                'name': 'foobargroup',
            }
        )
        self.assertEqual(ext_user_group['auth-source'], self.auth['server']['name'])
        role = make_role()
        UserGroup.add_role({'id': self.user_group['id'], 'role-id': role['id']})
        with self.assertNotRaises(CLIReturnCodeError):
            Task.with_user(username=self.ldap_user_name, password=self.ldap_user_passwd).list()
            UserGroupExternal.refresh(
                {'user-group-id': self.user_group['id'], 'name': 'foobargroup'}
            )
        self.assertEqual(User.info({'login': self.ldap_user_name})['user-groups'][1], role['name'])
        User.delete({'login': self.ldap_user_name})
示例#2
0
    def test_positive_automate_bz1426957(self):
        """Verify role is properly reflected on AD user.

        :id: 1c1209a6-5bb8-489c-a151-bb2fce4dbbfc

        :expectedresults: Roles from usergroup is applied on AD user successfully.

        :CaseLevel: Integration

        :BZ: 1426957
        """
        ext_user_group = make_usergroup_external({
            'auth-source-id': self.auth['server']['id'],
            'user-group-id': self.user_group['id'],
            'name': 'foobargroup'
        })
        self.assertEqual(
            ext_user_group['auth-source'], self.auth['server']['name']
        )
        role = make_role()
        UserGroup.add_role({'id': self.user_group['id'], 'role-id': role['id']})
        with self.assertNotRaises(CLIReturnCodeError):
            Task.with_user(username=self.ldap_user_name, password=self.ldap_user_passwd).list()
            UserGroupExternal.refresh({
                'user-group-id': self.user_group['id'],
                'name': 'foobargroup'
            })
        self.assertEqual(User.info({'login': self.ldap_user_name})['user-groups'][1],
                         role['name'])
        User.delete({'login': self.ldap_user_name})
示例#3
0
def test_negative_settings_access_to_non_admin():
    """Check non admin users can't access Administer -> Settings tab

    :id: 34bb9376-c5fe-431a-ac0d-ef030c0ab50e

    :steps:

        1. Login with non admin user
        2. Check "Administer" tab is not present
        3. Navigate to /settings
        4. Check message permission denied is present

    :expectedresults: Administer -> Settings tab should not be available to non admin users

    :CaseImportance: Medium

    :CaseLevel: Acceptance
    """
    login = gen_string('alpha')
    password = gen_string('alpha')
    entities.User(admin=False, login=login, password=password).create()
    try:
        with Session(user=login, password=password) as session:
            result = session.settings.permission_denied()
            assert (
                result == 'Permission denied You are not authorized to perform this action. '
                'Please request one of the required permissions listed below '
                'from a Satellite administrator: view_settings Back'
            )
    finally:
        User.delete({'login': login})
示例#4
0
def test_positive_automate_bz1426957(ldap_auth_source, function_user_group):
    """Verify role is properly reflected on AD user.

    :id: 1c1209a6-5bb8-489c-a151-bb2fce4dbbfc

    :expectedresults: Roles from usergroup is applied on AD user successfully.

    :CaseLevel: Integration

    :BZ: 1426957, 1667704
    """
    ext_user_group = make_usergroup_external({
        'auth-source-id':
        ldap_auth_source['id'],
        'user-group-id':
        function_user_group['id'],
        'name':
        'foobargroup',
    })
    assert ext_user_group['auth-source'] == ldap_auth_source['ldap_hostname']
    role = make_role()
    UserGroup.add_role({
        'id': function_user_group['id'],
        'role-id': role['id']
    })
    Task.with_user(username=ldap_auth_source['user_name'],
                   password=ldap_auth_source['user_password']).list()
    UserGroupExternal.refresh({
        'user-group-id': function_user_group['id'],
        'name': 'foobargroup'
    })
    assert role['name'] in User.info({'login': ldap_auth_source['user_name']
                                      })['user-groups']
    User.delete({'login': ldap_auth_source['user_name']})
示例#5
0
def test_negative_settings_access_to_non_admin():
    """Check non admin users can't access Administer -> Settings tab

    :id: 34bb9376-c5fe-431a-ac0d-ef030c0ab50e

    :steps:

        1. Login with non admin user
        2. Check "Administer" tab is not present
        3. Navigate to /settings
        4. Check message permission denied is present

    :expectedresults: Administer -> Settings tab should not be available to non admin users

    :CaseImportance: Medium

    :CaseLevel: Acceptance
    """
    login = gen_string('alpha')
    password = gen_string('alpha')
    entities.User(admin=False, login=login, password=password).create()
    try:
        with Session(user=login, password=password) as session:
            assert session.settings.browser.title == 'Permission denied'
    finally:
        User.delete({'login': login})
示例#6
0
    def test_negative_delete_internal_admin(self):
        """Attempt to delete internal admin user

        @id: 4fc92958-9e75-4bd2-bcbe-32f906e432f5

        @Assert: User is not deleted
        """
        with self.assertRaises(CLIReturnCodeError):
            User.delete({'login': self.foreman_user})
        self.assertTrue(User.info({'login': self.foreman_user}))
示例#7
0
    def test_negative_delete_internal_admin(self):
        """Attempt to delete internal admin user

        @Feature: User - Negative Delete

        @Assert: User is not deleted
        """
        login = settings.server.admin_username
        with self.assertRaises(CLIReturnCodeError):
            User.delete({'login': login})
        self.assertTrue(User.info({'login': login}))
示例#8
0
    def test_negative_delete_internal_admin(self):
        """Attempt to delete internal admin user

        @id: 4fc92958-9e75-4bd2-bcbe-32f906e432f5

        @Assert: User is not deleted
        """
        with self.assertRaises(CLIReturnCodeError) as raise_ctx:
            User.delete({'login': self.foreman_user})
        self.assert_error_msg(raise_ctx, u'Could not delete the user:'******'login': self.foreman_user}))
示例#9
0
    def test_negative_delete_internal_admin(self):
        """Attempt to delete internal admin user

        @Feature: User - Negative Delete

        @Assert: User is not deleted
        """
        login = settings.server.admin_username
        with self.assertRaises(CLIReturnCodeError):
            User.delete({'login': login})
        self.assertTrue(User.info({'login': login}))
示例#10
0
    def test_positive_delete_by_id(self):
        """Create an user and then delete it using its id

        @Feature: User - Positive Delete

        @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']})
示例#11
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']})
示例#12
0
    def test_negative_delete_internal_admin(self):
        """Attempt to delete internal admin user

        :id: 4fc92958-9e75-4bd2-bcbe-32f906e432f5

        :expectedresults: User is not deleted

        :CaseImportance: Critical
        """
        with pytest.raises(CLIReturnCodeError):
            User.delete({'login': settings.server.admin_username})
        assert User.info({'login': settings.server.admin_username})
示例#13
0
    def test_positive_delete_by_id(self):
        """Create an user and then delete it using its id

        @Feature: User - Positive Delete

        @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']})
示例#14
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']})
示例#15
0
    def test_negative_delete_internal_admin(self):
        """Attempt to delete internal admin user

        :id: 4fc92958-9e75-4bd2-bcbe-32f906e432f5

        :expectedresults: User is not deleted

        :CaseImportance: Critical
        """
        with self.assertRaisesRegex(CLIReturnCodeError, 'Could not delete the user:'******'login': self.foreman_user})
        self.assertTrue(User.info({'login': self.foreman_user}))
示例#16
0
    def test_positive_delete_admin(self):
        """Delete an admin user

        @id: 9752706c-fdbd-4a36-af6f-27824d22ea03

        @Assert: User is deleted
        """
        for login in valid_usernames_list():
            with self.subTest(login), self.assertRaises(CLIReturnCodeError):
                user = make_user({"login": login, "admin": 'true'})
                self.assertEqual(user['admin'], 'yes')
                User.delete({'login': user['login']})
                User.info({'login': user['login']})
示例#17
0
    def test_positive_delete_admin(self):
        """Delete an admin user

        @id: 9752706c-fdbd-4a36-af6f-27824d22ea03

        @Assert: User is deleted
        """
        for login in valid_usernames_list():
            with self.subTest(login), self.assertRaises(CLIReturnCodeError):
                user = make_user({"login": login, "admin": 'true'})
                self.assertEqual(user['admin'], 'yes')
                User.delete({'login': user['login']})
                User.info({'login': user['login']})
示例#18
0
    def test_positive_delete_by_name(self):
        """Create an user and then delete it using its name

        @id: 37cf4313-012f-4215-b537-030ee61c1c3c

        @Assert: User is deleted
        """
        for login in valid_usernames_list():
            with self.subTest(login), self.assertRaises(CLIReturnCodeError):
                user = make_user({'login': login})
                self.assertEqual(user['login'], login)
                User.delete({'login': user['login']})

                User.info({'login': user['login']})
示例#19
0
    def test_positive_delete_by_name(self):
        """Create an user and then delete it using its name

        @id: 37cf4313-012f-4215-b537-030ee61c1c3c

        @Assert: User is deleted
        """
        for login in valid_usernames_list():
            with self.subTest(login):
                user = make_user({'login': login})
                self.assertEqual(user['login'], login)
                User.delete({'login': user['login']})
                with self.assertRaises(CLIReturnCodeError):
                    User.info({'login': user['login']})
示例#20
0
    def test_positive_delete_admin(self):
        """Delete an admin user

        @Feature: User - Positive Delete

        @Assert: User is deleted
        """
        for login in valid_usernames_list():
            with self.subTest(login):
                user = make_user({"login": login, "admin": 'true'})
                self.assertEqual(user['admin'], 'yes')
                User.delete({'login': user['login']})
                with self.assertRaises(CLIReturnCodeError):
                    User.info({'login': user['login']})
示例#21
0
    def test_positive_delete_by_name(self):
        """Create an user and then delete it using its name

        @Feature: User - Positive Delete

        @Assert: User is deleted
        """
        for login in valid_usernames_list():
            with self.subTest(login):
                user = make_user({'login': login})
                self.assertEqual(user['login'], login)
                User.delete({'login': user['login']})
                with self.assertRaises(CLIReturnCodeError):
                    User.info({'login': user['login']})
示例#22
0
    def test_positive_delete_admin(self):
        """Delete an admin user

        @Feature: User - Positive Delete

        @Assert: User is deleted
        """
        for login in valid_usernames_list():
            with self.subTest(login):
                user = make_user({"login": login, "admin": 'true'})
                self.assertEqual(user['admin'], 'yes')
                User.delete({'login': user['login']})
                with self.assertRaises(CLIReturnCodeError):
                    User.info({'login': user['login']})
示例#23
0
    def test_positive_remove_user_assigned_to_usergroup(self):
        """Create new user and assign it to user group. Then remove that user.

        :id: 2a2623ce-4723-4402-aae7-8675473fd8bd

        :expectedresults: User should delete successfully.

        :CaseLevel: Integration
        """
        user = make_user()
        user_group = make_usergroup()
        UserGroup.add_user({'id': user_group['id'], 'user-id': user['id']})
        with self.assertNotRaises(CLIReturnCodeError):
            User.delete({'id': user['id']})
示例#24
0
    def test_positive_delete_by_name(self):
        """Create an user and then delete it using its name

        @Feature: User - Positive Delete

        @Assert: User is deleted
        """
        for login in valid_usernames_list():
            with self.subTest(login):
                user = make_user({'login': login})
                self.assertEqual(user['login'], login)
                User.delete({'login': user['login']})
                with self.assertRaises(CLIReturnCodeError):
                    User.info({'login': user['login']})
示例#25
0
    def test_positive_remove_user_assigned_to_usergroup(self):
        """Create new user and assign it to user group. Then remove that user.

        :id: 2a2623ce-4723-4402-aae7-8675473fd8bd

        :expectedresults: User should delete successfully.

        :CaseLevel: Integration
        """
        user = make_user()
        user_group = make_usergroup()
        UserGroup.add_user({'id': user_group['id'], 'user-id': user['id']})
        with self.assertNotRaises(CLIReturnCodeError):
            User.delete({'id': user['id']})
示例#26
0
    def test_negative_delete_internal_admin(self):
        """Attempt to delete internal admin user

        :id: 4fc92958-9e75-4bd2-bcbe-32f906e432f5

        :expectedresults: User is not deleted

        :CaseImportance: Critical
        """
        with self.assertRaisesRegex(
            CLIReturnCodeError,
            u'Could not delete the user:'******'login': self.foreman_user})
        self.assertTrue(User.info({'login': self.foreman_user}))
示例#27
0
    def test_positive_delete_by_name(self):
        """Create an user and then delete it using its name

        :id: 37cf4313-012f-4215-b537-030ee61c1c3c

        :expectedresults: User is deleted

        :CaseImportance: Critical
        """
        for login in valid_usernames_list():
            with self.subTest(login), self.assertRaises(CLIReturnCodeError):
                user = make_user({'login': login})
                self.assertEqual(user['login'], login)
                User.delete({'login': user['login']})

                User.info({'login': user['login']})
示例#28
0
def test_positive_remove_user_assigned_to_usergroup():
    """Create new user and assign it to user group. Then remove that user.

    :id: 2a2623ce-4723-4402-aae7-8675473fd8bd

    :expectedresults: User should delete successfully.

    :CaseLevel: Integration

    :BZ: 1667704
    """
    user = make_user()
    user_group = make_usergroup()
    UserGroup.add_user({'id': user_group['id'], 'user-id': user['id']})
    User.delete({'id': user['id']})
    user_group = UserGroup.info({'id': user_group['id']})
    assert user['login'] not in user_group['users']
示例#29
0
    def test_bugzilla_1079649_1(self):
        """@Test: Delete a user by it's name

        @Feature: User

        @Steps:
        1. Create User
        2. Delete the User

        @Assert: User is deleted
        """
        user = make_user()
        self.__assert_exists(user)
        UserObj.delete({'login': user['login']})
        # make sure user was removed
        with self.assertRaises(CLIReturnCodeError):
            UserObj.info({'login': user['login']})
示例#30
0
    def test_positive_delete_user_1(self, test_data):
        """@Test: Delete a user

        @Feature: User - Positive Delete

        @Steps:
        1. Create User
        2. Delete the User

        @Assert: User is deleted

        """
        user = make_user(test_data)
        self.__assert_exists(user)
        UserObj.delete({'login': user['login']})
        # make sure user was removed
        with self.assertRaises(CLIReturnCodeError):
            UserObj.info({'login': user['login']})
示例#31
0
    def test_positive_delete_user_2(self):
        """@Test: Delete an admin user

        @Feature: User - Positive Delete

        @Steps:
        1. Create an admin user
        2. Delete the User

        @Assert: User is deleted
        """
        for login in valid_usernames_list():
            with self.subTest(login):
                user = make_user({"login": login, "admin": 'true'})
                self.__assert_exists(user)
                UserObj.delete({'login': user['login']})
                with self.assertRaises(CLIReturnCodeError):
                    UserObj.info({'login': user['login']})
示例#32
0
    def test_positive_CRUD_admin(self):
        """Create an Admin user

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

        :expectedresults: Admin User is created, updated, deleted

        :CaseImportance: Critical
        """
        user = make_user({'admin': '1'})
        assert user['admin'] == 'yes'
        # update to non admin by id
        User.update({'id': user['id'], 'admin': '0'})
        user = User.info({'id': user['id']})
        assert user['admin'] == 'no'
        # update back to admin by name
        User.update({'login': user['login'], 'admin': '1'})
        user = User.info({'login': user['login']})
        assert user['admin'] == 'yes'
        # delete user
        User.delete({'login': user['login']})
        with pytest.raises(CLIReturnCodeError):
            User.info({'id': user['id']})
示例#33
0
    def test_positive_remove_user(self):
        """Delete any user who has previously created an activation key
        and check that activation key still exists

        :id: ba9c4b29-2349-47ea-8081-917de2c17ed2

        :expectedresults: Activation Key can be read

        :BZ: 1291271
        """
        password = gen_string('alpha')
        user = make_user({'password': password, 'admin': 'true'})
        ak = ActivationKey.with_user(
            username=user['login'],
            password=password
        ).create({
            'name': gen_string('alpha'),
            'organization-id': self.org['id'],
        })
        User.delete({'id': user['id']})
        try:
            ActivationKey.info({'id': ak['id']})
        except CLIReturnCodeError:
            self.fail("Activation Key can't be read")
示例#34
0
    def test_positive_remove_user(self):
        """Delete any user who has previously created an activation key
        and check that activation key still exists

        :id: ba9c4b29-2349-47ea-8081-917de2c17ed2

        :expectedresults: Activation Key can be read

        :BZ: 1291271
        """
        password = gen_string('alpha')
        user = make_user({'password': password, 'admin': 'true'})
        ak = ActivationKey.with_user(
            username=user['login'],
            password=password
        ).create({
            'name': gen_string('alpha'),
            'organization-id': self.org['id'],
        })
        User.delete({'id': user['id']})
        try:
            ActivationKey.info({'id': ak['id']})
        except CLIReturnCodeError:
            self.fail("Activation Key can't be read")
示例#35
0
 def test_negative_delete_user_1(self, opts):
     """
     @Test: Attempt to delete internal admin user
     @Feature: User - Negative Delete
     @Steps:
     1. Attempt to delete the last admin user
     @Assert: User is not deleted
     """
     user = UserObj()
     user.katello_user = opts["login"]
     user.katello_passwd = opts["password"]
     result = user.delete({"login": "******"})
     self.assertTrue(result.stderr)
     self.assertNotEqual(result.return_code, 0)
     result = UserObj().exists(("login", "admin"))
     self.assertTrue(result.stdout)
示例#36
0
 def test_negative_delete_user_1(self, opts):
     """
     @Test: Attempt to delete internal admin user
     @Feature: User - Negative Delete
     @Steps:
     1. Attempt to delete the last admin user
     @Assert: User is not deleted
     """
     user = UserObj()
     user.katello_user = opts['login']
     user.katello_passwd = opts['password']
     result = user.delete({'login': '******'})
     self.assertTrue(result.stderr)
     self.assertNotEqual(result.return_code, 0)
     result = UserObj().exists(tuple_search=('login', 'admin'))
     self.assertTrue(result.stdout)
示例#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']})
示例#38
0
 def _cleanup():
     if User.exists(search=('login', user['login'])):
         User.delete(options={'id': user['id']})
示例#39
0
 def tearDown(self):
     """Cleaning up user used on tests"""
     super(UserWithCleanUpTestCase, self).tearDown()
     User.delete({'id': self.user['id']})
示例#40
0
def _delete_test_user(cls_or_instance):
    """Helper function which deletes test user stored on a class or
    instance.
    """
    User.delete({'id': cls_or_instance.user['id']})
示例#41
0
 def tearDown(self):
     """Cleaning up user used on tests"""
     super(UserWithCleanUpTestCase, self).tearDown()
     User.delete({'id': self.user['id']})
示例#42
0
def _delete_test_user(cls_or_instance):
    """Helper function which deletes test user stored on a class or
    instance.
    """
    User.delete({'id': cls_or_instance.user['id']})