Esempio n. 1
0
    def test_negative_create_with_invalid_name(self):
        """@Test: Create OpenScap content with negative values

        @Feature: OpenScap - Negative Create.

        @Steps:

        1. Create an openscap content.
        2. Provide all the appropriate parameters.

        @Assert: Creating content for OpenScap is not successful.

        @BZ: 1289571
        """
        with Session(self.browser) as session:
            for content_name in invalid_values_list(interface='ui'):
                with self.subTest(content_name):
                    set_context(session, org=ANY_CONTEXT['org'])
                    make_oscapcontent(
                        session,
                        name=content_name,
                        content_path=self.content_path,
                    )
                    self.assertIsNotNone(session.nav.wait_until_element(
                        common_locators['haserror']))
Esempio n. 2
0
    def test_positive_sort_by_url(self):
        """Create some medium entities and sort them by url path

        :id: 6399f4ad-c081-46c4-89f6-70e552fb603a

        :expectedresults: Medium entities are sorted properly

        :CaseImportance: Medium
        """
        organization = entities.Organization().create()
        path_list = [
            gen_url(subdomain=gen_string('alpha', 20).lower(), scheme='https')
            for _ in range(5)
        ]
        for url in path_list:
            entities.Media(path_=url, organization=[organization]).create()
        path_list.sort(key=lambda x: x.split('.', 1)[0], reverse=True)
        with Session(self) as session:
            set_context(session, org=organization.name)
            self.medium.navigate_to_entity()
            self.assertEqual(
                self.medium.sort_table_by_column('Path'),
                path_list[::-1]
            )
            self.assertEqual(
                self.medium.sort_table_by_column('Path'),
                path_list
            )
Esempio n. 3
0
    def test_positive_search_by_hypervisor(self):
        """Able to find hypervisor or not hypervisor content host by searching
        hypervisor = true or hypervisor = false

        :id: 2165023f-7184-400c-a9d9-e0c0d065a7d2

        :expectedresults: the hypervisor search work properly

        :BZ: 1246554, 1495271

        :CaseLevel: System
        """
        with Session(self) as session:
            set_context(session, org=self.session_org.name)
            is_hypervisor_hosts = {
                True: self.virt_who_hypervisor_host.name,
                False: self.virt_who_vm.hostname
            }
            for is_hypervisor in is_hypervisor_hosts:
                if bz_bug_is_open(1495271):
                    session.dashboard.navigate_to_entity()
                self.assertIsNotNone(
                    session.contenthost.search(
                        is_hypervisor_hosts[is_hypervisor],
                        _raw_query='hypervisor = {0}'.format(
                            str(is_hypervisor).lower())
                    )
                )
                self.assertIsNone(
                    session.subscriptions.wait_until_element(
                        locators['contenthost.select_name'] %
                        is_hypervisor_hosts[not is_hypervisor]
                    )
                )
Esempio n. 4
0
    def test_positive_availability_for_hostgroup_in_multiple_orgs(self):
        """New environment that present in different organizations should be
        visible for any created hostgroup in these organizations

        :id: 07ff316e-16c2-493e-a987-73d59f8e81c7

        :expectedresults: Environment can be used for any new hostgroup and any
            organization where it is present in

        :BZ: 543178

        :CaseLevel: Integration

        :CaseImportance: High
        """
        env_name = gen_string('alpha')
        orgs_names = [entities.Organization().create().name for _ in range(2)]
        with Session(self) as session:
            make_env(session, name=env_name, organizations=orgs_names)
            self.assertIsNotNone(self.environment.search(env_name))
            for org in orgs_names:
                set_context(session, org=org)
                self.hostgroup.navigate_to_entity()
                self.hostgroup.click(locators['hostgroups.new'])
                self.hostgroup.assign_value(
                    locators['hostgroups.puppet_environment'], env_name)
Esempio n. 5
0
    def test_positive_vdc_subscription_contenthost_association(self):
        """Ensure vdc subscription hosts association is not empty and virt-who
        hypervisor is in the association list

        :id: 3b0f5795-7c31-4bd0-aecf-41a536f9d5a2

        :expectedresults:
            1. subscription hosts association is not empty
            2. virt-who hypervisor is in the association list

        :BZ: 1426403, 1506636

        :CaseLevel: System
        """
        with Session(self) as session:
            set_context(session, org=self.session_org.name)
            self.assertIsNotNone(
                session.contenthost.search(self.virt_who_hypervisor_host.name))
            session.subscriptions.search_and_click(VDC_SUBSCRIPTION_NAME)
            session.subscriptions.click(tab_locators['subs.sub.associations'])
            session.subscriptions.click(
                tab_locators['subs.sub.associations.hosts'])
            self.assertGreater(
                len(session.subscriptions.find_elements(
                    locators['subs.sub.associations.attached_hosts'])),
                0
            )
            self.assertIsNotNone(
                session.subscriptions.wait_until_element(
                    locators['subs.sub.associations.attached_host'] %
                    self.virt_who_hypervisor_host.name
                )
            )
Esempio n. 6
0
    def test_positive_update_url(self):
        """Update content repository with new URL

        @Feature: Content Repo - Positive Update

        @Assert: Repository is updated with expected url value
        """
        product = entities.Product(organization=self.organization).create()
        with Session(self.browser) as session:
            for repo_name in generate_strings_list():
                with self.subTest(repo_name):
                    set_context(session, org=self.organization.name)
                    self.products.search(product.name).click()
                    make_repository(
                        session,
                        name=repo_name,
                        url=FAKE_1_YUM_REPO,
                    )
                    self.assertIsNotNone(self.repository.search(repo_name))
                    self.assertTrue(self.repository.validate_field(
                        repo_name, 'url', FAKE_1_YUM_REPO))
                    self.products.search(product.name).click()
                    self.repository.update(repo_name, new_url=FAKE_2_YUM_REPO)
                    self.products.search(product.name).click()
                    self.assertTrue(self.repository.validate_field(
                        repo_name, 'url', FAKE_2_YUM_REPO))
Esempio n. 7
0
    def test_positive_update_checksum_type(self):
        """Update content repository with new checksum type

        @Feature: Content Repo - Positive Update of checksum type.

        @Assert: Repository is updated with expected checksum type.
        """
        repo_name = gen_string('alphanumeric')
        checksum_default = CHECKSUM_TYPE['default']
        checksum_update = CHECKSUM_TYPE['sha1']
        product = entities.Product(organization=self.organization).create()
        with Session(self.browser) as session:
            set_context(session, org=self.organization.name)
            self.products.search(product.name).click()
            make_repository(
                session,
                name=repo_name,
                url=FAKE_1_YUM_REPO,
            )
            self.assertIsNotNone(self.repository.search(repo_name))
            self.assertTrue(self.repository.validate_field(
                repo_name, 'checksum', checksum_default))
            self.products.search(product.name).click()
            self.repository.update(
                repo_name, new_repo_checksum=checksum_update)
            self.products.search(product.name).click()
            self.assertTrue(self.repository.validate_field(
                repo_name, 'checksum', checksum_update))
Esempio n. 8
0
    def test_positive_create_in_different_orgs(self):
        """Create repository in two different orgs with same name

        @Feature: Content Repos - Positive Create

        @Assert: Repository is created successfully for both organizations
        """
        org_2 = entities.Organization(name=gen_string('alpha')).create()
        product_1 = entities.Product(organization=self.organization).create()
        product_2 = entities.Product(organization=org_2).create()
        with Session(self.browser) as session:
            for repo_name in generate_strings_list():
                with self.subTest(repo_name):
                    set_context(session, org=self.organization.name)
                    self.products.search(product_1.name).click()
                    make_repository(
                        session,
                        name=repo_name,
                        url=FAKE_1_YUM_REPO,
                    )
                    self.assertIsNotNone(self.repository.search(repo_name))
                    set_context(session, org=org_2.name)
                    self.products.search(product_2.name).click()
                    make_repository(
                        session,
                        name=repo_name,
                        url=FAKE_1_YUM_REPO,
                        force_context=True,
                    )
                    self.assertIsNotNone(self.repository.search(repo_name))
