Exemple #1
0
    def test_positive_update_3(self):
        """@Test: Create a repository and update its GPGKey

        @Feature: Repositories

        @Assert: Repository is updated with new GPGkey

        """
        key_1_content = read_data_file(VALID_GPG_KEY_FILE)
        key_2_content = read_data_file(VALID_GPG_KEY_BETA_FILE)

        # Create an organization and product
        org_attrs = entities.Organization().create()
        product_attrs = entities.Product(
            organization=org_attrs['id']
        ).create()

        gpgkey_1_attrs = entities.GPGKey(
            content=key_1_content,
            organization=org_attrs['id']
        ).create()

        gpgkey_2_attrs = entities.GPGKey(
            content=key_2_content,
            organization=org_attrs['id']
        ).create()

        # Creates new repository
        repository_attrs = entities.Repository(
            url=FAKE_1_YUM_REPO,
            product=product_attrs['id'],
            gpg_key=gpgkey_1_attrs['id'],
        ).create()

        path = entities.Repository(id=repository_attrs['id']).path()

        repository_copy = copy.deepcopy(repository_attrs)
        repository_copy['gpg_key_id'] = gpgkey_2_attrs['id']

        response = client.put(
            path,
            repository_copy,
            auth=get_server_credentials(),
            verify=False,
        )
        status_code = httplib.OK
        self.assertEqual(
            response.status_code,
            status_code,
            status_code_error(path, status_code, response),
        )
        # Fetch the updated repository
        updated_attrs = entities.Repository(
            id=repository_attrs['id']
        ).read_json()
        # Assert that key is updated
        self.assertEqual(
            updated_attrs['gpg_key_id'],
            gpgkey_2_attrs['id'],
        )
Exemple #2
0
    def test_update_gpgkey(self):
        """@Test: Create a repository and update its GPGKey

        @Assert: The updated repository points to a new GPG key.

        @Feature: Repository

        """
        # Create a repo and make it point to a GPG key.
        key_1_id = entities.GPGKey(
            content=read_data_file(VALID_GPG_KEY_FILE),
            organization=self.org_id,
        ).create_json()['id']
        repo_id = entities.Repository(
            gpg_key=key_1_id,
            product=self.prod_id,
        ).create_json()['id']

        # Update the repo and make it point to a new GPG key.
        key_2_id = entities.GPGKey(
            content=read_data_file(VALID_GPG_KEY_BETA_FILE),
            organization=self.org_id,
        ).create_json()['id']
        client.put(
            entities.Repository(id=repo_id).path(),
            {u'gpg_key_id': key_2_id},
            auth=get_server_credentials(),
            verify=False,
        ).raise_for_status()

        # Verify the repository's attributes.
        attrs = entities.Repository(id=repo_id).read_json()
        self.assertEqual(attrs['gpg_key_id'], key_2_id)
Exemple #3
0
    def test_update_gpgkey(self):
        """@Test: Create a repository and update its GPGKey

        @Assert: The updated repository points to a new GPG key.

        @Feature: Repository

        """
        # Create a repo and make it point to a GPG key.
        key_1_id = entities.GPGKey(
            content=read_data_file(VALID_GPG_KEY_FILE),
            organization=self.org_id,
        ).create()['id']
        repo_id = entities.Repository(
            gpg_key=key_1_id,
            product=self.prod_id,
        ).create()['id']

        # Update the repo and make it point to a new GPG key.
        key_2_id = entities.GPGKey(
            content=read_data_file(VALID_GPG_KEY_BETA_FILE),
            organization=self.org_id,
        ).create()['id']
        client.put(
            entities.Repository(id=repo_id).path(),
            {
                u'gpg_key_id': key_2_id
            },
            auth=get_server_credentials(),
            verify=False,
        ).raise_for_status()

        # Verify the repository's attributes.
        attrs = entities.Repository(id=repo_id).read_json()
        self.assertEqual(attrs['gpg_key_id'], key_2_id)
