Example #1
0
def test_positive_add_host_collection_non_admin(module_org, test_name):
    """Test that host collection can be associated to Activation Keys by
    non-admin user.

    :id: 417f0b36-fd49-4414-87ab-6f72a09696f2

    :expectedresults: Activation key is created, added host collection is
        listed

    :BZ: 1473212

    :CaseLevel: Integration
    """
    ak_name = gen_string('alpha')
    hc = entities.HostCollection(organization=module_org).create()
    # Create non-admin user with specified permissions
    roles = [entities.Role().create()]
    user_permissions = {
        'Katello::ActivationKey': PERMISSIONS['Katello::ActivationKey'],
        'Katello::HostCollection': PERMISSIONS['Katello::HostCollection'],
    }
    viewer_role = entities.Role().search(query={'search': 'name="Viewer"'})[0]
    roles.append(viewer_role)
    create_role_permissions(roles[0], user_permissions)
    password = gen_string('alphanumeric')
    user = entities.User(
        admin=False,
        role=roles,
        password=password,
        organization=[module_org],
    ).create()
    with Session(test_name, user=user.login, password=password) as session:
        session.activationkey.create({
            'name': ak_name,
            'lce': {
                ENVIRONMENT: True
            },
        })
        assert session.activationkey.search(ak_name) == ak_name
        session.activationkey.add_host_collection(ak_name, hc.name)
        ak = session.activationkey.read(ak_name)
        assert hc.name in ak['host_collections']['resources']['assigned']
