Example #1
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)
Example #2
0
 def class_rexinfra_user(self, module_org):
     """Creates a user with all Remote Execution related permissions"""
     password = gen_string('alpha')
     rexinfra = gen_string('alpha')
     make_user({
         'login': rexinfra,
         'password': password,
         'organization-ids': module_org.id
     })
     role = make_role({'organization-ids': module_org.id})
     invocation_permissions = [
         permission['name'] for permission in Filter.available_permissions(
             {'search': 'resource_type=JobInvocation'})
     ]
     template_permissions = [
         permission['name'] for permission in Filter.available_permissions(
             {'search': 'resource_type=JobTemplate'})
     ]
     permissions = ','.join(invocation_permissions)
     make_filter({'role-id': role['id'], 'permissions': permissions})
     permissions = ','.join(template_permissions)
     # needs execute_jobs_on_infrastructure_host permission
     make_filter({'role-id': role['id'], 'permissions': permissions})
     User.add_role({'login': rexinfra, 'role': role['name']})
     User.add_role({'login': rexinfra, 'role': 'Remote Execution Manager'})
     yield (rexinfra, password)
Example #3
0
    def test_negative_create_with_invalid_username(self):
        """Create User with invalid Username

        @id: 8bb53001-6377-49fe-a85c-f92204a5dea4

        @Assert: User is not created. Appropriate error shown.
        """
        invalid_names = (
            '', 'space {0}'.format(gen_string('alpha')),
            gen_string('alpha', 101),
            gen_string('html')
        )
        for invalid_name in invalid_names:
            with self.subTest(invalid_name):
                options = {
                    'auth-source-id': 1,
                    'login': invalid_name,
                    'mail': 'root@localhost',
                    'password': gen_string('alpha'),
                }
                self.logger.debug(str(options))
                with self.assertRaises(CLIReturnCodeError) as raise_ctx:
                    User.create(options)
                self.assert_error_msg(
                    raise_ctx,
                    u'Could not create the user:'
                )
Example #4
0
def test_positive_change_session(admin_user, non_admin_user, target_sat):
    """Change from existing session to a different session

    :id: b6ea6f3c-fcbd-4e7b-97bd-f3e0e6b9da8f

    :Steps:

        1. Set use_sessions
        2. Authenticate, assert credentials are not demanded
           on next command run
        3. Login as a different user

    :CaseImportance: High

    :expectedresults: The session is altered

    """
    result = configure_sessions(target_sat)
    assert result == 0, 'Failed to configure hammer sessions'
    AuthLogin.basic({'username': admin_user['login'], 'password': password})
    result = Auth.with_user().status()
    assert LOGEDIN_MSG.format(admin_user['login']) in result[0]['message']
    # list organizations without supplying credentials
    assert User.with_user().list()
    AuthLogin.basic({
        'username': non_admin_user['login'],
        'password': password
    })
    result = Auth.with_user().status()
    assert LOGEDIN_MSG.format(non_admin_user['login']) in result[0]['message']
    assert User.with_user().list()
Example #5
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})
Example #6
0
def test_positive_update_with_manager_role(module_location, module_org):
    """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: Medium

    :BZ: 1277308
    """
    new_name = gen_string('alpha')
    username = gen_string('alpha')
    password = gen_string('alpha')
    template = make_template(
        {'organization-ids': module_org.id, 'location-ids': module_location.id}
    )
    # Create user with Manager role
    user = entities.User(
        login=username,
        password=password,
        admin=False,
        organization=[module_org.id],
        location=[module_location.id],
    ).create()
    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']})
    assert new_name == template['name']