Exemple #4
0
    def test_positive_create_2(self, name):
        """@Test: Create a product with gpg_key

        @Feature: Products

        @Assert: Product is created with gpg_key

        """
        key_content = read_data_file(VALID_GPG_KEY_FILE)
        key_name = orm.StringField(str_type=('alphanumeric',)).get_value()

        # Create an organization, GPG key and product.
        #
        # * GPG key points to organization
        # * Product points to organization and GPG key
        #
        org_attrs = entities.Organization().create()
        gpgkey_attrs = entities.GPGKey(
            name=key_name,
            content=key_content,
            organization=org_attrs['id']
        ).create()
        product_attrs = entities.Product(
            name=name,
            gpg_key=gpgkey_attrs['id'],
            organization=org_attrs['id']
        ).create()

        # GET the product and verify it's name and gpg_key id.
        response = entities.Product(id=product_attrs['id']).read_json()
        self.assertEqual(response['name'], name)
        self.assertEqual(response['gpg_key_id'], gpgkey_attrs['id'])
Exemple #5
0
    def test_positive_create_2(self):
        """@Test: Create a product and provide a GPG key.

        @Assert: A product is created with the specified GPG key.

        @Feature: Product

        """
        # Create an organization, GPG key and product.
        #
        # * GPG key points to organization
        # * Product points to organization and GPG key
        #
        # Re-using an organization speeds up the test.
        org_attrs = entities.Organization().create()
        gpgkey_attrs = entities.GPGKey(
            content=read_data_file(VALID_GPG_KEY_FILE),
            organization=org_attrs['id']
        ).create()
        product_attrs = entities.Product(
            gpg_key=gpgkey_attrs['id'],
            organization=org_attrs['id']
        ).create()

        # GET the product and verify it's GPG key ID.
        attrs = entities.Product(id=product_attrs['id']).read_json()
        self.assertEqual(attrs['gpg_key_id'], gpgkey_attrs['id'])
Exemple #6
0
    def test_create_gpgkey(self):
        """@Test: Create a repository and provide a GPG key ID.

        @Assert: A repository is created with the given GPG key ID.

        @Feature: Repository

        """
        # Create this dependency tree:
        #
        # repository -> product -.
        #           `-> gpg key --`-> organization
        #
        gpgkey_id = entities.GPGKey(
            content=read_data_file(VALID_GPG_KEY_FILE),
            organization=self.org_id,
        ).create_json()['id']
        repo_id = entities.Repository(
            gpg_key=gpgkey_id,
            product=self.prod_id,
        ).create_json()['id']

        # Verify that the given GPG key ID is used.
        repo_attrs = entities.Repository(id=repo_id).read_json()
        self.assertEqual(repo_attrs['gpg_key_id'], gpgkey_id)
Exemple #7
0
    def test_positive_create_2(self, name):
        """@Test: Create a repository with gpg_key

        @Feature: Repositories

        @Assert: Repository is created with gpg-key

        """

        key_content = read_data_file(VALID_GPG_KEY_FILE)

        # Create an organization, gpg_key, product and repository
        org_attrs = entities.Organization().create()

        gpgkey_attrs = entities.GPGKey(
            content=key_content,
            organization=org_attrs['id']
        ).create()

        product_attrs = entities.Product(
            organization=org_attrs['id']
        ).create()
        # Creates new repository with GPGKey
        repository_attrs = entities.Repository(
            name=name,
            url=FAKE_1_YUM_REPO,
            product=product_attrs['id'],
            gpg_key=gpgkey_attrs['id'],
        ).create()
        # Get the repository and verify it's name.
        response = entities.Repository(id=repository_attrs['id']).read_json()
        self.assertEqual(response['name'], name)
        self.assertEqual(response['gpg_key_id'], gpgkey_attrs['id'])
Exemple #8
0
    def test_create_gpgkey(self):
        """@Test: Create a repository and provide a GPG key ID.

        @Assert: A repository is created with the given GPG key ID.

        @Feature: Repository

        """
        # Create this dependency tree:
        #
        # repository -> product -.
        #           `-> gpg key --`-> organization
        #
        gpgkey_id = entities.GPGKey(
            content=read_data_file(VALID_GPG_KEY_FILE),
            organization=self.org_id,
        ).create()['id']
        repo_id = entities.Repository(
            gpg_key=gpgkey_id,
            product=self.prod_id,
        ).create()['id']

        # Verify that the given GPG key ID is used.
        repo_attrs = entities.Repository(id=repo_id).read_json()
        self.assertEqual(repo_attrs['gpg_key_id'], gpgkey_id)
Exemple #9
0
    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)