Example #2
0
    def test_positive_remove_user(self):
        """Create admin users then add user and remove it
        by using the organization name.

        @id: 01a221f7-d0fe-4b46-ab5c-b4e861677126

        @assert: The user is added then removed from the organization

        @CaseLevel: Integration
        """
        strategy, value = common_locators['entity_select']
        strategy1, value1 = common_locators['entity_deselect']
        with Session(self.browser) as session:
            for user_name in valid_users():
                with self.subTest(user_name):
                    org_name = gen_string('alpha')
                    # Use nailgun to create user
                    user = entities.User(
                        login=user_name,
                        firstname=user_name,
                        lastname=user_name,
                        password=gen_string('alpha'),
                    ).create()
                    self.assertEqual(user.login, user_name)
                    make_org(session, org_name=org_name, users=[user_name])
                    self.org.search(org_name).click()
                    session.nav.click(tab_locators['context.tab_users'])
                    element = session.nav.wait_until_element(
                        (strategy1, value1 % user_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.org.update(org_name,
                                    users=[user_name],
                                    new_users=None)
                    self.org.search(org_name).click()
                    session.nav.click(tab_locators['context.tab_users'])
                    element = session.nav.wait_until_element(
                        (strategy, value % user_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNotNone(element)
Example #3
0
def test_positive_create_product_with_limited_user_permission(
        session, test_name, module_org, module_loc):
    """A user with all permissions in Product and Repositories should be able to
    create a new product

    :id: 534a16f9-2d66-4fa1-aa5b-560f00eb4f67

    :expectedresults: User successfully creates new product

    :caseLevel: Component

    :CaseImportance: High

    :BZ: 1771937
    """
    username = gen_string('alpha')
    password = gen_string('alpha')
    product_name = gen_string('alpha')
    product_label = gen_string('alpha')
    product_description = gen_string('alpha')
    role = entities.Role().create()
    # Calling Products and Repositoy to get all the permissions in it
    create_role_permissions(
        role, {'Katello::Product': PERMISSIONS['Katello::Product']})
    entities.User(
        default_organization=module_org,
        organization=[module_org],
        firstname='sample',
        lastname='test',
        role=[role],
        login=username,
        password=password,
        mail='*****@*****.**',
    ).create()
    with Session(test_name, username, password) as newsession:
        newsession.product.create({
            'name': product_name,
            'label': product_label,
            'description': product_description
        })
        assert newsession.product.search(
            product_name)[0]['Name'] == product_name
Example #4
0
def test_positive_create_and_update_with_user(module_org, module_location,
                                              module_user):
    """Create and update host with user specified

    :id: 72e20f8f-17dc-4e38-8ac1-d08df8758f56

    :expectedresults: A host is created and updated with expected user assigned

    :CaseLevel: Integration
    """
    host = entities.Host(owner=module_user,
                         owner_type='User',
                         organization=module_org,
                         location=module_location).create()
    assert host.owner.read() == module_user
    new_user = entities.User(organization=[module_org],
                             location=[module_location]).create()
    host.owner = new_user
    host = host.update(['owner'])
    assert host.owner.read() == new_user
    def test_positive_remove_user(self):
        """Delete any user who has previously created an activation key
        and check that activation key still exists

        :id: 02ce92d4-8f49-48a0-bf9e-5d401f84cf46

        :expectedresults: Activation Key can be read

        :BZ: 1291271
        """
        password = gen_string('alpha')
        user = entities.User(password=password, login=gen_string('alpha'), admin=True).create()
        cfg = get_nailgun_config()
        cfg.auth = (user.login, password)
        ak = entities.ActivationKey(cfg).create()
        user.delete()
        try:
            entities.ActivationKey(id=ak.id).read()
        except HTTPError:
            self.fail("Activation Key can't be read")
Example #6
0
    def test_positive_update_user(self):
        """Update usergroup with new user

        @id: 5fdb1c36-196d-4ba5-898d-40f484b81090

        @Assert: Usergroup is updated
        """
        name = gen_string('alpha')
        user_name = gen_string('alpha')
        # Create a new user
        entities.User(
            login=user_name,
            password=gen_string('alpha'),
            organization=[self.organization],
        ).create()
        with Session(self.browser) as session:
            make_usergroup(session, name=name, org=self.organization.name)
            self.assertIsNotNone(self.usergroup.search(name))
            self.usergroup.update(name, users=[user_name])
            self.assertIsNotNone(self.usergroup.search(name))
    def test_positive_update_name(self):
        """Update usergroup with new name

        @Feature: Usergroup - Positive Update

        @Assert: Usergroup is updated
        """
        name = gen_string('alpha')
        user_name = gen_string('alpha')
        password = gen_string('alpha')
        # Create a new user
        entities.User(login=user_name, password=password).create()
        with Session(self.browser) as session:
            make_usergroup(session, name=name)
            self.assertIsNotNone(self.usergroup.search(name))
            for new_name in generate_strings_list():
                with self.subTest(new_name):
                    self.usergroup.update(name, new_name, users=[user_name])
                    self.assertIsNotNone(self.usergroup.search(new_name))
                    name = new_name  # for next iteration
Example #8
0
def test_positive_content_host_errata_details(session, erratatype_vm, module_org, test_name):
    """Read for errata details on a content_host by user with only viewer permission

    :id: 236de56f-8035-4072-b0fa-03abbf3fc692

    :Steps:

        1. Content Host with applicable security errata.
        2. Create a User with 'Viewer' Permission.
        3. Go to Content Hosts -> Select content host -> Errata Tab -> Select Errata_Id.

    :expectedresults: The errata details page should be displayed for User.

    :BZ: 1655130

    :CaseLevel: Integration
    """
    login = gen_string('alpha')
    password = gen_string('alpha')
    viewer_role = entities.Role().search(query={'search': 'name="Viewer"'})
    default_loc_id = entities.Location().search(query={'search': f'name="{DEFAULT_LOC}"'})[0].id
    default_loc = entities.Location(id=default_loc_id).read()

    entities.User(
        role=viewer_role,
        login=login,
        password=password,
        default_location=default_loc,
        organization=[module_org],
    ).create()

    pkgs = ' '.join(FAKE_9_YUM_OUTDATED_PACKAGES)
    assert _install_client_package(erratatype_vm, pkgs, errata_applicability=True)

    with Session(test_name, login, password) as session:
        session.organization.select(org_name=module_org.name)
        erratum_details = session.contenthost.read_errata_details(
            erratatype_vm.hostname, errata_id=CUSTOM_REPO_ERRATA_ID
        )
        assert erratum_details['advisory'] == CUSTOM_REPO_ERRATA_ID
        assert erratum_details['type'] == 'security'
Example #9
0
def test_positive_list_permission(test_name, module_org, module_repos_col,
                                  module_rhva_repos_col):
    """Show errata only if the User has permissions to view them

    :id: cdb28f6a-23df-47a2-88ab-cd3b492126b2

    :Setup:

        1. Create two products with one repo each. Sync them.
        2. Make sure that they both have errata.
        3. Create a user with view access on one product and not on the other.

    :Steps: Go to Content -> Errata.

    :expectedresults: Check that the new user is able to see errata for one
        product only.

    :CaseLevel: Integration
    """
    role = entities.Role().create()
    entities.Filter(
        organization=[module_org],
        permission=entities.Permission().search(
            query={'search': 'resource_type="Katello::Product"'}),
        role=role,
        search='name = "{}"'.format(PRDS['rhel']),
    ).create()
    user_password = gen_string('alphanumeric')
    user = entities.User(
        default_organization=module_org,
        organization=[module_org],
        role=[role],
        password=user_password,
    ).create()
    with Session(test_name, user=user.login,
                 password=user_password) as session:
        assert (session.errata.search(
            RHVA_ERRATA_ID,
            applicable=False)[0]['Errata ID'] == RHVA_ERRATA_ID)
        assert not session.errata.search(CUSTOM_REPO_ERRATA_ID,
                                         applicable=False)
Example #10
0
    def setUpClass(cls):
        """Display all the bookmarks on the same page, create user and entities
        for testing.
        """
        super(BookmarkTestCase, cls).setUpClass()
        cls.per_page = entities.Setting().search(
            query={'search': 'name="entries_per_page"'})[0]
        cls.saved_per_page = str(cls.per_page.value)
        cls.per_page.value = '100000'
        cls.per_page.update({'value'})
        cls.entities = []

        # Custom user for bookmark visibility testing
        role = entities.Role().search(query={'search': 'name="Viewer"'})[0]
        cls.custom_password = gen_string('alphanumeric')
        cls.custom_user = entities.User(
            role=[role],
            password=cls.custom_password,
        ).create()

        for entity in BOOKMARK_ENTITIES:
            # Skip the entities, which can't be tested ATM (require framework
            # update)
            skip = entity.get('skip_for_ui')
            if skip and (skip is True or bz_bug_is_open(skip)):
                continue
            cls.entities.append(entity)
            # Some pages require at least 1 existing entity for search bar to
            # appear. Creating 1 entity for such pages
            if entity.get('setup'):
                # entities with 1 organization
                if entity['name'] in ('Hosts', ):
                    entity['setup'](organization=cls.session_org).create()
                # entities with no organizations
                elif entity['name'] in ('Compute_Profile', 'ConfigGroups',
                                        'HardwareModel', 'PuppetClasses',
                                        'UserGroup'):
                    entity['setup']().create()
                # entities with multiple organizations
                else:
                    entity['setup'](organization=[cls.session_org]).create()
Example #11
0
    def test_positive_update_org_with_admin_perms(self):
        """Add non-admin user to a usergroup with administrative privileges and
        make sure user can update his organizations

        :id: 13d50901-d94a-4ede-a134-d7b5e84c9a2c

        :BZ: 1390833

        :expectedresults: user can update his assigned organizations
        """
        new_org = entities.Organization().create()
        password = gen_string('alpha')
        user = entities.User(
            admin=False,
            default_organization=self.organization,
            password=password,
            organization=[self.organization],
        ).create()
        group_name = gen_string('alpha')
        # Create a usergroup with admin permissions and associate the user
        with Session(self) as session:
            make_usergroup(
                session, name=group_name, org=self.organization.name)
            self.assertIsNotNone(self.usergroup.search(group_name))
            self.usergroup.update(
                group_name, users=[user.login], roles=['admin'])
            self.assertIsNotNone(self.usergroup.search(group_name))
        # Login as the user and assign new organization
        with Session(self, user=user.login, password=password):
            self.user.update(
                user.login,
                new_organizations=[new_org.name],
            )
            # Make sure both organizations are assigned
            self.user.click(self.user.search(user.login))
            self.user.click(tab_locators['users.tab_organizations'])
            for org in (self.organization.name, new_org.name):
                self.assertIsNotNone(
                    self.user.wait_until_element(
                        common_locators['entity_deselect'] % org)
                )
Example #12
0
def test_positive_end_to_end(session, module_org, module_loc):
    """Perform end to end testing for usergroup component

    :id: c1c7c383-b118-4caf-a5ef-4e75fdbbacdc

    :expectedresults: All expected CRUD actions finished successfully

    :CaseLevel: Integration

    :CaseImportance: High
    """
    name = gen_string('alpha')
    new_name = gen_string('alpha')
    user = entities.User(
        password=gen_string('alpha'), organization=[module_org], location=[module_loc]
    ).create()
    user_group = entities.UserGroup().create()
    with session:
        # Create new user group with assigned entities
        session.usergroup.create(
            {
                'usergroup.name': name,
                'usergroup.users': {'assigned': [user.login]},
                'usergroup.usergroups': {'assigned': [user_group.name]},
                'roles.admin': True,
                'roles.resources': {'assigned': ['Viewer']},
            }
        )
        assert session.usergroup.search(name)[0]['Name'] == name
        usergroup_values = session.usergroup.read(name)
        assert usergroup_values['usergroup']['name'] == name
        assert usergroup_values['usergroup']['usergroups']['assigned'][0] == user_group.name
        assert usergroup_values['usergroup']['users']['assigned'][0] == user.login
        assert usergroup_values['roles']['admin'] is True
        assert usergroup_values['roles']['resources']['assigned'][0] == 'Viewer'
        # Update user group with new name
        session.usergroup.update(name, {'usergroup.name': new_name})
        assert session.usergroup.search(new_name)[0]['Name'] == new_name
        # Delete user group
        session.usergroup.delete(new_name)
        assert not session.usergroup.search(new_name)
Example #13
0
    def test_positive_update(self):
        """Update an existing user and give it roles.

        :id: 7fdca879-d65f-44fa-b9f2-b6bb5df30c2d

        :expectedresults: The user has whatever roles are given.

        This test targets BZ 1216239.

        :CaseImportance: Critical
        """
        user = entities.User().create()
        self.assertEqual(len(user.role), 0)  # No roles assigned
        for i in range(1, len(self.roles) + 1):
            with self.subTest(str(i)):
                chosen_roles = self.roles[:i]
                user.role = chosen_roles
                user = user.update(['role'])
                self.assertEqual(
                    set([role.id for role in user.role]), set([role.id for role in chosen_roles])
                )
Example #14
0
    def test_positive_create_with_role(self):
        """Create a user with the ``role`` attribute.

        :id: 32daacf1-eed4-49b1-81e1-ab0a5b0113f2

        :expectedresults: A user is created with the given role(s).

        This test targets BZ 1216239.

        :CaseImportance: Critical
        """
        for i in range(1, len(self.roles) + 1):
            with self.subTest(str(i)):
                chosen_roles = self.roles[:i]
                user = entities.User(role=chosen_roles).create()
                self.assertEqual(len(user.role), i)
                self.assertEqual(
                    set([role.id for role in user.role]),
                    # pylint:disable=no-member
                    set([role.id for role in chosen_roles]),
                )
Example #15
0
    def setUpClass(cls):
        """Display all the bookmarks on the same page, create user and entities
        for testing.
        """
        super(BookmarkTestCase, cls).setUpClass()
        cls.entities = []

        # Custom user for bookmark visibility testing
        role = entities.Role().search(query={'search': 'name="Viewer"'})[0]
        cls.custom_password = gen_string('alphanumeric')
        cls.custom_user = entities.User(
            role=[role],
            password=cls.custom_password,
        ).create()

        for entity in BOOKMARK_ENTITIES:
            # Skip the entities, which can't be tested ATM (require framework
            # update)
            skip = entity.get('skip_for_ui')
            if isinstance(skip, tuple):
                if (skip[0] == 'bugzilla' and bz_bug_is_open(skip[1])
                        or skip[0] == 'redmine' and rm_bug_is_open(skip[1])):
                    skip = True
            if skip is True:
                continue
            cls.entities.append(entity)
            # Some pages require at least 1 existing entity for search bar to
            # appear. Creating 1 entity for such pages
            if entity.get('setup'):
                # entities with 1 organization
                if entity['name'] in ('Host', ):
                    entity['setup'](organization=cls.session_org).create()
                # entities with no organizations
                elif entity['name'] in ('Compute_Profile', 'GlobalParameters',
                                        'HardwareModel', 'PuppetClasses',
                                        'UserGroup'):
                    entity['setup']().create()
                # entities with multiple organizations
                else:
                    entity['setup'](organization=[cls.session_org]).create()
Example #16
0
    def test_positive_list_permission(self):
        """Show errata only if the User has permissions to view them

        @id: cdb28f6a-23df-47a2-88ab-cd3b492126b2

        @Setup:

        1. Create two products with one repo each. Sync them.
        2. Make sure that they both have errata.
        3. Create a user with view access on one product and not on the other.

        @Steps:

        1. Go to Content -> Errata.

        @Assert: Check that the new user is able to see errata for one product
        only.

        @CaseLevel: Integration
        """
        role = entities.Role().create()
        entities.Filter(
            organization=[self.session_org],
            permission=entities.Permission(
                resource_type='Katello::Product').search(),
            role=role,
            search='name = "{0}"'.format(PRDS['rhel']),
        ).create()
        user_password = gen_string('alphanumeric')
        user = entities.User(
            default_organization=self.session_org,
            organization=[self.session_org],
            role=[role],
            password=user_password,
        ).create()
        with Session(self.browser, user.login, user_password) as session:
            session.nav.go_to_errata()
            self.errata.show_only_applicable(False)
            self.assertIsNotNone(self.errata.search(REAL_0_ERRATA_ID))
            self.assertIsNone(self.errata.search(CUSTOM_REPO_ERRATA_ID))
Example #17
0
    def test_positive_remove_user(self):
        """Create admin users then add user and remove it by using the
        location name

        @feature: Locations

        @assert: The user is added then removed from the location
        """
        strategy, value = common_locators['entity_select']
        strategy1, value1 = common_locators['entity_deselect']
        with Session(self.browser) as session:
            # User names does not accept html values
            for user_name in generate_strings_list(length=10,
                                                   exclude_types=['html']):
                with self.subTest(user_name):
                    loc_name = gen_string('alpha')
                    user = entities.User(
                        login=user_name,
                        firstname=user_name,
                        lastname=user_name,
                        password=gen_string('alpha'),
                    ).create()
                    self.assertEqual(user.login, user_name)
                    set_context(session, org=ANY_CONTEXT['org'])
                    make_loc(session, name=loc_name, users=[user_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators['context.tab_users'])
                    element = session.nav.wait_until_element(
                        (strategy1, value1 % user_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.location.update(loc_name, users=[user_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators['context.tab_users'])
                    element = session.nav.wait_until_element(
                        (strategy, value % user_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNotNone(element)
def test_positive_search_with_non_admin_user(test_name, sc_params_list):
    """Search for specific smart class parameter using non admin user

    :id: 79bd4071-1baa-44af-91dd-1e093445af29

    :expectedresults: Specified smart class parameter can be found in the
        system

    :BZ: 1391556

    :CaseLevel: Integration
    """
    sc_param = sc_params_list.pop()
    username = gen_string('alpha')
    password = gen_string('alpha')
    required_user_permissions = {
        'Puppetclass': [
            'view_puppetclasses',
        ],
        'PuppetclassLookupKey': [
            'view_external_parameters',
            'create_external_parameters',
            'edit_external_parameters',
            'destroy_external_parameters',
        ],
    }
    role = entities.Role().create()
    create_role_permissions(role, required_user_permissions)
    entities.User(login=username, password=password, role=[role],
                  admin=False).create()
    # assert that the user is not an admin one and cannot read the current
    # role info (note: view_roles is not in the required permissions)
    cfg = get_nailgun_config()
    cfg.auth = (username, password)
    with raises(HTTPError) as context:
        entities.Role(cfg, id=role.id).read()
    assert '403 Client Error: Forbidden' in str(context.value)
    with Session(test_name, user=username, password=password) as session:
        assert session.sc_parameter.search(
            sc_param.parameter)[0]['Parameter'] == sc_param.parameter
Example #19
0
def create_org_admin_user(orgs, locs):
    """Helper function to create an Org Admin user by assigning org admin role and assign
    taxonomies to Role and User

    The taxonomies for role and user will be assigned based on parameters of this function

    :return User: Returns the ```nailgun.entities.User``` object with passwd attr
    """
    # Create Org Admin Role
    org_admin = create_org_admin_role(orgs=orgs, locs=locs)
    # Create Org Admin User
    user_login = gen_string('alpha')
    user_passwd = gen_string('alphanumeric')
    user = entities.User(
        login=user_login,
        password=user_passwd,
        organization=orgs,
        location=locs,
        role=[org_admin.id],
    ).create()
    user.passwd = user_passwd
    return user
Example #20
0
def test_positive_update_with_all_users(session):
    """Create location and do not add user to it. Check and uncheck
    'all users' setting. Verify that for both operation expected location
    is assigned to user. Then add user to location and retry.

    :id: 6596962b-8fd0-4a82-bf54-fa6a31147311

    :customerscenario: true

    :expectedresults: Location entity is assigned to user after checkbox
        was enabled and then disabled afterwards

    :BZ: 1321543, 1479736, 1479736

    :CaseLevel: Integration
    """
    user = entities.User().create()
    loc = entities.Location().create()
    with session:
        session.organization.select(org_name=ANY_CONTEXT['org'])
        session.location.select(loc_name=loc.name)
        session.location.update(loc.name, {'users.all_users': True})
        user_values = session.user.read(user.login)
        assert loc.name in user_values['locations']['resources']['assigned']
        session.location.update(loc.name, {'users.all_users': False})
        user_values = session.user.read(user.login)
        assert loc.name in user_values['locations']['resources']['unassigned']
        session.location.update(loc.name,
                                {'users.resources.assigned': [user.login]})
        loc_values = session.location.read(loc.name)
        user_values = session.user.read(user.login)
        assert loc_values['users']['resources']['assigned'][0] == user.login
        assert user_values['locations']['resources']['assigned'][0] == loc.name
        session.location.update(loc.name, {'users.all_users': True})
        user_values = session.user.read(user.login)
        assert loc.name in user_values['locations']['resources']['assigned']
        session.location.update(loc.name, {'users.all_users': False})
        user_values = session.user.read(user.login)
        assert loc.name in user_values['locations']['resources']['unassigned']
Example #21
0
    def test_positive_create_with_user(self):
        """Create different types of users then add user during organization
        creation.

        :id: 5f2ec06b-952d-445d-b8a1-c32d74d33584

        :expectedresults: User is added to organization during creation.

        :CaseLevel: Integration
        """
        with Session(self.browser):
            for user_name in valid_users():
                with self.subTest(user_name):
                    user = entities.User(
                        login=user_name,
                        firstname=user_name,
                        lastname=user_name,
                        password=gen_string('alpha')).create()
                    self.assertEqual(user.login, user_name)
                    self.assertIsNotNone(
                        self.org.create_with_entity(gen_string('alpha'),
                                                    'users', user_name))
Example #22
0
def test_positive_update_user(session):
    """Add new user and then remove it from location

    :id: bf9b3fc2-6193-4edc-aaec-cd7b87f0804c

    :expectedresults: User successfully added and then removed from
        location resources

    :CaseLevel: Integration
    """
    user = entities.User().create()
    loc = entities.Location().create()
    with session:
        session.location.update(loc.name,
                                {'users.resources.assigned': [user.login]})
        loc_values = session.location.read(loc.name)
        assert loc_values['users']['resources']['assigned'][0] == user.login
        session.location.update(loc.name,
                                {'users.resources.unassigned': [user.login]})
        loc_values = session.location.read(loc.name)
        assert len(loc_values['users']['resources']['assigned']) == 0
        assert user.login in loc_values['users']['resources']['unassigned']
Example #23
0
def test_positive_update_user(session):
    """Add new user and then remove it from organization

    :id: 01a221f7-d0fe-4b46-ab5c-b4e861677126

    :expectedresults: User successfully added and then removed from
        organization resources

    :CaseLevel: Integration
    """
    user = entities.User().create()
    org = entities.Organization().create()
    with session:
        session.organization.update(org.name,
                                    {'users.resources.assigned': [user.login]})
        org_values = session.organization.read(org.name)
        assert org_values['users']['resources']['assigned'][0] == user.login
        session.organization.update(
            org.name, {'users.resources.unassigned': [user.login]})
        org_values = session.organization.read(org.name)
        assert len(org_values['users']['resources']['assigned']) == 0
        assert user.login in org_values['users']['resources']['unassigned']
Example #24
0
    def test_positive_search_errata_non_admin(self):
        """Search for host's errata by non-admin user with enough permissions

        :id: 5b8887d2-987f-4bce-86a1-8f65ca7e1195

        :customerscenario: true

        :BZ: 1255515

        :expectedresults: User can access errata page and proper errata is
            listed

        :CaseLevel: System
        """
        self.client.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE))
        user_login = gen_string('alpha')
        user_password = gen_string('alpha')
        default_loc = entities.Location().search(
            query={'search': 'name="{0}"'.format(DEFAULT_LOC)})[0]
        role = entities.Role().create()
        for permission_name in ('view_hosts', 'view_lifecycle_environments',
                                'view_content_views', 'view_organizations'):
            entities.Filter(
                permission=entities.Permission(name=permission_name).search(),
                role=role,
            ).create()
        entities.User(
            role=[role],
            admin=False,
            login=user_login,
            password=user_password,
            organization=[self.session_org],
            location=[default_loc],
            default_organization=self.session_org,
        ).create()
        with Session(self, user=user_login, password=user_password):
            result = self.contenthost.errata_search(self.client.hostname,
                                                    FAKE_2_ERRATA_ID)
            self.assertIsNotNone(result)
Example #25
0
def test_positive_remove_user(session, module_org, test_name):
    """Delete any user who has previously created an activation key
    and check that activation key still exists

    :id: f0504bd8-52d2-40cd-91c6-64d71b14c876

    :expectedresults: Activation Key can be read

    :BZ: 1291271
    """
    ak_name = gen_string('alpha')
    # Create user
    password = gen_string('alpha')
    user = entities.User(admin=True, default_organization=module_org, password=password).create()
    # Create Activation Key using new user credentials
    with Session(test_name, user.login, password) as non_admin_session:
        non_admin_session.activationkey.create({'name': ak_name, 'lce': {ENVIRONMENT: True}})
        assert non_admin_session.activationkey.search(ak_name)[0]['Name'] == ak_name
    # Remove user and check that AK still exists
    user.delete()
    with session:
        assert session.activationkey.search(ak_name)[0]['Name'] == ak_name
Example #26
0
    def test_positive_list_users_ssh_key(self):
        """Satellite lists users ssh keys

        :id: 8098e74a-d81e-4410-b744-435901bd70c0

        :steps:

            1. Create user with all the details
            2. Add SSH key in above user
            3. List all the ssh keys of above user

        :expectedresults: Satellite should list all the SSH keys of user

        :CaseLevel: Integration
        """
        user = entities.User().create()
        for i in range(2):
            entities.SSHKey(user=user,
                            name=gen_string('alpha'),
                            key=self.gen_ssh_rsakey()).create()
        result = entities.SSHKey(user=user).search()
        self.assertEqual(len(result), 2)
Example #27
0
    def test_positive_create_multiple_ssh_key_types(self, create_user):
        """Multiple types of ssh keys can be added to user

        :id: d1ffa908-dc86-40c8-b6f0-20650cc67046

        :steps:
            1. Create user with all the details
            2. Add multiple types of supported ssh keys, type includes
                rsa, dsa, ed25519, ecdsa

        :expectedresults: Multiple types of supported ssh keys can be added to
            user
        """
        rsa = self.gen_ssh_rsakey()
        dsa = create_user['data_keys']['ssh_keys']['dsa']
        ecdsa = create_user['data_keys']['ssh_keys']['ecdsa']
        ed = create_user['data_keys']['ssh_keys']['ed']
        user = entities.User().create()
        for key in [rsa, dsa, ecdsa, ed]:
            entities.SSHKey(user=user, name=gen_string('alpha'), key=key).create()
        user_sshkeys = entities.SSHKey(user=user).search()
        assert len(user_sshkeys) == 4
Example #28
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 #29
0
def test_external_new_user_login_and_check_count_rhsso(
    enable_external_auth_rhsso, external_user_count, rhsso_setting_setup, session
):
    """Verify the external new user login and verify the external user count

    :id: bf938ea2-6df9-11ea-a7cf-951107ed0bbb

    :setup: Enroll the RH-SSO Configuration for External Authentication

    :CaseImportance: Medium

    :steps:
        1. Create new user on RHSSO Instance and Update the Settings in Satellite
        2. Verify the login for that user

    :expectedresults: New User created in RHSSO server should able to get log-in
        and correct count shown for external users
    """
    client_id = get_rhsso_client_id()
    user_details = create_new_rhsso_user(client_id)
    login_details = {
        'username': user_details['username'],
        'password': settings.rhsso.password,
    }
    with Session(login=False) as rhsso_session:
        rhsso_session.rhsso_login.login(login_details)
        actual_user = rhsso_session.task.read_all(widget_names="current_user")['current_user']
        assert user_details['firstName'] in actual_user
    users = entities.User().search()
    updated_count = len([user for user in users if user.auth_source_name == 'External'])
    assert updated_count == external_user_count + 1
    # checking delete user can't login anymore
    delete_rhsso_user(user_details['username'])
    with Session(login=False) as rhsso_session:
        with raises(NavigationTriesExceeded) as error:
            rhsso_session.rhsso_login.login(login_details)
            rhsso_session.task.read_all()
        assert error.typename == "NavigationTriesExceeded"
Example #30
0
def test_positive_create_filter_admin_user_with_locs(test_name):
    """Attempt to create a role filter by admin user, who has 6+ locations assigned.

    :id: 688ecb7d-1d49-494c-97cc-0d5e715f3bb1

    :customerscenario: true

    :expectedresults: filter was successfully created.

    :BZ: 1315580

    :CaseImportance: Critical
    """
    role_name = gen_string('alpha')
    resource_type = 'Architecture'
    permissions = ['view_architectures', 'edit_architectures']
    org = entities.Organization().create()
    locations = [
        entities.Location(organization=[org]).create() for _ in range(6)
    ]
    password = gen_string('alphanumeric')
    user = entities.User(
        admin=True,
        organization=[org],
        location=locations,
        default_organization=org,
        default_location=locations[0],
        password=password,
    ).create()
    with Session(test_name, user=user.login, password=password) as session:
        session.role.create({'name': role_name})
        assert session.role.search(role_name)[0]['Name'] == role_name
        session.filter.create(role_name, {
            'resource_type': resource_type,
            'permission.assigned': permissions
        })
        assigned_permissions = session.filter.read_permissions(role_name)
        assert set(assigned_permissions[resource_type]) == set(permissions)