Exemple #1
0
class Sync(UITestCase):
    """Implements Custom Sync tests in UI"""
    @classmethod
    def setUpClass(cls):  # noqa
        org_attrs = entities.Organization().create()
        cls.org_name = org_attrs['name']
        cls.org_id = org_attrs['id']

        super(Sync, cls).setUpClass()

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_sync_custom_repos(self, repository_name):
        """@Test: Create Content Custom Sync with minimal input parameters

        @Feature: Content Custom Sync - Positive Create

        @Assert: Whether Sync is successful

        """

        # Creates new product
        product_attrs = entities.Product(organization=self.org_id).create()
        # Creates new repository
        entities.Repository(name=repository_name,
                            url=FAKE_1_YUM_REPO,
                            product=product_attrs['id']).create()
        with Session(self.browser) as session:
            session.nav.go_to_select_org(Sync.org_name)
            session.nav.go_to_sync_status()
            sync = self.sync.sync_custom_repos(product_attrs['name'],
                                               [repository_name])
            # syn.sync_custom_repos returns boolean values and not objects
            self.assertTrue(sync)

    def test_sync_rh_repos(self):
        """@Test: Create Content RedHat Sync with two repos.

        @Feature: Content RedHat Sync - Positive Create

        @Assert: Whether Syncing RedHat Repos is successful

        """

        repos = self.sync.create_repos_tree(RHCT)
        manifest_path = manifests.clone()
        # upload_file function should take care of uploading to sauce labs.
        upload_file(manifest_path, remote_file=manifest_path)
        with Session(self.browser) as session:
            session.nav.go_to_select_org(self.org_name)
            session.nav.go_to_red_hat_subscriptions()
            self.subscriptions.upload(manifest_path)
            session.nav.go_to_red_hat_repositories()
            self.sync.enable_rh_repos(repos)
            session.nav.go_to_sync_status()
            sync = self.sync.sync_rh_repos(repos)
            # syn.sync_rh_repos returns boolean values and not objects
            self.assertTrue(sync)
class PuppetClasses(UITestCase):
    """Implements puppet classes tests in UI."""
    @data(
        {
            'name': gen_string('alpha', 10),
            'new_name': gen_string('alpha', 10)
        }, {
            'name': gen_string('numeric', 10),
            'new_name': gen_string('numeric', 10)
        }, {
            'name': gen_string('alphanumeric', 10),
            'new_name': gen_string('alphanumeric', 10)
        }, {
            'name': gen_string('utf8', 10),
            'new_name': gen_string('utf8', 10)
        }, {
            'name': gen_string('latin1', 20),
            'new_name': gen_string('latin1', 10)
        })
    def test_update_positive_1(self, testdata):
        """@Test: Create new puppet-class

        @Feature: Puppet-Classes - Positive Update

        @Assert: Puppet-Classes is updated.

        """
        name = testdata['name']
        new_name = testdata['new_name']
        with Session(self.browser) as session:
            make_puppetclasses(session, name=name)
            search = self.puppetclasses.search(name)
            self.assertIsNotNone(search)
            self.puppetclasses.update(name, new_name)

    @skip_if_bug_open('bugzilla', 1126473)
    @data(*generate_strings_list(len1=8))
    def test_delete_positive_1(self, name):
        """@Test: Create new puppet-class

        @Feature: Puppet-Classes - Positive delete

        @Assert: Puppet-Class is deleted

        @BZ: 1126473

        """
        with Session(self.browser) as session:
            make_puppetclasses(session, name=name)
            search = self.puppetclasses.search(name)
            self.assertIsNotNone(search)
            self.puppetclasses.delete(name, True)
            self.assertIsNotNone(
                session.nav.wait_until_element(
                    common_locators["notif.success"]))
            self.assertIsNone(self.puppetclasses.search(name))
Exemple #3
0
class Sync(BaseUI):
    """
    Implements Custom Sync tests in UI
    """

    org_name = None

    def setUp(self):
        super(Sync, self).setUp()
        # Make sure to use the Class' org_name instance
        if Sync.org_name is None:
            Sync.org_name = generate_string("alpha", 10)
            with Session(self.browser) as session:
                make_org(session, org_name=Sync.org_name)

    @attr('ui', 'sync', 'implemented')
    @data(*generate_strings_list())
    def test_sync_repos(self, repo_name):
        """
        @Feature: Content Custom Sync - Positive Create
        @Test: Create Content Custom Sync with minimal input parameters
        @Assert: Whether Sync is successful
        """
        prd_name = generate_string("alpha", 6)
        repo_url = "http://inecas.fedorapeople.org/fakerepos/zoo3/"
        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.repository.create(repo_name, product=prd_name, url=repo_url)
        self.assertIsNotNone(self.repository.search(repo_name))
        self.navigator.go_to_sync_status()
        sync = self.sync.sync_custom_repos(prd_name, [repo_name])
        self.assertIsNotNone(sync)

    @unittest.skip("Test needs to create manifests using stageportal stuff")
    def test_sync_rhrepos(self):
        """
        @Feature: Content RedHat Sync - Positive Create
        @Test: Create Content RedHat Sync with two repos.
        @Assert: Whether Syncing RedHat Repos is successful
        """

        repos = self.sync.create_repos_tree(RHCT)
        self.login.login(self.katello_user, self.katello_passwd)
        # TODO: Create manifests and import using stageportal stuff.
        self.navigator.go_to_red_hat_repositories()
        self.sync.enable_rh_repos(repos)
        self.navigator.go_to_sync_status()
        sync = self.sync.sync_rh_repos(repos)
        self.assertIsNotNone(sync)
Exemple #4
0
 def test_return_type(self):
     """Tests if generate string list returns a unicode string"""
     for string in generate_strings_list():
         self.assertIsInstance(string, unicode)
Exemple #5
0
    def test_end_to_end(self):
        """@Test: Perform end to end smoke tests using RH repos.

        1. Create new organization and environment
        2. Upload manifest
        3. Sync a RedHat repository
        4. Create content-view
        5. Add repository to contet-view
        6. Promote/publish content-view
        7. Create an activation-key
        8. Add product to activation-key
        9. Create new virtualmachine
        10. Pull rpm from Foreman server and install on client
        11. Register client with foreman server using activation-key
        12. Install rpm on client

        @Feature: Smoke test

        @Assert: All tests should succeed and Content should be successfully
        fetched by client

        """
        # Product, RepoSet and repository variables
        rhel_product_name = "Red Hat Enterprise Linux Server"
        rhel_repo_set = "Red Hat Enterprise Virtualization Agents " "for RHEL 6 Server (RPMs)"
        rhel_repo_name = "Red Hat Enterprise Virtualization Agents " "for RHEL 6 Server " "RPMs x86_64 6Server"
        org_name = random.choice(generate_strings_list())
        # Create new org and environment
        new_org = make_org({u"name": org_name})
        new_env = make_lifecycle_environment({u"organization-id": new_org["id"], u"name": gen_alphanumeric()})
        # Clone manifest and upload it
        manifest = manifests.clone()
        ssh.upload_file(manifest, remote_file=manifest)
        result = Subscription.upload({u"file": manifest, u"organization-id": new_org["id"]})
        self.assertEqual(result.return_code, 0)
        # Enable repo from Repository Set
        result = RepositorySet.enable(
            {
                u"name": rhel_repo_set,
                u"organization-id": new_org["id"],
                u"product": rhel_product_name,
                u"releasever": "6Server",
                u"basearch": "x86_64",
            }
        )
        self.assertEqual(result.return_code, 0)
        # Fetch repository info
        result = Repository.info(
            {u"name": rhel_repo_name, u"product": rhel_product_name, u"organization-id": new_org["id"]}
        )
        rhel_repo = result.stdout
        # Synchronize the repository
        result = Repository.synchronize(
            {u"name": rhel_repo_name, u"organization-id": new_org["id"], u"product": rhel_product_name}
        )
        self.assertEqual(result.return_code, 0)
        # Create CV and associate repo to it
        new_cv = make_content_view({u"organization-id": new_org["id"]})
        result = ContentView.add_repository(
            {u"id": new_cv["id"], u"repository-id": rhel_repo["id"], u"organization-id": new_org["id"]}
        )
        self.assertEqual(result.return_code, 0)
        # Publish a version1 of CV
        result = ContentView.publish({u"id": new_cv["id"]})
        self.assertEqual(result.return_code, 0)
        # Get the CV info
        result = ContentView.info({u"id": new_cv["id"]})
        self.assertEqual(result.return_code, 0)
        # Store the version1 id
        version1_id = result.stdout["versions"][0]["id"]
        # Promotion of version1 to next env
        result = ContentView.version_promote({u"id": version1_id, u"to-lifecycle-environment-id": new_env["id"]})
        self.assertEqual(result.return_code, 0)
        # Create activation key
        activation_key = make_activation_key(
            {
                u"name": gen_alphanumeric(),
                u"lifecycle-environment-id": new_env["id"],
                u"organization-id": new_org["id"],
                u"content-view": new_cv["name"],
            }
        )
        # List the subscriptions in given org
        result = Subscription.list({u"organization-id": new_org["id"]}, per_page=False)
        self.assertEqual(result.return_code, 0)
        # Get the subscription ID from subscriptions list
        for subscription in result.stdout:
            if subscription["name"] == DEFAULT_SUBSCRIPTION_NAME:
                subscription_id = subscription["id"]
                subscription_quantity = int(subscription["quantity"])
        self.assertGreater(int(subscription_quantity), 0)
        # Add the subscriptions to activation-key
        result = ActivationKey.add_subscription(
            {u"id": activation_key["id"], u"subscription-id": subscription_id, u"quantity": 1}
        )
        self.assertEqual(result.return_code, 0)
        # Enable product content
        ActivationKey.content_override(
            {
                u"id": activation_key["id"],
                u"organization-id": new_org["id"],
                u"content-label": "rhel-6-server-rhev-agent-rpms",
                u"value": "1",
            }
        )
        # Create VM
        package_name = "python-kitchen"
        server_name = conf.properties["main.server.hostname"]
        with VirtualMachine(distro="rhel66") as vm:
            # Download and Install rpm
            result = vm.run("wget -nd -r -l1 --no-parent -A '*.noarch.rpm' http://{0}/pub/".format(server_name))
            self.assertEqual(result.return_code, 0)
            result = vm.run("rpm -i katello-ca-consumer*.noarch.rpm")
            self.assertEqual(result.return_code, 0)
            # Register client with foreman server using activation-key
            result = vm.run(
                u"subscription-manager register --activationkey {0} "
                "--org {1} --force".format(activation_key["name"], new_org["label"])
            )
            self.assertEqual(result.return_code, 0)
            # Install contents from sat6 server
            result = vm.run("yum install -y {0}".format(package_name))
            self.assertEqual(result.return_code, 0)
            # Verify if package is installed by query it
            result = vm.run("rpm -q {0}".format(package_name))
            self.assertEqual(result.return_code, 0)