Exemple #10
0
 def create_partition_table(self, name, layout, os_family=None):
     """
     Creates partition table with navigation
     """
     name = name or generate_string("alpha", 8)
     layout = layout or read_data_file(PARTITION_SCRIPT_DATA_FILE)
     os_family = os_family or "Red Hat"
     self.navigator.go_to_partition_tables()
     self.partitiontable.create(name, layout, os_family)
     self.assertIsNotNone(self.partitiontable.search(name))
Exemple #11
0
 def create_partition_table(self, name, layout, os_family=None):
     """
     Creates partition table with navigation
     """
     name = name or generate_name(6)
     layout = layout or read_data_file(PARTITION_SCRIPT_DATA_FILE)
     os_family = os_family or "Red Hat"
     self.navigator.go_to_partition_tables()
     self.partitiontable.create(name, layout, os_family)
     self.assertIsNotNone(self.partitiontable.search(name))
Exemple #12
0
    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)
Exemple #13
0
    def test_create_partition_table(self):
        """
        @Feature: Partition table - Positive Create
        @Test: Create a new partition table
        @Assert: Partition table is created
        """

        name = generate_string("alpha", 8)
        layout = read_data_file(PARTITION_SCRIPT_DATA_FILE)
        os_family = "Red Hat"
        self.login.login(self.katello_user, self.katello_passwd)
        self.create_partition_table(name, layout, os_family)
Exemple #14
0
    def test_create_partition_table(self):
        """
        @Feature: Partition table - Positive Create
        @Test: Create a new partition table
        @Assert: Partition table is created
        """

        name = generate_name(6)
        layout = read_data_file(PARTITION_SCRIPT_DATA_FILE)
        os_family = "Red Hat"
        self.login.login(self.katello_user, self.katello_passwd)
        self.create_partition_table(name, layout, os_family)
Exemple #15
0
    def test_delete_version_default(self):
        """@Test: Delete a content-view version associated to 'Library'

        @Assert: Deletion fails

        @Feature: ContentViewVersion

        """
        key_content = read_data_file(ZOO_CUSTOM_GPG_KEY)
        org = entities.Organization().create()
        gpgkey_id = entities.GPGKey(
            content=key_content,
            organization=org.id
        ).create_json()['id']
        # Creates new product without selecting GPGkey
        product_id = entities.Product(
            organization=org.id
        ).create_json()['id']
        # Creates new repository with GPGKey
        repo = entities.Repository(
            url=FAKE_1_YUM_REPO,
            product=product_id,
            gpg_key=gpgkey_id,
        ).create()
        # sync repository
        repo.sync()
        # Create content view
        cv = entities.ContentView(
            organization=org.id
        ).create()
        # Associate repository to new content view
        client.put(
            cv.path(),
            {u'repository_ids': [repo.id]},
            auth=get_server_credentials(),
            verify=False,
        ).raise_for_status()
        # Publish content view
        cv.publish()
        # Get published content-view version info
        cv_info = entities.ContentView(id=cv.id).read_json()
        self.assertEqual(len(cv_info['versions']), 1)
        # API returns version like '1.0'
        version_num = cv_info['versions'][0]['version']
        # WebUI displays version like 'Version 1.0'
        version = 'Version {0}'.format(version_num)
        with Session(self.browser) as session:
            session.nav.go_to_select_org(org.name)
            session.nav.go_to_content_views()
            self.content_views.delete_version(cv.name, version)
            self.content_views.check_progress_bar_status(version)
            self.content_views.validate_version_deleted(cv.name, version)
Exemple #16
0
    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))