Esempio n. 9
0
    def test_negative_create_with_same_names(self):
        """Try to create two repositories with same name

        @Feature: Content Repos - Negative Create with same name

        @Assert: Repository is not created
        """
        repo_name = gen_string('alphanumeric')
        product = entities.Product(organization=self.organization).create()
        with Session(self.browser) as session:
            set_context(session, org=self.organization.name)
            self.products.search(product.name).click()
            make_repository(
                session,
                name=repo_name,
                url=FAKE_1_YUM_REPO,
            )
            self.assertIsNotNone(self.repository.search(repo_name))
            self.products.search(product.name).click()
            make_repository(
                session,
                name=repo_name,
                url=FAKE_1_YUM_REPO,
            )
            self.assertTrue(self.products.wait_until_element(
                common_locators['common_invalid']))
Esempio n. 10
0
    def test_positive_remove_domain(self):
        """Add a domain to an location and remove it by location name
        and domain name

        @feature: Locations

        @assert: the domain is removed from the location
        """
        strategy, value = common_locators['entity_select']
        strategy1, value1 = common_locators['entity_deselect']
        with Session(self.browser) as session:
            for domain_name in generate_strings_list():
                with self.subTest(domain_name):
                    loc_name = gen_string('alpha')
                    domain = entities.Domain(name=domain_name).create()
                    self.assertEqual(domain.name, domain_name)
                    set_context(session, org=ANY_CONTEXT['org'])
                    make_loc(session, name=loc_name, domains=[domain_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators['context.tab_domains'])
                    element = session.nav.wait_until_element(
                        (strategy1, value1 % domain_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.location.update(loc_name, domains=[domain_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators['context.tab_domains'])
                    element = session.nav.wait_until_element(
                        (strategy, value % domain_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNotNone(element)
Esempio n. 11
0
    def test_positive_update(self):
        """@Test: Update OpenScap content.

        @Feature: OpenScap - Positive Update.

        @Steps:

        1. Create an openscap content.
        2. Provide all the appropriate parameters.
        3. Update the openscap content, here the Org.

        @Assert: Whether creating  content for OpenScap is successful.
        """
        org = entities.Organization(name=gen_string('alpha')).create()
        content_name = gen_string('alpha')
        with Session(self.browser) as session:
            set_context(session, org=ANY_CONTEXT['org'])
            make_oscapcontent(
                session,
                name=content_name,
                content_path=self.content_path,
            )
            self.oscapcontent.update(content_name, content_org=org.name)
            session.nav.go_to_select_org(org.name)
            self.assertIsNotNone(
                self.oscapcontent.search(content_name))
Esempio n. 12
0
    def test_positive_delete(self):
        """@Test: Create OpenScap content and then delete it.

        @Feature: OpenScap - Delete.

        @Steps:

        1. Create an openscap content.
        2. Provide all the appropriate parameters.
        3. Delete the openscap content.

        @Assert: Deleting content for OpenScap is successful.
        """
        with Session(self.browser) as session:
            for content_name in valid_data_list():
                with self.subTest(content_name):
                    set_context(session, org=ANY_CONTEXT['org'])
                    make_oscapcontent(
                        session,
                        name=content_name,
                        content_path=self.content_path,
                    )
                    self.assertIsNotNone(
                        self.oscapcontent.search(content_name))
                    self.oscapcontent.delete(content_name)
Esempio n. 13
0
    def test_positive_unregister_client_from_rhai(self):
        """Verify that 'Unregister' a system from RHAI works correctly then the
        system should not be able to use the service.

        :id: 580f9704-8c6d-4f63-b027-68a6ac97af77

        :expectedresults: Once the system is unregistered from the RHAI web
            interface then the unregistered system should return `1` on running
            the service 'redhat-access-insights'
        """
        # Register a VM to Access Insights Service
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            try:
                vm.configure_rhai_client(self.ak_name, self.org_label,
                                         DISTRO_RHEL7)

                with Session(self) as session:
                    set_context(session, org=self.org_name, force_context=True)
                    session.rhai_inventory.unregister_system(vm.hostname)

                result = vm.run('redhat-access-insights')
                self.assertEqual(result.return_code, 1,
                                 "System has not been unregistered")
            finally:
                vm.get('/var/log/redhat-access-insights/'
                       'redhat-access-insights.log',
                       './insights_unregister.log')
Esempio n. 14
0
    def test_positive_register_client_to_rhai(self):
        """Check client registration to redhat-access-insights service.

        :id: f3aefdb3-ac99-402d-afd9-e53e9ee1e8d7

        :expectedresults: Registered client should appear in the Systems sub-
            menu of Red Hat Access Insights
        """
        # Register a VM to Access Insights Service
        with VirtualMachine(distro=DISTRO_RHEL6) as vm:
            try:
                vm.configure_rhai_client(self.ak_name, self.org_label,
                                         DISTRO_RHEL6)

                with Session(self) as session:
                    # view clients registered to Red Hat Access Insights
                    set_context(session, org=self.org_name, force_context=True)
                    self.assertIsNotNone(
                        session.rhai_inventory.search(vm.hostname)
                    )
                    result = session.rhai_inventory.get_total_systems()
                    self.assertIn("1", result,
                                  'Registered clients are not listed')
            finally:
                vm.get('/var/log/redhat-access-insights/'
                       'redhat-access-insights.log',
                       './insights_client_registration.log')
Esempio n. 15
0
    def test_positive_remove_compresource(self):
        """Remove compute resource by using the location name and
        compute resource name

        @feature: Locations

        @assert: compute resource is added then removed
        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        with Session(self.browser) as session:
            for resource_name in generate_strings_list():
                with self.subTest(resource_name):
                    loc_name = gen_string("alpha")
                    url = LIBVIRT_RESOURCE_URL % settings.server.hostname
                    resource = entities.LibvirtComputeResource(name=resource_name, url=url).create()
                    self.assertEqual(resource.name, resource_name)
                    set_context(session, org=ANY_CONTEXT["org"])
                    make_loc(session, name=loc_name, resources=[resource_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators["context.tab_resources"])
                    element = self.location.wait_until_element((strategy1, value1 % resource_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.location.update(loc_name, resources=[resource_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators["context.tab_resources"])
                    element = session.nav.wait_until_element((strategy, value % resource_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNotNone(element)
Esempio n. 16
0
    def test_positive_remove_medium(self):
        """Remove medium by using location name and medium name

        @feature: Locations

        @assert: medium is added then removed
        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        with Session(self.browser) as session:
            for medium_name in generate_strings_list():
                with self.subTest(medium_name):
                    loc_name = gen_string("alpha")
                    medium = entities.Media(
                        name=medium_name, path_=INSTALL_MEDIUM_URL % gen_string("alpha", 6), os_family="Redhat"
                    ).create()
                    self.assertEqual(medium.name, medium_name)
                    set_context(session, org=ANY_CONTEXT["org"])
                    make_loc(session, name=loc_name, medias=[medium_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators["context.tab_media"])
                    element = session.nav.wait_until_element((strategy1, value1 % medium_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.location.update(loc_name, medias=[medium_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators["context.tab_media"])
                    element = session.nav.wait_until_element((strategy, value % medium_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNotNone(element)
Esempio n. 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)
Esempio n. 18
0
    def test_positive_remove_subnet(self):
        """Remove subnet by using location name and subnet name

        @feature: Locations

        @assert: subnet is added then removed
        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        with Session(self.browser) as session:
            for subnet_name in generate_strings_list():
                with self.subTest(subnet_name):
                    loc_name = gen_string("alpha")
                    subnet = entities.Subnet(
                        name=subnet_name, network=gen_ipaddr(ip3=True), mask="255.255.255.0"
                    ).create()
                    self.assertEqual(subnet.name, subnet_name)
                    set_context(session, org=ANY_CONTEXT["org"])
                    make_loc(session, name=loc_name, subnets=[subnet_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators["context.tab_subnets"])
                    element = session.nav.wait_until_element((strategy1, value1 % subnet_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.location.update(loc_name, subnets=[subnet_name])
                    self.location.search(loc_name).click()
                    self.location.click(tab_locators["context.tab_subnets"])
                    element = session.nav.wait_until_element((strategy, value % subnet_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNotNone(element)
Esempio n. 19
0
    def test_remove_hostgroup_1(self, host_grp_name):
        """@test: Add a hostgroup and remove it by using the location
        name and hostgroup name

        @feature: Locations

        @assert: hostgroup is added to location then removed

        """
        strategy, value = common_locators["all_values_selection"]
        loc_name = gen_string("alpha", 8)
        host_grp = entities.HostGroup(name=host_grp_name).create_json()
        self.assertEqual(host_grp['name'], host_grp_name)
        with Session(self.browser) as session:
            set_context(session, org=ANY_CONTEXT['org'])
            make_loc(session, name=loc_name)
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_hostgrps"]).click()
            element = session.nav.wait_until_element((strategy,
                                                      value % host_grp_name))
            # Item is listed in 'Selected Items' list and not 'All Items' list.
            self.assertIsNotNone(element)
            self.hostgroup.delete(host_grp_name, True)
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_hostgrps"]).click()
            element = session.nav.wait_until_element((strategy,
                                                      value % host_grp_name))
            # Item is listed in 'All Items' list and not 'Selected Items' list.
            self.assertIsNone(element)
Esempio n. 20
0
    def test_positive_remove_environment(self):
        """Remove environment by using location name & environment name

        @feature: Locations

        @assert: environment is removed from Location
        """
        strategy, value = common_locators['entity_select']
        strategy1, value1 = common_locators['entity_deselect']
        with Session(self.browser) as session:
            for env_name in valid_env_names():
                with self.subTest(env_name):
                    loc_name = gen_string('alpha')
                    env = entities.Environment(name=env_name).create()
                    self.assertEqual(env.name, env_name)
                    set_context(session, org=ANY_CONTEXT['org'])
                    make_loc(session, name=loc_name, envs=[env_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators['context.tab_env'])
                    element = session.nav.wait_until_element(
                        (strategy1, value1 % env_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.location.update(loc_name, envs=[env_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators['context.tab_env'])
                    element = session.nav.wait_until_element(
                        (strategy, value % env_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNotNone(element)
Esempio n. 21
0
    def test_positive_remove_hostgroup(self):
        """Add a hostgroup and remove it by using the location name and
        hostgroup name

        @feature: Locations

        @assert: hostgroup is added to location then removed
        """
        strategy, value = common_locators['all_values_selection']
        with Session(self.browser) as session:
            for host_grp_name in generate_strings_list():
                with self.subTest(host_grp_name):
                    loc_name = gen_string('alpha')
                    host_grp = entities.HostGroup(name=host_grp_name).create()
                    self.assertEqual(host_grp.name, host_grp_name)
                    set_context(session, org=ANY_CONTEXT['org'])
                    make_loc(session, name=loc_name)
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators['context.tab_hostgrps'])
                    element = session.nav.wait_until_element(
                        (strategy, value % host_grp_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.hostgroup.delete(host_grp_name)
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators['context.tab_hostgrps'])
                    element = session.nav.wait_until_element(
                        (strategy, value % host_grp_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNone(element)
Esempio n. 22
0
    def test_positive_clear_search_box(self):
        """Check if the user is able to clear the search box in the Dashboard
        UI

        :id: 97335970-dc1a-485d-aeb2-de6ece2197c3

        :Steps:

            1. Navigate to Monitor -> Dashboard
            2. Add a filter to search box (eg. environment)
            3. Data displayed according to search box
            4. On left side of the box click the Clear cross sign

        :expectedresults: Search box is cleared

        :CaseImportance: Critical
        """
        org = entities.Organization().create()
        entities.Host(organization=org).create()
        host = entities.Host(organization=org).create()
        with Session(self.browser) as session:
            set_context(session, org=org.name)
            self.assertEqual(
                self.dashboard.search(host.name, 'name'), 1)
            self.dashboard.clear_search_box()
            self.dashboard.click(common_locators['search_button'])
            self.assertEqual(
                self.dashboard.get_total_hosts_count(), 2)
Esempio n. 23
0
    def test_positive_current_subscription_totals(self):
        """Check if the Current Subscriptions Totals widget is working in the
        Dashboard UI

        :id: 6d0f56ff-7007-4cdb-96f3-d9e8b6cc1701

        :Steps:

            1. Make sure sat6 has some active subscriptions
            2. Navigate to Monitor -> Dashboard
            3. Review the Current Subscription Total widget

        :expectedresults: The widget displays all the active subscriptions and
            expired subscriptions details

        :CaseImportance: Critical
        """
        org = entities.Organization().create()
        with manifests.clone() as manifest:
            upload_manifest(org.id, manifest.content)
        with Session(self.browser) as session:
            set_context(session, org=org.name)
            self.assertGreaterEqual(self.dashboard.get_cst_subs_count(
                'Active Subscriptions'), 1)
            self.assertEqual(self.dashboard.get_cst_subs_count(
                'Subscriptions Expiring in 120 Days'), 0)
            self.assertEqual(self.dashboard.get_cst_subs_count(
                'Recently Expired Subscriptions'), 0)
Esempio n. 24
0
    def test_positive_host_collections(self):
        """Check if the Host Collections widget displays list of host
        collection in UI

        :id: 1feae601-987d-4553-8644-4ceef5059e64

        :Steps:

            1. Make sure to have some hosts and host collections
            2. Navigate Monitor -> Dashboard
            3. Review the Host Collections Widget

        :expectedresults: The list of host collections along with content host
            is displayed in the widget

        :CaseLevel: Integration
        """
        org = entities.Organization().create()
        host = entities.Host(organization=org).create()
        host_collection = entities.HostCollection(
            host=[host],
            organization=org,
        ).create()
        with Session(self.browser) as session:
            set_context(session, org=org.name)
            self.assertEqual(
                self.dashboard.get_hc_host_count(host_collection.name),
                1
            )
Esempio n. 25
0
    def test_positive_rendering_after_env_removed(self):
        """Check if Dashboard UI rendered properly after lc environment for
        active organization is removed from the system

        :id: 81c52395-3476-4123-bc3b-49d6c658da9a

        :Steps:

            1. Create an environment (e.g. Dev)
            2. Create a content view and promote it to the environment
            3. Remove the environment.
            4. Visit the dashboard page and verify that it loads successfully.

        :expectedresults: Dashboard search box and necessary widgets are
            rendered before and after necessary environment is removed

        :BZ: 1361793

        :CaseLevel: Integration
        """
        org = entities.Organization().create()
        lc_env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        content_view.publish()
        promote(content_view.read().version[0], lc_env.id)
        with Session(self.browser) as session:
            set_context(session, org=org.name)
            self.assertIsNotNone(
                self.dashboard.search(lc_env.name, 'lifecycle_environment'))
            entities.LifecycleEnvironment(id=lc_env.id).delete()
            self.assertIsNotNone(
                self.dashboard.search(lc_env.name, 'lifecycle_environment'))
            self.assertIsNotNone(
                self.dashboard.get_widget('Content View History'))
Esempio n. 26
0
    def test_positive_sync_overview_widget(self):
        """Check if the Sync Overview Widget is working in the Dashboard UI

        :id: 515027f5-19e8-4f83-9042-1c347a63758f

        :Steps:

            1. Create a product
            2. Add a repo and sync it
            3. Navigate to Monitor -> Dashboard
            4. Review the Sync Overview widget for the above sync details

        :expectedresults: Sync Overview widget is updated with all sync
            processes

        :CaseImportance: Critical
        """
        org = entities.Organization().create()
        product = entities.Product(organization=org).create()
        repo = entities.Repository(
            url=FAKE_0_YUM_REPO,
            content_type='yum',
            product=product,
        ).create()
        repo.sync()
        with Session(self.browser) as session:
            set_context(session, org=org.name)
            self.assertEqual(
                self.dashboard.get_so_product_status(product.name),
                'Syncing Complete.'
            )
Esempio n. 27
0
    def test_positive_content_view_history(self):
        """Check if the Content View History are working in the Dashboard UI

        :id: cb63a67d-7cca-4d2c-9abf-9f4f5e92c856

        :Steps:

            1. Navigate to Monitor -> Dashboard
            2. Review the Content View History widget

        :expectedresults: Each Content View link shows its current status (the
            environment to which it is published)

        :CaseLevel: Integration
        """
        org = entities.Organization().create()
        lc_env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        content_view.publish()
        promote(content_view.read().version[0], lc_env.id)
        expected_list = [
            ['Promoted to {0}'.format(lc_env.name), 'Success'],
            ['Published new version', 'Success']
        ]
        with Session(self.browser) as session:
            set_context(session, org=org.name)
            actual_list = self.dashboard.get_cvh_tasks_list(content_view.name)
            self.assertTrue(all(
                element in exp_element
                for sublist, exp_sublist in zip(expected_list, actual_list)
                for element, exp_element in zip(sublist, exp_sublist)
            ))
Esempio n. 28
0
    def test_positive_latest_warning_error_tasks(self):
        """Check if the Latest Warning/Error
        Tasks Status are working in the Dashboard UI

        :id: c90df864-1472-4b7c-91e6-9ea9e98384a9

        :Steps:

            1. Navigate to Monitor -> Dashboard
            2. Review the Latest Warning/Error Tasks widget.

        :expectedresults: The links to all failed/warnings tasks are working

        :CaseLevel: Integration
        """
        name = entities.Organization().create().name
        with self.assertRaises(HTTPError):
            entities.Organization(name=name).create()
        with Session(self.browser) as session:
            set_context(session, org=name)
            self.assertTrue(self.dashboard.validate_error_navigation(
                'Create',
                'error',
                'Validation failed: Name has already been taken'
            ))
Esempio n. 29
0
    def test_positive_task_status(self):
        """Check if the Task Status is working in the Dashboard UI

        :id: fb667d6a-7255-4341-9f79-2f03d19e8e0f

        :Steps:

            1. Navigate to Monitor -> Dashboard
            2. Review the Task Status widget
            3. Click each link

        :expectedresults: Each link shows the right info

        :CaseLevel: Integration
        """
        org = entities.Organization().create()
        content_view = entities.ContentView(organization=org).create()
        content_view.publish()
        with Session(self.browser) as session:
            set_context(session, org=org.name)
            self.assertTrue(self.dashboard.validate_task_navigation(
                'pending', 'state=running&result=pending'))
            self.assertTrue(self.dashboard.validate_task_navigation(
                'success',
                'state=stopped&result=success',
                "Publish content view '{0}'; organization '{1}'".format(
                    content_view.name, org.name)
            ))
            self.assertTrue(self.dashboard.validate_task_navigation(
                'error', 'state=stopped&result=error'))
Esempio n. 30
0
    def test_positive_create_with_multiple_orgs(self):
        """Create User associated to multiple Orgs

        @id: d74c0284-3995-4a4a-8746-00858282bf5d

        @Assert: User is created successfully

        @CaseLevel: Integration
        """
        strategy, value = common_locators['entity_deselect']
        name = gen_string('alpha')
        org_name1 = gen_string('alpha')
        org_name2 = gen_string('alpha')
        for org_name in [org_name1, org_name2]:
            entities.Organization(name=org_name).create()
        with Session(self.browser) as session:
            set_context(session, org=DEFAULT_ORG)
            make_user(
                session,
                username=name,
                organizations=[org_name1, org_name2],
                edit=True,
            )
            self.user.click(self.user.search(name))
            self.user.click(tab_locators['users.tab_organizations'])
            for org_name in [org_name1, org_name2, DEFAULT_ORG]:
                element = self.user.wait_until_element(
                    (strategy, value % org_name))
                self.assertIsNotNone(element)
Esempio n. 31
0
    def test_positive_puppet_install(self):
        """Perform puppet end to end smoke tests using RH repos.

        :id: 30b0f872-d035-431a-988f-2b3fde620c78

        :expectedresults: Client should get configured by puppet-module.
        """
        activation_key_name = gen_string('alpha')
        cv_name = gen_string('alpha')
        env_name = gen_string('alpha')
        org_name = gen_string('alpha')
        product_name = gen_string('alpha')
        puppet_module = 'motd'
        puppet_repository_name = gen_string('alpha')
        repos = self.sync.create_repos_tree(SAT6_TOOLS_TREE)
        rhel_prd = DEFAULT_SUBSCRIPTION_NAME
        if settings.rhel6_repo is None:
            self.skipTest('Missing configuration for rhel6_repo')
        rhel6_repo = settings.rhel6_repo
        with Session(self) as session:
            # Create New organization
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            # Create New Lifecycle environment
            make_lifecycle_environment(session, org=org_name, name=env_name)
            self.assertIsNotNone(self.lifecycleenvironment.search(env_name))
            # Upload manifest from webui
            with manifests.clone() as manifest:
                self.subscriptions.upload(manifest)
            self.assertTrue(
                session.nav.wait_until_element(
                    common_locators['alert.success']))
            # List of dictionary passed to enable the redhat repos
            # It selects Product->Reposet-> Repo
            self.sync.enable_rh_repos(repos, REPO_TAB['rpms'])
            session.nav.go_to_sync_status()
            # Sync the repos
            # syn.sync_rh_repos returns boolean values and not objects
            self.assertTrue(
                self.sync.sync_noversion_rh_repos(PRDS['rhel'],
                                                  [REPOS['rhst6']['name']]))
            # Create custom product
            make_product(session, org=org_name, name=product_name)
            product = self.products.search(product_name)
            self.assertIsNotNone(product)
            # Create a puppet Repository
            product.click()
            make_repository(session,
                            name=puppet_repository_name,
                            url=FAKE_6_PUPPET_REPO,
                            repo_type=REPO_TYPE['puppet'])
            self.assertIsNotNone(
                self.repository.search(puppet_repository_name))
            # Sync the repos
            # syn.sync_rh_repos returns boolean values and not objects
            session.nav.go_to_sync_status()
            self.assertIsNotNone(
                self.sync.sync_custom_repos(product_name,
                                            [puppet_repository_name]))
            # Create new content-view
            make_contentview(session, org=org_name, name=cv_name)
            self.assertIsNotNone(self.content_views.search(cv_name))
            # Add YUM repository to content-view
            self.content_views.add_remove_repos(
                cv_name,
                [REPOS['rhst6']['name']],
            )
            if not bz_bug_is_open(1191422):
                self.assertIsNotNone(
                    self.content_views.wait_until_element(
                        common_locators['alert.success']))
            # Add puppet-module to content-view
            self.content_views.add_puppet_module(cv_name,
                                                 puppet_module,
                                                 filter_term='Latest')
            # Publish content-view
            self.content_views.publish(cv_name)
            if not bz_bug_is_open(1191422):
                self.assertIsNotNone(
                    self.content_views.wait_until_element(
                        common_locators['alert.success_sub_form']))
            # Promote content-view to life-cycle environment.
            self.content_views.promote(cv_name,
                                       version='Version 1',
                                       env=env_name)
            if not bz_bug_is_open(1191422):
                self.assertIsNotNone(
                    self.content_views.wait_until_element(
                        common_locators['alert.success_sub_form']))
            # Create Activation-Key
            make_activationkey(session,
                               org=org_name,
                               name=activation_key_name,
                               env=env_name,
                               content_view=cv_name)
            self.activationkey.associate_product(activation_key_name,
                                                 [product_name, rhel_prd])
            self.activationkey.enable_repos(activation_key_name,
                                            [REPOSET['rhst6']])
            if not bz_bug_is_open(1191541):
                self.assertIsNotNone(
                    self.activationkey.wait_until_element(
                        common_locators['alert.success']))
            # Create VM
            with VirtualMachine(distro=DISTRO_RHEL6) as vm:
                vm.install_katello_ca()
                vm.register_contenthost(org_name, activation_key_name)
                self.assertTrue(vm.subscribed)
                vm.configure_puppet(rhel6_repo)
                host = vm.hostname
                set_context(session, org=ANY_CONTEXT['org'])
                self.hosts.update_host_bulkactions(
                    [host],
                    action='Assign Organization',
                    parameters_list=[{
                        'organization': org_name
                    }],
                )
                self.hosts.update(
                    name=host,
                    parameters_list=[
                        ['Host', 'Lifecycle Environment', env_name],
                        ['Host', 'Content View', cv_name],
                        ['Host', 'Reset Puppet Environment', True],
                    ],
                    puppet_classes=[puppet_module])
                vm.run(u'puppet agent -t')
                result = vm.run(u'cat /etc/motd | grep FQDN')
                self.assertEqual(result.return_code, 0)
Esempio n. 32
0
    def test_positive_create_overridable_filter(self):
        """Create overridden filter in role

        :id: 325e7e3e-60fc-4182-9585-0449d9660e8d

        :steps:

            1. Create a role with some taxonomies (organizations and locations)
            2. Create a filter in role to which taxonomies can be associated
                e.g Domain filter
            3. Override a filter with some taxonomies which doesnt match the
                taxonomies of role
            4. Create user with taxonomies including filter taxonomies and
                assign role to it
            5. Login with user and attempt to access the resources

        :expectedresults:

            1. Filter is created with taxonomies
            2. Override checkmark is displayed in filters table for that filter
            3. User can access resources, permissions specified in filter
            4. User have access only in taxonomies specified in filter
        """
        name = gen_string('alpha')
        username = gen_string('alpha')
        password = gen_string('alpha')
        domain_name = gen_string('alpha')
        with Session(self.browser) as session:
            make_role(
                session,
                name=name,
                locations=[self.role_loc],
                organizations=[self.role_org],
            )
            self.assertIsNotNone(self.role.search(name))
            self.role.add_permission(
                name,
                resource_type='Domain',
                permission_list=['view_domains', 'create_domains'],
                override=True,
                override_check=True,
                organization=[self.filter_org],
                location=[self.filter_loc],
            )
            make_user(session,
                      username=username,
                      password1=password,
                      password2=password,
                      roles=[name],
                      locations=[self.role_loc, self.filter_loc],
                      organizations=[self.role_org, self.filter_org],
                      edit=True)
        with Session(self.browser, username, password) as session:
            set_context(session, org=self.filter_org)
            set_context(session, loc=self.filter_loc)
            make_domain(session, name=domain_name)
            self.assertIsNotNone(self.domain.search(domain_name))
            self.assertIsNone(
                session.nav.wait_until_element(menu_locators['menu.content'],
                                               timeout=3))
            self.assertIsNone(
                session.nav.wait_until_element(menu_locators['menu.configure'],
                                               timeout=3))

        with Session(self.browser, username, password) as session:
            set_context(session, org=self.role_org)
            set_context(session, loc=self.role_loc)
            self.assertIsNone(self.domain.search(domain_name))
            self.assertIsNone(
                session.nav.wait_until_element(menu_locators['menu.hosts'],
                                               timeout=3))
Esempio n. 33
0
    def test_positive_update_external_user_roles(self):
        """Assure that user has roles/can access feature areas for
        additional roles assigned outside any roles assigned by his group

        :id: a487f7d6-22f2-4e42-b34f-8d984f721c83

        :setup: Assign roles to UserGroup and configure external UserGroup
            subsequently assign specified roles to the user(s).  roles that are
            not part of the larger UserGroup

        :steps:
            1. Create an UserGroup.
            2. Assign some roles to UserGroup.
            3. Create an External AD UserGroup as per the UserGroup name in AD.
            4. Assign some more roles to a User(which is part of external AD
               UserGroup) at the User level.
            5. Login to sat6 with the above AD user and attempt to access areas
               assigned specifically to user.

        :expectedresults: User can access not only those feature areas in his
            UserGroup but those additional feature areas / roles assigned
            specifically to user

        :CaseLevel: Integration
        """
        self.check_external_user()
        foreman_role = gen_string('alpha')
        katello_role = gen_string('alpha')
        org_name = gen_string('alpha')
        loc_name = gen_string('alpha')
        with Session(self.browser) as session:
            make_role(session, name=foreman_role)
            self.role.add_permission(
                foreman_role,
                permission_list=PERMISSIONS['Location'],
                resource_type='Location',
            )
            make_usergroup(
                session,
                name=self.usergroup_name,
                roles=[foreman_role],
                ext_usergrp='foobargroup',
                ext_authsourceid='LDAP-' + self.ldap_server_name,
            )
            self.assertIsNotNone(self.usergroup.search(self.usergroup_name))
            set_context(session, org=ANY_CONTEXT['org'])
            self.user.update(
                username=self.ldap_user_name,
                authorized_by='LDAP-' + self.ldap_server_name,
                new_password=self.ldap_user_passwd,
                password_confirmation=self.ldap_user_passwd,
            )
        with Session(
                self.browser,
                self.ldap_user_name,
                self.ldap_user_passwd,
        ) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
        with Session(self.browser) as session:
            make_role(session, name=katello_role)
            self.role.add_permission(
                katello_role,
                permission_list=PERMISSIONS['Organization'],
                resource_type='Organization',
            )
            set_context(session, org=ANY_CONTEXT['org'])
            self.user.update(
                self.ldap_user_name,
                new_roles=[katello_role],
                select=True,
            )
        with Session(
                self.browser,
                self.ldap_user_name,
                self.ldap_user_passwd,
        ) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
Esempio n. 34
0
    def test_positive_list_hosts(self):
        """Verify only hosts registered by specific activation key are listed
        on Activation Key -> Associations -> Content Hosts page

        @id: 9364bfcc-ef69-4183-9ca8-e2904b3f4068

        @Steps:
        1. Create 2 activation keys
        2. Register 2 hosts, one for each activation key

        @Assert: Activation Key -> Associations -> Content Hosts page should
        show only hosts registered via the key

        @BZ: 1372826
        """
        org = make_org()
        env = make_lifecycle_environment({'organization-id': org['id']})
        content_view = make_content_view({'organization-id': org['id']})
        activation_key = make_activation_key({
            'lifecycle-environment-id':
            env['id'],
            'organization-id':
            org['id'],
        })
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org['id'],
            'content-view-id': content_view['id'],
            'lifecycle-environment-id': env['id'],
            'activationkey-id': activation_key['id'],
        })
        another_ak = make_activation_key({
            'content-view-id': content_view['id'],
            'lifecycle-environment-id': env['id'],
            'organization-id': org['id'],
        })
        activationkey_add_subscription_to_repo({
            'activationkey-id':
            another_ak['id'],
            'organization-id':
            org['id'],
            'subscription':
            DEFAULT_SUBSCRIPTION_NAME,
        })
        with VirtualMachine(distro=DISTRO_RHEL7) as client1, VirtualMachine(
                distro=DISTRO_RHEL7) as client2:
            client1.install_katello_ca()
            client2.install_katello_ca()
            result = client1.register_contenthost(org['label'],
                                                  activation_key['name'])
            self.assertEqual(result.return_code, 0)
            result = client2.register_contenthost(org['label'],
                                                  another_ak['name'])
            self.assertEqual(result.return_code, 0)
            with Session(self.browser) as session:
                set_context(session, org=org['name'])
                self.assertIsNotNone(
                    self.activationkey.search_host(activation_key['name'],
                                                   client1.hostname))
                self.assertIsNone(
                    self.activationkey.search_host(activation_key['name'],
                                                   client2.hostname))
                self.assertIsNotNone(
                    self.activationkey.search_host(another_ak['name'],
                                                   client2.hostname))
                self.assertIsNone(
                    self.activationkey.search_host(another_ak['name'],
                                                   client1.hostname))
Esempio n. 35
0
    def test_positive_update_external_roles(self):
        """Added AD UserGroup roles get pushed down to user

        :id: f3ca1aae-5461-4af3-a508-82679bb6afed

        :setup: assign additional roles to the UserGroup

        :steps:
            1. Create an UserGroup.
            2. Assign some roles to UserGroup.
            3. Create an External AD UserGroup as per the UserGroup name in AD.
            4. Login to sat6 with the AD user.
            5. Assign additional roles to the UserGroup.
            6. Login to sat6 with LDAP user that is part of aforementioned
               UserGroup.

        :expectedresults: User has access to all NEW functional areas that are
            assigned to aforementioned UserGroup.

        :CaseLevel: Integration
        """
        self.check_external_user()
        foreman_role = gen_string('alpha')
        katello_role = gen_string('alpha')
        org_name = gen_string('alpha')
        loc_name = gen_string('alpha')
        with Session(self.browser) as session:
            make_role(session, name=foreman_role)
            self.role.add_permission(
                foreman_role,
                permission_list=PERMISSIONS['Location'],
                resource_type='Location',
            )
            make_usergroup(
                session,
                name=self.usergroup_name,
                roles=[foreman_role],
                ext_usergrp='foobargroup',
                ext_authsourceid='LDAP-' + self.ldap_server_name,
            )
            self.assertIsNotNone(self.usergroup.search(self.usergroup_name))
            set_context(session, org=ANY_CONTEXT['org'])
            self.user.update(
                username=self.ldap_user_name,
                authorized_by='LDAP-' + self.ldap_server_name,
                new_password=self.ldap_user_passwd,
                password_confirmation=self.ldap_user_passwd,
            )
        with Session(
                self.browser,
                self.ldap_user_name,
                self.ldap_user_passwd,
        ) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
        with Session(self.browser) as session:
            make_role(session, name=katello_role)
            self.role.add_permission(
                katello_role,
                permission_list=PERMISSIONS['Organization'],
                resource_type='Organization',
            )
            self.usergroup.update(
                self.usergroup_name,
                new_roles=[katello_role],
                entity_select=True,
            )
            self.usergroup.refresh_ext_group(self.usergroup_name,
                                             'foobargroup')
            self.assertIsNotNone(
                self.usergroup.wait_until_element(
                    common_locators['notif.success']))
        with Session(
                self.browser,
                self.ldap_user_name,
                self.ldap_user_passwd,
        ) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
Esempio n. 36
0
    def test_positive_service_level_subscription_with_custom_product(self):
        """Subscribe a host to activation key with Premium service level and
         with custom product

        :id: 195a8049-860e-494d-b7f0-0794384194f7

        :customerscenario: true

        :steps:
            1. Create a product with custom repository synchronized
            2. Create and Publish a content view with the created repository
            3. Create an activation key and assign the created content view
            4. Add a RedHat subscription to activation key (The product
               subscription should be added automatically)
            5. Set the activation service_level to Premium
            6. Register a host to activation key
            7. List consumed subscriptions on host
            8. List the subscription in Content Host UI

        :expectedresults:
            1. The product subscription is listed in consumed subscriptions on
               host
            2. The product subscription is listed in the contenthost
               subscriptions UI

        :BZ: 1394357

        :CaseLevel: System
        """
        org = entities.Organization().create()
        self.upload_manifest(org.id, manifests.clone())
        subscription = entities.Subscription(organization=org)
        entities_ids = setup_org_for_a_custom_repo({
            'url': FAKE_1_YUM_REPO,
            'organization-id': org.id,
        })
        product = entities.Product(id=entities_ids['product-id']).read()
        activation_key = entities.ActivationKey(
            id=entities_ids['activationkey-id']).read()
        # add the default RH subscription
        for sub in subscription.search():
            if sub.read_json()['product_name'] == DEFAULT_SUBSCRIPTION_NAME:
                activation_key.add_subscriptions(data={
                    'quantity': 1,
                    'subscription_id': sub.id,
                })
                break
        # ensure all the needed subscriptions are attached to activation key
        results = activation_key.subscriptions()['results']
        self.assertEqual(
            {product.name, DEFAULT_SUBSCRIPTION_NAME},
            {ak_subscription['name']
             for ak_subscription in results})
        activation_key.service_level = 'Premium'
        activation_key = activation_key.update(['service_level'])
        with VirtualMachine() as vm:
            vm.install_katello_ca()
            vm.register_contenthost(org.label,
                                    activation_key=activation_key.name)
            self.assertTrue(vm.subscribed)
            result = vm.run('subscription-manager list --consumed')
            self.assertEqual(result.return_code, 0)
            self.assertIn('Subscription Name:   {0}'.format(product.name),
                          '\n'.join(result.stdout))
            with Session(self) as session:
                set_context(session, org=org.name)
                self.contenthost.search_and_click(vm.hostname)
                self.contenthost.click(
                    tab_locators['contenthost.tab_subscriptions'])
                self.contenthost.click(
                    tab_locators['contenthost.tab_subscriptions_subscriptions']
                )
                self.assertIsNotNone(
                    self.contenthost.wait_until_element(
                        locators['contenthost.subscription_select'] %
                        product.name))
Esempio n. 37
0
    def test_positive_run_scheduled_job_template_by_ip(self):
        """Schedule a job to be ran against a host by ip

        :id: 4387bed9-969d-45fb-80c2-b0905bb7f1bd

        :Setup: Use pre-defined job template.

        :Steps:

            1. Set remote_execution_connect_by_ip on host to true
            2. Navigate to an individual host and click Run Job
            3. Select the job and appropriate template
            4. Select "Schedule Future Job"
            5. Enter a desired time for the job to run
            6. Click submit

        :expectedresults:

            1. Verify the job was not immediately ran
            2. Verify the job was successfully ran after the designated time

        :CaseLevel: System
        """
        with VirtualMachine(
              distro=DISTRO_RHEL7,
              provisioning_server=settings.compute_resources.libvirt_hostname,
              bridge=settings.vlan_networking.bridge,
              ) as client:
            client.install_katello_ca()
            client.register_contenthost(self.organization.label, lce='Library')
            self.assertTrue(client.subscribed)
            add_remote_execution_ssh_key(client.ip_addr)
            Host.update({
                'name': client.hostname,
                'subnet-id': self.new_sub.id,
            })
            # connect to host by ip
            Host.set_parameter({
                'host': client.hostname,
                'name': 'remote_execution_connect_by_ip',
                'value': 'True',
            })
            with Session(self) as session:
                set_context(session, org=self.organization.name)
                self.hosts.click(self.hosts.search(client.hostname))
                plan_time = (
                        self.get_client_datetime() + timedelta(seconds=180)
                        ).strftime("%Y-%m-%d %H:%M")
                status = self.job.run(
                    job_category='Commands',
                    job_template='Run Command - SSH Default',
                    options_list=[{'name': 'command', 'value': 'ls'}],
                    schedule='future',
                    schedule_options=[
                        {'name': 'start_at', 'value': plan_time}],
                    result='queued to start executing in 1 minute'
                )
                self.assertTrue(status)
                strategy, value = locators['job_invocation.status']
                self.job.wait_until_element_is_not_visible(
                    (strategy, value % 'queued'), 95)
                if self.job.wait_until_element(
                        (strategy, value % 'succeeded'), 180) is not None:
                    status2 = True
                else:
                    status2 = False
                # get job invocation id from the current url
                invocation_id = self.browser.current_url.rsplit('/', 1)[-1]
                try:
                    self.assertTrue(status2)
                except AssertionError:
                    result = 'host output: {0}'.format(
                            ' '.join(JobInvocation.get_output({
                                'id': invocation_id,
                                'host': client.hostname})
                            )
                        )
                    raise AssertionError(result)
Esempio n. 38
0
    def test_positive_delete_external_roles(self):
        """Deleted AD UserGroup roles get pushed down to user

        :id: 479bc8fe-f6a3-4c89-8c7e-3d997315383f

        :setup: delete roles from an AD UserGroup

        :steps:
            1. Create an UserGroup.
            2. Assign some roles to UserGroup.
            3. Create an External AD UserGroup as per the UserGroup name in AD.
            4. Login to sat6 with the AD user.
            5. Unassign some of the existing roles of the UserGroup.
            6. Login to sat6 with LDAP user that is part of aforementioned
               UserGroup.

        :expectedresults: User no longer has access to all deleted functional
            areas that were assigned to aforementioned UserGroup.

        :CaseLevel: Integration
        """
        self.check_external_user()
        foreman_role = gen_string('alpha')
        with Session(self.browser) as session:
            make_role(session, name=foreman_role)
            self.role.add_permission(
                foreman_role,
                permission_list=PERMISSIONS['Location'],
                resource_type='Location',
            )
            make_usergroup(
                session,
                name=self.usergroup_name,
                roles=[foreman_role],
                ext_usergrp='foobargroup',
                ext_authsourceid='LDAP-' + self.ldap_server_name,
            )
            self.assertIsNotNone(self.usergroup.search(self.usergroup_name))
            set_context(session, org=ANY_CONTEXT['org'])
            self.user.update(
                username=self.ldap_user_name,
                authorized_by='LDAP-' + self.ldap_server_name,
                new_password=self.ldap_user_passwd,
                password_confirmation=self.ldap_user_passwd,
            )
        with Session(self.browser, self.ldap_user_name,
                     self.ldap_user_passwd) as session:
            session.nav.go_to_loc()
        with Session(self.browser):
            self.usergroup.update(self.usergroup_name,
                                  roles=[foreman_role],
                                  entity_select=False)
        with Session(
                self.browser,
                self.ldap_user_name,
                self.ldap_user_passwd,
        ) as session:
            ActionChains(self.browser).move_to_element(
                session.nav.wait_until_element(
                    menu_locators['menu.any_context'])).perform()
            self.assertIsNone(
                session.nav.wait_until_element(
                    menu_locators['loc.manage_loc']))
Esempio n. 39
0
    def test_positive_run_custom_job_template_by_ip(self):
        """Run a job template on a host connected by ip

        :id: e283ae09-8b14-4ce1-9a76-c1bbd511d58c

        :Setup: Create a working job template.

        :Steps:

            1. Set remote_execution_connect_by_ip on host to true
            2. Navigate to an individual host and click Run Job
            3. Select the job and appropriate template
            4. Run the job

        :expectedresults: Verify the job was successfully ran against the host

        :CaseLevel: System
        """
        jobs_template_name = gen_string('alpha')
        with VirtualMachine(
              distro=DISTRO_RHEL7,
              provisioning_server=settings.compute_resources.libvirt_hostname,
              bridge=settings.vlan_networking.bridge,
              ) as client:
            client.install_katello_ca()
            client.register_contenthost(self.organization.label, lce='Library')
            self.assertTrue(client.subscribed)
            add_remote_execution_ssh_key(client.ip_addr)
            Host.update({
                'name': client.hostname,
                'subnet-id': self.new_sub.id,
            })
            # connect to host by ip
            Host.set_parameter({
                'host': client.hostname,
                'name': 'remote_execution_connect_by_ip',
                'value': 'True',
            })
            with Session(self) as session:
                set_context(session, org=self.organization.name)
                make_job_template(
                    session,
                    name=jobs_template_name,
                    template_type='input',
                    template_content='<%= input("command") %>',
                    provider_type='SSH',
                )
                self.assertIsNotNone(
                    self.jobtemplate.search(jobs_template_name))
                self.jobtemplate.add_input(
                    jobs_template_name, 'command', required=True)
                self.hosts.click(self.hosts.search(client.hostname))
                status = self.job.run(
                    job_category='Miscellaneous',
                    job_template=jobs_template_name,
                    options_list=[{'name': 'command', 'value': 'ls'}]
                )
                # get job invocation id from the current url
                invocation_id = self.browser.current_url.rsplit('/', 1)[-1]
                try:
                    self.assertTrue(status)
                except AssertionError:
                    result = 'host output: {0}'.format(
                            ' '.join(JobInvocation.get_output({
                                'id': invocation_id,
                                'host': client.hostname})
                            )
                        )
                    raise AssertionError(result)
Esempio n. 40
0
    def test_positive_push_updated_content(self):
        """Perform end to end oscap test, and push the updated scap content
         after first run.

        :id: 7eb75ca5-2ea1-434e-bb43-1223fa4d8e9f

        :expectedresults: Satellite should push updated content to Clients and
            satellite should get updated reports

        :CaseLevel: System
        """
        if settings.rhel7_repo is None:
            self.skipTest('Missing configuration for rhel7_repo')
        rhel7_repo = settings.rhel7_repo
        content_update = OSCAP_DEFAULT_CONTENT['rhel_firefox']
        hgrp7_name = gen_string('alpha')
        policy_values = {
            'content': self.rhel7_content,
            'hgrp': hgrp7_name,
            'policy': gen_string('alpha'),
        }
        vm_values = {
            'distro': DISTRO_RHEL7,
            'hgrp': hgrp7_name,
            'rhel_repo': rhel7_repo,
        }
        with Session(self) as session:
            set_context(session,
                        org=ANY_CONTEXT['org'],
                        loc=ANY_CONTEXT['location'])
            self.oscapcontent.update(content_update,
                                     content_org=self.config_env['org_name'])
            session.nav.go_to_select_org(self.config_env['org_name'])
            # Creates host_group for rhel7
            make_hostgroup(
                session,
                content_source=self.config_env['sat6_hostname'],
                name=hgrp7_name,
                puppet_ca=self.config_env['sat6_hostname'],
                puppet_master=self.config_env['sat6_hostname'],
            )
            # Creates oscap_policy for both rhel6 and rhel7.
            make_oscappolicy(
                session,
                content=policy_values.get('content'),
                host_group=policy_values.get('hgrp'),
                name=policy_values.get('policy'),
                period=OSCAP_PERIOD['weekly'],
                profile=OSCAP_PROFILE['common'],
                period_value=OSCAP_WEEKDAY['friday'],
            )
            # Creates two vm's each for rhel6 and rhel7, runs
            # openscap scan and uploads report to satellite6.
            distro_os = vm_values.get('distro')
            with VirtualMachine(distro=distro_os) as vm:
                # host = vm.hostname
                host_name, _, host_domain = vm.hostname.partition('.')
                vm.install_katello_ca()
                vm.register_contenthost(
                    self.config_env['org_name'],
                    self.config_env['ak_name'].get(distro_os))
                self.assertTrue(vm.subscribed)
                vm.configure_puppet(vm_values.get('rhel_repo'))

                self.hosts.update(
                    name=host_name,
                    domain_name=host_domain,
                    parameters_list=[
                        ['Host', 'Host Group',
                         vm_values.get('hgrp')],
                        [
                            'Host', 'Lifecycle Environment',
                            self.config_env['env_name']
                        ],
                        ['Host', 'Content View', self.config_env['cv_name']],
                        ['Host', 'Reset Puppet Environment', True],
                        [
                            'Host', 'Openscap Capsule',
                            self.config_env['sat6_hostname']
                        ],
                    ],
                )
                self.hosts.update_host_bulkactions(
                    ['{0}'.format(vm.hostname.lower())],
                    action='Assign Compliance Policy',
                    parameters_list=[{
                        'policy': policy_values.get('policy')
                    }],
                )
                # Run "puppet agent -t" twice so that it detects it's,
                # satellite6 and fetch katello SSL certs.
                for _ in range(2):
                    vm.run(u'puppet agent -t 2> /dev/null')
                result = vm.run(u'cat /etc/foreman_scap_client/config.yaml'
                                '| grep content_path')
                self.assertEqual(result.return_code, 0)
                # Runs the actual oscap scan on the vm/clients and
                # uploads report to Internal Capsule.
                vm.execute_foreman_scap_client()
                # Assert whether oscap reports are uploaded to
                # Satellite6.
                self.assertTrue(self.oscapreports.search(vm.hostname.lower()))
                session.nav.go_to_oscap_policy()
                self.oscappolicy.update(
                    name=policy_values.get('policy'),
                    new_name=gen_string('alpha'),
                    content=OSCAP_DEFAULT_CONTENT['rhel_firefox'],
                    profile=OSCAP_PROFILE['firefox'],
                    period=OSCAP_PERIOD['weekly'],
                    period_value=OSCAP_WEEKDAY['friday'],
                )
                self.oscapreports.delete(vm.hostname.lower(), really=True)
                for _ in range(2):
                    vm.run(u'puppet agent -t 2> /dev/null')
                updated_result = vm.run(
                    u'cat /etc/foreman_scap_client/config.yaml'
                    '| grep content_path')
                self.assertIsNot(result, updated_result)
                self.assertEqual(updated_result.return_code, 0)
                # Runs the actual oscap scan on the vm/clients and
                # uploads report to Internal Capsule.
                vm.execute_foreman_scap_client()
                self.assertTrue(self.oscapreports.search(vm.hostname.lower()))
Esempio n. 41
0
    def test_positive_upload_to_satellite(self):
        """Perform end to end oscap test and upload reports.

        :id: 17a0978d-64f9-44ad-8303-1f54ada08602

        :expectedresults: Oscap reports from rhel6 and rhel7 clients should be
            uploaded to satellite6 and be searchable.

        :CaseLevel: System
        """
        if settings.rhel6_repo is None:
            self.skipTest('Missing configuration for rhel6_repo')
        rhel6_repo = settings.rhel6_repo
        if settings.rhel7_repo is None:
            self.skipTest('Missing configuration for rhel7_repo')
        rhel7_repo = settings.rhel7_repo
        rhel6_content = OSCAP_DEFAULT_CONTENT['rhel6_content']
        rhel7_content = OSCAP_DEFAULT_CONTENT['rhel7_content']
        hgrp6_name = gen_string('alpha')
        hgrp7_name = gen_string('alpha')
        policy_values = [
            {
                'content': rhel6_content,
                'hgrp': hgrp6_name,
                'policy': gen_string('alpha'),
            },
            {
                'content': rhel7_content,
                'hgrp': hgrp7_name,
                'policy': gen_string('alpha'),
            },
        ]
        vm_values = [
            {
                'distro': DISTRO_RHEL6,
                'hgrp': hgrp6_name,
                'rhel_repo': rhel6_repo,
            },
            {
                'distro': DISTRO_RHEL7,
                'hgrp': hgrp7_name,
                'rhel_repo': rhel7_repo,
            },
        ]
        with Session(self.browser) as session:
            set_context(session, org=ANY_CONTEXT['org'])
            # Creates oscap content for both rhel6 and rhel7
            for content in [rhel6_content, rhel7_content]:
                session.nav.go_to_oscap_content()
                self.oscapcontent.update(
                    content, content_org=self.config_env['org_name'])
            set_context(session, org=self.config_env['org_name'])
            # Creates host_group for both rhel6 and rhel7
            for host_group in [hgrp6_name, hgrp7_name]:
                make_hostgroup(
                    session,
                    content_source=self.config_env['sat6_hostname'],
                    name=host_group,
                    puppet_ca=self.config_env['sat6_hostname'],
                    puppet_master=self.config_env['sat6_hostname'],
                )
            # Creates oscap_policy for both rhel6 and rhel7.
            for value in policy_values:
                make_oscappolicy(
                    session,
                    content=value['content'],
                    host_group=value['hgrp'],
                    name=value['policy'],
                    period=OSCAP_PERIOD['weekly'],
                    profile=OSCAP_PROFILE['common'],
                    period_value=OSCAP_WEEKDAY['friday'],
                )
            # Creates two vm's each for rhel6 and rhel7, runs
            # openscap scan and uploads report to satellite6.
            for value in vm_values:
                with VirtualMachine(distro=value['distro']) as vm:
                    host = vm.hostname
                    vm.install_katello_ca()
                    vm.register_contenthost(self.config_env['org_name'],
                                            self.config_env['ak_name'])
                    self.assertTrue(vm.subscribed)
                    vm.configure_puppet(value['rhel_repo'])
                    self.hosts.update(
                        name=vm._target_image,
                        domain_name=vm._domain,
                        parameters_list=[
                            [
                                'Host', 'Lifecycle Environment',
                                self.config_env['env_name']
                            ],
                            [
                                'Host', 'Content View',
                                self.config_env['cv_name']
                            ],
                            ['Host', 'Host Group', value['hgrp']],
                            ['Host', 'Reset Puppet Environment', True],
                        ],
                    )
                    session.nav.go_to_hosts()
                    # Run "puppet agent -t" twice so that it detects it's,
                    # satellite6 and fetch katello SSL certs.
                    for _ in range(2):
                        vm.run(u'puppet agent -t 2> /dev/null')
                    result = vm.run(u'cat /etc/foreman_scap_client/config.yaml'
                                    '| grep profile')
                    self.assertEqual(result.return_code, 0)
                    # Runs the actual oscap scan on the vm/clients and
                    # uploads report to Internal Capsule.
                    vm.execute_foreman_scap_client()
                    # Assert whether oscap reports are uploaded to
                    # Satellite6.
                    self.assertTrue(self.oscapreports.search(host))
Esempio n. 42
0
    def test_positive_run_job_template_multiple_hosts_by_ip(self):
        """Run a job template against multiple hosts by ip

        :id: c4439ec0-bb80-47f6-bc31-fa7193bfbeeb

        :Setup: Create a working job template.

        :Steps:

            1. Set remote_execution_connect_by_ip on hosts to true
            2. Navigate to the hosts page and select at least two hosts
            3. Click the "Select Action"
            4. Select the job and appropriate template
            5. Run the job

        :expectedresults: Verify the job was successfully ran against the hosts

        :CaseLevel: System
        """
        prov_server = settings.compute_resources.libvirt_hostname
        with VirtualMachine(
              distro=DISTRO_RHEL7,
              provisioning_server=prov_server,
              bridge=settings.vlan_networking.bridge,
              ) as client:
            with VirtualMachine(
                  distro=DISTRO_RHEL7,
                  provisioning_server=prov_server,
                  bridge=settings.vlan_networking.bridge,
                  ) as client2:
                for vm in client, client2:
                    vm.install_katello_ca()
                    vm.register_contenthost(
                        self.organization.label, lce='Library')
                    self.assertTrue(vm.subscribed)
                    add_remote_execution_ssh_key(vm.ip_addr)
                    Host.update({
                        'name': vm.hostname,
                        'subnet-id': self.new_sub.id,
                    })
                    # connect to host by ip
                    Host.set_parameter({
                        'host': vm.hostname,
                        'name': 'remote_execution_connect_by_ip',
                        'value': 'True',
                    })
                with Session(self) as session:
                    set_context(session, org=self.organization.name)
                    self.hosts.update_host_bulkactions(
                        [client.hostname, client2.hostname],
                        action='Schedule Remote Job',
                        parameters_list=[{'command': 'ls'}],
                    )
                    strategy, value = locators['job_invocation.status']
                    if self.job.wait_until_element(
                            (strategy, value % 'succeeded'), 240) is not None:
                        status = True
                    else:
                        status = False
                    # get job invocation id from the current url
                    invocation_id = self.browser.current_url.rsplit('/', 1)[-1]
                    try:
                        self.assertTrue(status)
                    except AssertionError:
                        result = 'host output: {0}'.format(
                                ' '.join(JobInvocation.get_output({
                                     'id': invocation_id,
                                     'host': client.hostname})
                                )
                            )
                        raise AssertionError(result)