Example #7
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})
Example #8
0
    def test_positive_last_login_for_new_user(self):
        """Create new user with admin role and check last login updated for that user

        :id: 967282d3-92d0-42ce-9ef3-e542d2883408

        :customerscenario: true

        :expectedresults: last login should be updated for user after login using hammer

        :BZ: 1763816

        :CaseLevel: Integration
        """
        login = gen_string('alpha')
        password = gen_string('alpha')
        org_name = gen_string('alpha')

        make_user({'login': login, 'password': password})
        User.add_role({'login': login, 'role': 'System admin'})
        result_before_login = User.list({'search': f'login = {login}'})

        # this is because satellite uses the UTC timezone
        before_login_time = datetime.datetime.utcnow()
        assert result_before_login[0]['login'] == login
        assert result_before_login[0]['last-login'] == ""

        Org.with_user(username=login,
                      password=password).create({'name': org_name})
        result_after_login = User.list({'search': f'login = {login}'})

        # checking user last login should not be empty
        assert result_after_login[0]['last-login'] != ""
        after_login_time = datetime.datetime.strptime(
            result_after_login[0]['last-login'], "%Y/%m/%d %H:%M:%S")
        assert after_login_time > before_login_time
Example #9
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})
Example #10
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'],
         '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'],
         'password': cls.password,
     })
     cls.user_reader['password'] = cls.password
     User.add_role({
         'login': cls.user_reader['login'],
         'role': 'Discovery Reader',
     })
Example #11
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',
     })
Example #12
0
    def test_positive_create_ssh_key_super_admin_from_file(self):
        """SSH Key can be added to Super Admin user from file

        :id: b865d0ae-6317-475c-a6da-600615b71eeb

        :expectedresults: SSH Key should be added to Super Admin user
                          from ssh pub file

        :CaseImportance: Critical
        """
        ssh_name = gen_string('alpha')
        ssh_key = self.gen_ssh_rsakey()
        with get_connection() as connection:
            result = connection.run(
                '''echo '{}' > test_key.pub'''.format(ssh_key))
        self.assertEqual(result.return_code, 0, 'key file not created')
        User.ssh_keys_add({
            'user': '******',
            'key-file': 'test_key.pub',
            'name': ssh_name
        })
        result = User.ssh_keys_list({'user': '******'})
        self.assertIn(ssh_name, [i['name'] for i in result])
        result = User.ssh_keys_info({'user': '******', 'name': ssh_name})
        self.assertEqual(ssh_key, result[0]['public-key'])
Example #13
0
    def test_negative_create_with_invalid_username(self):
        """Create User with invalid Username

        :id: 8bb53001-6377-49fe-a85c-f92204a5dea4

        :expectedresults: User is not created. Appropriate error shown.

        :CaseImportance: Critical
        """
        invalid_names = (
            '', 'space {0}'.format(gen_string('alpha')),
            gen_string('alpha', 101),
            gen_string('html')
        )
        for invalid_name in invalid_names:
            with self.subTest(invalid_name):
                options = {
                    'auth-source-id': 1,
                    'login': invalid_name,
                    'mail': 'root@localhost',
                    'password': gen_string('alpha'),
                }
                self.logger.debug(str(options))
                with self.assertRaisesRegex(
                    CLIReturnCodeError,
                    u'Could not create the user:'
                ):
                    User.create(options)
Example #14
0
    def test_positive_add_roles(self):
        """Add multiple roles to User

        For now add-role user sub command does not allow multiple role ids
        (https://github.com/SatelliteQE/robottelo/issues/3729)
        So if if it gets fixed this test can be updated:
        (http://projects.theforeman.org/issues/16206)

        :id: d769ac61-f158-4e4e-a176-1c87de8b00f6

        :expectedresults: Roles are added to user

        :CaseLevel: Integration
        """
        user = self.user
        original_role_names = set(user['roles'])
        expected_role_names = set(original_role_names)

        for role_id, role in self.stubbed_roles.items():
            User.add_role({'login': user['login'], 'role-id': role_id})
            expected_role_names.add(role['name'])

        self.assertItemsEqual(
            expected_role_names,
            User.info({'id': user['id']})['roles']
        )
Example #15
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'])
Example #16
0
    def test_negative_create_user_1(self):
        """@Test: Create User with invalid Username

        @Feature: User - Negative Create

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

        @Assert: User is not created. Appropriate error shown.
        """
        for invalid_name in ('',
                             'space {0}'.format(gen_string('alpha')),
                             gen_string('alpha', 101),
                             gen_string('html')):
            with self.subTest(invalid_name):
                options = {
                    'auth-source-id': 1,
                    'login': invalid_name,
                    'mail': 'root@localhost',
                    'password': gen_string('alpha'),
                }
                self.logger.debug(str(options))
                with self.assertRaises(CLIReturnCodeError):
                    UserObj.create(options)