Exemple #17
0
    def test_negative_create_partition_table_2(self, test_data):
        """
        @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=test_data['name'], layout=layout,
                                os_family=os_family)
            self.assertIsNotNone(self.partitiontable.wait_until_element
                                 (common_locators["name_haserror"]))
Exemple #18
0
    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))
Exemple #19
0
    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))
Exemple #20
0
    def test_update_partition_table(self):
        """
        @Feature: Partition table - Positive Update
        @Test: Update partition table with its name, layout and OS family
        @Assert: Partition table is updated
        """

        name = generate_name(6)
        new_name = generate_name(4)
        layout = "test layout"
        new_layout = read_data_file(PARTITION_SCRIPT_DATA_FILE)
        os_family = "Debian"
        new_os_family = "Red Hat"
        self.login.login(self.katello_user, self.katello_passwd)
        self.create_partition_table(name, layout, os_family)
        self.partitiontable.update(name, new_name, new_layout, new_os_family)
        self.assertIsNotNone(self, self.partitiontable.search(new_name))
    def test_delete_version(self):
        """@Test: Create content view and publish it. After that try to
        disassociate content view from 'Library' environment through
        'delete_from_environment' command and delete content view version from
        that content view. Add repository and gpg key to initial content view
        for better coverage

        @Assert: Content version deleted successfully

        @Feature: ContentViewVersion

        """
        key_content = read_data_file(ZOO_CUSTOM_GPG_KEY)
        org = entities.Organization().create()
        gpgkey = entities.GPGKey(
            content=key_content,
            organization=org,
        ).create()
        # Creates new product without selecting GPGkey
        product = entities.Product(organization=org).create()
        # Creates new repository with GPGKey
        repo = entities.Repository(
            gpg_key=gpgkey,
            product=product,
            url=FAKE_1_YUM_REPO,
        ).create()
        # sync repository
        repo.sync()
        # Create content view
        content_view = entities.ContentView(organization=org).create()
        # Associate repository to new content view
        content_view.repository = [repo]
        content_view = content_view.update(['repository'])
        # Publish content view
        content_view.publish()
        content_view = content_view.read()
        # Get published content-view version id
        self.assertEqual(len(content_view.version), 1)
        cvv = content_view.version[0].read()
        self.assertEqual(len(cvv.environment), 1)
        # Delete the content-view version from selected env
        content_view.delete_from_environment(cvv.environment[0].id)
        # Delete the version
        content_view.version[0].delete()
        # Make sure that content view version is really removed
        self.assertEqual(len(content_view.read().version), 0)
Exemple #22
0
    def test_update_partition_table(self):
        """
        @Feature: Partition table - Positive Update
        @Test: Update partition table with its name, layout and OS family
        @Assert: Partition table is updated
        """

        name = generate_string("alpha", 6)
        new_name = generate_string("alpha", 4)
        layout = "test layout"
        new_layout = read_data_file(PARTITION_SCRIPT_DATA_FILE)
        os_family = "Debian"
        new_os_family = "Red Hat"
        self.login.login(self.katello_user, self.katello_passwd)
        self.create_partition_table(name, layout, os_family)
        self.partitiontable.update(name, new_name, new_layout, new_os_family)
        self.assertIsNotNone(self, self.partitiontable.search(new_name))
Exemple #23
0
    def test_positive_create_2(self):
        """@Test: Create a product and provide a GPG key.

        @Assert: A product is created with the specified GPG key.

        @Feature: Product

        """
        # Create an organization, GPG key and product.
        #
        # product -----------↘
        #       `-→ gpg_key → organization
        #
        # Re-using an organization speeds up the test.
        org = entities.Organization().create()
        gpg_key = entities.GPGKey(content=read_data_file(VALID_GPG_KEY_FILE), organization=org).create()
        product = entities.Product(gpg_key=gpg_key, organization=org).create()
        self.assertEqual(product.gpg_key.id, gpg_key.id)
Exemple #24
0
    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"]))
Exemple #25
0
    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 #26
0
    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 #27
0
"""Tests related to hammer command and its options and subcommands."""
import json

from robottelo.cli import hammer
from robottelo.common import ssh
from robottelo.common.helpers import bz_bug_is_open, read_data_file
from robottelo.test import CLITestCase

HAMMER_COMMANDS = json.loads(read_data_file('hammer_commands.json'))


class HammerCommandsTestCase(CLITestCase):
    """Tests for ensuring that  all expected hammer subcommands and its options
    are present.

    """
    def __init__(self, *args, **kwargs):
        super(HammerCommandsTestCase, self).__init__(*args, **kwargs)
        self.differences = {}

    def _fetch_command_info(self, command):
        """Fetch command info from expected commands info dictionary."""
        info = HAMMER_COMMANDS
        if command != 'hammer':
            found = False
            parts = command.split(' ')[1:]  # exclude hammer
            for part in parts:
                for command in info['subcommands']:
                    if command['name'] == part:
                        info = command
                        found = True