Exemple #6
0
class HardwareModelTestCase(UITestCase):
    """Implements Hardware Model tests in UI."""
    @data(*generate_strings_list(len1=8))
    def test_create_positive_1(self, name):
        """@test: Create new Hardware-Model

        @feature: Hardware-Model - Positive Create

        @assert: Hardware-Model is created

        """
        with Session(self.browser) as session:
            make_hw_model(session, name=name)
            search = self.hardwaremodel.search(name)
            self.assertIsNotNone(search)

    @data(gen_string('alphanumeric', 255), gen_string('alpha', 255),
          gen_string('numeric', 255), gen_string('latin1', 255),
          gen_string('utf8', 255))
    def test_create_positive_2(self, name):
        """@test: Create new Hardware-Model with 255 chars

        @feature: Hardware-Model - Positive Create

        @assert: Hardware-Model is created with 255 chars

        """
        with Session(self.browser) as session:
            make_hw_model(session, name=name)
            search = self.hardwaremodel.search(name)
            self.assertIsNotNone(search)

    @data(*generate_strings_list(len1=256))
    def test_create_negative_1(self, name):
        """@test: Create new Hardware-Model with 256 chars

        @feature: Hardware-Model - Negative Create

        @assert: Hardware-Model is not created

        """
        with Session(self.browser) as session:
            make_hw_model(session, name=name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    def test_create_negative_2(self):
        """@test: Create new Hardware-Model with blank name

        @feature: Hardware-Model - Negative Create

        @assert: Hardware-Model is not created

        """
        name = ""
        with Session(self.browser) as session:
            make_hw_model(session, name=name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    def test_create_negative_3(self):
        """@test: Create new Hardware-Model with whitespace name

        @feature: Hardware-Model - Negative Create

        @assert: Hardware-Model is not created

        """
        name = "    "
        with Session(self.browser) as session:
            make_hw_model(session, name=name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    @data({
        'name': gen_string('alpha'),
        'new_name': gen_string('alpha')
    }, {
        'name': gen_string('numeric'),
        'new_name': gen_string('numeric')
    }, {
        'name': gen_string('alphanumeric'),
        'new_name': gen_string('alphanumeric')
    }, {
        'name': gen_string('utf8'),
        'new_name': gen_string('utf8')
    }, {
        'name': gen_string('latin1'),
        'new_name': gen_string('latin1')
    })
    def test_update_positive_1(self, testdata):
        """@test: Updates the Hardware-Model

        @feature: Hardware-Model - Positive Update

        @assert: Hardware-Model is updated.

        """
        name = testdata['name']
        new_name = testdata['new_name']
        with Session(self.browser) as session:
            make_hw_model(session, name=name)
            search = self.hardwaremodel.search(name)
            self.assertIsNotNone(search)
            self.hardwaremodel.update(name, new_name)
            search = self.hardwaremodel.search(new_name)
            self.assertIsNotNone(search)

    @data(*generate_strings_list(len1=8))
    def test_delete_positive_1(self, name):
        """@test: Deletes the Hardware-Model

        @feature: Hardware-Model - Positive delete

        @assert: Hardware-Model is deleted

        """

        with Session(self.browser) as session:
            make_hw_model(session, name=name)
            search = self.hardwaremodel.search(name)
            self.assertIsNotNone(search)
            self.hardwaremodel.delete(name, True)
            self.assertIsNone(self.hardwaremodel.search(name, timeout=3))
Exemple #7
0
class Org(UITestCase):
    """Implements Organization tests in UI"""

    # Tests for issues

    @skip_if_bug_open('bugzilla', 1177610)
    def test_auto_search(self):
        """@test: Can auto-complete search for an organization by partial name

        @feature: Organizations

        @assert: Created organization can be auto search by its partial name

        @BZ: 1177610

        """
        org_name = gen_string("alpha", 8)
        part_string = org_name[:3]
        with Session(self.browser) as session:
            page = session.nav.go_to_org
            make_org(session, org_name=org_name)
            auto_search = self.org.auto_complete_search(
                page,
                locators["org.org_name"],
                part_string,
                org_name,
                search_key='name')
            self.assertIsNotNone(auto_search)

    # Positive Create

    @data(*generate_strings_list())
    def test_positive_create_1(self, org_name):
        """@test: Create organization with valid name only.

        @feature: Organizations

        @assert: organization is created, label is auto-generated

        @BZ: 1131469

        """
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))

    @stubbed('parent_org feature is disabled currently')
    @data(
        {
            'label': gen_string('alpha'),
            'name': gen_string('alpha'),
            'desc': gen_string('alpha')
        }, {
            'label': gen_string('numeric'),
            'name': gen_string('numeric'),
            'desc': gen_string('numeric')
        }, {
            'label': gen_string('alphanumeric'),
            'name': gen_string('alphanumeric'),
            'desc': gen_string('alphanumeric')
        }, {
            'label': gen_string('alpha'),
            'name': gen_string('utf8'),
            'desc': gen_string('utf8')
        }, {
            'label': gen_string('alpha'),
            'name': gen_string('latin1'),
            'desc': gen_string('latin1')
        }, {
            'label': gen_string('alpha'),
            'name': gen_string('html'),
            'desc': gen_string('html')
        })
    def test_positive_create_2(self, test_data):
        """@test: Create organization with valid name, label, parent_org, desc.

        @feature: Organizations

        @assert: organization is created.

        """
        parent = gen_string("alpha", 8)
        desc = test_data['desc']
        label = test_data['label']
        org_name = test_data['name']
        with Session(self.browser) as session:
            make_org(session, org_name=parent)
            make_org(session,
                     org_name=org_name,
                     label=label,
                     desc=desc,
                     parent_org=parent)
            self.assertIsNotNone(self.org.search(org_name))

    @data({
        'name': gen_string('alpha', 10),
        'label': gen_string('alpha', 10)
    }, {
        'name': gen_string('numeric', 10),
        'label': gen_string('numeric', 10)
    }, {
        'name': gen_string('alphanumeric', 10),
        'label': gen_string('alphanumeric', 10)
    })
    # As label cannot contain chars other than ascii alpha numerals, '_', '-'.
    def test_positive_create_3(self, test_data):
        """@test: Create organization with valid unmatching name and label only

        @feature: Organizations

        @assert: organization is created, label does not match name

        """

        name_loc = locators["org.name"]
        label_loc = locators["org.label"]
        org_name = test_data['name']
        org_label = test_data['label']
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, label=org_label)
            self.org.search(org_name).click()
            name = session.nav.wait_until_element(name_loc).get_attribute(
                "value")
            label = session.nav.wait_until_element(label_loc).get_attribute(
                "value")
            self.assertNotEqual(name, label)

    @data(gen_string('alpha', 10), gen_string('numeric', 10),
          gen_string('alphanumeric', 10))
    # As label cannot contain chars other than ascii alpha numerals, '_', '-'.
    def test_positive_create_4(self, org_label):
        """@test: Create organization with valid matching name and label only.

        @feature: Organizations

        @assert: organization is created, label matches name

        """
        name_loc = locators["org.name"]
        label_loc = locators["org.label"]
        org_name = org_label
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, label=org_label)
            self.org.search(org_name).click()
            name = self.org.wait_until_element(name_loc).get_attribute("value")
            label = self.org.wait_until_element(label_loc).get_attribute(
                "value")
            self.assertEqual(name, label)

    @skip_if_bug_open('bugzilla', 1079482)
    @skip_if_bug_open('bugzilla', 1131469)
    @data({
        'name': gen_string('alpha', 10),
        'desc': gen_string('alpha', 10)
    }, {
        'name': gen_string('numeric', 10),
        'desc': gen_string('numeric', 10)
    }, {
        'name': gen_string('alphanumeric', 10),
        'desc': gen_string('alphanumeric', 10)
    }, {
        'name': gen_string('utf8', 10),
        'desc': gen_string('utf8', 10)
    }, {
        'name': gen_string('latin1', 20),
        'desc': gen_string('latin1', 10)
    }, {
        'name': gen_string('html', 20),
        'desc': gen_string('html', 10)
    })
    def test_positive_create_5(self, test_data):
        """@test: Create organization with valid name and description only.

        @feature: Organizations

        @assert: organization is created, label is auto-generated

        @BZ: 1079482

        @BZ: 1131469

        """

        desc = test_data['desc']
        org_name = test_data['name']
        label_loc = locators["org.label"]
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, desc=desc)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.search(org_name).click()
            label_ele = session.nav.wait_until_element(label_loc)
            label_value = label_ele.get_attribute("value")
            self.assertIsNotNone(label_value)

    @data(
        {
            'org_name': gen_string('alpha', 10),
            'loc_name': gen_string('alpha', 10)
        }, {
            'org_name': gen_string('numeric', 10),
            'loc_name': gen_string('numeric', 10)
        }, {
            'org_name': gen_string('alphanumeric', 10),
            'loc_name': gen_string('alphanumeric', 10)
        }, {
            'org_name': gen_string('utf8', 10),
            'loc_name': gen_string('utf8', 10)
        }, {
            'org_name': gen_string('latin1', 20),
            'loc_name': gen_string('latin1', 10)
        }, {
            'org_name': gen_string('html', 20),
            'loc_name': gen_string('html', 10)
        })
    def test_positive_create_6(self, test_data):
        """@test: Select both organization and location.

        @feature: Organizations

        @assert: Both organization and location are selected.

        """
        org_name = test_data['org_name']
        loc_name = test_data['loc_name']
        location = entities.Location(name=loc_name).create()
        self.assertEqual(location['name'], loc_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            organization = session.nav.go_to_select_org(org_name)
            location = session.nav.go_to_select_loc(loc_name)
            self.assertEqual(organization, org_name)
            self.assertEqual(location, loc_name)

    @data(*generate_strings_list(len1=256))
    def test_negative_create_0(self, org_name):
        """@test: Create organization with valid label and description, name is
        too long.

        @feature: Organizations Negative Tests

        @assert: organization is not created

        """
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    def test_negative_create_1(self):
        """@test: Create organization with valid label and description, name is
        blank.

        @feature: Organizations - Negative Tests

        @assert: organization is not created

        """
        org_name = ""
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    def test_negative_create_2(self):
        """@test: Create organization with valid label and description, name is
        whitespace.

        @feature: Organizations Negative Test.

        @assert: organization is not created

        """
        org_name = "    "
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    @skip_if_bug_open('bugzilla', 1131469)
    @data(*generate_strings_list())
    def test_negative_create_3(self, org_name):
        """@test: Create organization with valid values, then create a new one
        with same values.

        @feature: Organizations Negative Test.

        @assert: organization is not created

        @BZ: 1131469

        """
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.create(org_name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    # Positive Delete

    @stubbed('Organization deletion is disabled')
    @data(*generate_strings_list())
    def test_positive_delete_1(self, org_name):
        """@test: Create organization with valid values then delete it.

        @feature: Organizations Positive Delete test.

        @assert: organization is deleted

        """
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.remove(org_name, really=True)
            self.assertIsNone(self.org.search(org_name))

    # Negative Delete

    # Positive Update

    @skip_if_bug_open('bugzilla', 1131469)
    @data(*generate_strings_list())
    def test_positive_update_1(self, new_name):
        """@test: Create organization with valid values then update its name.

        @feature: Organizations Positive Update test.

        @assert: organization name is updated

        @BZ: 1131469

        """

        org_name = gen_string("alpha", 8)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.update(org_name, new_name=new_name)
            self.assertIsNotNone(self.org.search(new_name))

    # Negative Update

    @skip_if_bug_open('bugzilla', 1131469)
    @data(*generate_strings_list())
    def test_negative_update_1(self, org_name):
        """@test: Create organization with valid values then fail to update
        its name.

        @feature: Organizations Negative Update test.

        @assert: organization name is not updated

        @BZ: 1131469

        """
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            new_name = gen_string("alpha", 256)
            self.org.update(org_name, new_name=new_name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    # Miscellaneous

    @skip_if_bug_open('bugzilla', 1131469)
    @data(*generate_strings_list())
    def test_search_key_1(self, org_name):
        """@test: Create organization and search/find it.

        @feature: Organizations search.

        @assert: organization can be found

        @BZ: 1131469

        """
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))

    # Associations

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_remove_domain_1(self, domain_name):
        """@test: Add a domain to an organization and remove it by organization
        name and domain name.

        @feature: Organizations Disassociate domain.

        @assert: the domain is removed from the organization

        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        domain = entities.Domain(name=domain_name).create()
        self.assertEqual(domain['name'], domain_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, domains=[domain_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_domains"]).click()
            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.org.update(org_name, domains=[domain_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_domains"]).click()
            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)

    #  Note: HTML username is invalid as per the UI msg.
    @data(
        {u'user_name': gen_string('alpha', 8)},
        {u'user_name': gen_string('numeric', 8)},
        {u'user_name': gen_string('alphanumeric', 8)},
        {u'user_name': gen_string('utf8', 8)},
        {u'user_name': gen_string('latin1', 8)},
    )
    def test_remove_user_1(self, test_data):
        """@test: Create admin users then add user and remove it
        by using the organization name.

        @feature: Organizations dis-associate user.

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

        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        password = gen_string("alpha", 8)
        user_name = test_data['user_name']
        user = entities.User(login=user_name,
                             firstname=user_name,
                             lastname=user_name,
                             password=password).create()
        self.assertEqual(user['login'], user_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, users=[user_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_users"]).click()
            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.wait_until_element(
                tab_locators["context.tab_users"]).click()
            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)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_remove_hostgroup_1(self, host_grp_name):
        """@test: Add a hostgroup and remove it by using the organization
        name and hostgroup name.

        @feature: Organizations remove hostgroup.

        @assert: hostgroup is added to organization then removed.

        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        host_grp = entities.HostGroup(name=host_grp_name).create()
        self.assertEqual(host_grp['name'], host_grp_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, hostgroups=[host_grp_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_hostgrps"]).click()
            element = session.nav.wait_until_element(
                (strategy1, value1 % host_grp_name))
            # Item is listed in 'Selected Items' list and not 'All Items' list.
            self.assertIsNotNone(element)
            self.org.update(org_name,
                            hostgroups=[host_grp_name],
                            new_hostgroups=None)
            self.org.search(org_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.assertIsNotNone(element)

    @run_only_on('sat')
    @stubbed()
    @data("""DATADRIVENGOESHERE
        smartproxy name is alpha
        smartproxy name is numeric
        smartproxy name is alpha_numeric
        smartproxy name  is utf-8
        smartproxy name is latin1
        smartproxy name is html
    """)
    def test_add_smartproxy_1(self, test_data):
        """@test: Add a smart proxy by using org and smartproxy name

        @feature: Organizations

        @assert: smartproxy is added

        @status: manual

        """

        pass

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_add_subnet_1(self, subnet_name):
        """@test: Add a subnet by using organization name and subnet name.

        @feature: Organizations associate subnet.

        @assert: subnet is added.

        """
        strategy, value = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        subnet_network = gen_ipaddr(ip3=True)
        subnet_mask = "255.255.255.0"
        subnet = entities.Subnet(name=subnet_name,
                                 network=subnet_network,
                                 mask=subnet_mask).create()
        self.assertEqual(subnet['name'], subnet_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.update(org_name, new_subnets=[subnet_name])
            self.org.search(org_name).click()
            self.org.wait_until_element(
                tab_locators["context.tab_subnets"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % subnet_name))
            self.assertIsNotNone(element)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_add_domain_1(self, domain_name):
        """@test: Add a domain to an organization.

        @feature: Organizations associate domain.

        @assert: Domain is added to organization.

        """
        strategy, value = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        domain = entities.Domain(name=domain_name).create()
        self.assertEqual(domain['name'], domain_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.update(org_name, new_domains=[domain_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_domains"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % domain_name))
            self.assertIsNotNone(element)

    @data(
        {u'user_name': gen_string('alpha', 8)},
        {u'user_name': gen_string('numeric', 8)},
        {u'user_name': gen_string('alphanumeric', 8)},
        {u'user_name': gen_string('utf8', 8)},
        {u'user_name': gen_string('latin1', 8)},
    )
    def test_add_user_2(self, test_data):
        """@test: Create different types of users then add user
        by using the organization name.

        @feature: Organizations associate user.

        @assert: User is added to organization.

        """
        user_name = test_data['user_name']
        strategy, value = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        password = gen_string("alpha", 8)
        user = entities.User(login=user_name,
                             firstname=user_name,
                             lastname=user_name,
                             password=password).create()
        self.assertEqual(user['login'], user_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.update(org_name, new_users=[user_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_users"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % user_name))
            self.assertIsNotNone(element)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_add_hostgroup_1(self, host_grp_name):
        """@test: Add a hostgroup by using the organization
        name and hostgroup name.

        @feature: Organizations associate host-group.

        @assert: hostgroup is added to organization

        """
        strategy, value = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        host_grp = entities.HostGroup(name=host_grp_name).create()
        self.assertEqual(host_grp['name'], host_grp_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.update(org_name, new_hostgroups=[host_grp_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_hostgrps"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % host_grp_name))
            self.assertIsNotNone(element)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_add_location_1(self, location_name):
        """@test: Add a location by using the organization
        name and location name.

        @feature: Organizations associate location.

        @assert: location is added to organization.

        """
        strategy, value = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        location = entities.Location(name=location_name).create()
        self.assertEqual(location['name'], location_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.update(org_name, new_locations=[location_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_locations"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % location_name))
            self.assertIsNotNone(element)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_remove_computeresource_1(self, resource_name):
        """@test: Remove computeresource by using the organization
        name and computeresource name.

        @feature: Organizations dis-associate compute-resource.

        @assert: computeresource is added then removed.

        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        libvirt_url = "qemu+tcp://%s:16509/system"
        url = (libvirt_url % conf.properties['main.server.hostname'])
        resource = entities.ComputeResource(name=resource_name,
                                            provider='Libvirt',
                                            url=url).create()
        self.assertEqual(resource['name'], resource_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, resources=[resource_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_resources"]).click()
            element = session.nav.wait_until_element(
                (strategy1, value1 % resource_name))
            # Item is listed in 'Selected Items' list and not 'All Items' list.
            self.assertIsNotNone(element)
            self.org.update(org_name,
                            resources=[resource_name],
                            new_resources=None)
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_resources"]).click()
            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)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_remove_medium_1(self, medium_name):
        """@test: Remove medium by using organization name and medium name.

        @feature: Organizations disassociate installation media.

        @assert: medium is added then removed.

        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        path = URL % gen_string("alpha", 6)
        medium = entities.Media(
            name=medium_name,
            media_path=path,
            os_family='Redhat',
        ).create()
        self.assertEqual(medium['name'], medium_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, medias=[medium_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_media"]).click()
            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.navigator.go_to_org()
            self.org.update(org_name, medias=[medium_name], new_medias=None)
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_media"]).click()
            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)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_remove_configtemplate_1(self, template_name):
        """@test: Remove config template.

        @feature: Organizations dissociate config templates.

        @assert: configtemplate is added then removed.

        @BZ: 1129612

        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        entities.ConfigTemplate(name=template_name).create()
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, templates=[template_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_template"]).click()
            element = session.nav.wait_until_element(
                (strategy1, value1 % template_name))
            # Item is listed in 'Selected Items' list and not 'All Items' list.
            self.assertIsNotNone(element)
            self.org.update(org_name, templates=[template_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_template"]).click()
            element = self.org.wait_until_element(
                (strategy, value % template_name))
            # Item is listed in 'All Items' list and not 'Selected Items' list.
            self.assertIsNotNone(element)

    @run_only_on('sat')
    @data(gen_string('alpha', 8), gen_string('numeric', 8),
          gen_string('alphanumeric', 8))
    def test_add_environment_1(self, env_name):
        """@test: Add environment by using organization name and env name.

        @feature: Organizations associate environment.

        @assert: environment is added.

        """
        strategy, value = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        env = entities.Environment(name=env_name).create()
        self.assertEqual(env['name'], env_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.update(org_name, new_envs=[env_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_env"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % env_name))
            self.assertIsNotNone(element)

    @run_only_on('sat')
    @stubbed()
    @data("""DATADRIVENGOESHERE
        smartproxy name is alpha
        smartproxy name is numeric
        smartproxy name is alpha_numeric
        smartproxy name  is utf-8
        smartproxy name is latin1
        smartproxy name is html
    """)
    def test_remove_smartproxy_1(self, test_data):
        """@test: Remove smartproxy by using organization name and smartproxy
        name

        @feature: Organizations

        @assert: smartproxy is added then removed

        @status: manual

        """

        pass

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_add_computeresource_1(self, resource_name):
        """@test: Add compute resource using the organization
        name and computeresource name.

        @feature: Organizations associate compute resource.

        @assert: computeresource is added.

        """
        strategy, value = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        libvirt_url = "qemu+tcp://%s:16509/system"
        url = (libvirt_url % conf.properties['main.server.hostname'])
        resource = entities.ComputeResource(name=resource_name,
                                            provider='Libvirt',
                                            url=url).create()
        self.assertEqual(resource['name'], resource_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.update(org_name, new_resources=[resource_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_resources"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % resource_name))
            self.assertIsNotNone(element)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_add_medium_1(self, medium_name):
        """@test: Add medium by using the organization name and medium name.

        @feature: Organizations associate medium.

        @assert: medium is added.

        """
        strategy, value = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        path = URL % gen_string("alpha", 6)
        medium = entities.Media(
            name=medium_name,
            media_path=path,
            os_family='Redhat',
        ).create()
        self.assertEqual(medium['name'], medium_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.update(org_name, new_medias=[medium_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_media"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % medium_name))
            self.assertIsNotNone(element)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_add_configtemplate_1(self, template_name):
        """@test: Add config template by using organization name and
        configtemplate name.

        @feature: Organizations associate config template.

        @assert: configtemplate is added

        @BZ: 1129612

        """
        strategy, value = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        entities.ConfigTemplate(name=template_name).create()

        with Session(self.browser) as session:
            make_org(session, org_name=org_name)
            self.assertIsNotNone(self.org.search(org_name))
            self.org.update(org_name, new_templates=[template_name])
            self.org.search(org_name).click()
            self.org.wait_until_element(
                tab_locators["context.tab_template"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % template_name))
            self.assertIsNotNone(element)

    @run_only_on('sat')
    @data(gen_string('alpha', 8), gen_string('numeric', 8),
          gen_string('alphanumeric', 8))
    def test_remove_environment_1(self, env_name):
        """@test: Remove environment by using org & evironment name.

        @feature: Organizations dis-associate environment.

        @assert: environment is removed from Organization.

        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        env = entities.Environment(name=env_name).create()
        self.assertEqual(env['name'], env_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, envs=[env_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_env"]).click()
            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.org.update(org_name, envs=[env_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_env"]).click()
            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)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_remove_subnet_1(self, subnet_name):
        """@test: Remove subnet by using organization name and subnet name.

        @feature: Organizations dis-associate subnet.

        @assert: subnet is added then removed.

        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        org_name = gen_string("alpha", 8)
        subnet_network = gen_ipaddr(ip3=True)
        subnet_mask = "255.255.255.0"
        subnet = entities.Subnet(name=subnet_name,
                                 network=subnet_network,
                                 mask=subnet_mask).create()
        self.assertEqual(subnet['name'], subnet_name)
        with Session(self.browser) as session:
            make_org(session, org_name=org_name, subnets=[subnet_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_subnets"]).click()
            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.org.update(org_name, subnets=[subnet_name])
            self.org.search(org_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_subnets"]).click()
            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)
Exemple #8
0
 def test_return_type(self):
     """Tests if generate string list returns a unicode string"""
     for string in generate_strings_list():
         self.assertIsInstance(string, unicode)
Exemple #9
0
class Template(UITestCase):
    """Implements Provisioning Template tests from UI"""
    @data(*generate_strings_list(len1=8))
    def test_positive_create_template(self, name):
        """@Test: Create new template

        @Feature: Template - Positive Create

        @Assert: New provisioning template of type 'provision'
        should be created successfully

        """
        temp_type = 'provision'
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            make_templates(session,
                           name=name,
                           template_path=template_path,
                           custom_really=True,
                           template_type=temp_type)
            self.assertIsNotNone(self.template.search(name))

    def test_negative_create_template_1(self):
        """@Test: Template - Create a new template with 256 characters in name

        @Feature: Template - Negative Create

        @Assert: Template is not created

        """
        name = gen_string("alpha", 256)
        temp_type = 'provision'
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            make_templates(session,
                           name=name,
                           template_path=template_path,
                           custom_really=True,
                           template_type=temp_type)
            self.assertIsNotNone(
                self.template.wait_until_element(
                    common_locators["name_haserror"]))

    @data(" ", "")
    def test_negative_create_template_2(self, name):
        """@Test: Create a new template with blank and whitespace in name

        @Feature: Template - Negative Create

        @Assert: Template is not created

        """
        temp_type = 'provision'
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            make_templates(session,
                           name=name,
                           template_path=template_path,
                           custom_really=True,
                           template_type=temp_type)
            self.assertIsNotNone(
                self.template.wait_until_element(
                    common_locators["name_haserror"]))

    def test_negative_create_template_4(self):
        """@Test: Template - Create a new template with same name

        @Feature: Template - Negative Create

        @Assert: Template is not created

        """
        name = gen_string("alpha", 16)
        temp_type = 'provision'
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            make_templates(session,
                           name=name,
                           template_path=template_path,
                           custom_really=True,
                           template_type=temp_type)
            self.assertIsNotNone(self.template.search(name))
            make_templates(session,
                           name=name,
                           template_path=template_path,
                           custom_really=True,
                           template_type=temp_type)
            self.assertIsNotNone(
                self.template.wait_until_element(
                    common_locators["name_haserror"]))

    def test_negative_create_template_5(self):
        """@Test: Template - Create a new template without selecting its type

        @Feature: Template - Negative Create

        @Assert: Template is not created

        """
        name = gen_string("alpha", 16)
        temp_type = ""
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            with self.assertRaises(Exception) as context:
                make_templates(session,
                               name=name,
                               template_path=template_path,
                               custom_really=True,
                               template_type=temp_type)
            self.assertEqual(
                context.exception.message, "Could not create template '%s'"
                " without type" % name)

    def test_negative_create_template_6(self):
        """@Test: Template - Create a new template without uploading a template

        @Feature: Template - Negative Create

        @Assert: Template is not created

        """
        name = gen_string("alpha", 16)
        temp_type = 'PXELinux'
        template_path = ""
        with Session(self.browser) as session:
            with self.assertRaises(Exception) as context:
                make_templates(session,
                               name=name,
                               template_path=template_path,
                               custom_really=True,
                               template_type=temp_type)
            self.assertEqual(context.exception.message,
                             "Could not create blank template '%s'" % name)

    def test_negative_create_template_7(self):
        """@Test: Create a new template with 256 characters in audit comments

        @Feature: Template - Negative Create

        @Assert: Template is not created

        """
        name = gen_string("alpha", 16)
        audit_comment = gen_string("alpha", 256)
        temp_type = 'PXELinux'
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            make_templates(session,
                           name=name,
                           template_path=template_path,
                           custom_really=True,
                           audit_comment=audit_comment,
                           template_type=temp_type)
            self.assertIsNotNone(
                self.template.wait_until_element(common_locators["haserror"]))

    @data(*generate_strings_list(len1=8))
    def test_positive_create_snippet_template(self, name):
        """@Test: Create new template of type snippet

        @Feature: Template - Positive Create

        @Assert: New provisioning template of type 'snippet'
        should be created successfully

        """
        template_path = get_data_file(SNIPPET_DATA_FILE)
        with Session(self.browser) as session:
            make_templates(session,
                           name=name,
                           template_path=template_path,
                           custom_really=True,
                           snippet=True)
            self.assertIsNotNone(self.template.search(name))

    @skip_if_bug_open('bugzilla', 1177756)
    @data(*generate_strings_list(len1=8))
    def test_remove_template(self, template_name):
        """@Test: Remove a template

        @Feature: Template - Positive Delete

        @Assert: Template removed successfully

        @BZ: 1177756

        """
        entities.ConfigTemplate(name=template_name).create_json()
        with Session(self.browser):
            self.template.delete(template_name, True)
            self.assertIsNotNone(
                self.template.wait_until_element(
                    common_locators["notif.success"]))

    def test_update_template(self):
        """@Test: Update template name and template type

        @Feature: Template - Positive Update

        @Assert: The template name and type should be updated successfully

        """
        name = gen_string("alpha", 6)
        new_name = gen_string("alpha", 6)
        temp_type = 'provision'
        new_temp_type = 'PXELinux'
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            make_templates(session,
                           name=name,
                           template_path=template_path,
                           custom_really=True,
                           template_type=temp_type)
            self.assertIsNotNone(self.template.search(name))
            self.template.update(name, False, new_name, None, new_temp_type)
            self.assertIsNotNone(self.template.search(new_name))

    def test_update_template_os(self):
        """@Test: Creates new template, along with two OS's
        and associate list of OS's with created template

        @Feature: Template - Positive Update

        @Assert: The template should be updated with newly created OS's
        successfully

        """
        name = gen_string("alpha", 6)
        new_name = gen_string("alpha", 6)
        temp_type = 'provision'
        os_list = [
            entities.OperatingSystem().create_json()['name'] for _ in range(2)
        ]
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            make_templates(session,
                           name=name,
                           template_path=template_path,
                           custom_really=True,
                           template_type=temp_type)
            self.assertIsNotNone(self.template.search(name))
            self.template.update(name, False, new_name, new_os_list=os_list)
            self.assertIsNotNone(self.template.search(new_name))

    def test_clone_template(self):
        """@Test: Assure ability to clone a provisioning template

        @Feature: Template - Clone

        @Steps:
         1.  Go to Provisioning template UI
         2.  Choose a template and attempt to clone it

        @Assert: template is cloned

        """
        name = gen_string("alpha", 6)
        clone_name = gen_string("alpha", 6)
        temp_type = 'provision'
        os_list = [
            entities.OperatingSystem().create_json()['name'] for _ in range(2)
        ]
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            make_templates(session,
                           name=name,
                           template_path=template_path,
                           custom_really=True,
                           template_type=temp_type)
            self.assertIsNotNone(self.template.search(name))
            self.template.clone(name,
                                custom_really=False,
                                clone_name=clone_name,
                                os_list=os_list)
            self.assertIsNotNone(self.template.search(clone_name))
Exemple #10
0
class UserGroup(UITestCase):
    """Implements UserGroup tests from UI"""
    @classmethod
    def setUpClass(cls):  # noqa
        cls.org_name = entities.Organization().create()

        super(UserGroup, cls).setUpClass()

    @skip_if_bug_open('bugzilla', 1142588)
    @data(*generate_strings_list())
    def test_positive_create_usergroup(self, group_name):
        """@Test: Create new Usergroup

        @Feature: Usergroup - Positive Create

        @Assert: Usergroup is created

        """

        user_name = gen_string("alpha", 6)
        password = gen_string("alpha", 6)
        # Create a new user
        entities.User(
            login=user_name,
            password=password,
        ).create()

        with Session(self.browser) as session:
            make_usergroup(session, name=group_name, users=[user_name])
            self.assertIsNotNone(self.usergroup.search(group_name))

    @skip_if_bug_open('bugzilla', 1142588)
    @data(*generate_strings_list(len1=256))
    def test_negative_create_usergroup_1(self, group_name):
        """@Test: Create a new UserGroup with 256 characters in name

        @Feature:  Usergroup - Negative Create

        @Assert:  Usergroup is not created

        """

        with Session(self.browser) as session:
            make_usergroup(session, org=self.org_name, name=group_name)
            self.assertIsNotNone(
                self.usergroup.wait_until_element(
                    common_locators["name_haserror"]))
            self.assertIsNone(self.usergroup.search(group_name))

    @data(" ", "")
    def test_negative_create_usergroup_2(self, group_name):
        """@Test: Create a new UserGroup with blank and whitespace in name

        @Feature: Usergroup - Negative Create

        @Assert: Usergroup is not created

        """

        with Session(self.browser) as session:
            make_usergroup(session, org=self.org_name, name=group_name)
            self.assertIsNotNone(
                self.usergroup.wait_until_element(
                    common_locators["name_haserror"]))

    @data(*generate_strings_list())
    def test_negative_create_usergroup_3(self, group_name):
        """@Test: Create a new UserGroup with same name

        @Feature: Usergroup - Negative Create

        @Assert: Usergroup cannot be  created with existing name

        """

        with Session(self.browser) as session:
            make_usergroup(session, org=self.org_name, name=group_name)
            self.assertIsNotNone(self.usergroup.search(group_name))
            make_usergroup(session, org=self.org_name, name=group_name)
            self.assertIsNotNone(
                self.usergroup.wait_until_element(
                    common_locators["name_haserror"]))

    @skip_if_bug_open('bugzilla', 1142588)
    @data(*generate_strings_list())
    def test_remove_empty_usergroup(self, group_name):
        """@Test: Delete an empty Usergroup

        @Feature: Usergroup - Positive Delete

        @Assert: Usergroup is deleted

        """

        with Session(self.browser) as session:
            make_usergroup(session, org=self.org_name, name=group_name)
            self.assertIsNotNone(self.usergroup.search(group_name))
            self.usergroup.delete(group_name, True)
            self.assertIsNotNone(
                self.usergroup.wait_until_element(
                    common_locators["notif.success"]))
            self.assertIsNone(self.usergroup.search(group_name))

    @skip_if_bug_open('bugzilla', 1142588)
    @data(*generate_strings_list())
    def test_remove_usergroup(self, group_name):
        """@Test: Delete an Usergroup that contains a user

        @Feature: Usergroup - Positive Delete

        @Assert: Usergroup is deleted but not the added user

        """

        user_name = gen_string("alpha", 6)
        password = gen_string("alpha", 6)
        # Create a new user
        entities.User(login=user_name, password=password).create()

        with Session(self.browser) as session:
            make_usergroup(session, name=group_name, users=[user_name])
            self.assertIsNotNone(self.usergroup.search(group_name))
            self.usergroup.delete(group_name, True)
            self.assertIsNotNone(
                self.usergroup.wait_until_element(
                    common_locators["notif.success"]))
            self.assertIsNone(self.usergroup.search(group_name))
            self.assertIsNotNone(
                self.user.search(name=user_name, search_key="login"))

    @skip_if_bug_open('bugzilla', 1142588)
    @data({
        'name': gen_string("alpha", 6),
        'new_name': gen_string("alpha", 6)
    }, {
        'name': gen_string("alphanumeric", 6),
        'new_name': gen_string("alphanumeric", 6)
    }, {
        'name': gen_string("numeric", 6),
        'new_name': gen_string("numeric", 6)
    }, {
        'name': gen_string("utf8", 6),
        'new_name': gen_string("utf8", 6)
    }, {
        'name': gen_string("latin1", 6),
        'new_name': gen_string("latin1", 6)
    })
    def test_update_usergroup(self, test_data):
        """@Test: Update usergroup with name or users

        @Feature: Usergroup - Positive Update

        @Assert: Usergroup is updated

        """
        name = test_data['name']
        new_name = test_data['new_name']
        user_name = gen_string("alpha", 6)
        password = gen_string("alpha", 6)
        # 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))
            self.usergroup.update(name, new_name, users=[user_name])
            self.assertIsNotNone(self.usergroup.search(new_name))
Exemple #11
0
class Repos(UITestCase):
    """Implements Repos tests in UI"""
    @classmethod
    def setUpClass(cls):  # noqa
        org_attrs = entities.Organization().create()
        loc_attrs = entities.Location().create()
        cls.org_name = org_attrs['name']
        cls.org_id = org_attrs['id']
        cls.loc_name = loc_attrs['name']
        cls.loc_id = loc_attrs['id']

        super(Repos, cls).setUpClass()

    def setup_navigate_syncnow(self, session, prd_name, repo_name):
        """Helps with Navigation for syncing via the repos page."""
        strategy1, value1 = locators["repo.select"]
        strategy2, value2 = locators["repo.select_checkbox"]
        session.nav.go_to_select_org(self.org_name)
        session.nav.go_to_products()
        session.nav.wait_until_element((strategy1, value1 % prd_name)).click()
        session.nav.wait_until_element((strategy2, value2 % repo_name)).click()
        session.nav.wait_for_ajax()
        session.nav.wait_until_element(locators["repo.sync_now"]).click()
        session.nav.wait_for_ajax()

    def prd_sync_is_ok(self, repo_name):
        """Asserts whether the sync Result is successful."""
        strategy1, value1 = locators["repo.select_event"]
        self.repository.wait_until_element(
            tab_locators["prd.tab_tasks"]).click()
        self.repository.wait_for_ajax()
        self.repository.wait_until_element(
            (strategy1, value1 % repo_name)).click()
        self.repository.wait_for_ajax()
        timeout = time.time() + 60 * 10
        spinner = self.repository.wait_until_element(
            locators["repo.result_spinner"], 20)
        # Waits until result spinner is visible on the UI or times out
        # after 10mins
        while spinner:
            if time.time() > timeout:
                break
            spinner = self.repository.wait_until_element(
                locators["repo.result_spinner"], 3)
        result = self.repository.wait_until_element(
            locators["repo.result_event"]).text
        return result == 'success'

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_create_repo_1(self, repo_name):
        """@Test: Create repository with minimal input parameters

        @Feature: Content Repos - Positive Create

        @Assert: Repos is created

        """
        # Creates new product
        product_name = entities.Product(
            organization=self.org_id,
            location=self.loc_id,
        ).create()['name']
        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            url=FAKE_1_YUM_REPO)
            self.assertIsNotNone(self.repository.search(repo_name))

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_create_repo_2(self, repo_name):
        """@Test: Create repository in two different orgs with same name

        @Assert: Repos is created

        @Feature: Content Repos - Positive Create

        """
        org_2_name = gen_string("alpha", 10)
        # Creates new product_1
        product_1_name = entities.Product(
            organization=self.org_id,
            location=self.loc_id,
        ).create()['name']

        # Create new product_2 under new organization_2
        org_2_id = entities.Organization(name=org_2_name).create()['id']
        product_2_name = entities.Product(
            organization=org_2_id,
            location=self.loc_id,
        ).create()['name']

        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_1_name,
                            url=FAKE_1_YUM_REPO)
            self.assertIsNotNone(self.repository.search(repo_name))
            make_repository(session,
                            org=org_2_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_2_name,
                            url=FAKE_1_YUM_REPO,
                            force_context=True)
            self.assertIsNotNone(self.repository.search(repo_name))

    @run_only_on('sat')
    def test_create_repo_3(self):
        """@Test: Create a Docker-based repository

        @Feature: Content Repos - Positive Create

        @Assert: Docker-based repo is created.

        """
        # Creates new product
        repo_name = u'busybox'
        product_name = entities.Product(
            organization=self.org_id,
            location=self.loc_id,
        ).create()['name']
        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            repo_type=REPO_TYPE['docker'],
                            url=DOCKER_REGISTRY_HUB)
            self.assertIsNotNone(self.repository.search(repo_name))

    @run_only_on('sat')
    @skip_if_bug_open('bugzilla', 1167837)
    def test_create_repo_4(self):
        """@Test: Create and sync a Docker-based repository

        @Feature: Content Repos - Positive Create

        @Assert: Docker-based repo is created and synchronized.

        """
        # Creates new product
        repo_name = u'busybox'
        product_name = entities.Product(
            organization=self.org_id,
            location=self.loc_id,
        ).create()['name']
        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            repo_type=REPO_TYPE['docker'],
                            url=DOCKER_REGISTRY_HUB)
            self.assertIsNotNone(self.repository.search(repo_name))
            # Synchronize it
            self.navigator.go_to_sync_status()
            synced = self.sync.sync_custom_repos(product_name, [repo_name])
            self.assertTrue(synced)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_create_repo_5(self, repo_name):
        """@Test: Create repository with checksum type as sha256.

        @Feature: Content Repos - Positive Create

        @Assert: Repos is created with checksum type as sha256.

        """
        locator = locators['repo.fetch_checksum']
        checksum = CHECKSUM_TYPE[u'sha256']
        # Creates new product
        product_name = entities.Product(
            organization=self.org_id,
            location=self.loc_id,
        ).create()['name']
        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            url=FAKE_1_YUM_REPO,
                            repo_checksum=checksum)
            self.repository.search(repo_name).click()
            self.repository.wait_for_ajax()
            checksum_text = session.nav.wait_until_element(locator).text
            self.assertEqual(checksum_text, checksum)

    @run_only_on('sat')
    @data("", "   ")
    def test_negative_create_1(self, repo_name):
        """@Test: Create repository with blank and whitespace in name

        @Feature: Content Repos - Negative Create zero length

        @Assert: Repos is not created

        """
        # Creates new product
        product_name = entities.Product(organization=self.org_id,
                                        location=self.loc_id).create()['name']

        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            url=FAKE_1_YUM_REPO)
            invalid = self.products.wait_until_element(
                common_locators["common_invalid"])
            self.assertIsNotNone(invalid)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_negative_create_2(self, repo_name):
        """@Test: Create repository with same name

        @Feature: Content Repos - Negative Create with same name

        @Assert: Repos is not created

        """
        # Creates new product
        product_name = entities.Product(organization=self.org_id,
                                        location=self.loc_id).create()['name']

        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            url=FAKE_1_YUM_REPO)
            self.assertIsNotNone(self.repository.search(repo_name))
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            url=FAKE_1_YUM_REPO)
            invalid = self.products.wait_until_element(
                common_locators["common_invalid"])
            self.assertTrue(invalid)

    @run_only_on('sat')
    @data(*generate_strings_list(len1=256))
    def test_negative_create_3(self, repo_name):
        """@Test: Create content repository with 256 characters in name

        @Feature: Content Repos - Negative Create

        @Assert: Repos is not created

        """
        # Creates new product
        product_name = entities.Product(organization=self.org_id,
                                        location=self.loc_id).create()['name']

        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            url=FAKE_1_YUM_REPO)
            error = self.repository.wait_until_element(
                common_locators["common_haserror"])
            self.assertTrue(error)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_positive_update_1(self, repo_name):
        """@Test: Update content repository with new URL

        @Feature: Content Repo - Positive Update

        @Assert: Repo is updated with new url

        """
        locator = locators["repo.fetch_url"]
        # Creates new product
        product_name = entities.Product(organization=self.org_id,
                                        location=self.loc_id).create()['name']

        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            url=FAKE_1_YUM_REPO)
            self.assertIsNotNone(self.repository.search(repo_name))
            self.repository.search(repo_name).click()
            self.repository.wait_for_ajax()
            url_text = self.repository.wait_until_element(locator).text
            self.assertEqual(url_text, FAKE_1_YUM_REPO)
            self.navigator.go_to_products()
            self.products.search(product_name).click()
            self.repository.update(repo_name, new_url=FAKE_2_YUM_REPO)
            url_text = self.repository.wait_until_element(locator).text
            self.assertEqual(url_text, FAKE_2_YUM_REPO)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_positive_update_2(self, repo_name):
        """@Test: Update content repository with new gpg-key

        @Feature: Content Repo - Positive Update

        @Assert: Repo is updated with new gpg key

        """
        key_1_content = read_data_file(VALID_GPG_KEY_FILE)
        key_2_content = read_data_file(VALID_GPG_KEY_BETA_FILE)
        locator = locators["repo.fetch_gpgkey"]
        # Create two new GPGKey's
        gpgkey_1_name = entities.GPGKey(content=key_1_content,
                                        organization=self.org_id,
                                        location=self.loc_id).create()['name']
        gpgkey_2_name = entities.GPGKey(content=key_2_content,
                                        organization=self.org_id,
                                        location=self.loc_id).create()['name']

        # Creates new product
        product_name = entities.Product(organization=self.org_id,
                                        location=self.loc_id).create()['name']

        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            url=FAKE_1_YUM_REPO,
                            gpg_key=gpgkey_1_name)
            self.assertIsNotNone(self.repository.search(repo_name))
            self.repository.search(repo_name).click()
            self.repository.wait_for_ajax()
            gpgkey_1_text = self.repository.wait_until_element(locator).text
            self.assertEqual(gpgkey_1_text, gpgkey_1_name)
            self.navigator.go_to_products()
            self.products.search(product_name).click()
            self.repository.update(repo_name, new_gpg_key=gpgkey_2_name)
            gpgkey_2_text = self.repository.wait_until_element(locator).text
            self.assertEqual(gpgkey_2_text, gpgkey_2_name)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_positive_update_3(self, repo_name):
        """@Test: Update content repository with new checksum type

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

        @Assert: Repo is updated with new checksum type.

        """
        locator = locators["repo.fetch_checksum"]
        checksum_default = CHECKSUM_TYPE['default']
        checksum_update = CHECKSUM_TYPE['sha1']
        # Creates new product
        product_name = entities.Product(organization=self.org_id,
                                        location=self.loc_id).create()['name']

        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            url=FAKE_1_YUM_REPO)
            self.assertIsNotNone(self.repository.search(repo_name))
            self.repository.search(repo_name).click()
            self.repository.wait_for_ajax()
            checksum_text = self.repository.wait_until_element(locator).text
            self.assertEqual(checksum_text, checksum_default)
            self.navigator.go_to_products()
            self.products.search(product_name).click()
            self.repository.update(repo_name,
                                   new_repo_checksum=checksum_update)
            checksum_text = self.repository.wait_until_element(locator).text
            self.assertEqual(checksum_text, checksum_update)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_remove_repo(self, repo_name):
        """@Test: Create content repository and remove it

        @Feature: Content Repos - Positive Delete

        @Assert: Repos is Deleted

        """
        # Creates new product
        product_name = entities.Product(organization=self.org_id,
                                        location=self.loc_id).create()['name']

        with Session(self.browser) as session:
            make_repository(session,
                            org=self.org_name,
                            loc=self.loc_name,
                            name=repo_name,
                            product=product_name,
                            url=FAKE_1_YUM_REPO)
            self.assertIsNotNone(self.repository.search(repo_name))
            self.repository.delete(repo_name)
            self.assertIsNone(self.repository.search(repo_name))

    @run_only_on('sat')
    def test_discover_repo_1(self):
        """@Test: Create repository via repo-discovery under existing product

        @Feature: Content Repos - Discover repo via http URL

        @Assert: Repos is discovered and created

        """
        discovered_urls = "fakerepo01/"

        product_name = entities.Product(organization=self.org_id,
                                        location=self.loc_id).create()['name']

        with Session(self.browser) as session:
            session.nav.go_to_select_org(self.org_name)
            session.nav.go_to_products()
            self.repository.discover_repo(url_to_discover=REPO_DISCOVERY_URL,
                                          discovered_urls=[discovered_urls],
                                          product=product_name)

    @run_only_on('sat')
    def test_discover_repo_2(self):
        """@Test: Create repository via repo discovery under new product

        @Feature: Content Repos - Discover repo via http URL

        @Assert: Repos is discovered and created

        """
        product_name = gen_string("alpha", 8)
        discovered_urls = "fakerepo01/"
        with Session(self.browser) as session:
            session.nav.go_to_select_org(self.org_name)
            session.nav.go_to_select_loc(self.loc_name)
            session.nav.go_to_products()
            self.repository.discover_repo(url_to_discover=REPO_DISCOVERY_URL,
                                          discovered_urls=[discovered_urls],
                                          product=product_name,
                                          new_product=True)
            self.assertIsNotNone(self.products.search(product_name))

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_syncnow_custom_repos_1(self, repository_name):
        """@Test: Create Custom yum repos and sync it via the repos page.

        @Feature: Custom yum Repos - Sync via repos page

        @Assert: Whether Sync is successful

        """
        # Creates new product
        product_attrs = entities.Product(organization=self.org_id).create()
        # Creates new repository
        entities.Repository(name=repository_name,
                            url=FAKE_1_YUM_REPO,
                            product=product_attrs['id']).create()
        with Session(self.browser) as session:
            self.setup_navigate_syncnow(session, product_attrs['name'],
                                        repository_name)
            # prd_sync_is_ok returns boolean values and not objects
            self.assertTrue(self.prd_sync_is_ok(repository_name))

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_syncnow_custom_repos_2(self, repository_name):
        """@Test: Create Custom puppet repos and sync it via the repos page.

        @Feature: Custom puppet Repos - Sync via repos page

        @Assert: Whether Sync is successful

        """
        # Creates new product
        product_attrs = entities.Product(organization=self.org_id).create()
        # Creates new puppet repository
        entities.Repository(
            name=repository_name,
            url=FAKE_0_PUPPET_REPO,
            product=product_attrs['id'],
            content_type=REPO_TYPE['puppet'],
        ).create()
        with Session(self.browser) as session:
            self.setup_navigate_syncnow(session, product_attrs['name'],
                                        repository_name)
            # prd_sync_is_ok returns boolean values and not objects
            self.assertTrue(self.prd_sync_is_ok(repository_name))

    @run_only_on('sat')
    @skip_if_bug_open('bugzilla', 1167837)
    @data(
        gen_string('alpha', 8).lower(), gen_string('numeric', 8),
        gen_string('alphanumeric', 8).lower(), gen_string('html', 8),
        gen_string('utf8', 8))
    def test_syncnow_custom_repos_3(self, repository_name):
        """@Test: Create Custom docker repos and sync it via the repos page.

        @Feature: Custom docker Repos - Sync via repos page

        @Assert: Whether Sync is successful

        """
        # Creates new product
        product_attrs = entities.Product(organization=self.org_id).create()
        # Creates new puppet repository
        entities.Repository(
            name=repository_name,
            url=DOCKER_REGISTRY_HUB,
            product=product_attrs['id'],
            content_type=REPO_TYPE['docker'],
        ).create()
        with Session(self.browser) as session:
            self.setup_navigate_syncnow(session, product_attrs['name'],
                                        repository_name)
            # prd_sync_is_ok returns boolean values and not objects
            self.assertTrue(self.prd_sync_is_ok(repository_name))
Exemple #12
0
class Subnet(UITestCase):
    """Implements Subnet tests in UI"""
    @data(*generate_strings_list(len1=8))
    def test_create_subnet_1(self, name):
        """@Test: Create new subnet

        @Feature: Subnet - Positive Create

        @Assert: Subnet is created

        """
        network = gen_ipaddr(ip3=True)
        mask = gen_netmask()
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask)
            self.assertIsNotNone(self.subnet.search_subnet(subnet_name=name))

    @skip_if_bug_open('bugzilla', 1123815)
    @data({'name': gen_string('alphanumeric', 255)},
          {'name': gen_string('alpha', 255)},
          {'name': gen_string('numeric', 255)},
          {'name': gen_string('latin1', 255)}, {
              'name': gen_string('utf8', 255),
              u'bz-bug': 1180066
          })
    def test_create_subnet_2(self, test_data):
        """@Test: Create new subnet with 255 characters in name

        @Feature: Subnet - Positive Create

        @Assert: Subnet is created with 255 chars

        """
        bug_id = test_data.pop('bz-bug', None)
        if bug_id is not None and bz_bug_is_open(bug_id):
            self.skipTest('Bugzilla bug {0} is open.'.format(bug_id))

        network = gen_ipaddr(ip3=True)
        mask = gen_netmask()
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=test_data['name'],
                        subnet_network=network,
                        subnet_mask=mask)
            self.assertIsNotNone(
                self.subnet.search_subnet(subnet_name=test_data['name']))

    def test_create_subnet_3(self):
        """@Test: Create new subnet and associate domain with it

        @Feature: Subnet - Positive Create

        @Assert: Subnet is created with domain associated

        """
        strategy1, value1 = common_locators["entity_deselect"]
        strategy2, value2 = common_locators["entity_checkbox"]
        name = gen_string("alpha", 4)
        network = gen_ipaddr(ip3=True)
        mask = gen_netmask()
        domain_name = entities.Domain().create()['name']
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask,
                        domains=[domain_name])
            self.assertIsNotNone(self.subnet.search_subnet(subnet_name=name))
            session.nav.search_entity(name,
                                      locators['subnet.display_name']).click()
            session.nav.wait_until_element(
                tab_locators["subnet.tab_domain"]).click()
            element = session.nav.wait_until_element(
                (strategy1, value1 % domain_name))
            checkbox_element = session.nav.wait_until_element(
                (strategy2, value2 % domain_name))
            # Depending upon the number of domains either, checkbox or
            # selection list appears.
            if element:
                self.assertIsNotNone(element)
            elif checkbox_element:
                self.assertTrue(checkbox_element.is_selected())
            else:
                self.assertIsNotNone()

    @skip_if_bug_open('bugzilla', 1123815)
    @data(*generate_strings_list(len1=256))
    def test_create_subnet_negative_1(self, name):
        """@Test: Create new subnet with 256 characters in name

        @Feature: Subnet - Negative Create

        @Assert: Subnet is not created with 256 chars

        """
        locator = common_locators["haserror"]
        network = gen_ipaddr(ip3=True)
        mask = gen_netmask()
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask)
            error_element = session.nav.wait_until_element(locator)
            self.assertIsNotNone(error_element)

    @data("", " ")
    def test_create_subnet_negative_2(self, name):
        """@Test: Create new subnet with whitespace and blank in name.

        @Feature: Subnet - Negative Create.

        @Assert: Subnet is not created.

        """
        locator = common_locators["haserror"]
        network = gen_ipaddr(ip3=True)
        mask = gen_netmask()
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask)
            error_element = session.nav.wait_until_element(locator)
            self.assertIsNotNone(error_element)

    def test_create_subnet_negative_4(self):
        """@Test: Create new subnet with negative values

        @Feature: Subnet - Negative Create.

        @Assert: Subnet is not created with negative values

        """
        name = gen_string("alpha", 8)
        network = "292.256.256.0"
        mask = "292.292.292.0"
        gateway = "292.256.256.254"
        primarydns = "292.256.256.2"
        secondarydns = "292.256.256.3"
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask,
                        subnet_gateway=gateway,
                        subnet_primarydns=primarydns,
                        subnet_secondarydns=secondarydns)
            network_element = session.nav.wait_until_element(
                locators["subnet.network_haserror"])
            mask_element = session.nav.wait_until_element(
                locators["subnet.mask_haserror"])
            gateway_element = session.nav.wait_until_element(
                locators["subnet.gateway_haserror"])
            primarydns_element = session.nav.wait_until_element(
                locators["subnet.dnsprimary_haserror"])
            secondarydns_element = session.nav.wait_until_element(
                locators["subnet.dnssecondary_haserror"])
            self.assertIsNotNone(network_element)
            self.assertIsNotNone(mask_element)
            self.assertIsNotNone(gateway_element)
            self.assertIsNotNone(primarydns_element)
            self.assertIsNotNone(secondarydns_element)

    @data(*generate_strings_list(len1=8))
    def test_remove_subnet_1(self, name):
        """@Test: Delete a subnet

        @Feature: Subnet - Positive Delete

        @Assert: Subnet is deleted

        """
        network = gen_ipaddr(ip3=True)
        mask = gen_netmask()
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask)
            self.subnet.delete(name, True)
            self.assertIsNone(
                self.subnet.search_subnet(subnet_name=name, timeout=5))

    @data(*generate_strings_list(len1=8))
    def test_remove_subnet_2(self, name):
        """@Test: Delete subnet.

        Attempt to delete subnet but cancel in the confirmation dialog box.

        @Feature: Subnet - Negative Delete

        @Assert: Subnet is not deleted

        """
        network = gen_ipaddr(ip3=True)
        mask = gen_netmask()
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask)
            self.subnet.delete(name, False)
            self.assertIsNotNone(
                self.subnet.search_subnet(subnet_name=name, timeout=5))

    @data(*generate_strings_list(len1=8))
    def test_update_subnet_1(self, name):
        """@Test: Update Subnet name

        @Feature: Subnet - Positive Update

        @Assert: Subnet name is updated

        """
        network = gen_ipaddr(ip3=True)
        mask = gen_netmask()
        new_name = gen_string("alpha", 10)
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask)
            self.subnet.update(name, new_subnet_name=new_name)
            result_object = self.subnet.search_subnet(new_name)
            self.assertEqual(new_name, result_object['name'])

    @data(*generate_strings_list(len1=8))
    def test_update_subnet_2(self, name):
        """@Test: Update Subnet network

        @Feature: Subnet - Positive Update

        @Assert: Subnet network is updated

        """
        network = gen_ipaddr(ip3=True)
        mask = gen_netmask()
        new_network = gen_ipaddr(ip3=True)
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask)
            self.subnet.update(name, new_subnet_network=new_network)
            result_object = self.subnet.search_subnet(name)
            self.assertEqual(new_network, result_object['network'])

    @data(*generate_strings_list(len1=8))
    def test_update_subnet_3(self, name):
        """@Test: Update Subnet mask

        @Feature: Subnet - Positive Update

        @Assert: Subnet mask is updated

        """
        network = gen_ipaddr(ip3=True)
        mask = gen_netmask(1, 15)
        new_mask = gen_netmask(16, 31)
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask)
            self.subnet.update(name, new_subnet_mask=new_mask)
            result_object = self.subnet.search_subnet(name)
            self.assertEqual(new_mask, result_object['mask'])

    @data(*generate_strings_list(len1=8))
    def test_search_subnet_1(self, name):
        """@Test: Search Subnet with Subnet name

        @Feature: Subnet - Positive Search

        @Assert: Subnet is found

        """
        network = gen_ipaddr(ip3=True)
        mask = gen_netmask()
        with Session(self.browser) as session:
            make_subnet(session,
                        subnet_name=name,
                        subnet_network=network,
                        subnet_mask=mask)
            result_object = self.subnet.search_subnet(name)
            self.assertEqual(name, result_object['name'])
            self.assertEqual(network, result_object['network'])
            self.assertEqual(mask, result_object['mask'])
    def test_end_to_end(self):
        """@Test: Perform end to end smoke tests using RH repos.

        1. Create new organization and environment
        2. Upload manifest
        3. Sync a RedHat repository
        4. Create content-view
        5. Add repository to contet-view
        6. Promote/publish content-view
        7. Create an activation-key
        8. Add product to activation-key
        9. Create new virtualmachine
        10. Pull rpm from Foreman server and install on client
        11. Register client with foreman server using activation-key
        12. Install rpm on client

        @Feature: Smoke test

        @Assert: All tests should succeed and Content should be successfully
        fetched by client

        """
        # Product, RepoSet and repository variables
        rhel_product_name = 'Red Hat Enterprise Linux Server'
        rhel_repo_set = (
            'Red Hat Enterprise Virtualization Agents '
            'for RHEL 6 Server (RPMs)'
        )
        rhel_repo_name = (
            'Red Hat Enterprise Virtualization Agents '
            'for RHEL 6 Server '
            'RPMs x86_64 6Server'
        )
        org_name = random.choice(generate_strings_list())
        # Create new org and environment
        new_org = make_org({u'name': org_name})
        new_env = make_lifecycle_environment({
            u'organization-id': new_org['id'],
            u'name': gen_alphanumeric(),
        })
        # Clone manifest and upload it
        manifest = manifests.clone()
        upload_file(manifest, remote_file=manifest)
        result = Subscription.upload({
            u'file': manifest,
            u'organization-id': new_org['id'],
        })
        self.assertEqual(
            result.return_code, 0,
            "Failed to upload manifest: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Enable repo from Repository Set
        result = RepositorySet.enable({
            u'name': rhel_repo_set,
            u'organization-id': new_org['id'],
            u'product': rhel_product_name,
            u'releasever': '6Server',
            u'basearch': 'x86_64',
        })
        self.assertEqual(
            result.return_code, 0,
            "Repo was not enabled: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Fetch repository info
        result = Repository.info({
            u'name': rhel_repo_name,
            u'product': rhel_product_name,
            u'organization-id': new_org['id'],
        })
        rhel_repo = result.stdout
        # Synchronize the repository
        result = Repository.synchronize({
            u'name': rhel_repo_name,
            u'organization-id': new_org['id'],
            u'product': rhel_product_name,
        })
        self.assertEqual(
            result.return_code, 0,
            "Repo was not synchronized: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Create CV and associate repo to it
        new_cv = make_content_view({u'organization-id': new_org['id']})
        result = ContentView.add_repository({
            u'id': new_cv['id'],
            u'repository-id': rhel_repo['id'],
            u'organization-id': new_org['id'],
        })
        self.assertEqual(
            result.return_code, 0,
            "Failed repository association: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Publish a version1 of CV
        result = ContentView.publish({u'id': new_cv['id']})
        self.assertEqual(
            result.return_code, 0,
            "Version1 publishing failed: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Get the CV info
        result = ContentView.info({u'id': new_cv['id']})
        self.assertEqual(
            result.return_code, 0,
            "ContentView was not found: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Store the version1 id
        version1_id = result.stdout['versions'][0]['id']
        # Promotion of version1 to next env
        result = ContentView.version_promote({
            u'id': version1_id,
            u'to-lifecycle-environment-id': new_env['id'],
        })
        self.assertEqual(
            result.return_code, 0,
            "version1 promotion failed: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Create activation key
        activation_key = make_activation_key({
            u'name': gen_alphanumeric(),
            u'lifecycle-environment-id': new_env['id'],
            u'organization-id': new_org['id'],
            u'content-view': new_cv['name'],
        })
        # List the subscriptions in given org
        result = Subscription.list(
            {u'organization-id': new_org['id']},
            per_page=False
        )
        self.assertEqual(
            result.return_code, 0,
            "Failed to list subscriptions: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Get the subscription ID from subscriptions list
        for subscription in result.stdout:
            if subscription['name'] == "Red Hat Employee Subscription":
                subscription_id = subscription['id']
                subscription_quantity = int(subscription['quantity'])
        self.assertGreater(
            int(subscription_quantity), 0,
            'Unexpected subscription quantity {0}'
            .format(subscription_quantity)
        )
        # Add the subscriptions to activation-key
        result = ActivationKey.add_subscription({
            u'id': activation_key['id'],
            u'subscription-id': subscription_id,
            u'quantity': 1,
        })
        self.assertEqual(
            result.return_code, 0,
            "Failed to add subscription: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Create VM
        package_name = "python-kitchen"
        server_name = conf.properties['main.server.hostname']
        with VirtualMachine(distro='rhel65') as vm:
            # Download and Install rpm
            result = vm.run(
                "wget -nd -r -l1 --no-parent -A '*.noarch.rpm' http://{0}/pub/"
                .format(server_name)
            )
            self.assertEqual(
                result.return_code, 0,
                "failed to fetch katello-ca rpm: {0}, return code: {1}"
                .format(result.stderr, result.return_code)
            )
            result = vm.run(
                'rpm -i katello-ca-consumer*.noarch.rpm'
            )
            self.assertEqual(
                result.return_code, 0,
                "failed to install katello-ca rpm: {0} and return code: {1}"
                .format(result.stderr, result.return_code)
            )
            # Register client with foreman server using activation-key
            result = vm.run(
                u'subscription-manager register --activationkey {0} '
                '--org {1} --force'
                .format(activation_key['name'], new_org['label'])
            )
            self.assertEqual(
                result.return_code, 0,
                "failed to register client:: {0} and return code: {1}"
                .format(result.stderr, result.return_code)
            )
            # Install contents from sat6 server
            result = vm.run('yum install -y {0}'.format(package_name))
            self.assertEqual(
                result.return_code, 0,
                "Package install failed: {0} and return code: {1}"
                .format(result.stderr, result.return_code)
            )
            # Verify if package is installed by query it
            result = vm.run('rpm -q {0}'.format(package_name))
            self.assertIn(package_name, result.stdout[0])
class ComputeResource(UITestCase):
    """Implements Compute Resource tests in UI"""
    @data(*generate_strings_list(len1=8))
    def test_create_resource_1(self, name):
        """@Test: Create a new libvirt Compute Resource

        @Feature: Compute Resource - Create

        @Assert: A libvirt Compute Resource is created

        """
        libvirt_url = "qemu+tcp://%s:16509/system"
        provider_type = FOREMAN_PROVIDERS['libvirt']
        url = (libvirt_url % conf.properties['main.server.hostname'])
        with Session(self.browser) as session:
            make_resource(session,
                          name=name,
                          provider_type=provider_type,
                          url=url)
            search = self.compute_resource.search(name)
            self.assertIsNotNone(search)

    @data(gen_string('alphanumeric', 255), gen_string('alpha', 255),
          gen_string('numeric', 255), gen_string('latin1', 255),
          gen_string('utf8', 255))
    def test_create_resource_2(self, name):
        """@Test: Create a new libvirt Compute Resource with 255 char name

        @Feature: Compute Resource - Create

        @Assert: A libvirt Compute Resource is created

        """
        libvirt_url = "qemu+tcp://%s:16509/system"
        provider_type = FOREMAN_PROVIDERS['libvirt']
        url = (libvirt_url % conf.properties['main.server.hostname'])
        with Session(self.browser) as session:
            make_resource(session,
                          name=name,
                          provider_type=provider_type,
                          url=url)
            search = self.compute_resource.search(name)
            self.assertIsNotNone(search)

    @data(gen_string('alphanumeric', 255), gen_string('alpha', 255),
          gen_string('numeric', 255), gen_string('latin1', 255),
          gen_string('utf8', 255))
    def test_create_resource_3(self, description):
        """@Test: Create libvirt Compute Resource with 255 char description.

        @Feature: Compute Resource - Create with long description.

        @Assert: A libvirt Compute Resource is not created with 255 char
        description.

        """
        name = gen_string("alpha", 8)
        libvirt_url = "qemu+tcp://%s:16509/system"
        provider_type = FOREMAN_PROVIDERS['libvirt']
        url = (libvirt_url % conf.properties['main.server.hostname'])
        with Session(self.browser) as session:
            make_resource(session,
                          name=name,
                          description=description,
                          provider_type=provider_type,
                          url=url)
            search = self.compute_resource.search(name)
            self.assertIsNotNone(search)

    @data(*generate_strings_list(len1=256))
    def test_create_resource_negative_1(self, name):
        """@Test: Create a new libvirt Compute Resource with 256 char name

        @Feature: Compute Resource - Create

        @Assert: A libvirt Compute Resource is not created

        """
        libvirt_url = "qemu+tcp://%s:16509/system"
        provider_type = FOREMAN_PROVIDERS['libvirt']
        url = (libvirt_url % conf.properties['main.server.hostname'])
        with Session(self.browser) as session:
            make_resource(session,
                          name=name,
                          provider_type=provider_type,
                          url=url)
            self.assertIsNotNone(
                self.compute_resource.wait_until_element(
                    common_locators["name_haserror"]))

    @data(*generate_strings_list(len1=256))
    def test_create_resource_negative_2(self, description):
        """@Test: Create libvirt Compute Resource with 256 char description.

        @Feature: Compute Resource - Create with long description.

        @Assert: A libvirt Compute Resource is not created with 256 char
        description.

        """
        name = gen_string("alpha", 8)
        libvirt_url = "qemu+tcp://%s:16509/system"
        provider_type = FOREMAN_PROVIDERS['libvirt']
        url = (libvirt_url % conf.properties['main.server.hostname'])
        with Session(self.browser) as session:
            make_resource(session,
                          name=name,
                          description=description,
                          provider_type=provider_type,
                          url=url)
            error_element = session.nav.wait_until_element(
                common_locators["haserror"])
            self.assertIsNotNone(error_element)

    @data("", "  ")
    def test_create_resource_negative_3(self, name):
        """@Test: Create a new libvirt Compute Resource with whitespace

        @Feature: Compute Resource - Create

        @Assert: A libvirt Compute Resource is not created

        """
        libvirt_url = "qemu+tcp://%s:16509/system"
        provider_type = FOREMAN_PROVIDERS['libvirt']
        url = (libvirt_url % conf.properties['main.server.hostname'])
        with Session(self.browser) as session:
            make_resource(session,
                          name=name,
                          provider_type=provider_type,
                          url=url)
            error_element = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error_element)

    @data({
        'name': gen_string('alpha'),
        'newname': gen_string('alpha')
    }, {
        'name': gen_string('numeric'),
        'newname': gen_string('numeric')
    }, {
        'name': gen_string('alphanumeric'),
        'newname': gen_string('alphanumeric')
    }, {
        'name': gen_string('utf8'),
        'newname': gen_string('utf8')
    }, {
        'name': gen_string('latin1'),
        'newname': gen_string('latin1')
    }, {
        'name': gen_string('html'),
        'newname': gen_string('html')
    })
    def test_update_resource(self, testdata):
        """@Test: Update a libvirt Compute Resource's Organization

        @Feature: Compute Resource - Update

        @Assert: The libvirt Compute Resource is updated

        """
        name = testdata['name']
        newname = testdata['newname']
        org_name1 = entities.Organization(
            name=gen_string("alpha", 8)).create_json()['name']
        org_name2 = entities.Organization(
            name=gen_string("alpha", 8)).create_json()['name']
        libvirt_url = "qemu+tcp://%s:16509/system"
        provider_type = FOREMAN_PROVIDERS['libvirt']
        url = (libvirt_url % conf.properties['main.server.hostname'])
        with Session(self.browser) as session:
            make_resource(session,
                          name=name,
                          orgs=[org_name1],
                          provider_type=provider_type,
                          url=url,
                          org_select=True)
            search = self.compute_resource.search(name)
            self.assertIsNotNone(search)
            self.compute_resource.update(name,
                                         newname, [org_name1], [org_name2],
                                         libvirt_set_passwd=False)
            search = self.compute_resource.search(newname)
            self.assertIsNotNone(search)

    @data(*generate_strings_list(len1=8))
    def test_remove_resource(self, name):
        """@Test: Delete a Compute Resource

        @Feature: Compute Resource - Delete

        @Assert: The Compute Resource is deleted

        """
        libvirt_url = "qemu+tcp://%s:16509/system"
        provider_type = FOREMAN_PROVIDERS['libvirt']
        url = (libvirt_url % conf.properties['main.server.hostname'])
        with Session(self.browser) as session:
            make_resource(session,
                          name=name,
                          provider_type=provider_type,
                          url=url)
            search = self.compute_resource.search(name)
            self.assertIsNotNone(search)
            self.compute_resource.delete(name, really=True)
            self.assertIsNone(self.compute_resource.search(name))
Exemple #15
0
    def test_end_to_end(self):
        """@Test: Perform end to end smoke tests using RH repos.

        1. Create new organization and environment
        2. Upload manifest
        3. Sync a RedHat repository
        4. Create content-view
        5. Add repository to contet-view
        6. Promote/publish content-view
        7. Create an activation-key
        8. Add product to activation-key
        9. Create new virtualmachine
        10. Pull rpm from Foreman server and install on client
        11. Register client with foreman server using activation-key
        12. Install rpm on client

        @Feature: Smoke test

        @Assert: All tests should succeed and Content should be successfully
        fetched by client

        """
        # Product, RepoSet and repository variables
        rhel_product_name = 'Red Hat Enterprise Linux Server'
        rhel_repo_set = (
            'Red Hat Enterprise Virtualization Agents '
            'for RHEL 6 Server (RPMs)'
        )
        rhel_repo_name = (
            'Red Hat Enterprise Virtualization Agents '
            'for RHEL 6 Server '
            'RPMs x86_64 6Server'
        )
        org_name = random.choice(generate_strings_list())
        # Create new org and environment
        new_org = make_org({u'name': org_name})
        new_env = make_lifecycle_environment({
            u'organization-id': new_org['id'],
            u'name': gen_alphanumeric(),
        })
        # Clone manifest and upload it
        manifest = manifests.clone()
        upload_file(manifest, remote_file=manifest)
        result = Subscription.upload({
            u'file': manifest,
            u'organization-id': new_org['id'],
        })
        self.assertEqual(
            result.return_code, 0,
            "Failed to upload manifest: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Enable repo from Repository Set
        result = RepositorySet.enable({
            u'name': rhel_repo_set,
            u'organization-id': new_org['id'],
            u'product': rhel_product_name,
            u'releasever': '6Server',
            u'basearch': 'x86_64',
        })
        self.assertEqual(
            result.return_code, 0,
            "Repo was not enabled: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Fetch repository info
        result = Repository.info({
            u'name': rhel_repo_name,
            u'product': rhel_product_name,
            u'organization-id': new_org['id'],
        })
        rhel_repo = result.stdout
        # Synchronize the repository
        result = Repository.synchronize({
            u'name': rhel_repo_name,
            u'organization-id': new_org['id'],
            u'product': rhel_product_name,
        })
        self.assertEqual(
            result.return_code, 0,
            "Repo was not synchronized: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Create CV and associate repo to it
        new_cv = make_content_view({u'organization-id': new_org['id']})
        result = ContentView.add_repository({
            u'id': new_cv['id'],
            u'repository-id': rhel_repo['id'],
            u'organization-id': new_org['id'],
        })
        self.assertEqual(
            result.return_code, 0,
            "Failed repository association: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Publish a version1 of CV
        result = ContentView.publish({u'id': new_cv['id']})
        self.assertEqual(
            result.return_code, 0,
            "Version1 publishing failed: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Get the CV info
        result = ContentView.info({u'id': new_cv['id']})
        self.assertEqual(
            result.return_code, 0,
            "ContentView was not found: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Store the version1 id
        version1_id = result.stdout['versions'][0]['id']
        # Promotion of version1 to next env
        result = ContentView.version_promote({
            u'id': version1_id,
            u'to-lifecycle-environment-id': new_env['id'],
        })
        self.assertEqual(
            result.return_code, 0,
            "version1 promotion failed: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Create activation key
        activation_key = make_activation_key({
            u'name': gen_alphanumeric(),
            u'lifecycle-environment-id': new_env['id'],
            u'organization-id': new_org['id'],
            u'content-view': new_cv['name'],
        })
        # List the subscriptions in given org
        result = Subscription.list(
            {u'organization-id': new_org['id']},
            per_page=False
        )
        self.assertEqual(
            result.return_code, 0,
            "Failed to list subscriptions: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Get the subscription ID from subscriptions list
        for subscription in result.stdout:
            if subscription['name'] == "Red Hat Employee Subscription":
                subscription_id = subscription['id']
                subscription_quantity = int(subscription['quantity'])
        self.assertGreater(
            int(subscription_quantity), 0,
            'Unexpected subscription quantity {0}'
            .format(subscription_quantity)
        )
        # Add the subscriptions to activation-key
        result = ActivationKey.add_subscription({
            u'id': activation_key['id'],
            u'subscription-id': subscription_id,
            u'quantity': 1,
        })
        self.assertEqual(
            result.return_code, 0,
            "Failed to add subscription: {0} and return code: {1}"
            .format(result.stderr, result.return_code)
        )
        # Create VM
        package_name = "python-kitchen"
        server_name = conf.properties['main.server.hostname']
        with VirtualMachine(distro='rhel66') as vm:
            # Download and Install rpm
            result = vm.run(
                "wget -nd -r -l1 --no-parent -A '*.noarch.rpm' http://{0}/pub/"
                .format(server_name)
            )
            self.assertEqual(
                result.return_code, 0,
                "failed to fetch katello-ca rpm: {0}, return code: {1}"
                .format(result.stderr, result.return_code)
            )
            result = vm.run(
                'rpm -i katello-ca-consumer*.noarch.rpm'
            )
            self.assertEqual(
                result.return_code, 0,
                "failed to install katello-ca rpm: {0} and return code: {1}"
                .format(result.stderr, result.return_code)
            )
            # Register client with foreman server using activation-key
            result = vm.run(
                u'subscription-manager register --activationkey {0} '
                '--org {1} --force'
                .format(activation_key['name'], new_org['label'])
            )
            self.assertEqual(
                result.return_code, 0,
                "failed to register client:: {0} and return code: {1}"
                .format(result.stderr, result.return_code)
            )
            # Enable Red Hat Enterprise Virtualization Agents repo via cli
            # As the below repo is disabled by default under ak's prd-content
            result = vm.run(
                'subscription-manager repos --enable '
                'rhel-6-server-rhev-agent-rpms'
            )
            self.assertEqual(
                result.return_code, 0,
                "Enabling repo failed: {0} and return code: {1}"
                .format(result.stderr, result.return_code)
            )
            # Install contents from sat6 server
            result = vm.run('yum install -y {0}'.format(package_name))
            self.assertEqual(
                result.return_code, 0,
                "Package install failed: {0} and return code: {1}"
                .format(result.stderr, result.return_code)
            )
            # Verify if package is installed by query it
            result = vm.run('rpm -q {0}'.format(package_name))
            self.assertIn(package_name, result.stdout[0])
Exemple #16
0
class PartitionTable(UITestCase):
    """Implements the partition table tests from UI"""
    @data(*generate_strings_list(len1=10))
    def test_positive_create_partition_table(self, name):
        """@Test: Create a new partition table

        @Feature: Partition table - Positive Create

        @Assert: Partition table is created

        """
        layout = read_data_file(PARTITION_SCRIPT_DATA_FILE)
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_partitiontable(session,
                                name=name,
                                layout=layout,
                                os_family=os_family)
            self.assertIsNotNone(self.partitiontable.search(name))

    @data(*generate_strings_list(len1=256))
    def test_negative_create_partition_table_1(self, name):
        """@Test: Create a new partition table with 256 characters in name

        @Feature: Partition table - Negative Create

        @Assert: Partition table is not created

        """
        layout = read_data_file(PARTITION_SCRIPT_DATA_FILE)
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_partitiontable(session,
                                name=name,
                                layout=layout,
                                os_family=os_family)
            self.assertIsNotNone(
                self.partitiontable.wait_until_element(
                    common_locators["name_haserror"]))
            self.assertIsNone(self.partitiontable.search(name))

    @data("", "  ")
    def test_negative_create_partition_table_2(self, name):
        """@Test: Create partition table with blank and whitespace in name

        @Feature: Partition table - Negative Create

        @Assert: Partition table is not created

        """
        layout = read_data_file(PARTITION_SCRIPT_DATA_FILE)
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_partitiontable(session,
                                name=name,
                                layout=layout,
                                os_family=os_family)
            self.assertIsNotNone(
                self.partitiontable.wait_until_element(
                    common_locators["name_haserror"]))

    @data(*generate_strings_list(len1=10))
    def test_negative_create_partition_table_3(self, name):
        """@Test: Create a new partition table with same name

        @Feature: Partition table - Negative Create

        @Assert: Partition table is not created

        """
        layout = read_data_file(PARTITION_SCRIPT_DATA_FILE)
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_partitiontable(session,
                                name=name,
                                layout=layout,
                                os_family=os_family)
            self.assertIsNotNone(self.partitiontable.search(name))
            make_partitiontable(session,
                                name=name,
                                layout=layout,
                                os_family=os_family)
            self.assertIsNotNone(
                self.partitiontable.wait_until_element(
                    common_locators["name_haserror"]))

    @data(*generate_strings_list(len1=10))
    def test_negative_create_partition_table_4(self, name):
        """@Test: Create a new partition table with empty layout

        @Feature: Partition table - Negative Create

        @Assert: Partition table is not created

        """
        layout = ""
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_partitiontable(session,
                                name=name,
                                layout=layout,
                                os_family=os_family)
            self.assertIsNotNone(
                self.partitiontable.wait_until_element(
                    common_locators["haserror"]))
            self.assertIsNone(self.partitiontable.search(name))

    @skip_if_bug_open('bugzilla', 1177591)
    @data(*generate_strings_list(len1=10))
    def test_remove_partition_table(self, name):
        """@Test: Delete a partition table

        @Feature: Partition table - Positive Delete

        @Assert: Partition table is deleted

        """
        layout = "test layout"
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_partitiontable(session,
                                name=name,
                                layout=layout,
                                os_family=os_family)
            self.assertIsNotNone(self.partitiontable.search(name))
            self.partitiontable.delete(name, really=True)
            self.assertIsNotNone(
                self.partitiontable.wait_until_element(
                    common_locators["notif.success"]))
            self.assertIsNone(self.partitiontable.search(name))

    @data({
        u'name': gen_string('alpha'),
        u'new_name': gen_string('alpha')
    }, {
        u'name': gen_string('html'),
        u'new_name': gen_string('html')
    }, {
        u'name': gen_string('utf8'),
        u'new_name': gen_string('utf8')
    }, {
        u'name': gen_string('alphanumeric'),
        u'new_name': gen_string('alphanumeric')
    })
    def test_update_partition_table(self, test_data):
        """@Test: Update partition table with its name, layout and OS family

        @Feature: Partition table - Positive Update

        @Assert: Partition table is updated

        """
        layout = "test layout"
        new_layout = read_data_file(PARTITION_SCRIPT_DATA_FILE)
        os_family = "Debian"
        new_os_family = "Red Hat"
        with Session(self.browser) as session:
            make_partitiontable(session,
                                name=test_data['name'],
                                layout=layout,
                                os_family=os_family)
            self.assertIsNotNone(self.partitiontable.search(test_data['name']))
            self.partitiontable.update(test_data['name'],
                                       test_data['new_name'], new_layout,
                                       new_os_family)
            self.assertIsNotNone(
                self.partitiontable.search(test_data['new_name']))
Exemple #17
0
class Repos(BaseUI):
    """
    Implements Repos tests in UI
    """

    org_name = None

    def setUp(self):
        super(Repos, self).setUp()
        # Make sure to use the Class' org_name instance
        if Repos.org_name is None:
            Repos.org_name = generate_string("alpha", 8)
            with Session(self.browser) as session:
                make_org(session, org_name=Repos.org_name)

    @attr('ui', 'repo', 'implemented')
    @data(*generate_strings_list())
    def test_create_repo(self, repo_name):
        """
        @Feature: Content Repos - Positive Create
        @Test: Create Content Repos with minimal input parameters
        @Assert: Repos is created
        """

        prd_name = generate_string("alpha", 8)
        repo_url = "http://inecas.fedorapeople.org/fakerepos/zoo3/"
        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.repository.create(repo_name, product=prd_name, url=repo_url)
        self.assertIsNotNone(self.repository.search(repo_name))

    def test_negative_create_1(self):
        """
        @Feature: Content Repos - Negative Create zero length
        @Test: Create Content Repos without input parameter
        @Assert: Repos is not created
        """

        locator = common_locators["common_invalid"]
        repo_name = ""
        prd_name = generate_string("alpha", 8)
        repo_url = "http://inecas.fedorapeople.org/fakerepos/zoo3/"
        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.repository.create(repo_name, product=prd_name, url=repo_url)
        invalid = self.products.wait_until_element(locator)
        self.assertTrue(invalid)

    def test_negative_create_2(self):
        """
        @Feature: Content Repos - Negative Create with whitespace
        @Test: Create Content Repos with whitespace input parameter
        @Assert: Repos is not created
        """

        locator = common_locators["common_invalid"]
        repo_name = "   "
        prd_name = generate_string("alpha", 8)
        repo_url = "http://inecas.fedorapeople.org/fakerepos/zoo3/"
        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.repository.create(repo_name, product=prd_name, url=repo_url)
        invalid = self.products.wait_until_element(locator)
        self.assertTrue(invalid)

    @bzbug("1081059")
    @attr('ui', 'repo', 'implemented')
    @data(*generate_strings_list())
    def test_negative_create_3(self, repo_name):
        """
        @Feature: Content Repos - Negative Create with same name
        @Test: Create Content Repos with same name input parameter
        @Assert: Repos is not created
        @BZ: 1081059
        """

        locator = common_locators["common_invalid"]
        prd_name = generate_string("alpha", 8)
        repo_url = "http://inecas.fedorapeople.org/fakerepos/zoo3/"
        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.repository.create(repo_name, product=prd_name, url=repo_url)
        self.assertIsNotNone(self.repository.search(repo_name))
        self.navigator.go_to_products()
        self.repository.create(repo_name, product=prd_name, url=repo_url)
        invalid = self.products.wait_until_element(locator)
        self.assertTrue(invalid)

    @attr('ui', 'repo', 'implemented')
    @data(*generate_strings_list(len1=256))
    def test_negative_create_4(self, repo_name):
        """
        @Feature: Content Repos - Negative Create with same name
        @Test: Create Content Repos with long name input parameter
        @Assert: Repos is not created
        """

        locator = common_locators["common_haserror"]
        prd_name = generate_string("alpha", 8)
        repo_url = "http://inecas.fedorapeople.org/fakerepos/zoo3/"
        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.repository.create(repo_name, product=prd_name, url=repo_url)
        error = self.repository.wait_until_element(locator)
        self.assertTrue(error)

    @attr('ui', 'repo', 'implemented')
    @data(*generate_strings_list())
    def test_positive_update_1(self, repo_name):
        """
        @Feature: Content Repo - Positive Update
        @Test: Update Content Repo with repository url
        @Assert: Repo is updated with new url
        """

        prd_name = generate_string("alpha", 8)
        locator = locators["repo.fetch_url"]
        repo_url = "http://inecas.fedorapeople.org/fakerepos/zoo3/"
        new_repo_url = "http://inecas.fedorapeople.org/fakerepos/zoo2/"
        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.repository.create(repo_name, product=prd_name, url=repo_url)
        self.assertIsNotNone(self.repository.search(repo_name))
        self.repository.search(repo_name).click()
        url_text = self.repository.wait_until_element(locator).text
        self.assertEqual(url_text, repo_url)
        self.navigator.go_to_products()
        self.products.search(prd_name).click()
        self.repository.update(repo_name, new_url=new_repo_url)
        url_text = self.repository.wait_until_element(locator).text
        self.assertEqual(url_text, new_repo_url)

    @attr('ui', 'repo', 'implemented')
    @data(*generate_strings_list())
    def test_positive_update_2(self, repo_name):
        """
        @Feature: Content Repo - Positive Update
        @Test: Update Content Repo with gpg key
        @Assert: Repo is updated with new gpg key
        """

        key_path1 = get_data_file(VALID_GPG_KEY_FILE)
        key_path2 = get_data_file(VALID_GPG_KEY_BETA_FILE)
        prd_name = generate_string("alpha", 8)
        gpgkey_name1 = generate_string("alpha", 8)
        gpgkey_name2 = generate_string("alpha", 8)
        locator = locators["repo.fetch_gpgkey"]
        repo_url = "http://inecas.fedorapeople.org/fakerepos/zoo3/"
        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_gpg_keys()
        self.gpgkey.create(gpgkey_name1, upload_key=True, key_path=key_path1)
        self.assertIsNotNone(self.gpgkey.search(gpgkey_name1))
        self.gpgkey.create(gpgkey_name2, upload_key=True, key_path=key_path2)
        self.assertIsNotNone(self.gpgkey.search(gpgkey_name2))
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.repository.create(repo_name,
                               product=prd_name,
                               url=repo_url,
                               gpg_key=gpgkey_name1)
        self.assertIsNotNone(self.repository.search(repo_name))
        self.repository.search(repo_name).click()
        gpgkey_text1 = self.repository.wait_until_element(locator).text
        self.assertEqual(gpgkey_text1, gpgkey_name1)
        self.navigator.go_to_products()
        self.products.search(prd_name).click()
        self.repository.update(repo_name, new_gpg_key=gpgkey_name2)
        gpgkey_text2 = self.repository.wait_until_element(locator).text
        self.assertEqual(gpgkey_text2, gpgkey_name2)

    @attr('ui', 'repo', 'implemented')
    @data(*generate_strings_list())
    def test_remove_repo(self, repo_name):
        """
        @Feature: Content Repos - Positive Delete
        @Test: Create Content Repos with minimal input parameters
        @Assert: Repos is Deleted
        """

        prd_name = generate_string("alpha", 8)
        repo_url = "http://inecas.fedorapeople.org/fakerepos/zoo3/"
        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.repository.create(repo_name, product=prd_name, url=repo_url)
        self.assertIsNotNone(self.repository.search(repo_name))
        self.repository.delete(repo_name)
        self.assertIsNone(self.repository.search(repo_name))

    def test_discover_repo_1(self):
        """
        @Feature: Content Repos - Discover repo via http URL
        @Test: Create Content Repos via repo discovery under existing
        product
        @Assert: Repos is discovered and created
        """

        prd_name = generate_string("alpha", 8)
        url = "http://omaciel.fedorapeople.org/"
        discovered_urls = ["fakerepo01/"]
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name)
        self.assertIsNotNone(self.products.search(prd_name))
        self.repository.discover_repo(url, discovered_urls, product=prd_name)

    def test_discover_repo_2(self):
        """
        @Feature: Content Repos - Discover repo via http URL
        @Test: Create Content Repos via repo discovery under new
        product
        @Assert: Repos is discovered and created
        """

        prd_name = generate_string("alpha", 8)
        url = "http://omaciel.fedorapeople.org/"
        discovered_urls = ["fakerepo01/"]
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.repository.discover_repo(url,
                                      discovered_urls,
                                      product=prd_name,
                                      new_product=True)
        self.assertIsNotNone(self.products.search(prd_name))
Exemple #18
0
class Architecture(UITestCase):
    """Implements Architecture tests from UI"""
    @data({
        u'name': gen_string('alpha'),
        u'os_name': gen_string('alpha')
    }, {
        u'name': gen_string('html'),
        u'os_name': gen_string('html')
    }, {
        u'name': gen_string('utf8'),
        u'os_name': gen_string('utf8')
    }, {
        u'name': gen_string('alphanumeric'),
        u'os_name': gen_string('alphanumeric')
    })
    def test_positive_create_arch_1(self, test_data):
        """@Test: Create a new Architecture with OS

        @Feature: Architecture - Positive Create

        @Assert: Architecture is created

        """
        entities.OperatingSystem(name=test_data['os_name']).create()
        with Session(self.browser) as session:
            make_arch(session,
                      name=test_data['name'],
                      os_names=[test_data['os_name']])
            self.assertIsNotNone(self.architecture.search(test_data['name']))

    @data(*generate_strings_list(len1=8))
    def test_positive_create_arch_2(self, name):
        """@Test: Create a new Architecture with different data

        @Feature: Architecture - Positive Create

        @Assert: Architecture is created

        """
        with Session(self.browser) as session:
            make_arch(session, name=name)
            self.assertIsNotNone(self.architecture.search(name))

    @data(*generate_strings_list(len1=256))
    def test_negative_create_arch_1(self, name):
        """@Test: Create a new Architecture with 256 characters in name

        @Feature: Architecture - Negative Create

        @Assert: Architecture is not created

        """
        with Session(self.browser) as session:
            make_arch(session, name=name)
            self.assertIsNotNone(
                self.architecture.wait_until_element(
                    common_locators["name_haserror"]))

    @data("", "  ")
    def test_negative_create_arch_2(self, name):
        """@Test: Create a new Architecture with whitespace in name

        @Feature: Architecture - Negative Create

        @Assert: Architecture is not created

        """
        with Session(self.browser) as session:
            make_arch(session, name=name)
            self.assertIsNotNone(
                self.architecture.wait_until_element(
                    common_locators["name_haserror"]))

    @data(*generate_strings_list(len1=6))
    def test_negative_create_arch_4(self, name):
        """@Test: Create a new Architecture with same name

        @Feature: Architecture - Negative Create

        @Assert: Architecture is not created

        """
        with Session(self.browser) as session:
            make_arch(session, name=name)
            self.assertIsNotNone(self.architecture.search(name))
            make_arch(session, name=name)
            self.assertIsNotNone(
                self.architecture.wait_until_element(
                    common_locators["name_haserror"]))

    @skip_if_bug_open('bugzilla', 1123388)
    @data({
        u'name': gen_string('alpha'),
        u'os_name': gen_string('alpha')
    }, {
        u'name': gen_string('html'),
        u'os_name': gen_string('html')
    }, {
        u'name': gen_string('utf8'),
        u'os_name': gen_string('utf8')
    }, {
        u'name': gen_string('alphanumeric'),
        u'os_name': gen_string('alphanumeric')
    })
    def test_remove_arch(self, test_data):
        """@Test: Delete an existing Architecture

        @Feature: Architecture - Delete

        @Assert: Architecture is deleted

        @BZ: 1131815

        """
        entities.OperatingSystem(name=test_data['os_name']).create()
        with Session(self.browser) as session:
            make_arch(session,
                      name=test_data['name'],
                      os_names=[test_data['os_name']])
            self.assertIsNotNone(self.architecture.search(test_data['name']))
            self.architecture.delete(test_data['name'], True)
            self.assertIsNone(self.architecture.search(test_data['name']))

    @skip_if_bug_open('bugzilla', 1123388)
    @data(
        {
            u'old_name': gen_string('alpha'),
            u'new_name': gen_string('alpha'),
            u'os_name': gen_string('alpha')
        }, {
            u'old_name': gen_string('html'),
            u'new_name': gen_string('html'),
            u'os_name': gen_string('html')
        }, {
            u'old_name': gen_string('utf8'),
            u'new_name': gen_string('utf8'),
            u'os_name': gen_string('utf8')
        }, {
            u'old_name': gen_string('alphanumeric'),
            u'new_name': gen_string('alphanumeric'),
            u'os_name': gen_string('alphanumeric')
        })
    def test_update_arch(self, test_data):
        """@Test: Update Architecture with new name and OS

        @Feature: Architecture - Update

        @Assert: Architecture is updated

        """
        entities.OperatingSystem(name=test_data['os_name']).create()
        with Session(self.browser) as session:
            make_arch(session, name=test_data['old_name'])
            self.assertIsNotNone(
                self.architecture.search(test_data['old_name']))
            self.architecture.update(test_data['old_name'],
                                     test_data['new_name'],
                                     new_os_names=[test_data['os_name']])
            self.assertIsNotNone(
                self.architecture.search(test_data['new_name']))
Exemple #19
0
class Org(BaseUI):
    """
    Implements Organization tests in UI
    """

    # Tests for issues

    def test_redmine_4443(self):
        """
        @test: Can auto-complete search for an organization by partial name
        @feature: Organizations
        @assert: Created organization can be auto search by its partial name
        @BZ: redmine #4443
        """

        org_name = generate_string("alpha", 8)
        part_string = org_name[:3]
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(
            self.org.auto_complete_search(part_string,
                                          org_name,
                                          search_key='name'))

    # Positive Create

    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_positive_create_1(self, org_name):
        """
        @feature: Organizations
        @test: Create organization with valid name only
        @assert: organization is created, label is auto-generated
        """
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))

    @attr('ui', 'org', 'implemented')
    @data(
        {
            'label': generate_string('alpha', 10),
            'name': generate_string('alpha', 10),
            'desc': generate_string('alpha', 10)
        }, {
            'label': generate_string('numeric', 10),
            'name': generate_string('numeric', 10),
            'desc': generate_string('numeric', 10)
        }, {
            'label': generate_string('alphanumeric', 10),
            'name': generate_string('alphanumeric', 10),
            'desc': generate_string('alphanumeric', 10)
        }, {
            'label': generate_string('alpha', 10),
            'name': generate_string('utf8', 10),
            'desc': generate_string('utf8', 10)
        }, {
            'label': generate_string('alpha', 10),
            'name': generate_string('latin1', 20),
            'desc': generate_string('latin1', 10)
        }, {
            'label': generate_string('alpha', 10),
            'name': generate_string('html', 20),
            'desc': generate_string('html', 10)
        })
    def test_positive_create_2(self, test_data):
        """
        @feature: Organizations
        @test: Create organization with valid name, label, parent_org, desc
        @assert: organization is created
        """

        parent = generate_string("alpha", 8)
        desc = test_data['desc']
        label = test_data['label']
        org_name = test_data['name']
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        # If parent org is not required to be static.
        self.org.create(parent)
        self.navigator.go_to_org()
        self.org.create(org_name, label=label, desc=desc, parent_org=parent)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))

    @attr('ui', 'org', 'implemented')
    @data(
        {
            'name': generate_string('alpha', 10),
            'label': generate_string('alpha', 10)
        }, {
            'name': generate_string('numeric', 10),
            'label': generate_string('numeric', 10)
        }, {
            'name': generate_string('alphanumeric', 10),
            'label': generate_string('alphanumeric', 10)
        })
    # As label cannot contain chars other than ascii alpha numerals, '_', '-'.
    def test_positive_create_3(self, test_data):
        """
        @feature: Organizations
        @test: Create organization with valid unmatching name and label only
        @assert: organization is created, label does not match name
        """

        name_loc = locators["org.name"]
        label_loc = locators["org.label"]
        org_name = test_data['name']
        org_label = test_data['label']
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name, label=org_label)
        self.navigator.go_to_org()
        self.org.search(org_name).click()
        name = self.org.wait_until_element(name_loc).get_attribute("value")
        label = self.org.wait_until_element(label_loc).get_attribute("value")
        self.assertNotEqual(name, label)

    @attr('ui', 'org', 'implemented')
    @data({'data': generate_string('alpha', 10)},
          {'data': generate_string('numeric', 10)},
          {'data': generate_string('alphanumeric', 10)})
    # As label cannot contain chars other than ascii alpha numerals, '_', '-'.
    def test_positive_create_4(self, test_data):
        """
        @feature: Organizations
        @test: Create organization with valid matching name and label only
        @assert: organization is created, label matches name
        """
        name_loc = locators["org.name"]
        label_loc = locators["org.label"]
        org_name = org_label = test_data['data']
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name, label=org_label)
        self.navigator.go_to_org()
        self.org.search(org_name).click()
        name = self.org.wait_until_element(name_loc).get_attribute("value")
        label = self.org.wait_until_element(label_loc).get_attribute("value")
        self.assertEqual(name, label)

    @bzbug("1079482")
    @attr('ui', 'org', 'implemented')
    @data(
        {
            'name': generate_string('alpha', 10),
            'desc': generate_string('alpha', 10)
        }, {
            'name': generate_string('numeric', 10),
            'desc': generate_string('numeric', 10)
        }, {
            'name': generate_string('alphanumeric', 10),
            'desc': generate_string('alphanumeric', 10)
        }, {
            'name': generate_string('utf8', 10),
            'desc': generate_string('utf8', 10)
        }, {
            'name': generate_string('latin1', 20),
            'desc': generate_string('latin1', 10)
        }, {
            'name': generate_string('html', 20),
            'desc': generate_string('html', 10)
        })
    def test_positive_create_5(self, test_data):
        """
        @feature: Organizations
        @test: Create organization with valid name and description only
        @assert: organization is created, label is auto-generated
        @BZ: 1079482
        """

        desc = test_data['desc']
        org_name = test_data['name']
        label_loc = locators["org.label"]
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name, desc=desc)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.navigator.go_to_org()
        self.org.search(org_name).click()
        label_ele = self.org.wait_until_element(label_loc)
        label_value = label_ele.get_attribute("value")
        self.assertTrue(label_value)

    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list(len1=256))
    def test_negative_create_0(self, org_name):
        """
        @feature: Organizations
        @test: Create organization with valid label and description, name is
        too long
        @assert: organization is not created
        """
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        error = self.org.wait_until_element(common_locators["name_haserror"])
        self.assertTrue(error)

    def test_negative_create_1(self):
        """
        @feature: Organizations
        @test: Create organization with valid label and description, name is
        blank
        @assert: organization is not created
        """

        org_name = ""
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        error = self.org.wait_until_element(common_locators["name_haserror"])
        self.assertTrue(error)

    def test_negative_create_2(self):
        """
        @feature: Organizations
        @test: Create organization with valid label and description, name is
        whitespace
        @assert: organization is not created
        """

        org_name = "    "
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        error = self.org.wait_until_element(common_locators["name_haserror"])
        self.assertTrue(error)

    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_negative_create_3(self, org_name):
        """
        @feature: Organizations
        @test: Create organization with valid values, then create a new one
        with same values.
        @assert: organization is not created
        """

        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.org.create(org_name)
        error = self.org.wait_until_element(common_locators["name_haserror"])
        self.assertTrue(error)

    # Positive Delete

    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_positive_delete_1(self, org_name):
        """
        @feature: Organizations
        @test: Create organization with valid values then delete it
        @assert: organization is deleted
        """

        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.org.remove(org_name, really=True)
        self.assertIsNone(self.org.search(org_name))

    # Negative Delete

    # Positive Update

    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_positive_update_1(self, new_name):
        """
        @feature: Organizations
        @test: Create organization with valid values then update its name
        @assert: organization name is updated
        """
        org_name = generate_string("alpha", 8)
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.org.update(org_name, new_name)
        self.assertIsNotNone(self.org.search(new_name))

    # Negative Update

    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_negative_update_1(self, org_name):
        """
        @feature: Organizations
        @test: Create organization with valid values then fail to update
        its name
        @assert: organization name is not updated
        """

        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        new_name = generate_string("alpha", 256)
        self.org.update(org_name, new_name)
        error = self.org.wait_until_element(common_locators["name_haserror"])
        self.assertTrue(error)

    # Miscellaneous

    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_search_key_1(self, org_name):
        """
        @feature: Organizations
        @test: Create organization and search/find it
        @assert: organization can be found
        """

        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))

    # Associations

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_remove_domain_1(self, domain):
        """
        @feature: Organizations
        @test: Add a domain to an organization and remove it by organization
        name and domain name
        @assert: the domain is removed from the organization
        @BZ: 1076562
        """

        strategy = common_locators["entity_select"][0]
        value = common_locators["entity_select"][1]
        strategy1 = common_locators["entity_deselect"][0]
        value1 = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_domains()
        self.domain.create(domain)
        self.assertIsNotNone(self.domain.search(domain))
        self.navigator.go_to_org()
        self.org.create(org_name, domains=[domain], edit=True)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_domains"]).click()
        element = self.org.wait_until_element((strategy1, value1 % domain))
        # Item is listed in 'Selected Items' list and not 'All Items' list.
        self.assertTrue(element)
        self.org.update(org_name, domains=[domain])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_domains"]).click()
        element = self.org.wait_until_element((strategy, value % domain))
        # Item is listed in 'All Items' list and not 'Selected Items' list.
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_remove_user_3(self, user_name):
        """
        @feature: Organizations
        @test: Create admin users then add user and remove it
        by using the organization name
        @assert: The user is added then removed from the organization
        @BZ: 1076562
        """

        strategy = common_locators["entity_select"][0]
        value = common_locators["entity_select"][1]
        strategy1 = common_locators["entity_deselect"][0]
        value1 = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        password = generate_string("alpha", 8)
        email = generate_email_address()
        search_key = "login"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_users()
        self.user.create(user_name, email, password, password)
        self.assertIsNotNone(self.user.search(user_name, search_key))
        self.navigator.go_to_org()
        self.org.create(org_name, users=[user_name], edit=True)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_users"]).click()
        element = self.org.wait_until_element((strategy1, value1 % user_name))
        # Item is listed in 'Selected Items' list and not 'All Items' list.
        self.assertTrue(element)
        self.navigator.go_to_org()
        self.org.update(org_name, users=[user_name], new_users=None)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_users"]).click()
        element = self.org.wait_until_element((strategy, value % user_name))
        # Item is listed in 'All Items' list and not 'Selected Items' list.
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_remove_hostgroup_1(self, host_grp):
        """
        @feature: Organizations
        @test: Add a hostgroup and remove it by using the organization
        name and hostgroup name
        @assert: hostgroup is added to organization then removed
        @BZ: 1076562
        """

        strategy = common_locators["entity_select"][0]
        value = common_locators["entity_select"][1]
        strategy1 = common_locators["entity_deselect"][0]
        value1 = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_host_groups()
        self.hostgroup.create(host_grp)
        self.assertIsNotNone(self.hostgroup.search(host_grp))
        self.navigator.go_to_org()
        self.org.create(org_name, hostgroups=[host_grp], edit=True)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_hostgrps"]).click()
        element = self.org.wait_until_element((strategy1, value1 % host_grp))
        # Item is listed in 'Selected Items' list and not 'All Items' list.
        self.assertTrue(element)
        self.navigator.go_to_org()
        self.org.update(org_name, hostgroups=[host_grp], new_hostgroups=None)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_hostgrps"]).click()
        element = self.org.wait_until_element((strategy, value % host_grp))
        # Item is listed in 'All Items' list and not 'Selected Items' list.
        self.assertTrue(element)

    @unittest.skip(NOT_IMPLEMENTED)
    @data("""DATADRIVENGOESHERE
        smartproxy name is alpha
        smartproxy name is numeric
        smartproxy name is alpha_numeric
        smartproxy name  is utf-8
        smartproxy name is latin1
        smartproxy name is html
    """)
    def test_add_smartproxy_1(self, test_data):
        """
        @feature: Organizations
        @test: Add a smart proxy by using organization name and smartproxy name
        @assert: smartproxy is added
        @status: manual
        """

        pass

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_add_subnet_1(self, subnet_name):
        """
        @feature: Organizations
        @test: Add a subnet by using organization name and subnet name
        @assert: subnet is added
        @BZ: 1076562
        """

        strategy = common_locators["entity_deselect"][0]
        value = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        subnet_network = generate_ipaddr(ip3=True)
        subnet_mask = "255.255.255.0"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.navigator.go_to_subnets()
        self.subnet.create(None, subnet_name, subnet_network, subnet_mask)
        self.assertIsNotNone(self.subnet.search_subnet(subnet_name))
        self.navigator.go_to_org()
        self.org.update(org_name, new_subnets=[subnet_name])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_subnets"]).click()
        element = self.org.wait_until_element((strategy, value % subnet_name))
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_add_domain_1(self, domain):
        """
        @feature: Organizations
        @test: Add a domain to an organization
        @assert: Domain is added to organization
        @BZ: 1076562
        """

        strategy = common_locators["entity_deselect"][0]
        value = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.navigator.go_to_domains()
        self.domain.create(domain)
        self.assertIsNotNone(self.domain.search(domain))
        self.navigator.go_to_org()
        self.org.update(org_name, new_domains=[domain])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_domains"]).click()
        element = self.org.wait_until_element((strategy, value % domain))
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_add_user_2(self, user):
        """
        @feature: Organizations
        @test: Create different types of users then add user
        by using the organization name
        @assert: User is added to organization
        @BZ: 1076562
        """

        strategy = common_locators["entity_deselect"][0]
        value = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        password = generate_string("alpha", 8)
        email = generate_email_address()
        search_key = "login"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.navigator.go_to_users()
        self.user.create(user, email, password, password)
        self.assertIsNotNone(self.user.search(user, search_key))
        self.navigator.go_to_org()
        self.org.update(org_name, new_users=[user])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_users"]).click()
        element = self.org.wait_until_element((strategy, value % user))
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_add_hostgroup_1(self, host_grp):
        """
        @feature: Organizations
        @test: Add a hostgroup by using the organization
        name and hostgroup name
        @assert: hostgroup is added to organization
        @BZ: 1076562
        """

        strategy = common_locators["entity_deselect"][0]
        value = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.navigator.go_to_host_groups()
        self.hostgroup.create(host_grp)
        self.assertIsNotNone(self.hostgroup.search(host_grp))
        self.org.update(org_name, new_hostgroups=[host_grp])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_hostgrps"]).click()
        element = self.org.wait_until_element((strategy, value % host_grp))
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_add_location_1(self, location):
        """
        @feature: Organizations
        @test: Add a location by using the organization
        name and location name
        @assert: location is added to organization
        @BZ: 1076562
        """

        strategy = common_locators["entity_deselect"][0]
        value = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.navigator.go_to_host_groups()
        self.location.create(location)
        self.assertIsNotNone(self.location.search(location))
        self.org.update(org_name, new_locations=[location])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_locations"]).click()
        element = self.org.wait_until_element((strategy, value % location))
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_remove_computeresource_1(self, resource_name):
        """
        @feature: Organizations
        @test: Remove computeresource by using the organization
        name and computeresource name
        @assert: computeresource is added then removed
        @BZ: 1076562
        """

        strategy = common_locators["entity_select"][0]
        value = common_locators["entity_select"][1]
        strategy1 = common_locators["entity_deselect"][0]
        value1 = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        libvirt_url = "qemu+tcp://%s:16509/system"
        url = (libvirt_url % conf.properties['main.server.hostname'])
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_compute_resources()
        self.compute_resource.create(resource_name,
                                     None,
                                     provider_type="Libvirt",
                                     url=url)
        self.navigator.go_to_compute_resources()
        self.assertIsNotNone(self.compute_resource.search(resource_name))
        self.navigator.go_to_org()
        self.org.create(org_name, resources=[resource_name], edit=True)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_resources"]).click()
        element = self.org.wait_until_element(
            (strategy1, value1 % resource_name))
        # Item is listed in 'Selected Items' list and not 'All Items' list.
        self.assertTrue(element)
        self.org.update(org_name,
                        resources=[resource_name],
                        new_resources=None)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_resources"]).click()
        element = self.org.wait_until_element(
            (strategy, value % resource_name))
        # Item is listed in 'All Items' list and not 'Selected Items' list.
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_remove_medium_1(self, medium):
        """
        @feature: Organizations
        @test: Remove medium by using organization name and medium name
        @assert: medium is added then removed
        @BZ: 1076562
        """

        strategy = common_locators["entity_select"][0]
        value = common_locators["entity_select"][1]
        strategy1 = common_locators["entity_deselect"][0]
        value1 = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        path = URL % generate_string("alpha", 6)
        os_family = "Red Hat"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_installation_media()
        self.medium.create(medium, path, os_family)
        self.assertIsNotNone(self.medium.search(medium))
        self.navigator.go_to_org()
        self.org.create(org_name, medias=[medium], edit=True)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_media"]).click()
        element = self.org.wait_until_element((strategy1, value1 % medium))
        # Item is listed in 'Selected Items' list and not 'All Items' list.
        self.assertTrue(element)
        self.org.update(org_name, medias=[medium], new_medias=None)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_media"]).click()
        element = self.org.wait_until_element((strategy, value % medium))
        # Item is listed in 'All Items' list and not 'Selected Items' list.
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_remove_configtemplate_1(self, template):
        """
        @feature: Organizations
        @test: Remove config template
        @assert: configtemplate is added then removed
        @BZ: 1076562
        """

        strategy = common_locators["entity_select"][0]
        value = common_locators["entity_select"][1]
        strategy1 = common_locators["entity_deselect"][0]
        value1 = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        temp_type = 'provision'
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_provisioning_templates()
        self.template.create(template, template_path, True, temp_type, None)
        self.assertIsNotNone(self.template.search(template))
        self.navigator.go_to_org()
        self.org.create(org_name, templates=[template], edit=True)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_template"]).click()
        element = self.org.wait_until_element((strategy1, value1 % template))
        # Item is listed in 'Selected Items' list and not 'All Items' list.
        self.assertTrue(element)
        self.org.update(org_name, templates=[template])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_template"]).click()
        element = self.org.wait_until_element((strategy, value % template))
        # Item is listed in 'All Items' list and not 'Selected Items' list.
        self.assertTrue(element)

    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_add_environment_1(self, env):
        """
        @feature: Organizations
        @test: Add environment by using organization name and evironment name
        @assert: environment is added
        @status: manual
        """

        strategy = common_locators["entity_deselect"][0]
        value = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.navigator.go_to_environments()
        self.environment.create(env, None)
        search = self.environment.search(env)
        self.assertIsNotNone(search)
        self.navigator.go_to_org()
        self.org.update(org_name, new_envs=[env])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_env"]).click()
        element = self.org.wait_until_element((strategy, value % env))
        self.assertTrue(element)

    @unittest.skip(NOT_IMPLEMENTED)
    @data("""DATADRIVENGOESHERE
        smartproxy name is alpha
        smartproxy name is numeric
        smartproxy name is alpha_numeric
        smartproxy name  is utf-8
        smartproxy name is latin1
        smartproxy name is html
    """)
    def test_remove_smartproxy_1(self, test_data):
        """
        @feature: Organizations
        @test: Remove smartproxy by using organization name and smartproxy name
        @assert: smartproxy is added then removed
        @status: manual
        """

        pass

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_add_computeresource_1(self, resource_name):
        """
        @feature: Organizations
        @test: Add compute resource using the organization
        name and computeresource name
        @assert: computeresource is added
        @BZ: 1076562
        """

        strategy = common_locators["entity_deselect"][0]
        value = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        libvirt_url = "qemu+tcp://%s:16509/system"
        url = (libvirt_url % conf.properties['main.server.hostname'])
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.navigator.go_to_compute_resources()
        self.compute_resource.create(resource_name, [org_name],
                                     provider_type="Libvirt",
                                     url=url)
        self.navigator.go_to_compute_resources()
        self.assertIsNotNone(self.compute_resource.search(resource_name))
        self.navigator.go_to_org()
        self.org.update(org_name, new_resources=[resource_name])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_resources"]).click()
        element = self.org.wait_until_element(
            (strategy, value % resource_name))
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_add_medium_1(self, medium):
        """
        @feature: Organizations
        @test: Add medium by using the organization name and medium name
        @assert: medium is added
        @BZ: 1076562
        """

        strategy = common_locators["entity_deselect"][0]
        value = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        path = URL % generate_string("alpha", 6)
        os_family = "Red Hat"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.navigator.go_to_installation_media()
        self.medium.create(medium, path, os_family)
        self.assertIsNotNone(self.medium.search(medium))
        self.navigator.go_to_org()
        self.org.update(org_name, new_medias=[medium])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_media"]).click()
        element = self.org.wait_until_element((strategy, value % medium))
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_add_configtemplate_1(self, template):
        """
        @feature: Organizations
        @test: Add config template by using organization name and
        configtemplate name
        @assert: configtemplate is added
        @BZ: 1076562
        """

        strategy = common_locators["entity_deselect"][0]
        value = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        temp_type = 'provision'
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_org()
        self.org.create(org_name)
        self.navigator.go_to_org()
        self.assertIsNotNone(self.org.search(org_name))
        self.navigator.go_to_provisioning_templates()
        self.template.create(template, template_path, True, temp_type, None)
        self.assertIsNotNone(self.template.search(template))
        self.navigator.go_to_org()
        self.org.update(org_name, new_templates=[template])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_media"]).click()
        element = self.org.wait_until_element((strategy, value % template))
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_remove_environment_1(self, env):
        """
        @feature: Organizations
        @test: Remove environment by using organization name & evironment name
        @assert: environment is removed from Organization
        @BZ: 1076562
        """

        strategy = common_locators["entity_select"][0]
        value = common_locators["entity_select"][1]
        strategy1 = common_locators["entity_deselect"][0]
        value1 = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_environments()
        self.environment.create(env, None)
        search = self.environment.search(env)
        self.assertIsNotNone(search)
        self.navigator.go_to_org()
        self.org.create(org_name, envs=[env], edit=True)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_env"]).click()
        element = self.org.wait_until_element((strategy1, value1 % env))
        # Item is listed in 'Selected Items' list and not 'All Items' list.
        self.assertTrue(element)
        self.org.update(org_name, new_envs=[env])
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_env"]).click()
        element = self.org.wait_until_element((strategy, value % env))
        # Item is listed in 'All Items' list and not 'Selected Items' list.
        self.assertTrue(element)

    @bzbug('1076562')
    @attr('ui', 'org', 'implemented')
    @data(*generate_strings_list())
    def test_remove_subnet_1(self, subnet_name):
        """
        @feature: Organizations
        @test: Remove subnet by using organization name and subnet name
        @assert: subnet is added then removed
        @BZ: 1076562
        """

        strategy = common_locators["entity_select"][0]
        value = common_locators["entity_select"][1]
        strategy1 = common_locators["entity_deselect"][0]
        value1 = common_locators["entity_deselect"][1]
        org_name = generate_string("alpha", 8)
        subnet_network = generate_ipaddr(ip3=True)
        subnet_mask = "255.255.255.0"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_subnets()
        self.subnet.create(None, subnet_name, subnet_network, subnet_mask)
        self.assertIsNotNone(self.subnet.search_subnet(subnet_name))
        self.navigator.go_to_org()
        self.org.create(org_name, subnets=[subnet_name], edit=True)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_subnets"]).click()
        element = self.org.wait_until_element(
            (strategy1, value1 % subnet_name))
        # Item is listed in 'Selected Items' list and not 'All Items' list.
        self.assertTrue(element)
        self.org.update(org_name, subnets=[subnet_name], new_subnets=None)
        self.org.search(org_name).click()
        self.org.wait_until_element(tab_locators["orgs.tab_subnets"]).click()
        element = self.org.wait_until_element((strategy, value % subnet_name))
        # Item is listed in 'All Items' list and not 'Selected Items' list.
        self.assertTrue(element)
Exemple #20
0
class ConfigGroups(UITestCase):
    """Implements Config Groups tests in UI."""
    @data(*generate_strings_list(len1=8))
    def test_create_positive_1(self, name):
        """@Test: Create new Config-Group

        @Feature: Config-Groups - Positive Create

        @Assert: Config-Groups is created

        """
        with Session(self.browser) as session:
            make_config_groups(session, name=name)
            search = self.configgroups.search(name)
            self.assertIsNotNone(search)

    @data(gen_string('alphanumeric', 255), gen_string('alpha', 255),
          gen_string('numeric', 255), gen_string('latin1', 255),
          gen_string('utf8', 255))
    def test_create_positive_2(self, name):
        """@Test: Create new config-groups with 255 chars

        @Feature: Config-Groups - Positive Create

        @Assert: Config-Groups is created with 255 chars

        """
        with Session(self.browser) as session:
            make_config_groups(session, name=name)
            search = self.configgroups.search(name)
            self.assertIsNotNone(search)

    @data(*generate_strings_list(len1=256))
    def test_create_negative_1(self, name):
        """@Test: Create new config-groups with 256 chars

        @Feature: Config-Groups - Negative Create

        @Assert: Config-Groups is not created

        """
        with Session(self.browser) as session:
            make_config_groups(session, name=name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)
            search = self.configgroups.search(name)
            self.assertIsNone(search)

    @data("", "  ")
    def test_create_negative_2(self, name):
        """@Test: Create new config-groups with blank name

        @Feature: Config-Groups - Negative Create

        @Assert: Config-Groups is not created

        """

        with Session(self.browser) as session:
            make_config_groups(session, name=name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    @data(
        {
            'name': gen_string('alpha', 10),
            'new_name': gen_string('alpha', 10)
        }, {
            'name': gen_string('numeric', 10),
            'new_name': gen_string('numeric', 10)
        }, {
            'name': gen_string('alphanumeric', 10),
            'new_name': gen_string('alphanumeric', 10)
        }, {
            'name': gen_string('utf8', 10),
            'new_name': gen_string('utf8', 10)
        }, {
            'name': gen_string('latin1', 20),
            'new_name': gen_string('latin1', 10)
        })
    def test_update_positive_1(self, testdata):
        """@Test: Create new config-group

        @Feature: Config-Groups - Positive Update

        @Assert: Config-Groups is updated.

        """
        name = testdata['name']
        new_name = testdata['new_name']
        with Session(self.browser) as session:
            make_config_groups(session, name=name)
            search = self.configgroups.search(name)
            self.assertIsNotNone(search)
            self.configgroups.update(name, new_name)
            search = self.configgroups.search(new_name)
            self.assertIsNotNone(search)

    @data(*generate_strings_list(len1=8))
    def test_delete_positive_1(self, name):
        """@Test: Create new config-groups

        @Feature: Config-Groups - Positive delete

        @Assert: Config-Groups is deleted

        """

        with Session(self.browser) as session:
            make_config_groups(session, name=name)
            search = self.configgroups.search(name)
            self.assertIsNotNone(search)
            self.configgroups.delete(
                name, True, drop_locator=locators["config_groups.dropdown"])
            self.assertIsNotNone(
                session.nav.wait_until_element(
                    common_locators["notif.success"]))
            self.assertIsNone(self.configgroups.search(name))
Exemple #21
0
class Location(UITestCase):
    """Implements Location tests in UI"""

    # Auto Search

    @skip_if_bug_open('bugzilla', 1177610)
    def test_auto_search(self):
        """@test: Can auto-complete search for location by partial name

        @feature: Locations

        @assert: Created location can be auto search by its partial name

        @BZ: 1177610

        """
        loc_name = gen_string("alpha", 8)
        part_string = loc_name[:3]
        with Session(self.browser) as session:
            page = session.nav.go_to_loc
            make_loc(session, name=loc_name)
            auto_search = self.location.auto_complete_search(
                page,
                locators['location.select_name'],
                part_string,
                loc_name,
                search_key='name')
            self.assertIsNotNone(auto_search)

    # Positive Create

    @data(*generate_strings_list())
    def test_positive_create_1(self, loc_name):
        """@test: Create Location with valid name only

        @feature: Locations

        @assert: Location is created, label is auto-generated

        """

        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))

    @skip_if_bug_open('bugzilla', 1123818)
    @data(*generate_strings_list(len1=247))
    def test_negative_create_1(self, loc_name):
        """@test: Create location with name as too long

        @feature: Locations

        @assert: location is not created

        @BZ: 1123818

        """
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    def test_negative_create_2(self):
        """@test: Create location with name as blank

        @feature: Locations

        @assert: location is not created

        """

        loc_name = ""
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    def test_negative_create_3(self):
        """@test: Create location with name as whitespace

        @feature: Locations

        @assert: location is not created

        """

        loc_name = "    "
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    @data(*generate_strings_list())
    def test_negative_create_4(self, loc_name):
        """@test: Create location with valid values, then create a new one
        with same values.

        @feature: Locations

        @assert: location is not created

        """

        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            make_loc(session, name=loc_name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    @data(
        {
            'org_name': gen_string('alpha', 10),
            'loc_name': gen_string('alpha', 10)
        }, {
            'org_name': gen_string('numeric', 10),
            'loc_name': gen_string('numeric', 10)
        }, {
            'org_name': gen_string('alphanumeric', 10),
            'loc_name': gen_string('alphanumeric', 10)
        }, {
            'org_name': gen_string('utf8', 10),
            'loc_name': gen_string('utf8', 10)
        }, {
            'org_name': gen_string('latin1', 20),
            'loc_name': gen_string('latin1', 10)
        }, {
            'org_name': gen_string('html', 20),
            'loc_name': gen_string('html', 10)
        })
    def test_positive_create_6(self, test_data):
        """@test: Select both organization and location.

        @feature: Locations

        @assert: Both organization and location are selected.

        """
        org_name = test_data['org_name']
        loc_name = test_data['loc_name']
        org = entities.Organization(name=org_name).create()
        self.assertEqual(org['name'], org_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            location = session.nav.go_to_select_loc(loc_name)
            organization = session.nav.go_to_select_org(org_name)
            self.assertEqual(location, loc_name)
            self.assertEqual(organization, org_name)

    # Positive Update

    @data(*generate_strings_list())
    def test_positive_update_1(self, new_name):
        """@test: Create Location with valid values then update its name

        @feature: Locations

        @assert: Location name is updated

        """

        loc_name = gen_string("alpha", 8)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            self.location.update(loc_name, new_name=new_name)
            self.assertIsNotNone(self.location.search(new_name))

    # Negative Update

    @skip_if_bug_open('bugzilla', 1123818)
    @data(*generate_strings_list())
    def test_negative_update_1(self, loc_name):
        """@test: Create Location with valid values then fail to update
        its name

        @feature: Locations

        @assert: Location name is not updated

        @BZ: 1123818

        """

        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            new_name = gen_string("alpha", 256)
            self.location.update(loc_name, new_name=new_name)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    # Miscellaneous

    @data(*generate_strings_list())
    def test_search_key_1(self, loc_name):
        """@test: Create location and search/find it

        @feature: Locations

        @assert: location can be found

        """
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))

    @data(*generate_strings_list())
    def test_add_subnet_1(self, subnet_name):
        """@test: Add a subnet by using location name and subnet name

        @feature: Locations

        @assert: subnet is added

        """
        strategy, value = common_locators["entity_deselect"]
        loc_name = gen_string("alpha", 8)
        subnet_network = gen_ipaddr(ip3=True)
        subnet_mask = "255.255.255.0"
        subnet = entities.Subnet(name=subnet_name,
                                 network=subnet_network,
                                 mask=subnet_mask).create()
        self.assertEqual(subnet['name'], subnet_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            self.location.update(loc_name, new_subnets=[subnet_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_subnets"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % subnet_name))
            self.assertIsNotNone(element)

    @data(*generate_strings_list())
    def test_add_domain_1(self, domain_name):
        """@test: Add a domain to a Location

        @feature: Locations

        @assert: Domain is added to Location

        """
        strategy, value = common_locators["entity_deselect"]
        loc_name = gen_string("alpha", 8)
        domain = entities.Domain(name=domain_name).create()
        self.assertEqual(domain['name'], domain_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            self.location.update(loc_name, new_domains=[domain_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_domains"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % domain_name))
            self.assertIsNotNone(element)

    @data(gen_string('alpha', 8), gen_string('numeric', 8),
          gen_string('alphanumeric', 8), gen_string('utf8', 8),
          gen_string('latin1', 8))
    def test_add_user_1(self, user_name):
        """@test: Create user then add user
        by using the location name

        @feature: Locations

        @assert: User is added to location

        """
        strategy, value = common_locators["entity_deselect"]
        loc_name = gen_string("alpha", 8)
        password = gen_string("alpha", 8)
        user = entities.User(login=user_name,
                             firstname=user_name,
                             lastname=user_name,
                             password=password).create()
        self.assertEqual(user['login'], user_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            self.location.update(loc_name, new_users=[user_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_users"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % user_name))
            self.assertIsNotNone(element)

    def test_allvalues_hostgroup(self):
        """@test: check whether host group has the 'All values' checked.

        @feature: Locations

        @assert: host group 'All values' checkbox is checked.

        """
        loc_name = gen_string("alpha", 8)
        with Session(self.browser) as session:
            page = session.nav.go_to_loc
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            selected = self.location.check_all_values(
                page,
                loc_name,
                locators["location.select_name"],
                tab_locators["context.tab_hostgrps"],
                context="location")
            self.assertIsNotNone(selected)

    @data(*generate_strings_list())
    def test_add_hostgroup_1(self, host_grp_name):
        """@test: Add a hostgroup by using the location
        name and hostgroup name

        @feature: Locations

        @assert: hostgroup is added to location

        """
        strategy, value = common_locators["all_values_selection"]
        loc_name = gen_string("alpha", 8)
        host_grp = entities.HostGroup(name=host_grp_name).create()
        self.assertEqual(host_grp['name'], host_grp_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(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))
            self.assertIsNotNone(element)

    @data(*generate_strings_list())
    def test_add_org_1(self, org_name):
        """@test: Add a organization by using the location
        name

        @feature: Locations

        @assert: organization is added to location

        """
        strategy, value = common_locators["entity_deselect"]
        loc_name = gen_string("alpha", 8)
        org = entities.Organization(name=org_name).create()
        self.assertEqual(org['name'], org_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            self.location.update(loc_name, new_organizations=[org_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_organizations"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % org_name))
            self.assertIsNotNone(element)

    @data(gen_string('alpha', 8), gen_string('numeric', 8),
          gen_string('alphanumeric', 8))
    def test_add_environment_1(self, env_name):
        """@test: Add environment by using location name and evironment name

        @feature: Locations

        @assert: environment is added

        """
        strategy, value = common_locators["entity_deselect"]
        loc_name = gen_string("alpha", 8)
        env = entities.Environment(name=env_name).create()
        self.assertEqual(env['name'], env_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            self.location.update(loc_name, new_envs=[env_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_env"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % env_name))
            self.assertIsNotNone(element)

    @data(*generate_strings_list())
    def test_add_computeresource_1(self, resource_name):
        """@test: Add compute resource using the location
        name and computeresource name

        @feature: Locations

        @assert: computeresource is added

        """
        strategy, value = common_locators["entity_deselect"]
        loc_name = gen_string("alpha", 8)
        libvirt_url = "qemu+tcp://%s:16509/system"
        url = (libvirt_url % conf.properties['main.server.hostname'])
        resource = entities.ComputeResource(name=resource_name,
                                            provider='Libvirt',
                                            url=url).create()
        self.assertEqual(resource['name'], resource_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            self.location.update(loc_name, new_resources=[resource_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_resources"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % resource_name))
            self.assertIsNotNone(element)

    @data(*generate_strings_list())
    def test_add_medium_1(self, medium_name):
        """@test: Add medium by using the location name and medium name

        @feature: Locations

        @assert: medium is added

        """
        strategy, value = common_locators["entity_deselect"]
        loc_name = gen_string("alpha", 8)
        path = INSTALL_MEDIUM_URL % gen_string("alpha", 6)
        medium = entities.Media(
            name=medium_name,
            media_path=path,
            os_family='Redhat',
        ).create()
        self.assertEqual(medium['name'], medium_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            self.location.update(loc_name, new_medias=[medium_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_media"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % medium_name))
            self.assertIsNotNone(element)

    def test_allvalues_configtemplate(self):
        """@test: check whether config template has the 'All values' checked.

        @feature: Locations

        @assert: configtemplate 'All values' checkbox is checked.

        """
        loc_name = gen_string("alpha", 8)
        with Session(self.browser) as session:
            page = session.nav.go_to_loc
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            selected = self.location.check_all_values(
                page,
                loc_name,
                locators["location.select_name"],
                tab_locators["context.tab_template"],
                context="location")
            self.assertIsNotNone(selected)

    @data(*generate_strings_list())
    def test_add_configtemplate_1(self, template):
        """@test: Add config template by using location name and
        configtemplate name.

        @feature: Locations

        @assert: configtemplate is added.

        """
        strategy, value = common_locators["all_values_selection"]
        loc_name = gen_string("alpha", 8)
        temp_type = 'provision'
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name)
            self.assertIsNotNone(self.location.search(loc_name))
            make_templates(session,
                           name=template,
                           template_path=template_path,
                           custom_really=True,
                           template_type=temp_type)
            self.assertIsNotNone(self.template.search(template))
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_template"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % template))
            self.assertIsNotNone(element)

    @data(gen_string('alpha', 8), gen_string('numeric', 8),
          gen_string('alphanumeric', 8))
    def test_remove_environment_1(self, env_name):
        """@test: Remove environment by using location name & evironment name

        @feature: Locations

        @assert: environment is removed from Location

        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        loc_name = gen_string("alpha", 8)
        env = entities.Environment(name=env_name).create()
        self.assertEqual(env['name'], env_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name, envs=[env_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_env"]).click()
            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.wait_until_element(
                tab_locators["context.tab_env"]).click()
            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)

    @data(*generate_strings_list())
    def test_remove_subnet_1(self, subnet_name):
        """@test: 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"]
        loc_name = gen_string("alpha", 8)
        subnet_network = gen_ipaddr(ip3=True)
        subnet_mask = "255.255.255.0"
        subnet = entities.Subnet(name=subnet_name,
                                 network=subnet_network,
                                 mask=subnet_mask).create()
        self.assertEqual(subnet['name'], subnet_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name, subnets=[subnet_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_subnets"]).click()
            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.wait_until_element(
                tab_locators["context.tab_subnets"]).click()
            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)

    @data(*generate_strings_list())
    def test_remove_domain_1(self, domain_name):
        """@test: 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"]
        loc_name = gen_string("alpha", 8)
        domain = entities.Domain(name=domain_name).create()
        self.assertEqual(domain['name'], domain_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name, domains=[domain_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_domains"]).click()
            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.wait_until_element(
                tab_locators["context.tab_domains"]).click()
            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)

    @data(gen_string('alpha', 8), gen_string('numeric', 8),
          gen_string('alphanumeric', 8), gen_string('utf8', 8),
          gen_string('latin1', 8))
    def test_remove_user_1(self, user_name):
        """@test: 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"]
        loc_name = gen_string("alpha", 8)
        password = gen_string("alpha", 8)
        user = entities.User(login=user_name,
                             firstname=user_name,
                             lastname=user_name,
                             password=password).create()
        self.assertEqual(user['login'], user_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name, users=[user_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_users"]).click()
            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.wait_until_element(
                tab_locators["context.tab_users"]).click()
            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)

    @data(*generate_strings_list())
    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()
        self.assertEqual(host_grp['name'], host_grp_name)
        with Session(self.browser) as session:
            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)

    @data(*generate_strings_list())
    def test_remove_computeresource_1(self, resource_name):
        """@test: Remove computeresource by using the location
        name and computeresource name

        @feature: Locations

        @assert: computeresource is added then removed

        """
        strategy, value = common_locators["entity_select"]
        strategy1, value1 = common_locators["entity_deselect"]
        loc_name = gen_string("alpha", 8)
        libvirt_url = "qemu+tcp://%s:16509/system"
        url = (libvirt_url % conf.properties['main.server.hostname'])
        resource = entities.ComputeResource(name=resource_name,
                                            provider='Libvirt',
                                            url=url).create()
        self.assertEqual(resource['name'], resource_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name, resources=[resource_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_resources"]).click()
            ele = self.location.wait_until_element(
                (strategy1, value1 % resource_name))
            # Item is listed in 'Selected Items' list and not 'All Items' list.
            self.assertIsNotNone(ele)
            self.location.update(loc_name, resources=[resource_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_resources"]).click()
            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)

    @data(*generate_strings_list())
    def test_remove_medium_1(self, medium_name):
        """@test: 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"]
        loc_name = gen_string("alpha", 8)
        path = INSTALL_MEDIUM_URL % gen_string("alpha", 6)
        medium = entities.Media(
            name=medium_name,
            media_path=path,
            os_family='Redhat',
        ).create()
        self.assertEqual(medium['name'], medium_name)
        with Session(self.browser) as session:
            make_loc(session, name=loc_name, medias=[medium_name])
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_media"]).click()
            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.wait_until_element(
                tab_locators["context.tab_media"]).click()
            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)

    @data(
        {u'user_name': gen_string('alpha', 8)},
        {u'user_name': gen_string('numeric', 8)},
        {u'user_name': gen_string('alphanumeric', 8)},
        {
            u'user_name': gen_string('utf8', 8),
            'bugzilla': 1164247
        },
        {u'user_name': gen_string('latin1', 8)},
        {u'user_name': gen_string('html', 8)},
    )
    def test_remove_configtemplate_1(self, testdata):
        """
        @test: Remove config template

        @feature: Locations

        @assert: configtemplate is added then removed

        """

        bug_id = testdata.pop('bugzilla', None)
        if bug_id is not None and bz_bug_is_open(bug_id):
            self.skipTest('Bugzilla bug {0} is open.'.format(bug_id))

        template = testdata['user_name']
        strategy, value = common_locators["all_values_selection"]
        loc_name = gen_string("alpha", 8)
        temp_type = 'provision'
        template_path = get_data_file(OS_TEMPLATE_DATA_FILE)
        with Session(self.browser) as session:
            make_templates(session,
                           name=template,
                           template_path=template_path,
                           template_type=temp_type,
                           custom_really=True)
            self.assertIsNotNone(self.template.search(template))
            make_loc(session, name=loc_name)
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_template"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % template))
            # Item is listed in 'Selected Items' list and not 'All Items' list.
            self.assertIsNotNone(element)
            self.template.delete(template, True)
            self.location.search(loc_name).click()
            session.nav.wait_until_element(
                tab_locators["context.tab_template"]).click()
            element = session.nav.wait_until_element(
                (strategy, value % template))
            # Item is listed in 'All Items' list and not 'Selected Items' list.
            self.assertIsNone(element)
Exemple #22
0
class Hostgroup(UITestCase):
    """Implements HostGroup tests from UI"""
    @data(*generate_strings_list(len1=4))
    def test_create_hostgroup(self, name):
        """@Test: Create new hostgroup

        @Feature: Hostgroup - Positive Create

        @Assert: Hostgroup is created

        """
        with Session(self.browser) as session:
            make_hostgroup(session, name=name)
            self.assertIsNotNone(self.hostgroup.search(name))

    @skip_if_bug_open('bugzilla', 1121755)
    @skip_if_bug_open('bugzilla', 1131416)
    @data(*generate_strings_list(len1=4))
    def test_delete_hostgroup(self, name):
        """@Test: Delete a hostgroup

        @Feature: Hostgroup - Positive Delete

        @Assert: Hostgroup is deleted

        """
        with Session(self.browser) as session:
            make_hostgroup(session, name=name)
            self.assertIsNotNone(self.hostgroup.search(name))
            self.hostgroup.delete(name, really=True)
            self.assertIsNone(self.hostgroup.search(name))

    @data({
        u'name': gen_string('alpha'),
        u'new_name': gen_string('alpha')
    }, {
        u'name': gen_string('latin1'),
        u'new_name': gen_string('latin1')
    }, {
        u'name': gen_string('numeric'),
        u'new_name': gen_string('numeric')
    }, {
        u'name': gen_string('html'),
        u'new_name': gen_string('html')
    }, {
        u'name': gen_string('utf8'),
        u'new_name': gen_string('utf8')
    }, {
        u'name': gen_string('alphanumeric'),
        u'new_name': gen_string('alphanumeric')
    })
    def test_update_hostgroup(self, test_data):
        """@Test: Update hostgroup with a new name

        @Feature: Hostgroup - Positive Update

        @Assert: Hostgroup is updated

        """
        with Session(self.browser) as session:
            make_hostgroup(session, name=test_data['name'])
            self.assertIsNotNone(self.hostgroup.search(test_data['name']))
            self.hostgroup.update(test_data['name'],
                                  new_name=test_data['new_name'])
            self.assertIsNotNone(self.hostgroup.search(test_data['new_name']))

    @data(*generate_strings_list(len1=256))
    def test_negative_create_hostgroup_1(self, name):
        """@Test: Create new hostgroup with 256 chars in name

        @Feature: Hostgroup - Negative Create

        @Assert: Hostgroup is not created

        """
        with Session(self.browser) as session:
            make_hostgroup(session, name=name)
            self.assertIsNotNone(
                self.hostgroup.wait_until_element(
                    common_locators["name_haserror"]))

    @data(*generate_strings_list(len1=6))
    def test_negative_create_hostgroup_2(self, name):
        """@Test: Create new hostgroup with same name

        @Feature: Hostgroup - Negative Create

        @Assert: Hostgroup is not created

        """
        with Session(self.browser) as session:
            make_hostgroup(session, name=name)
            self.assertIsNotNone(self.hostgroup.search(name))
            make_hostgroup(session, name=name)
            self.assertIsNotNone(
                self.hostgroup.wait_until_element(
                    common_locators["name_haserror"]))

    @ddt_data("", "  ")
    def test_negative_create_hostgroup_3(self, name):
        """@Test: Create new hostgroup with whitespaces in name

        @Feature: Hostgroup - Negative Create

        @Assert: Hostgroup is not created

        """
        with Session(self.browser) as session:
            make_hostgroup(session, name=name)
            self.assertIsNotNone(
                self.hostgroup.wait_until_element(
                    common_locators["name_haserror"]))
Exemple #23
0
class Syncplan(BaseUI):
    """
    Implements Sync Plan tests in UI
    """

    org_name = None

    def setUp(self):
        super(Syncplan, self).setUp()
        # Make sure to use the Class' org_name instance
        if Syncplan.org_name is None:
            Syncplan.org_name = generate_string("alpha", 8)
            with Session(self.browser) as session:
                make_org(session, org_name=Syncplan.org_name)

    def configure_syncplan(self):
        """
        Configures sync plan in UI
        """
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_sync_plans()

    @attr('ui', 'syncplan', 'implemented')
    @data(
        {
            u'name': generate_string('alpha', 10),
            u'desc': generate_string('alpha', 10),
            u'interval': SYNC_INTERVAL['hour']
        }, {
            u'name': generate_string('numeric', 10),
            u'desc': generate_string('numeric', 10),
            u'interval': SYNC_INTERVAL['hour']
        }, {
            u'name': generate_string('alphanumeric', 10),
            u'desc': generate_string('alphanumeric', 10),
            u'interval': SYNC_INTERVAL['hour']
        }, {
            u'name': generate_string('utf8', 10),
            u'desc': generate_string('utf8', 10),
            u'interval': SYNC_INTERVAL['hour']
        }, {
            u'name': generate_string('html', 20),
            u'desc': generate_string('html', 10),
            u'interval': SYNC_INTERVAL['hour']
        }, {
            u'name': generate_string('alpha', 10),
            u'desc': generate_string('alpha', 10),
            u'interval': SYNC_INTERVAL['day']
        }, {
            u'name': generate_string('numeric', 10),
            u'desc': generate_string('numeric', 10),
            u'interval': SYNC_INTERVAL['day']
        }, {
            u'name': generate_string('alphanumeric', 10),
            u'desc': generate_string('alphanumeric', 10),
            u'interval': SYNC_INTERVAL['day']
        }, {
            u'name': generate_string('utf8', 10),
            u'desc': generate_string('utf8', 10),
            u'interval': SYNC_INTERVAL['day']
        }, {
            u'name': generate_string('html', 20),
            u'desc': generate_string('html', 10),
            u'interval': SYNC_INTERVAL['day']
        }, {
            u'name': generate_string('alpha', 10),
            u'desc': generate_string('alpha', 10),
            u'interval': SYNC_INTERVAL['week']
        }, {
            u'name': generate_string('numeric', 10),
            u'desc': generate_string('numeric', 10),
            u'interval': SYNC_INTERVAL['week']
        }, {
            u'name': generate_string('alphanumeric', 10),
            u'desc': generate_string('alphanumeric', 10),
            u'interval': SYNC_INTERVAL['week']
        }, {
            u'name': generate_string('utf8', 10),
            u'desc': generate_string('utf8', 10),
            u'interval': SYNC_INTERVAL['week']
        }, {
            u'name': generate_string('html', 20),
            u'desc': generate_string('html', 10),
            u'interval': SYNC_INTERVAL['week']
        })
    def test_positive_create_1(self, test_data):
        """
        @Feature: Content Sync Plan - Positive Create
        @Test: Create Sync Plan with minimal input parameters
        @Assert: Sync Plan is created
        """

        self.configure_syncplan()
        self.syncplan.create(test_data['name'],
                             description=test_data['desc'],
                             sync_interval=test_data['interval'])
        self.assertIsNotNone(self.products.search(test_data['name']))

    @bzbug("1087425")
    @attr('ui', 'syncplan', 'implemented')
    @data(*generate_strings_list())
    def test_positive_create_2(self, name):
        """
        @Feature: Content Sync Plan - Positive Create
        @Test: Create Sync Plan with same input parameters
        @Assert: Sync Plan is not created
        @BZ: 1087425
        """

        description = "with same name"
        # TODO: Due to bug 1087425 using common_haserror instead of name_error
        locator = common_locators["common_haserror"]
        self.configure_syncplan()
        self.syncplan.create(name)
        self.assertIsNotNone(self.products.search(name))
        self.syncplan.create(name, description)
        error = self.products.wait_until_element(locator)
        self.assertTrue(error)

    @bzbug("1082632")
    @attr('ui', 'syncplan', 'implemented')
    def test_positive_create_3(self):
        """
        @Feature: Content Sync Plan - Positive Create
        @Test: Create Sync plan with specified start time
        @Assert: Sync Plan is created with the specified time.
        @BZ: 1082632
        """

        locator = locators["sp.fetch_startdate"]
        plan_name = generate_string("alpha", 8)
        self.configure_syncplan()
        description = "sync plan create with start date"
        current_date = datetime.now()
        startdate = current_date + timedelta(minutes=10)
        starthour = startdate.strftime("%H")
        startminute = startdate.strftime("%M")
        # Formatting current_date to web-UI format "%b %d, %Y %I:%M:%S %p"
        # Removed zero padded hrs & mins as fetching via web-UI doesn't have it
        # Removed the seconds info as it would be too quick to validate via UI.
        fetch_starttime = startdate.strftime("%b %d, %Y %I:%M:%S %p").\
            lstrip("0").replace(" 0", " ").rpartition(':')[0]
        self.syncplan.create(plan_name,
                             description,
                             start_hour=starthour,
                             start_minute=startminute)
        self.assertIsNotNone(self.products.search(plan_name))
        self.syncplan.search(plan_name).click()
        self.syncplan.wait_for_ajax()
        # Removed the seconds info as it would be too quick to validate via UI.
        starttime_text = str(self.syncplan.wait_until_element(locator).text).\
            rpartition(':')[0]
        self.assertEqual(starttime_text, fetch_starttime)

    @attr('ui', 'syncplan', 'implemented')
    def test_positive_create_4(self):
        """
        @Feature: Content Sync Plan - Positive Create
        @Test: Create Sync plan with specified start date
        @Assert: Sync Plan is created with the specified date
        """

        locator = locators["sp.fetch_startdate"]
        plan_name = generate_string("alpha", 8)
        self.configure_syncplan()
        description = "sync plan create with start date"
        current_date = datetime.now()
        startdate = current_date + timedelta(days=10)
        startdate_str = startdate.strftime("%Y-%m-%d")
        # validating only for date
        fetch_startdate = startdate.strftime("%b %d, %Y %I:%M:%S %p").\
            rpartition(',')[0]
        self.syncplan.create(plan_name, description, startdate=startdate_str)
        self.assertIsNotNone(self.products.search(plan_name))
        self.syncplan.search(plan_name).click()
        self.syncplan.wait_for_ajax()
        startdate_text = str(self.syncplan.wait_until_element(locator).text).\
            rpartition(',')[0]
        self.assertEqual(startdate_text, fetch_startdate)

    def test_negative_create_1(self):
        """
        @Feature: Content Sync Plan - Negative Create
        @Test: Create Sync Plan with whitespace as name input parameters
        @Assert: Sync Plan is not created with whitespace input
        """

        name = "   "
        locator = common_locators["common_invalid"]
        self.configure_syncplan()
        self.syncplan.create(name)
        invalid = self.products.wait_until_element(locator)
        self.assertTrue(invalid)

    def test_negative_create_2(self):
        """
        @Feature: Content Sync Plan - Negative Create
        @Test: Create Sync Plan with blank as name input parameters
        @Assert: Sync Plan is not created with blank input
        """

        name = ""
        locator = common_locators["common_invalid"]
        self.configure_syncplan()
        self.syncplan.create(name)
        invalid = self.products.wait_until_element(locator)
        self.assertTrue(invalid)

    @bzbug("1087425")
    @attr('ui', 'syncplan', 'implemented')
    @data(*generate_strings_list(len1=256))
    def test_negative_create_3(self, name):
        """
        @Feature: Content Sync Plan - Negative Create
        @Test: Create Sync Plan with long chars for name as input parameters
        @Assert: Sync Plan is not created with more than 255 chars
        @BZ: 1087425
        """

        locator = common_locators["common_haserror"]
        description = "more than 255 chars"
        self.configure_syncplan()
        self.syncplan.create(name, description)
        error = self.products.wait_until_element(locator)
        self.assertTrue(error)

    @attr('ui', 'syncplan', 'implemented')
    @data(*generate_strings_list())
    def test_positive_update_1(self, plan_name):
        """
        @Feature: Content Sync Plan - Positive Update name
        @Test: Update Sync plan's name
        @Assert: Sync Plan's name is updated
        """

        new_plan_name = generate_string("alpha", 8)
        description = "update sync plan"
        self.configure_syncplan()
        self.syncplan.create(plan_name, description)
        self.assertIsNotNone(self.products.search(plan_name))
        self.syncplan.update(plan_name, new_name=new_plan_name)
        self.assertIsNotNone(self.products.search(new_plan_name))

    @attr('ui', 'syncplan', 'implemented')
    @data(
        {
            u'name': generate_string('alpha', 10),
            u'interval': SYNC_INTERVAL['hour']
        }, {
            u'name': generate_string('numeric', 10),
            u'interval': SYNC_INTERVAL['hour']
        }, {
            u'name': generate_string('alphanumeric', 10),
            u'interval': SYNC_INTERVAL['hour']
        }, {
            u'name': generate_string('utf8', 10),
            u'interval': SYNC_INTERVAL['hour']
        }, {
            u'name': generate_string('html', 20),
            u'interval': SYNC_INTERVAL['hour']
        }, {
            u'name': generate_string('alpha', 10),
            u'interval': SYNC_INTERVAL['day']
        }, {
            u'name': generate_string('numeric', 10),
            u'interval': SYNC_INTERVAL['day']
        }, {
            u'name': generate_string('alphanumeric', 10),
            u'interval': SYNC_INTERVAL['day']
        }, {
            u'name': generate_string('utf8', 10),
            u'interval': SYNC_INTERVAL['day']
        }, {
            u'name': generate_string('html', 20),
            u'interval': SYNC_INTERVAL['day']
        }, {
            u'name': generate_string('alpha', 10),
            u'interval': SYNC_INTERVAL['week']
        }, {
            u'name': generate_string('numeric', 10),
            u'interval': SYNC_INTERVAL['week']
        }, {
            u'name': generate_string('alphanumeric', 10),
            u'interval': SYNC_INTERVAL['week']
        }, {
            u'name': generate_string('utf8', 10),
            u'interval': SYNC_INTERVAL['week']
        }, {
            u'name': generate_string('html', 20),
            u'interval': SYNC_INTERVAL['week']
        })
    def test_positive_update_2(self, test_data):
        """
        @Feature: Content Sync Plan - Positive Update interval
        @Test: Update Sync plan's interval
        @Assert: Sync Plan's interval is updated
        """

        description = "delete sync plan"
        locator = locators["sp.fetch_interval"]
        self.configure_syncplan()
        self.syncplan.create(test_data['name'], description)
        self.assertIsNotNone(self.products.search(test_data['name']))
        self.syncplan.update(test_data['name'],
                             new_sync_interval=test_data['interval'])
        self.navigator.go_to_sync_plans()
        self.syncplan.search(test_data['name']).click()
        interval_text = self.syncplan.wait_until_element(locator).text
        self.assertEqual(interval_text, test_data['interval'])

    @attr('ui', 'syncplan', 'implemented')
    @data(*generate_strings_list())
    def test_positive_update_3(self, plan_name):
        """
        @Feature: Content Sync Plan - Positive Update add products
        @Test: Update Sync plan and associate products
        @Assert: Sync Plan has the associated product
        """

        prd_name = generate_string("alpha", 8)
        description = "update sync plan, add prds"
        strategy, value = locators["sp.prd_select"]
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.navigator.go_to_sync_plans()
        self.syncplan.create(plan_name, description)
        self.assertIsNotNone(self.products.search(plan_name))
        self.syncplan.update(plan_name, add_products=[prd_name])
        self.syncplan.search(plan_name).click()
        self.syncplan.wait_for_ajax()
        self.syncplan.wait_until_element(tab_locators["sp.tab_products"]).\
            click()
        self.syncplan.wait_for_ajax()
        prd_element = self.syncplan.wait_until_element(
            (strategy, value % prd_name))
        self.assertTrue(prd_element)

    @attr('ui', 'syncplan', 'implemented')
    @data(*generate_strings_list())
    def test_positive_update_4(self, plan_name):
        """
        @Feature: Content Sync Plan - Positive Update remove products
        @Test: Update Sync plan and disassociate products
        @Assert: Sync Plan does not have the associated product
        """

        prd_name = generate_string("alpha", 8)
        plan_name = generate_string("alpha", 8)
        description = "update sync plan, add prds"
        strategy, value = locators["sp.prd_select"]
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.navigator.go_to_sync_plans()
        self.syncplan.create(plan_name, description)
        self.assertIsNotNone(self.products.search(plan_name))
        self.syncplan.update(plan_name, add_products=[prd_name])
        self.syncplan.search(plan_name).click()
        self.syncplan.wait_for_ajax()
        self.syncplan.wait_until_element(tab_locators["sp.tab_products"]).\
            click()
        self.syncplan.wait_for_ajax()
        prd_element = self.syncplan.wait_until_element(
            (strategy, value % prd_name))
        self.assertTrue(prd_element)
        self.syncplan.update(plan_name, rm_products=[prd_name])
        self.syncplan.search(plan_name).click()
        self.syncplan.wait_for_ajax()
        self.syncplan.wait_until_element(tab_locators["sp.tab_products"]).\
            click()
        self.syncplan.wait_for_ajax()
        self.syncplan.wait_until_element(tab_locators["sp.add_prd"]).\
            click()
        self.syncplan.wait_for_ajax()
        prd_element = self.syncplan.wait_until_element(
            (strategy, value % prd_name))
        self.assertTrue(prd_element)

    @attr('ui', 'syncplan', 'implemented')
    @data(*generate_strings_list())
    def test_positive_delete_1(self, plan_name):
        """
        @Feature: Content Sync Plan - Positive Delete
        @Test: Delete a Sync plan
        @Assert: Sync Plan is deleted
        """

        description = "delete sync plan"
        self.configure_syncplan()
        self.syncplan.create(plan_name, description)
        self.assertIsNotNone(self.products.search(plan_name))
        self.syncplan.delete(plan_name)
        self.assertIsNone(self.products.search(plan_name))
Exemple #24
0
class Products(UITestCase):
    """Implements Product tests in UI"""
    @classmethod
    def setUpClass(cls):  # noqa
        cls.org_name = entities.Organization().create()['name']
        cls.loc_name = entities.Location().create()['name']

        super(Products, cls).setUpClass()

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_positive_create_1(self, prd_name):
        """@Test: Create Content Product minimal input parameters

        @Feature: Content Product - Positive Create

        @Assert: Product is created

        """
        description = "test 123"
        with Session(self.browser) as session:
            make_product(session,
                         org=self.org_name,
                         loc=self.loc_name,
                         name=prd_name,
                         description=description)
            self.assertIsNotNone(self.products.search(prd_name))

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_positive_create_2(self, prd_name):
        """@Test: Create Content Product with same name but in another org

        @Feature: Content Product - Positive Create

        @Assert: Product is created successfully in both the orgs.

        """
        description = "test 123"
        org2_name = entities.Organization(
            name=gen_string("alpha", 8)).create()['name']
        with Session(self.browser) as session:
            make_product(session,
                         org=self.org_name,
                         loc=self.loc_name,
                         name=prd_name,
                         description=description)
            self.assertIsNotNone(self.products.search(prd_name))
            make_product(session,
                         org=org2_name,
                         loc=self.loc_name,
                         name=prd_name,
                         description=description,
                         force_context=True)
            self.assertIsNotNone(self.products.search(prd_name))

    @run_only_on('sat')
    @data(*generate_strings_list(len1=256))
    def test_negative_create_1(self, prd_name):
        """@Test: Create Content Product with too long input parameters

        @Feature: Content Product - Negative Create too long

        @Assert: Product is not created

        """
        locator = common_locators["common_haserror"]
        description = "test_negative_create_1"
        with Session(self.browser) as session:
            make_product(session,
                         org=self.org_name,
                         loc=self.loc_name,
                         name=prd_name,
                         description=description)
            error = session.nav.wait_until_element(locator)
            self.assertIsNotNone(error)

    @run_only_on('sat')
    def test_negative_create_2(self):
        """@Test: Create Content Product without input parameter

        @Feature: Content Product - Negative Create zero length

        @Assert: Product is not created

        """
        locator = common_locators["common_invalid"]
        prd_name = ""
        description = "test_negative_create_2"
        with Session(self.browser) as session:
            make_product(session,
                         org=self.org_name,
                         loc=self.loc_name,
                         name=prd_name,
                         description=description)
            invalid = self.products.wait_until_element(locator)
            self.assertIsNotNone(invalid)

    @run_only_on('sat')
    def test_negative_create_3(self):
        """@Test: Create Content Product with whitespace input parameter

        @Feature: Content Product - Negative Create with whitespace

        @Assert: Product is not created

        """
        locator = common_locators["common_invalid"]
        prd_name = "   "
        description = "test_negative_create_3"
        with Session(self.browser) as session:
            make_product(session,
                         org=self.org_name,
                         loc=self.loc_name,
                         name=prd_name,
                         description=description)
            invalid = self.products.wait_until_element(locator)
            self.assertIsNotNone(invalid)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_negative_create_4(self, prd_name):
        """@Test: Create Content Product with same name input parameter

        @Feature: Content Product - Negative Create with same name

        @Assert: Product is not created

        """
        locator = common_locators["common_haserror"]
        description = "test_negative_create_4"
        with Session(self.browser) as session:
            make_product(session,
                         org=self.org_name,
                         loc=self.loc_name,
                         name=prd_name,
                         description=description)
            self.assertIsNotNone(self.products.search(prd_name))
            self.products.create(prd_name, description)
            error = self.products.wait_until_element(locator)
            self.assertIsNotNone(error)

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_positive_update_1(self, prd_name):
        """@Test: Update Content Product with minimal input parameters

        @Feature: Content Product - Positive Update

        @Assert: Product is updated

        """
        new_prd_name = gen_string("alpha", 8)
        description = "test 123"
        with Session(self.browser) as session:
            make_product(session,
                         org=self.org_name,
                         loc=self.loc_name,
                         name=prd_name,
                         description=description)
            self.assertIsNotNone(self.products.search(prd_name))
            self.products.update(prd_name, new_name=new_prd_name)
            self.assertIsNotNone(self.products.search(new_prd_name))

    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_negative_update_1(self, prd_name):
        """@Test: Update Content Product with too long input parameters

        @Feature: Content Product - Negative Update

        @Assert: Product is not updated

        """
        locator = common_locators["alert.error"]
        new_prd_name = gen_string("alpha", 256)
        description = "test_negative_update_0"
        with Session(self.browser) as session:
            make_product(session,
                         org=self.org_name,
                         loc=self.loc_name,
                         name=prd_name,
                         description=description)
            self.assertIsNotNone(self.products.search(prd_name))
            self.products.update(prd_name, new_name=new_prd_name)
            error = self.products.wait_until_element(locator)
            self.assertIsNotNone(error)

    @skip_if_bug_open('redmine', 7845)
    @run_only_on('sat')
    @data(*generate_strings_list())
    def test_remove_prd(self, prd_name):
        """@Test: Delete Content Product

        @Feature: Content Product - Positive Delete

        @Assert: Product is deleted

        """
        description = "test 123"
        with Session(self.browser) as session:
            make_product(session,
                         org=self.org_name,
                         loc=self.loc_name,
                         name=prd_name,
                         description=description)
            self.assertIsNotNone(self.products.search(prd_name))
            self.products.delete(prd_name, True)
            self.assertIsNone(self.products.search(prd_name))
Exemple #25
0
class Domain(UITestCase):
    """Implements Domain tests in UI"""

    @data(*generate_strings_list(len1=4))
    def test_create_domain_1(self, name):
        """@Test: Create a new domain

        @Feature: Domain - Positive Create domain

        @Assert: Domain is created

        """
        domain_name = description = DOMAIN % name
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description)
            self.assertIsNotNone(element)

    # The length of chars is in accordance with DOMAIN global variable.
    @data(
        gen_string('alphanumeric', 243),
        gen_string('alpha', 243),
        gen_string('numeric', 243),
        gen_string('latin1', 243),
        gen_string('utf8', 243),
    )
    def test_create_domain_2(self, name):
        """@Test: Create a new domain

        @Feature: Domain - Positive Create domain with 255 chars

        @Assert: Domain is created

        """
        domain_name = description = DOMAIN % name
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description)
            self.assertIsNotNone(element)

    @data(*generate_strings_list(len1=4))
    def test_remove_domain(self, name):
        """@Test: Delete a domain

        @Feature: Domain - Delete

        @Assert: Domain is deleted

        """
        name = gen_string("alpha", 4)
        domain_name = description = DOMAIN % name
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description)
            self.assertIsNotNone(element)
            self.domain.delete(description, really=True,)
            self.assertIsNotNone(self.user.wait_until_element(
                common_locators["notif.success"]))
            self.assertIsNone(self.domain.search(description, timeout=5))

    @data({'name': gen_string('alpha', 10),
           'newname': gen_string('alpha', 10)},
          {'name': gen_string('numeric', 10),
           'newname': gen_string('numeric', 10)},
          {'name': gen_string('alphanumeric', 10),
           'newname': gen_string('alphanumeric', 10)},
          {'name': gen_string('utf8', 10),
           'newname': gen_string('utf8', 10)},
          {'name': gen_string('latin1', 10),
           'newname': gen_string('latin1', 10)},
          {'name': gen_string('html', 10),
           'newname': gen_string('html', 10)})
    def test_update_domain(self, testdata):
        """@Test: Update a domain with name and description\

        @Feature: Domain - Update

        @Assert: Domain is updated

        """
        domain_name = description = DOMAIN % testdata['name']
        new_name = new_description = DOMAIN % testdata['newname']
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description)
            self.assertIsNotNone(element)
            self.domain.update(domain_name, new_name, new_description)
            self.assertIsNotNone(self.domain.search(new_description))

    # The length of chars is in accordance with DOMAIN global variable.
    @data(*generate_strings_list(len1=244))
    def test_negative_create_domain_1(self, name):
        """@Test: Negative create a domain with name and description\

        @Feature: Domain - Negative Create

        @Assert: Domain is not created

        """
        domain_name = description = DOMAIN % name
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description, timeout=5)
            self.assertIsNone(element)

    @data("", "  ")
    def test_negative_create_domain_2(self, name):
        """@Test: Create domain with whitespace and blank in name

        @Feature: Domain - Negative Create

        @Assert: Domain is not created

        """
        domain_name = description = name
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            error = session.nav.wait_until_element(
                common_locators["name_haserror"])
            self.assertIsNotNone(error)

    @data(*generate_strings_list(len1=4))
    def test_positive_set_domain_parameter_1(self, name):
        """@Test: Set parameter name and value for domain

        @Feature: Domain - Misc

        @Assert: Domain is updated

        """
        domain_name = description = DOMAIN % name
        param_name = gen_string("alpha", 4)
        param_value = gen_string("alpha", 3)
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description)
            self.assertIsNotNone(element)
            try:
                self.domain.set_domain_parameter(description, param_name,
                                                 param_value)
            except Exception as e:
                self.fail(e)

    def test_positive_set_domain_parameter_2(self):
        """@Test: Set a parameter in a domain with 255 chars in name and value.

        @Feature: Domain - Misc.

        @Assert: Domain parameter is created.

        """
        name = gen_string("alpha", 4)
        domain_name = description = DOMAIN % name
        param_name = gen_string("alpha", 255)
        param_value = gen_string("alpha", 255)
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description)
            self.assertIsNotNone(element)
            try:
                self.domain.set_domain_parameter(description, param_name,
                                                 param_value)
            except Exception as e:
                self.fail(e)

    def test_positive_set_domain_parameter_3(self):
        """@Test: Set a parameter in a domain with blank value.

        @Feature: Domain - Misc.

        @Assert: Domain parameter is created with blank value.

        """
        name = gen_string("alpha", 4)
        domain_name = description = DOMAIN % name
        param_name = gen_string("alpha", 4)
        param_value = ""
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description)
            self.assertIsNotNone(element)
            try:
                self.domain.set_domain_parameter(description, param_name,
                                                 param_value)
            except Exception as e:
                self.fail(e)

    def test_set_domain_parameter_negative_1(self):
        """@Test: Set a parameter in a domain with 256 chars in name and value.

        @Feature: Domain - Misc.

        @Assert: Domain parameter is not updated.

        """
        name = gen_string("alpha", 4)
        domain_name = description = DOMAIN % name
        param_name = gen_string("alpha", 256)
        param_value = gen_string("alpha", 256)
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description)
            self.assertIsNotNone(element)
            try:
                self.domain.set_domain_parameter(description, param_name,
                                                 param_value)
            except Exception as e:
                self.fail(e)
            self.assertIsNotNone(session.nav.wait_until_element(
                common_locators["common_param_error"]))

    @skip_if_bug_open('bugzilla', 1123360)
    def test_set_domain_parameter_negative_2(self):
        """@Test: Again set the same parameter for domain with name and value.

        @Feature: Domain - Misc.

        @Assert: Domain parameter is not updated.

        @BZ: 1123360

        """
        name = gen_string("alpha", 4)
        domain_name = description = DOMAIN % name
        param_name = gen_string("alpha", 8)
        param_value = gen_string("alpha", 8)
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description)
            self.assertIsNotNone(element)
            try:
                self.domain.set_domain_parameter(description, param_name,
                                                 param_value)
                self.domain.set_domain_parameter(description, param_name,
                                                 param_value)
            except Exception as e:
                self.fail(e)
            self.assertIsNotNone(session.nav.wait_until_element(
                common_locators["common_param_error"]))

    @data(*generate_strings_list(len1=4))
    def test_remove_domain_parameter(self, name):
        """@Test: Remove a selected domain paramter

        @Feature: Domain - Misc

        @Assert: Domain parameter is removed

        """
        domain_name = description = DOMAIN % name
        param_name = gen_string("alpha", 3)
        param_value = gen_string("alpha", 3)
        with Session(self.browser) as session:
            make_domain(session, name=domain_name, description=description)
            element = self.domain.search(description)
            self.assertIsNotNone(element)
            try:
                self.domain.set_domain_parameter(description, param_name,
                                                 param_value)
                self.domain.remove_domain_parameter(description, param_name)
            except Exception as e:
                self.fail(e)
Exemple #26
0
class Medium(UITestCase):
    """Implements all Installation Media tests"""
    @data(*generate_strings_list(len1=4))
    def test_positive_create_medium_1(self, name):
        """@Test: Create a new media

        @Feature:  Media - Positive Create

        @Assert: Media is created

        """

        path = INSTALL_MEDIUM_URL % gen_string("alpha", 6)
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_media(session, name=name, path=path, os_family=os_family)
            self.assertIsNotNone(self.medium.search(name))

    @data(gen_string('alphanumeric', 255), gen_string('alpha', 255),
          gen_string('numeric', 255), gen_string('latin1', 255),
          gen_string('utf8', 255))
    def test_positive_create_medium_2(self, name):
        """@Test: Create a new media with 255 characters in name

        @Feature:  Media - Positive Create

        @Assert: Media is created

        """

        path = INSTALL_MEDIUM_URL % gen_string("alpha", 6)
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_media(session, name=name, path=path, os_family=os_family)
            self.assertIsNotNone(self.medium.search(name))

    def test_negative_create_medium_1(self):
        """@Test: Create a new install media with 256 characters in name

        @Feature:  Media - Negative Create

        @Assert: Media is not created

        """

        name = gen_string("alpha", 256)
        path = INSTALL_MEDIUM_URL % name
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_media(session, name=name, path=path, os_family=os_family)
            self.assertIsNotNone(
                self.medium.wait_until_element(
                    common_locators["name_haserror"]))
            self.assertIsNone(self.medium.search(name))

    @data("", "  ")
    def test_negative_create_medium_2(self, name):
        """@Test: Create a new install media with blank and whitespace in name

        @Feature:  Media - Negative Create

        @Assert: Media is not created

        """

        path = INSTALL_MEDIUM_URL % gen_string("alpha", 6)
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_media(session, name=name, path=path, os_family=os_family)
            self.assertIsNotNone(
                self.medium.wait_until_element(
                    common_locators["name_haserror"]))

    def test_negative_create_medium_4(self):
        """@Test: Create a new install media with same name

        @Feature:  Media - Negative Create

        @Assert: Media is not created

        """

        name = gen_string("alpha", 6)
        path = INSTALL_MEDIUM_URL % name
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_media(session, name=name, path=path, os_family=os_family)
            self.assertIsNotNone(self.medium.search(name))
            make_media(session, name=name, path=path, os_family=os_family)
            self.assertIsNotNone(
                self.medium.wait_until_element(
                    common_locators["name_haserror"]))

    def test_negative_create_medium_5(self):
        """@Test: Create a new install media without media URL

        @Feature:  Media - Negative Create

        @Assert: Media is not created

        """

        name = gen_string("alpha", 6)
        path = ""
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_media(session, name=name, path=path, os_family=os_family)
            self.assertIsNotNone(
                self.medium.wait_until_element(common_locators["haserror"]))
            self.assertIsNone(self.medium.search(name))

    def test_negative_create_medium_6(self):
        """@Test: Create an install media with an existing URL

        @Feature:  Media - Negative Create

        @Assert: Media is not created

        """

        name = gen_string("alpha", 6)
        new_name = gen_string("alpha", 6)
        path = INSTALL_MEDIUM_URL % gen_string("alpha", 6)
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_media(session, name=name, path=path, os_family=os_family)
            self.assertIsNotNone(self.medium.search(name))
            make_media(session, name=new_name, path=path, os_family=os_family)
            self.assertIsNotNone(
                self.medium.wait_until_element(common_locators["haserror"]))
            self.assertIsNone(self.medium.search(new_name))

    def test_remove_medium(self):
        """@Test: Delete a media

        @Feature: Media - Delete

        @Assert: Media is deleted

        """
        name = gen_string("alpha", 6)
        path = INSTALL_MEDIUM_URL % name
        os_family = "Red Hat"
        with Session(self.browser) as session:
            make_media(session, name=name, path=path, os_family=os_family)
            self.assertIsNotNone(self.medium.search(name))
            self.medium.delete(name, True)
            self.assertIsNone(self.medium.search(name))

    def test_update_medium(self):
        """@Test: Updates Install media with name, path, OS family

        @Feature: Media - Update

        @Assert: Media is updated

        """
        name = gen_string("alpha", 6)
        newname = gen_string("alpha", 4)
        path = INSTALL_MEDIUM_URL % name
        newpath = INSTALL_MEDIUM_URL % newname
        os_family = "Red Hat"
        new_os_family = "Debian"
        with Session(self.browser) as session:
            make_media(session, name=name, path=path, os_family=os_family)
            self.assertIsNotNone(self.medium.search(name))
            self.medium.update(name, newname, newpath, new_os_family)
            self.assertTrue(self, self.medium.search(newname))
Exemple #27
0
class Syncplan(UITestCase):
    """Implements Sync Plan tests in UI"""

    @classmethod
    def setUpClass(cls):  # noqa
        org_attrs = entities.Organization().create()
        cls.org_name = org_attrs['name']
        cls.org_id = org_attrs['id']

        super(Syncplan, cls).setUpClass()

    @data({u'name': gen_string('alpha', 10),
           u'desc': gen_string('alpha', 10),
           u'interval': SYNC_INTERVAL['hour']},
          {u'name': gen_string('numeric', 10),
           u'desc': gen_string('numeric', 10),
           u'interval': SYNC_INTERVAL['hour']},
          {u'name': gen_string('alphanumeric', 10),
           u'desc': gen_string('alphanumeric', 10),
           u'interval': SYNC_INTERVAL['hour']},
          {u'name': gen_string('utf8', 10),
           u'desc': gen_string('utf8', 10),
           u'interval': SYNC_INTERVAL['hour']},
          {u'name': gen_string('html', 20),
           u'desc': gen_string('html', 10),
           u'interval': SYNC_INTERVAL['hour']},
          {u'name': gen_string('alpha', 10),
           u'desc': gen_string('alpha', 10),
           u'interval': SYNC_INTERVAL['day']},
          {u'name': gen_string('numeric', 10),
           u'desc': gen_string('numeric', 10),
           u'interval': SYNC_INTERVAL['day']},
          {u'name': gen_string('alphanumeric', 10),
           u'desc': gen_string('alphanumeric', 10),
           u'interval': SYNC_INTERVAL['day']},
          {u'name': gen_string('utf8', 10),
           u'desc': gen_string('utf8', 10),
           u'interval': SYNC_INTERVAL['day']},
          {u'name': gen_string('html', 20),
           u'desc': gen_string('html', 10),
           u'interval': SYNC_INTERVAL['day']},
          {u'name': gen_string('alpha', 10),
           u'desc': gen_string('alpha', 10),
           u'interval': SYNC_INTERVAL['week']},
          {u'name': gen_string('numeric', 10),
           u'desc': gen_string('numeric', 10),
           u'interval': SYNC_INTERVAL['week']},
          {u'name': gen_string('alphanumeric', 10),
           u'desc': gen_string('alphanumeric', 10),
           u'interval': SYNC_INTERVAL['week']},
          {u'name': gen_string('utf8', 10),
           u'desc': gen_string('utf8', 10),
           u'interval': SYNC_INTERVAL['week']},
          {u'name': gen_string('html', 20),
           u'desc': gen_string('html', 10),
           u'interval': SYNC_INTERVAL['week']})
    def test_positive_create_1(self, test_data):
        """@Test: Create Sync Plan with minimal input parameters

        @Feature: Content Sync Plan - Positive Create

        @Assert: Sync Plan is created

        """
        with Session(self.browser) as session:
            make_syncplan(session, org=self.org_name,
                          name=test_data['name'],
                          description=test_data['desc'],
                          sync_interval=test_data['interval'])
            self.assertIsNotNone(self.syncplan.search(test_data['name']))

    @skip_if_bug_open('bugzilla', 1131661)
    def test_positive_create_2(self):
        """@Test: Create Sync plan with specified start time

        @Feature: Content Sync Plan - Positive Create

        @Assert: Sync Plan is created with the specified time.

        @BZ: 1131661

        """
        locator = locators["sp.fetch_startdate"]
        plan_name = gen_string("alpha", 8)
        description = "sync plan create with start date"
        current_date = datetime.now()
        startdate = current_date + timedelta(minutes=10)
        starthour = startdate.strftime("%H")
        startminute = startdate.strftime("%M")
        # Formatting current_date to web-UI format "%b %d, %Y %I:%M:%S %p" and
        # removed zero-padded date(%-d) and hrs(%l) as fetching via web-UI
        # doesn't have it
        formatted_date_time = startdate.strftime("%b %-d, %Y %l:%M:%S %p")
        # Removed the seconds info as it would be too quick to validate via UI.
        starttime = formatted_date_time.rpartition(':')[0]
        with Session(self.browser) as session:
            make_syncplan(session, org=self.org_name, name=plan_name,
                          description=description, start_hour=starthour,
                          start_minute=startminute)
            self.assertIsNotNone(self.syncplan.search(plan_name))
            self.syncplan.search(plan_name).click()
            self.syncplan.wait_for_ajax()
            starttime_text = self.syncplan.wait_until_element(locator).text
            # Removed the seconds info as it would be too quick
            # to validate via UI.
            saved_starttime = str(starttime_text).rpartition(':')[0]
            self.assertEqual(saved_starttime, starttime)

    @skip_if_bug_open('bugzilla', 1131661)
    def test_positive_create_3(self):
        """@Test: Create Sync plan with specified start date

        @Feature: Content Sync Plan - Positive Create

        @Assert: Sync Plan is created with the specified date

        @BZ: 1131661

        """
        locator = locators["sp.fetch_startdate"]
        plan_name = gen_string("alpha", 8)
        description = "sync plan create with start date"
        current_date = datetime.now()
        startdate = current_date + timedelta(days=10)
        startdate_str = startdate.strftime("%Y-%m-%d")
        current_date_time = startdate.strftime("%b %-d, %Y %I:%M:%S %p")
        # validating only for date
        fetch_startdate = current_date_time.rpartition(',')[0]
        with Session(self.browser) as session:
            make_syncplan(session, org=self.org_name, name=plan_name,
                          description=description, startdate=startdate_str)
            self.assertIsNotNone(self.syncplan.search(plan_name))
            self.syncplan.search(plan_name).click()
            self.syncplan.wait_for_ajax()
            startdate_text = self.syncplan.wait_until_element(locator).text
            saved_startdate = str(startdate_text).rpartition(',')[0]
            self.assertEqual(saved_startdate, fetch_startdate)

    @data("", "  ")
    def test_negative_create_1(self, name):
        """@Test: Create Sync Plan with blank and whitespace in name

        @Feature: Content Sync Plan - Negative Create

        @Assert: Sync Plan is not created
        """
        locator = common_locators["common_invalid"]
        with Session(self.browser) as session:
            make_syncplan(session, org=self.org_name, name=name,
                          submit_validate=False)
            invalid = self.syncplan.wait_until_element(locator)
            self.assertIsNotNone(invalid)

    @skip_if_bug_open('bugzilla', 1087425)
    @data(*generate_strings_list(len1=256))
    def test_negative_create_2(self, name):
        """@Test: Create Sync Plan with 256 characters in name

        @Feature: Content Sync Plan - Negative Create

        @Assert: Sync Plan is not created with more than 255 chars

        @BZ: 1087425

        """
        locator = common_locators["common_haserror"]
        description = "more than 255 chars"
        with Session(self.browser) as session:
            make_syncplan(session, org=self.org_name, name=name,
                          description=description, submit_validate=False)
            error = self.syncplan.wait_until_element(locator)
            self.assertIsNotNone(error)

    @data(*generate_strings_list())
    def test_negative_create_3(self, name):
        """@Test: Create Sync Plan with an existing name

        @Feature: Content Sync Plan - Positive Create

        @Assert: Sync Plan cannot be created with existing name

        @BZ: 1087425

        """
        description = "with same name"
        # TODO: Due to bug 1087425 using common_haserror instead of name_error
        locator = common_locators["common_haserror"]
        with Session(self.browser) as session:
            make_syncplan(session, org=self.org_name, name=name)
            self.assertIsNotNone(self.syncplan.search(name))
            make_syncplan(session, org=self.org_name, name=name,
                          description=description, submit_validate=False)
            error = self.syncplan.wait_until_element(locator)
            self.assertIsNotNone(error)

    @data(*generate_strings_list())
    def test_positive_update_1(self, plan_name):
        """@Test: Update Sync plan's name

        @Feature: Content Sync Plan - Positive Update name

        @Assert: Sync Plan's name is updated

        """
        new_plan_name = gen_string("alpha", 8)
        entities.Organization(id=self.org_id).sync_plan(
            name=plan_name,
            interval=SYNC_INTERVAL['day']
        )
        with Session(self.browser) as session:
            session.nav.go_to_select_org(self.org_name)
            session.nav.go_to_sync_plans()
            self.syncplan.update(plan_name, new_name=new_plan_name)
            self.assertIsNotNone(self.syncplan.search(new_plan_name))

    @data({u'name': gen_string('alpha', 10),
           u'interval': SYNC_INTERVAL['hour']},
          {u'name': gen_string('numeric', 10),
           u'interval': SYNC_INTERVAL['hour']},
          {u'name': gen_string('alphanumeric', 10),
           u'interval': SYNC_INTERVAL['hour']},
          {u'name': gen_string('utf8', 10),
           u'interval': SYNC_INTERVAL['hour']},
          {u'name': gen_string('html', 20),
           u'interval': SYNC_INTERVAL['hour']},
          {u'name': gen_string('alpha', 10),
           u'interval': SYNC_INTERVAL['day']},
          {u'name': gen_string('numeric', 10),
           u'interval': SYNC_INTERVAL['day']},
          {u'name': gen_string('alphanumeric', 10),
           u'interval': SYNC_INTERVAL['day']},
          {u'name': gen_string('utf8', 10),
           u'interval': SYNC_INTERVAL['day']},
          {u'name': gen_string('html', 20),
           u'interval': SYNC_INTERVAL['day']},
          {u'name': gen_string('alpha', 10),
           u'interval': SYNC_INTERVAL['week']},
          {u'name': gen_string('numeric', 10),
           u'interval': SYNC_INTERVAL['week']},
          {u'name': gen_string('alphanumeric', 10),
           u'interval': SYNC_INTERVAL['week']},
          {u'name': gen_string('utf8', 10),
           u'interval': SYNC_INTERVAL['week']},
          {u'name': gen_string('html', 20),
           u'interval': SYNC_INTERVAL['week']})
    def test_positive_update_2(self, test_data):
        """@Test: Update Sync plan's interval

        @Feature: Content Sync Plan - Positive Update interval

        @Assert: Sync Plan's interval is updated

        """
        locator = locators["sp.fetch_interval"]
        entities.Organization(id=self.org_id).sync_plan(
            name=test_data['name'],
            interval=SYNC_INTERVAL['day']
        )
        with Session(self.browser) as session:
            session.nav.go_to_select_org(self.org_name)
            session.nav.go_to_sync_plans()
            self.syncplan.update(test_data['name'],
                                 new_sync_interval=test_data['interval'])
            session.nav.go_to_sync_plans()
            self.syncplan.search(test_data['name']).click()
            self.syncplan.wait_for_ajax()
            # Assert updated sync interval
            interval_text = self.syncplan.wait_until_element(locator).text
            self.assertEqual(interval_text, test_data['interval'])

    @data(*generate_strings_list())
    def test_positive_update_3(self, plan_name):
        """@Test: Update Sync plan and associate products

        @Feature: Content Sync Plan - Positive Update add products

        @Assert: Sync Plan has the associated product

        """
        strategy, value = locators["sp.prd_select"]
        product_name = entities.Product(
            organization=self.org_id
        ).create()['name']
        entities.Organization(id=self.org_id).sync_plan(
            name=plan_name,
            interval=SYNC_INTERVAL['week']
        )
        with Session(self.browser) as session:
            session.nav.go_to_select_org(self.org_name)
            session.nav.go_to_sync_plans()
            self.syncplan.update(plan_name, add_products=[product_name])
            self.syncplan.search(plan_name).click()
            self.syncplan.wait_for_ajax()
            # Assert product is associated with sync plan
            self.syncplan.wait_until_element(
                tab_locators["sp.tab_products"]).click()
            self.syncplan.wait_for_ajax()
            element = self.syncplan.wait_until_element(
                (strategy, value % product_name))
            self.assertIsNotNone(element)

    @data(*generate_strings_list())
    def test_positive_update_4(self, plan_name):
        """@Test: Update Sync plan and disassociate products

        @Feature: Content Sync Plan - Positive Update remove products

        @Assert: Sync Plan does not have the associated product

        """
        strategy, value = locators["sp.prd_select"]
        product_name = entities.Product(
            organization=self.org_id
        ).create()['name']
        entities.Organization(id=self.org_id).sync_plan(
            name=plan_name,
            interval=SYNC_INTERVAL['week']
        )
        with Session(self.browser) as session:
            session.nav.go_to_select_org(self.org_name)
            session.nav.go_to_sync_plans()
            self.syncplan.update(plan_name, add_products=[product_name])
            self.syncplan.search(plan_name).click()
            self.syncplan.wait_for_ajax()
            self.syncplan.wait_until_element(
                tab_locators["sp.tab_products"]).click()
            self.syncplan.wait_for_ajax()
            element = self.syncplan.wait_until_element(
                (strategy, value % product_name))
            self.assertIsNotNone(element)
            # Dis-associate the product from sync plan and the selected product
            # should automatically move from 'List/Remove` tab to 'Add' tab
            self.syncplan.update(plan_name, rm_products=[product_name])
            self.syncplan.search(plan_name).click()
            self.syncplan.wait_for_ajax()
            self.syncplan.wait_until_element(
                tab_locators["sp.tab_products"]).click()
            self.syncplan.wait_for_ajax()
            self.syncplan.wait_until_element(
                tab_locators["sp.add_prd"]).click()
            self.syncplan.wait_for_ajax()
            element = self.syncplan.wait_until_element(
                (strategy, value % product_name))
            self.assertIsNotNone(element)

    @data(*generate_strings_list())
    def test_positive_delete_1(self, plan_name):
        """@Test: Delete a Sync plan

        @Feature: Content Sync Plan - Positive Delete

        @Assert: Sync Plan is deleted

        """
        entities.Organization(id=self.org_id).sync_plan(
            name=plan_name,
            interval=SYNC_INTERVAL['day']
        )
        with Session(self.browser) as session:
            session.nav.go_to_select_org(self.org_name)
            session.nav.go_to_sync_plans()
            self.syncplan.delete(plan_name)
            self.assertIsNone(self.syncplan.search(plan_name))
Exemple #28
0
class Products(BaseUI):
    """
    Implements Product tests in UI
    """

    org_name = None

    def setUp(self):
        super(Products, self).setUp()
        # Make sure to use the Class' org_name instance
        if Products.org_name is None:
            Products.org_name = generate_string("alpha", 8)
            with Session(self.browser) as session:
                make_org(session, org_name=Products.org_name)

    @attr('ui', 'prd', 'implemented')
    @data(*generate_strings_list())
    def test_positive_create_0(self, prd_name):
        """
        @Feature: Content Product - Positive Create
        @Test: Create Content Product minimal input parameters
        @Assert: Product is created
        """

        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))

    @attr('ui', 'prd', 'implemented')
    @data(*generate_strings_list(len1=256))
    def test_negative_create_0(self, prd_name):
        """
        @Feature: Content Product - Negative Create too long
        @Test: Create Content Product with too long input parameters
        @Assert: Product is not created
        """

        locator = common_locators["common_haserror"]
        description = "test_negative_create_0"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(Products.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        error = self.products.wait_until_element(locator)
        self.assertTrue(error)

    def test_negative_create_1(self):
        """
        @Feature: Content Product - Negative Create zero length
        @Test: Create Content Product without input parameter
        @Assert: Product is not created
        """

        locator = common_locators["common_invalid"]
        prd_name = ""
        description = "test_negative_create_1"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(Products.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        invalid = self.products.wait_until_element(locator)
        self.assertTrue(invalid)

    def test_negative_create_2(self):
        """
        @Feature: Content Product - Negative Create with whitespace
        @Test: Create Content Product with whitespace input parameter
        @Assert: Product is not created
        """

        locator = common_locators["common_invalid"]
        prd_name = "   "
        description = "test_negative_create_2"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(Products.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        invalid = self.products.wait_until_element(locator)
        self.assertTrue(invalid)

    @attr('ui', 'prd', 'implemented')
    @data(*generate_strings_list())
    def test_negative_create_3(self, prd_name):
        """
        @Feature: Content Product - Negative Create with same name
        @Test: Create Content Product with same name input parameter
        @Assert: Product is not created
        """

        locator = common_locators["common_haserror"]
        description = "test_negative_create_3"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(Products.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.products.create(prd_name, description)
        error = self.products.wait_until_element(locator)
        self.assertTrue(error)

    @attr('ui', 'prd', 'implemented')
    @data(*generate_strings_list())
    def test_positive_update_0(self, prd_name):
        """
        @Feature: Content Product - Positive Update
        @Test: Update Content Product with minimal input parameters
        @Assert: Product is updated
        """

        new_prd_name = generate_string("alpha", 8)
        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.products.update(prd_name, new_name=new_prd_name)
        self.assertIsNotNone(self.products.search(new_prd_name))

    @attr('ui', 'prd', 'implemented')
    @data(*generate_strings_list())
    def test_negative_update_0(self, prd_name):
        """
        @Feature: Content Product - Negative Update
        @Test: Update Content Product with too long input parameters
        @Assert: Product is not updated
        """

        locator = common_locators["common_haserror"]
        new_prd_name = generate_string("alpha", 256)
        description = "test_negative_update_0"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(Products.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.products.update(prd_name, new_name=new_prd_name)
        error = self.products.wait_until_element(locator)
        self.assertTrue(error)

    @attr('ui', 'prd', 'implemented')
    @data(*generate_strings_list())
    def test_remove_prd(self, prd_name):
        """
        @Feature: Content Product - Positive Delete
        @Test: Delete Content Product
        @Assert: Product is deleted
        """

        description = "test 123"
        self.login.login(self.katello_user, self.katello_passwd)
        self.navigator.go_to_select_org(self.org_name)
        self.navigator.go_to_products()
        self.products.create(prd_name, description)
        self.assertIsNotNone(self.products.search(prd_name))
        self.products.delete(prd_name, True)
        self.assertIsNone(self.products.search(prd_name))