Example #17
0
    def test_positive_list_with_non_admin_user(self, module_puppet):
        """List all the parameters for specific puppet class by id.

        :id: 00fbf150-34fb-45d0-80e9-d5798d24a24f

        :expectedresults: Parameters listed for specific Puppet class.

        :BZ: 1391556

        :CaseImportance: Medium
        """
        password = gen_string('alpha')
        required_user_permissions = {
            'Puppetclass': {'permissions': ['view_puppetclasses']},
            'PuppetclassLookupKey': {
                'permissions': [
                    'view_external_parameters',
                    'create_external_parameters',
                    'edit_external_parameters',
                    'destroy_external_parameters',
                ]
            },
        }
        user = make_user({'admin': '0', 'password': password})
        role = make_role()
        add_role_permissions(role['id'], required_user_permissions)
        # Add the created and initiated role with permissions to user
        User.add_role({'id': user['id'], 'role-id': role['id']})
        sc_params = SmartClassParameter.with_user(user['login'], password).list(
            {'puppet-class-id': module_puppet['class']['id']}
        )
        assert len(sc_params) > 0
        # Check that only unique results are returned
        assert len(sc_params) == len({scp['id'] for scp in sc_params})
Example #18
0
    def test_personal_access_token_admin_user(self, default_sat):
        """Personal access token for admin user

        :id: f2d3813f-e477-4b6b-8507-246b08fcb3b4

        :steps:
            1. Create an admin user and add personal access token
            2. Use any api endpoint with the token
            3. Revoke the token and check for the result.

        :expectedresults:
            1. Should show output of the api endpoint
            2. When revoked, authentication error

        :CaseLevel: System

        :CaseImportance: High
        """
        user = make_user({'admin': '1'})
        token_name = gen_alphanumeric()
        result = User.access_token(
            action="create", options={'name': token_name, 'user-id': user['id']}
        )
        token_value = result[0]['message'].split(':')[-1]
        curl_command = f'curl -k -u {user["login"]}:{token_value} {default_sat.url}/api/v2/users'
        command_output = default_sat.execute(curl_command)
        assert user['login'] in command_output.stdout
        assert user['email'] in command_output.stdout
        User.access_token(action="revoke", options={'name': token_name, 'user-id': user['id']})
        command_output = default_sat.execute(curl_command)
        assert f'Unable to authenticate user {user["login"]}' in command_output.stdout
Example #19
0
    def test_positive_add_roles(self):
        """Add multiple roles to User

        For now add-role user sub command does not allow multiple role ids
        (https://github.com/SatelliteQE/robottelo/issues/3729)
        So if if it gets fixed this test can be updated:
        (http://projects.theforeman.org/issues/16206)

        :id: d769ac61-f158-4e4e-a176-1c87de8b00f6

        :expectedresults: Roles are added to user

        :CaseLevel: Integration
        """
        user = self.user
        original_role_names = set(user['roles'])
        expected_role_names = set(original_role_names)

        for role_id, role in self.stubbed_roles.items():
            User.add_role({'login': user['login'], 'role-id': role_id})
            expected_role_names.add(role['name'])

        self.assertItemsEqual(
            expected_role_names,
            User.info({'id': user['id']})['roles']
        )
Example #20
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'])
Example #21
0
    def test_negative_create_with_invalid_username(self):
        """Create User with invalid Username

        :id: 8bb53001-6377-49fe-a85c-f92204a5dea4

        :expectedresults: User is not created. Appropriate error shown.

        :CaseImportance: Critical
        """
        invalid_names = (
            '', 'space {0}'.format(gen_string('alpha')),
            gen_string('alpha', 101),
            gen_string('html')
        )
        for invalid_name in invalid_names:
            with self.subTest(invalid_name):
                options = {
                    'auth-source-id': 1,
                    'login': invalid_name,
                    'mail': 'root@localhost',
                    'password': gen_string('alpha'),
                }
                self.logger.debug(str(options))
                with self.assertRaisesRegex(
                    CLIReturnCodeError,
                    u'Could not create the user:'
                ):
                    User.create(options)
Example #22
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']})
Example #23
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})
Example #24
0
 def create_test_user_viewer_role(cls):
     """Create's a user with Viewer role"""
     cls.login = gen_string('alpha')
     cls.password = gen_string('alpha')
     user = make_user({'login': cls.login, 'password': cls.password, 'admin': False})
     role = Role.info({'name': 'Viewer'})
     User.add_role({'login': user['login'], 'role-id': role['id']})
     return cls.login, cls.password
Example #25
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]
Example #26
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'})
Example #27
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}))
Example #28
0
    def test_positive_update_email(self):
        """Update Email Address in My Account

        @Feature: My Account - Positive Update

        @Assert: Current User is updated
        """
        email = u'{0}@example.com'.format(gen_string('alphanumeric'))
        User.update({'id': self.user['id'], 'mail': email})
        result = User.info({'id': self.user['id']})
        self.assertEqual(result['email'], email)
Example #29
0
    def test_positive_update_email(self):
        """Update Email Address in My Account

        @id: 70bab43b-0842-45a1-81fb-e47ff8646c8e

        @Assert: Current User is updated
        """
        email = u'{0}@example.com'.format(gen_string('alphanumeric'))
        User.update({'id': self.user['id'], 'mail': email})
        result = User.info({'id': self.user['id']})
        self.assertEqual(result['email'], email)
Example #30
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}))
Example #31
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}))
Example #32
0
    def test_positive_update_email(self):
        """Update Email Address in My Account

        @Feature: My Account - Positive Update

        @Assert: Current User is updated
        """
        email = u'{0}@example.com'.format(gen_string('alphanumeric'))
        User.update({'id': self.user['id'], 'mail': email})
        result = User.info({'id': self.user['id']})
        self.assertEqual(result['email'], email)
Example #33
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}))
Example #34
0
    def test_positive_update_surname(self):
        """Update Surname in My Account

        @id: 40ad2e78-a2af-45ca-bbd8-e9ca5178dc41

        @Assert: Current User is updated
        """
        new_lastname = gen_string('alphanumeric')
        User.update({'id': self.user['id'], 'lastname': new_lastname})
        result = User.info({'id': self.user['id']})
        updated_last_name = result['name'].split(' ')
        self.assertEqual(updated_last_name[1], new_lastname)
Example #35
0
    def test_positive_update_first_name(self):
        """Update Firstname in My Account

        @id: f8de3843-f2dc-4121-ab75-625c8f542627

        @Assert: Current User is updated
        """
        new_firstname = gen_string('alphanumeric')
        User.update({'id': self.user['id'], 'firstname': new_firstname})
        result = User.info({'id': self.user['id']})
        updated_first_name = result['name'].split(' ')
        self.assertEqual(updated_first_name[0], new_firstname)
Example #36
0
    def test_negative_update_surname(self):
        """Update My Account with invalid Surname

        @id: 4d31ba71-2dcc-47ee-94d2-adc168ba89d7

        @Assert: User is not updated. Appropriate error shown.
        """
        with self.assertRaises(CLIReturnCodeError):
            User.update({
                'id': self.user['id'],
                'lastname': gen_string('alphanumeric', 300),
            })
Example #37
0
    def test_negative_update_first_name(self):
        """Update My Account with invalid FirstName

        @id: 1e0e1a94-4cef-4110-b65c-8cd35df254e0

        @Assert: User is not updated. Appropriate error shown.
        """
        with self.assertRaises(CLIReturnCodeError):
            User.update({
                'id': self.user['id'],
                'firstname': gen_string('alphanumeric', 300),
            })
Example #38
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}))
Example #39
0
    def test_negative_update_surname(self):
        """Update My Account with invalid Surname

        @Feature: My Account - Negative Update

        @Assert: User is not updated. Appropriate error shown.
        """
        with self.assertRaises(CLIReturnCodeError):
            User.update({
                'id': self.user['id'],
                'lastname': gen_string('alphanumeric', 300),
            })
Example #40
0
    def test_positive_update_surname(self):
        """Update Surname in My Account

        @Feature: My Account - Positive Update

        @Assert: Current User is updated
        """
        new_lastname = gen_string('alphanumeric')
        User.update({'id': self.user['id'], 'lastname': new_lastname})
        result = User.info({'id': self.user['id']})
        updated_last_name = result['name'].split(' ')
        self.assertEqual(updated_last_name[1], new_lastname)
Example #41
0
    def test_positive_update_surname(self):
        """Update Surname in My Account

        @Feature: My Account - Positive Update

        @Assert: Current User is updated
        """
        new_lastname = gen_string('alphanumeric')
        User.update({'id': self.user['id'], 'lastname': new_lastname})
        result = User.info({'id': self.user['id']})
        updated_last_name = result['name'].split(' ')
        self.assertEqual(updated_last_name[1], new_lastname)
Example #42
0
 def assert_user_roles(self, roles_dct):
     """
     Check if roles present on roles_dct are added to user
     :param roles_dct: dictionary if roles
     """
     user = self.user
     expected_role_names = set(user['roles'])
     for role_id, role in roles_dct.items():
         User.add_role({'login': user['login'], 'role-id': role_id})
         expected_role_names.add(role['name'])
     self.assertItemsEqual(expected_role_names,
                           User.info({'id': user['id']})['roles'])
Example #43
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})
Example #44
0
    def test_negative_create_with_blank_authorized_by(self):
        """Create User with blank Authorized by

        @Feature: User - Negative Create

        @Assert: User is not created. Appropriate error shown.
        """
        with self.assertRaises(CLIReturnCodeError):
            User.create({
                'auth-source-id': '',
                'login': gen_string('alpha'),
                'mail': 'root@localhost',
            })
Example #45
0
    def test_negative_create_with_blank_authorized_by(self):
        """Create User with blank Authorized by

        @id: 1f60fbf8-a5f0-432e-9b4e-60bc0224294a

        @Assert: User is not created. Appropriate error shown.
        """
        with self.assertRaises(CLIReturnCodeError):
            User.create({
                'auth-source-id': '',
                'login': gen_string('alpha'),
                'mail': 'root@localhost',
            })
Example #46
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']})
Example #47
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']})
Example #48
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']})
Example #49
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']})
Example #50
0
 def assert_user_roles(self, roles_dct):
     """
     Check if roles present on roles_dct are added to user
     :param roles_dct: dictionary if roles
     """
     user = self.user
     expected_role_names = set(user['roles'])
     for role_id, role in roles_dct.items():
         User.add_role({'login': user['login'], 'role-id': role_id})
         expected_role_names.add(role['name'])
     self.assertItemsEqual(
         expected_role_names,
         User.info({'id': user['id']})['roles']
     )
Example #51
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']})
Example #52
0
    def test_negative_update_email(self):
        """Update My Account with invalid Email Address

        @Feature: My Account - Negative Update

        @Assert: User is not updated. Appropriate error shown.
        """
        for email in invalid_emails_list():
            with self.subTest(email):
                with self.assertRaises(CLIReturnCodeError):
                    User.update({
                        'login': self.user['login'],
                        'mail': email,
                    })
Example #53
0
    def test_negative_update_email(self):
        """Update My Account with invalid Email Address

        @id: 619f6285-8d50-47d4-b074-d8854c7567a6

        @Assert: User is not updated. Appropriate error shown.
        """
        for email in invalid_emails_list():
            with self.subTest(email):
                with self.assertRaises(CLIReturnCodeError):
                    User.update({
                        'login': self.user['login'],
                        'mail': email,
                    })
Example #54
0
 def create_test_user_viewer_role(cls):
     """Create's a user with Viewer role"""
     cls.login = gen_string('alpha')
     cls.password = gen_string('alpha')
     user = make_user({
         'login': cls.login,
         'password': cls.password,
         'admin': False
     })
     role = Role.info({'name': 'Viewer'})
     User.add_role({
         'login': user['login'],
         'role-id': role['id'],
     })
     return cls.login, cls.password
Example #55
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}))