Beispiel #1
0
    def test_positive_add_repo_from_product_with_repo(self):
        """@test: Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        one repository

        @feature: GPG Keys

        @assert: gpg key is associated with the repository but not with
        the product
        """
        product = make_product({'organization-id': self.org['id']})
        repo = make_repository({'product-id': product['id']})
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        Repository.update({
            'gpg-key-id': gpg_key['id'],
            'id': repo['id'],
            'organization-id': self.org['id'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        repo = Repository.info({'id': repo['id']})
        self.assertEqual(repo['gpg-key']['id'], gpg_key['id'])
        self.assertNotEqual(product['gpg'].get('gpg-key-id'), gpg_key['id'])
Beispiel #2
0
    def test_positive_add_repo_from_product_with_repos(self):
        """@test: Create gpg key via file import and associate with custom repo

        GPGKey should contain valid name and valid key and should be associated
        to one repository from custom product. Make sure custom product should
        have more than one repository.

        @feature: GPG Keys

        @assert: gpg key is associated with the repository
        """
        product = make_product({'organization-id': self.org['id']})
        repos = [
            make_repository({'product-id': product['id']})
            for _ in range(gen_integer(2, 5))
        ]
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        Repository.update({
            'gpg-key': gpg_key['name'],
            'id': repos[0]['id'],
            'organization-id': self.org['id'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        self.assertNotEqual(product['gpg'].get('gpg-key-id'), gpg_key['id'])
        # First repo should have a valid gpg key assigned
        repo = Repository.info({'id': repos.pop(0)['id']})
        self.assertEqual(repo['gpg-key']['id'], gpg_key['id'])
        # The rest of repos should not
        for repo in repos:
            repo = Repository.info({'id': repo['id']})
            self.assertNotEqual(repo['gpg-key'].get('id'), gpg_key['id'])
    def test_negative_update_auth_url_too_long(self):
        """Update the original url for a repository to value which is too long

        @id: a703de60-8631-4e31-a9d9-e51804f27f03

        @Assert: Repository url not updated
        """
        new_repo = self._make_repository()
        # generate repo URLs with all invalid credentials
        auth_repos = [
            repo.format(cred['login'], cred['pass'])
            for cred in invalid_http_credentials()
            for repo in (FAKE_5_YUM_REPO, FAKE_7_PUPPET_REPO)
        ]

        for url in auth_repos:
            with self.subTest(url):
                with self.assertRaises(CLIReturnCodeError):
                    Repository.update({
                        u'id': new_repo['id'],
                        u'url': url,
                    })
                # Fetch it again
                result = Repository.info({'id': new_repo['id']})
                self.assertEqual(result['url'], new_repo['url'])
    def test_positive_update_url(self):
        """Update the original url for a repository

        @id: 1a2cf29b-5c30-4d4c-b6d1-2f227b0a0a57

        @Assert: Repository url is updated
        """
        new_repo = self._make_repository()
        # generate repo URLs with all valid credentials
        auth_repos = [
            repo.format(creds['login'], creds['pass'])
            for creds in valid_http_credentials(url_encoded=True)
            for repo in (FAKE_5_YUM_REPO, FAKE_7_PUPPET_REPO)
        ]

        for url in [FAKE_4_YUM_REPO, FAKE_1_PUPPET_REPO, FAKE_2_PUPPET_REPO,
                    FAKE_3_PUPPET_REPO, FAKE_2_YUM_REPO] + auth_repos:
            with self.subTest(url):
                # Update the url
                Repository.update({
                    u'id': new_repo['id'],
                    u'url': url,
                })
                # Fetch it again
                result = Repository.info({'id': new_repo['id']})
                self.assertEqual(result['url'], url)
Beispiel #5
0
    def test_positive_add_repo_from_product_with_repo(self):
        """Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        one repository

        @id: 1427f145-9faf-41ef-ae42-dc91d61ce1f6

        @assert: gpg key is associated with the repository but not with
        the product

        @CaseLevel: Integration
        """
        product = make_product({'organization-id': self.org['id']})
        repo = make_repository({'product-id': product['id']})
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        Repository.update({
            'gpg-key-id': gpg_key['id'],
            'id': repo['id'],
            'organization-id': self.org['id'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        repo = Repository.info({'id': repo['id']})
        self.assertEqual(repo['gpg-key']['id'], gpg_key['id'])
        self.assertNotEqual(product['gpg'].get('gpg-key-id'), gpg_key['id'])
Beispiel #6
0
    def test_positive_add_repo_from_product_with_repo(self):
        """Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        one repository

        :id: 1427f145-9faf-41ef-ae42-dc91d61ce1f6

        :expectedresults: gpg key is associated with the repository but not
            with the product

        :CaseLevel: Integration
        """
        product = make_product({'organization-id': self.org['id']})
        repo = make_repository({'product-id': product['id']})
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        Repository.update({
            'gpg-key-id': gpg_key['id'],
            'id': repo['id'],
            'organization-id': self.org['id'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        repo = Repository.info({'id': repo['id']})
        self.assertEqual(repo['gpg-key']['id'], gpg_key['id'])
        self.assertNotEqual(product['gpg'].get('gpg-key-id'), gpg_key['id'])
    def test_positive_update_checksum_type(self):
        """Create a YUM repository and update the checksum type

        @Feature: Repository

        @Assert: A YUM repository is updated and contains the correct checksum
        type

        @BZ: 1208305
        """
        content_type = u'yum'
        repository = self._make_repository({
            u'content-type': content_type
        })
        self.assertEqual(repository['content-type'], content_type)
        self.assertEqual(repository['checksum-type'], '')
        for checksum_type in u'sha1', u'sha256':
            with self.subTest(checksum_type):
                # Update the checksum
                Repository.update({
                    u'checksum-type': checksum_type,
                    u'id': repository['id'],
                })
                # Fetch it again
                result = Repository.info({'id': repository['id']})
                self.assertEqual(result['checksum-type'], checksum_type)
Beispiel #8
0
def test_positive_add_repo_from_product_with_repo(module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then associate it to repository from custom product that has
    one repository

    :id: da568a0e-69b1-498e-a747-6881aac7409e

    :expectedresults: gpg key is associated with the repository but not
        with the product

    :CaseLevel: Integration
    """
    product = make_product({'organization-id': module_org.id})
    repo = make_repository({'product-id': product['id']})
    gpg_key = make_content_credential({'organization-id': module_org.id})
    Repository.update({
        'gpg-key-id': gpg_key['id'],
        'id': repo['id'],
        'organization-id': module_org.id
    })
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    repo = Repository.info({'id': repo['id']})
    assert repo['gpg-key']['id'] == gpg_key['id']
    assert product['gpg'].get('gpg-key-id') != gpg_key['id']
Beispiel #9
0
    def test_negative_update_auth_url_with_special_characters(self):
        """Verify that repository URL credentials cannot be updated to contain
        the forbidden characters

        @id: 566553b2-d077-4fd8-8ed5-00ba75355386

        @Assert: Repository url not updated
        """
        new_repo = self._make_repository()
        # get auth repos with credentials containing unquoted special chars
        auth_repos = [
            repo.format(cred['login'], cred['pass'])
            for cred in valid_http_credentials() if cred['quote']
            for repo in (FAKE_5_YUM_REPO, FAKE_7_PUPPET_REPO)
        ]

        for url in auth_repos:
            with self.subTest(url):
                with self.assertRaises(CLIReturnCodeError):
                    Repository.update({
                        u'id': new_repo['id'],
                        u'url': url,
                    })
                # Fetch it again
                result = Repository.info({'id': new_repo['id']})
                self.assertEqual(result['url'], new_repo['url'])
Beispiel #10
0
    def test_negative_update_auth_url_too_long(self):
        """Update the original url for a repository to value which is too long

        @id: a703de60-8631-4e31-a9d9-e51804f27f03

        @Assert: Repository url not updated
        """
        new_repo = self._make_repository()
        # generate repo URLs with all invalid credentials
        auth_repos = [
            repo.format(cred['login'], cred['pass'])
            for cred in invalid_http_credentials()
            for repo in (FAKE_5_YUM_REPO, FAKE_7_PUPPET_REPO)
        ]

        for url in auth_repos:
            with self.subTest(url):
                with self.assertRaises(CLIReturnCodeError):
                    Repository.update({
                        u'id': new_repo['id'],
                        u'url': url,
                    })
                # Fetch it again
                result = Repository.info({'id': new_repo['id']})
                self.assertEqual(result['url'], new_repo['url'])
Beispiel #11
0
    def test_positive_update_url(self):
        """Update the original url for a repository

        @id: 1a2cf29b-5c30-4d4c-b6d1-2f227b0a0a57

        @Assert: Repository url is updated
        """
        new_repo = self._make_repository()
        # generate repo URLs with all valid credentials
        auth_repos = [
            repo.format(creds['login'], creds['pass'])
            for creds in valid_http_credentials(url_encoded=True)
            for repo in (FAKE_5_YUM_REPO, FAKE_7_PUPPET_REPO)
        ]

        for url in [
                FAKE_4_YUM_REPO, FAKE_1_PUPPET_REPO, FAKE_2_PUPPET_REPO,
                FAKE_3_PUPPET_REPO, FAKE_2_YUM_REPO
        ] + auth_repos:
            with self.subTest(url):
                # Update the url
                Repository.update({
                    u'id': new_repo['id'],
                    u'url': url,
                })
                # Fetch it again
                result = Repository.info({'id': new_repo['id']})
                self.assertEqual(result['url'], url)
    def test_negative_update_auth_url_with_special_characters(self):
        """Verify that repository URL credentials cannot be updated to contain
        the forbidden characters

        @id: 566553b2-d077-4fd8-8ed5-00ba75355386

        @Assert: Repository url not updated
        """
        new_repo = self._make_repository()
        # get auth repos with credentials containing unquoted special chars
        auth_repos = [
            repo.format(cred['login'], cred['pass'])
            for cred in valid_http_credentials() if cred['quote']
            for repo in (FAKE_5_YUM_REPO, FAKE_7_PUPPET_REPO)
        ]

        for url in auth_repos:
            with self.subTest(url):
                with self.assertRaises(CLIReturnCodeError):
                    Repository.update({
                        u'id': new_repo['id'],
                        u'url': url,
                    })
                # Fetch it again
                result = Repository.info({'id': new_repo['id']})
                self.assertEqual(result['url'], new_repo['url'])
Beispiel #13
0
 def create(self, organization_id, product_id=None,
            download_policy=DOWNLOAD_POLICY_ON_DEMAND, synchronize=True):
     # type: (int, Optional[int], Optional[str], Optional[bool]) -> Dict
     """Create an RH repository"""
     if not self.cdn and not self.url:
         raise ValueError('Can not handle Custom repository with url not supplied')
     if self.cdn:
         data = self.data
         RepositorySet.enable({
             'organization-id': organization_id,
             'product': data['product'],
             'name': data['repository-set'],
             'basearch': data.get('arch', DEFAULT_ARCHITECTURE),
             'releasever': data.get('releasever'),
         })
         repo_info = Repository.info({
             'organization-id': organization_id,
             'name': data['repository'],
             'product': data['product'],
         })
         if download_policy:
             # Set download policy
             Repository.update({
                 'download-policy': download_policy,
                 'id': repo_info['id'],
             })
         self._repo_info = repo_info
         if synchronize:
             self.synchronize()
     else:
         repo_info = super(GenericRHRepository, self).create(
             organization_id, product_id, download_policy=download_policy)
     return repo_info
Beispiel #14
0
    def test_positive_export_rh_product(self):
        """Export a repository from the Red Hat product

        @Feature: Repository - Export

        @Assert: Repository was successfully exported, rpm files are present on
        satellite machine
        """
        # Enable RH repository
        with manifests.clone() as manifest:
            ssh.upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': self.org['id'],
        })
        RepositorySet.enable({
            'basearch': 'x86_64',
            'name': REPOSET['rhva6'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
        })
        repo = Repository.info({
            'name': REPOS['rhva6']['name'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
        })
        repo_export_dir = (
            '/mnt/{0}/{1}-{2}-{3}/{1}/{4}/content/dist/rhel/server/6/6Server/'
            'x86_64/rhev-agent/3/os'.format(
                self.export_dir,
                self.org['label'],
                PRDS['rhel'].replace(' ', '_'),
                repo['label'],
                ENVIRONMENT,
            ))

        # Update the download policy to 'immediate'
        Repository.update({
            'download-policy': 'immediate',
            'id': repo['id'],
        })

        # Export the repository
        Repository.export({'id': repo['id']})

        # Verify export directory is empty
        result = ssh.command('ls -l {0} | grep .rpm'.format(repo_export_dir))
        self.assertEqual(len(result.stdout), 0)

        # Synchronize the repository
        Repository.synchronize({'id': repo['id']})

        # Export the repository once again
        Repository.export({'id': repo['id']})

        # Verify RPMs were successfully exported
        result = ssh.command('ls -l {0} | grep .rpm'.format(repo_export_dir))
        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)
Beispiel #15
0
def test_positive_update_key_for_repo_from_product_with_repos(module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then associate it to repository from custom product that has
    more than one repository then update the key

    :id: c548ed4f-7f2d-456f-a644-7597644f6457

    :expectedresults: gpg key is associated with a single repository
        before/after update and not associated with product or other
        repositories

    :CaseLevel: Integration
    """
    # Create a product and a gpg key
    product = make_product({'organization-id': module_org.id})
    gpg_key = make_content_credential({'organization-id': module_org.id})
    # Create repositories and assign them to the product
    repos = [
        make_repository({'product-id': product['id']})
        for _ in range(gen_integer(2, 5))
    ]
    # Associate gpg key with a single repository
    Repository.update({
        'gpg-key': gpg_key['name'],
        'id': repos[0]['id'],
        'organization-id': module_org.id
    })
    # Verify gpg key was associated
    repos[0] = Repository.info({'id': repos[0]['id']})
    assert repos[0]['gpg-key']['name'] == gpg_key['name']
    # Update the gpg key
    new_name = gen_choice(list(valid_data_list().values()))
    ContentCredential.update({
        'name': gpg_key['name'],
        'new-name': new_name,
        'organization-id': module_org.id
    })
    # Verify changes are reflected in the gpg key
    gpg_key = ContentCredential.info({
        'id': gpg_key['id'],
        'organization-id': module_org.id
    })
    assert gpg_key['name'] == new_name
    # Verify changes are reflected in the associated repository
    repos[0] = Repository.info({'id': repos[0]['id']})
    assert repos[0]['gpg-key'].get('name') == new_name
    # Verify changes are not reflected in the product
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    assert product['gpg']['gpg-key'] != new_name
    # Verify changes are not reflected in the rest of repositories
    for repo in repos[1:]:
        repo = Repository.info({'id': repo['id']})
        assert repo['gpg-key'].get('name') != new_name
Beispiel #16
0
    def test_positive_update_key_for_repo_from_product_with_repos(self):
        """Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        more than one repository then update the key

        :id: 773a9141-9f04-40ba-b3df-4b6d80db25a6

        :expectedresults: gpg key is associated with a single repository
            before/after update and not associated with product or other
            repositories

        :CaseLevel: Integration
        """
        # Create a product and a gpg key
        product = make_product({'organization-id': self.org['id']})
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        # Create repositories and assign them to the product
        repos = [
            make_repository({'product-id': product['id']})
            for _ in range(gen_integer(2, 5))
        ]
        # Associate gpg key with a single repository
        Repository.update({
            'gpg-key': gpg_key['name'],
            'id': repos[0]['id'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was associated
        repos[0] = Repository.info({'id': repos[0]['id']})
        self.assertEqual(repos[0]['gpg-key']['name'], gpg_key['name'])
        # Update the gpg key
        new_name = gen_choice(valid_data_list())
        GPGKey.update({
            'name': gpg_key['name'],
            'new-name': new_name,
            'organization-id': self.org['id'],
        })
        # Verify changes are reflected in the gpg key
        gpg_key = GPGKey.info({
            'id': gpg_key['id'],
            'organization-id': self.org['id'],
        })
        self.assertEqual(gpg_key['name'], new_name)
        # Verify changes are reflected in the associated repository
        repos[0] = Repository.info({'id': repos[0]['id']})
        self.assertEqual(repos[0]['gpg-key'].get('name'), new_name)
        # Verify changes are not reflected in the product
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        self.assertNotEqual(product['gpg']['gpg-key'], new_name)
        # Verify changes are not reflected in the rest of repositories
        for repo in repos[1:]:
            repo = Repository.info({'id': repo['id']})
            self.assertNotEqual(repo['gpg-key'].get('name'), new_name)
Beispiel #17
0
    def test_positive_update_key_for_repo_from_product_with_repos(self):
        """Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        more than one repository then update the key

        :id: 773a9141-9f04-40ba-b3df-4b6d80db25a6

        :expectedresults: gpg key is associated with a single repository
            before/after update and not associated with product or other
            repositories

        :CaseLevel: Integration
        """
        # Create a product and a gpg key
        product = make_product({'organization-id': self.org['id']})
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        # Create repositories and assign them to the product
        repos = [
            make_repository({'product-id': product['id']})
            for _ in range(gen_integer(2, 5))
        ]
        # Associate gpg key with a single repository
        Repository.update({
            'gpg-key': gpg_key['name'],
            'id': repos[0]['id'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was associated
        repos[0] = Repository.info({'id': repos[0]['id']})
        self.assertEqual(repos[0]['gpg-key']['name'], gpg_key['name'])
        # Update the gpg key
        new_name = gen_choice(valid_data_list())
        GPGKey.update({
            'name': gpg_key['name'],
            'new-name': new_name,
            'organization-id': self.org['id'],
        })
        # Verify changes are reflected in the gpg key
        gpg_key = GPGKey.info({
            'id': gpg_key['id'],
            'organization-id': self.org['id'],
        })
        self.assertEqual(gpg_key['name'], new_name)
        # Verify changes are reflected in the associated repository
        repos[0] = Repository.info({'id': repos[0]['id']})
        self.assertEqual(repos[0]['gpg-key'].get('name'), new_name)
        # Verify changes are not reflected in the product
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        self.assertNotEqual(product['gpg']['gpg-key'], new_name)
        # Verify changes are not reflected in the rest of repositories
        for repo in repos[1:]:
            repo = Repository.info({'id': repo['id']})
            self.assertNotEqual(repo['gpg-key'].get('name'), new_name)
    def test_negative_update_to_invalid_download_policy(self):
        """Verify that YUM repository cannot be updated to invalid download policy

        @id: 5bd6a2e4-7ff0-42ac-825a-6b2a2f687c89

        @Assert: YUM repository is not updated to invalid download policy
        """
        with self.assertRaises(CLIReturnCodeError):
            new_repo = self._make_repository({u"content-type": u"yum"})
            Repository.update({u"id": new_repo["id"], u"download-policy": gen_string("alpha", 5)})
    def test_positive_update_publish_method(self):
        """Update the original publishing method

        @id: e7bd2667-4851-4a64-9c70-1b5eafbc3f71

        @Assert: Repository publishing method is updated
        """
        new_repo = self._make_repository({u"publish-via-http": "no"})
        Repository.update({u"id": new_repo["id"], u"publish-via-http": "yes"})
        result = Repository.info({"id": new_repo["id"]})
        self.assertEqual(result["publish-via-http"], "yes")
    def test_positive_create_background_update_to_on_demand(self):
        """Update `background` download policy to `on_demand`
        for a newly created YUM repository

        @id: 0f943e3d-44b7-4b6e-9a7d-d33f7f4864d1

        @Assert: background download policy is updated to on_demand
        """
        new_repo = self._make_repository({u"content-type": u"yum", u"download-policy": "background"})
        Repository.update({u"id": new_repo["id"], u"download-policy": "on_demand"})
        result = Repository.info({"id": new_repo["id"]})
        self.assertEqual(result["download-policy"], "on_demand")
    def test_positive_create_background_update_to_immediate(self):
        """Update `background` download policy to `immediate`
        for a newly created YUM repository

        @id: cf4dca0c-36bd-4a3c-aa29-f435ac60b3f8

        @Assert: background download policy is updated to immediate
        """
        new_repo = self._make_repository({u"content-type": u"yum", u"download-policy": "background"})
        Repository.update({u"id": new_repo["id"], u"download-policy": "immediate"})
        result = Repository.info({"id": new_repo["id"]})
        self.assertEqual(result["download-policy"], "immediate")
    def test_positive_create_on_demand_update_to_background(self):
        """Update `on_demand` download policy to `background`
        for a newly created YUM repository

        @id: da600200-5bd4-4cb8-a891-37cd2233803e

        @Assert: on_demand download policy is updated to background
        """
        new_repo = self._make_repository({u"content-type": u"yum", u"download-policy": "on_demand"})
        Repository.update({u"id": new_repo["id"], u"download-policy": "background"})
        result = Repository.info({"id": new_repo["id"]})
        self.assertEqual(result["download-policy"], "background")
    def test_positive_create_immediate_update_to_background(self):
        """Update `immediate` download policy to `background`
        for a newly created YUM repository

        @id: 7a9243eb-012c-40ad-9105-b078ed0a9eda

        @Assert: immediate download policy is updated to background
        """
        new_repo = self._make_repository({u"content-type": u"yum", u"download-policy": "immediate"})
        Repository.update({u"id": new_repo["id"], u"download-policy": "background"})
        result = Repository.info({"id": new_repo["id"]})
        self.assertEqual(result["download-policy"], "background")
    def test_positive_create_immediate_update_to_on_demand(self):
        """Update `immediate` download policy to `on_demand`
        for a newly created YUM repository

        @id: 1a80d686-3f7b-475e-9d1a-3e1f51d55101

        @Assert: immediate download policy is updated to on_demand
        """
        new_repo = self._make_repository({u"content-type": u"yum", u"download-policy": "immediate"})
        Repository.update({u"id": new_repo["id"], u"download-policy": "on_demand"})
        result = Repository.info({"id": new_repo["id"]})
        self.assertEqual(result["download-policy"], "on_demand")
    def test_positive_create_on_demand_update_to_immediate(self):
        """Update `on_demand` download policy to `immediate`
        for a newly created YUM repository

        @id: 1e8338af-32e5-4f92-9215-bfdc1973c8f7

        @Assert: on_demand download policy is updated to immediate
        """
        new_repo = self._make_repository({u"content-type": u"yum", u"download-policy": "on_demand"})
        Repository.update({u"id": new_repo["id"], u"download-policy": "immediate"})
        result = Repository.info({"id": new_repo["id"]})
        self.assertEqual(result["download-policy"], "immediate")
Beispiel #26
0
    def test_key_associate_13(self):
        """@test: Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        more than one repository then update the key

        @feature: GPG Keys

        @assert: gpg key is associated with a single repository before/after
        update and not associated with product or other repositories
        """
        # Create a product and a gpg key
        product = make_product({'organization-id': self.org['id']})
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        # Create repositories and assign them to the product
        repos = [
            make_repository({'product-id': product['id']})
            for _ in range(gen_integer(2, 5))
        ]
        # Associate gpg key with a single repository
        Repository.update({
            'gpg-key': gpg_key['name'],
            'id': repos[0]['id'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was associated
        repos[0] = Repository.info({'id': repos[0]['id']})
        self.assertEqual(repos[0]['gpg-key']['name'], gpg_key['name'])
        # Update the gpg key
        new_name = gen_choice(valid_data_list())
        GPGKey.update({
            'name': gpg_key['name'],
            'new-name': new_name,
            'organization-id': self.org['id'],
        })
        # Verify changes are reflected in the gpg key
        gpg_key = GPGKey.info({
            'id': gpg_key['id'],
            'organization-id': self.org['id'],
        })
        self.assertEqual(gpg_key['name'], new_name)
        # Verify changes are reflected in the associated repository
        repos[0] = Repository.info({'id': repos[0]['id']})
        self.assertEqual(repos[0]['gpg-key'].get('name'), new_name)
        # Verify changes are not reflected in the product
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        self.assertNotEqual(product['gpg']['gpg-key'], new_name)
        # Verify changes are not reflected in the rest of repositories
        for repo in repos[1:]:
            repo = Repository.info({'id': repo['id']})
            self.assertNotEqual(repo['gpg-key'].get('name'), new_name)
Beispiel #27
0
    def test_negative_update_to_invalid_download_policy(self):
        """Verify that YUM repository cannot be updated to invalid download policy

        @id: 5bd6a2e4-7ff0-42ac-825a-6b2a2f687c89

        @Assert: YUM repository is not updated to invalid download policy
        """
        with self.assertRaises(CLIReturnCodeError):
            new_repo = self._make_repository({u'content-type': u'yum'})
            Repository.update({
                u'id': new_repo['id'],
                u'download-policy': gen_string('alpha', 5)
            })
    def test_negative_update_to_invalid_download_policy(self):
        """Verify that YUM repository cannot be updated to invalid download policy

        @id: 5bd6a2e4-7ff0-42ac-825a-6b2a2f687c89

        @Assert: YUM repository is not updated to invalid download policy
        """
        with self.assertRaises(CLIReturnCodeError):
            new_repo = self._make_repository({u'content-type': u'yum'})
            Repository.update({
                u'id': new_repo['id'],
                u'download-policy': gen_string('alpha', 5)
            })
    def test_positive_update_gpg_key(self):
        """Update the original gpg key

        @id: 367ff375-4f52-4a8c-b974-8c1c54e3fdd3

        @Assert: Repository gpg key is updated
        """
        gpg_key = make_gpg_key({"organization-id": self.org["id"]})
        gpg_key_new = make_gpg_key({"organization-id": self.org["id"]})
        new_repo = self._make_repository({u"gpg-key-id": gpg_key["id"]})
        Repository.update({u"id": new_repo["id"], u"gpg-key-id": gpg_key_new["id"]})
        result = Repository.info({"id": new_repo["id"]})
        self.assertEqual(result["gpg-key"]["id"], gpg_key_new["id"])
Beispiel #30
0
 def create(
     self,
     organization_id,
     product_id=None,
     download_policy=DOWNLOAD_POLICY_ON_DEMAND,
     synchronize=True,
 ):
     # type: (int, Optional[int], Optional[str], Optional[bool]) -> Dict
     """Create an RH repository"""
     if not self.cdn and not self.url:
         raise ValueError(
             'Can not handle Custom repository with url not supplied')
     if self.cdn:
         data = self.data
         if not Repository.list({
                 'organization-id': organization_id,
                 'name': data['repository'],
                 'product': data['product'],
         }):
             RepositorySet.enable({
                 'organization-id':
                 organization_id,
                 'product':
                 data['product'],
                 'name':
                 data['repository-set'],
                 'basearch':
                 data.get('arch', constants.DEFAULT_ARCHITECTURE),
                 'releasever':
                 data.get('releasever'),
             })
         repo_info = Repository.info({
             'organization-id': organization_id,
             'name': data['repository'],
             'product': data['product'],
         })
         if download_policy:
             # Set download policy
             Repository.update({
                 'download-policy': download_policy,
                 'id': repo_info['id']
             })
         self._repo_info = repo_info
         if synchronize:
             self.synchronize()
     else:
         repo_info = super().create(organization_id,
                                    product_id,
                                    download_policy=download_policy)
     return repo_info
Beispiel #31
0
    def test_positive_delete_key_for_repo_from_product_with_repos(self):
        """Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        more than one repository then delete the key

        :id: e7ed4ed9-ecfe-4954-b806-cdd0668e8822

        :expectedresults: gpg key is associated with a single repository but
            not the product during creation and removed from repository after
            deletion

        :CaseLevel: Integration
        """
        # Create product, repositories and gpg key
        product = make_product({'organization-id': self.org['id']})
        repos = []
        for _ in range(gen_integer(2, 5)):
            repos.append(make_repository({'product-id': product['id']}))
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        # Associate gpg key with a repository
        Repository.update({
            'gpg-key': gpg_key['name'],
            'id': repos[0]['id'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was associated with the repository
        repos[0] = Repository.info({'id': repos[0]['id']})
        self.assertEqual(repos[0]['gpg-key']['name'], gpg_key['name'])
        # Delete the gpg key
        GPGKey.delete({
            'name': gpg_key['name'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was actually deleted
        with self.assertRaises(CLIReturnCodeError):
            GPGKey.info({
                'id': gpg_key['id'],
                'organization-id': self.org['id'],
            })
        # Verify gpg key is not associated with any repository or the product
        # itself
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        self.assertNotEqual(product['gpg']['gpg-key'], gpg_key['name'])
        for repo in repos:
            repo = Repository.info({'id': repo['id']})
            self.assertNotEqual(repo['gpg-key'].get('name'), gpg_key['name'])
Beispiel #32
0
    def test_positive_delete_key_for_repo_from_product_with_repos(self):
        """Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        more than one repository then delete the key

        :id: e7ed4ed9-ecfe-4954-b806-cdd0668e8822

        :expectedresults: gpg key is associated with a single repository but
            not the product during creation and removed from repository after
            deletion

        :CaseLevel: Integration
        """
        # Create product, repositories and gpg key
        product = make_product({'organization-id': self.org['id']})
        repos = []
        for _ in range(gen_integer(2, 5)):
            repos.append(make_repository({'product-id': product['id']}))
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        # Associate gpg key with a repository
        Repository.update({
            'gpg-key': gpg_key['name'],
            'id': repos[0]['id'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was associated with the repository
        repos[0] = Repository.info({'id': repos[0]['id']})
        self.assertEqual(repos[0]['gpg-key']['name'], gpg_key['name'])
        # Delete the gpg key
        GPGKey.delete({
            'name': gpg_key['name'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was actually deleted
        with self.assertRaises(CLIReturnCodeError):
            GPGKey.info({
                'id': gpg_key['id'],
                'organization-id': self.org['id'],
            })
        # Verify gpg key is not associated with any repository or the product
        # itself
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        self.assertNotEqual(product['gpg']['gpg-key'], gpg_key['name'])
        for repo in repos:
            repo = Repository.info({'id': repo['id']})
            self.assertNotEqual(repo['gpg-key'].get('name'), gpg_key['name'])
Beispiel #33
0
def test_positive_delete_key_for_repo_from_product_with_repos(module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then associate it to repository from custom product that has
    more than one repository then delete the key

    :id: 7d6a278b-1063-4e72-bc32-ca60bd17bb84

    :expectedresults: gpg key is associated with a single repository but
        not the product during creation and removed from repository after
        deletion

    :CaseLevel: Integration
    """
    # Create product, repositories and gpg key
    product = make_product({'organization-id': module_org.id})
    repos = []
    for _ in range(gen_integer(2, 5)):
        repos.append(make_repository({'product-id': product['id']}))
    gpg_key = make_content_credential({'organization-id': module_org.id})
    # Associate gpg key with a repository
    Repository.update({
        'gpg-key': gpg_key['name'],
        'id': repos[0]['id'],
        'organization-id': module_org.id
    })
    # Verify gpg key was associated with the repository
    repos[0] = Repository.info({'id': repos[0]['id']})
    assert repos[0]['gpg-key']['name'] == gpg_key['name']
    # Delete the gpg key
    ContentCredential.delete({
        'name': gpg_key['name'],
        'organization-id': module_org.id
    })
    # Verify gpg key was actually deleted
    with pytest.raises(CLIReturnCodeError):
        ContentCredential.info({
            'id': gpg_key['id'],
            'organization-id': module_org.id
        })
    # Verify gpg key is not associated with any repository or the product
    # itself
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    assert product['gpg']['gpg-key'] != gpg_key['name']
    for repo in repos:
        repo = Repository.info({'id': repo['id']})
        assert repo['gpg-key'].get('name') != gpg_key['name']
Beispiel #34
0
    def test_positive_update_publish_method(self):
        """Update the original publishing method

        @id: e7bd2667-4851-4a64-9c70-1b5eafbc3f71

        @Assert: Repository publishing method is updated
        """
        new_repo = self._make_repository({
            u'publish-via-http': 'no',
        })
        Repository.update({
            u'id': new_repo['id'],
            u'publish-via-http': 'yes',
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['publish-via-http'], 'yes')
Beispiel #35
0
    def test_positive_update_1(self, url):
        """@Test: Update the original url for a repository

        @Feature: Repository

        @Assert: Repository url is updated

        """

        new_repo = self._make_repository()

        # Update the url
        result = Repository.update({
            u'id': new_repo['id'],
            u'url': url,
        })
        self.assertEqual(result.return_code, 0, "Repository was not updated")
        self.assertEqual(len(result.stderr), 0, "No error was expected")

        # Fetch it again
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result.return_code, 0, "Repository was not found")
        self.assertEqual(len(result.stderr), 0, "No error was expected")
        self.assertNotEqual(result.stdout['url'], new_repo['url'],
                            "Urls should not match")
        self.assertEqual(result.stdout['url'], url, "Urls don't match")
Beispiel #36
0
    def test_positive_update_1(self, url):
        """@Test: Update the original url for a repository

        @Feature: Repository

        @Assert: Repository url is updated

        """

        new_repo = self._make_repository()

        # Update the url
        result = Repository.update({
            u'id': new_repo['id'],
            u'url': url,
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # Fetch it again
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertNotEqual(result.stdout['url'], new_repo['url'])
        self.assertEqual(result.stdout['url'], url)
Beispiel #37
0
    def test_positive_delete_key_for_repo_from_product_with_repo(self):
        """Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        one repository then delete the key

        :id: 3658e04d-fc63-499f-a22d-b512941cc96b

        :expectedresults: gpg key is associated with the single repository but
            not the product during creation and was removed from repository
            after deletion

        :CaseLevel: Integration
        """
        # Create product, repository and gpg key
        product = make_product({'organization-id': self.org['id']})
        repo = make_repository({'product-id': product['id']})
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        # Associate gpg key with a repository
        Repository.update({
            'gpg-key': gpg_key['name'],
            'id': repo['id'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was associated with the repository but not with the
        # product
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        repo = Repository.info({'id': repo['id']})
        self.assertNotEqual(product['gpg']['gpg-key'], gpg_key['name'])
        self.assertEqual(repo['gpg-key'].get('name'), gpg_key['name'])
        # Delete the gpg key
        GPGKey.delete({
            'name': gpg_key['name'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was actually deleted
        with self.assertRaises(CLIReturnCodeError):
            GPGKey.info({
                'id': gpg_key['id'],
                'organization-id': self.org['id'],
            })
        # Verify gpg key was disassociated from the repository
        repo = Repository.info({'id': repo['id']})
        self.assertNotEqual(repo['gpg-key'].get('name'), gpg_key['name'])
Beispiel #38
0
    def test_key_associate_20(self):
        """@test: Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        more than one repository then delete the key

        @feature: GPG Keys

        @assert: gpg key is associated with a single repository but not the
        product during creation and removed from repository after deletion
        """
        # Create product, repositories and gpg key
        product = make_product({'organization-id': self.org['id']})
        repos = []
        for _ in range(gen_integer(2, 5)):
            repos.append(make_repository({'product-id': product['id']}))
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        # Associate gpg key with a repository
        Repository.update({
            'gpg-key': gpg_key['name'],
            'id': repos[0]['id'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was associated with the repository
        repos[0] = Repository.info({'id': repos[0]['id']})
        self.assertEqual(repos[0]['gpg-key']['name'], gpg_key['name'])
        # Delete the gpg key
        GPGKey.delete({
            'name': gpg_key['name'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was actually deleted
        with self.assertRaises(CLIReturnCodeError):
            GPGKey.info({
                'id': gpg_key['id'],
                'organization-id': self.org['id'],
            })
        # Verify gpg key is not associated with any repository or the product
        # itself
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        self.assertNotEqual(product['gpg']['gpg-key'], gpg_key['name'])
        for repo in repos:
            repo = Repository.info({'id': repo['id']})
            self.assertNotEqual(repo['gpg-key'].get('name'), gpg_key['name'])
Beispiel #39
0
def test_positive_delete_key_for_repo_from_product_with_repo(module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then associate it to repository from custom product that has
    one repository then delete the key

    :id: 2555b08f-8cee-4e84-8f4d-9b46743f5758

    :expectedresults: gpg key is associated with the single repository but
        not the product during creation and was removed from repository
        after deletion

    :CaseLevel: Integration
    """
    # Create product, repository and gpg key
    product = make_product({'organization-id': module_org.id})
    repo = make_repository({'product-id': product['id']})
    gpg_key = make_content_credential({'organization-id': module_org.id})
    # Associate gpg key with a repository
    Repository.update({
        'gpg-key': gpg_key['name'],
        'id': repo['id'],
        'organization-id': module_org.id
    })
    # Verify gpg key was associated with the repository but not with the
    # product
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    repo = Repository.info({'id': repo['id']})
    assert product['gpg']['gpg-key'] != gpg_key['name']
    assert repo['gpg-key'].get('name') == gpg_key['name']
    # Delete the gpg key
    ContentCredential.delete({
        'name': gpg_key['name'],
        'organization-id': module_org.id
    })
    # Verify gpg key was actually deleted
    with pytest.raises(CLIReturnCodeError):
        ContentCredential.info({
            'id': gpg_key['id'],
            'organization-id': module_org.id
        })
    # Verify gpg key was disassociated from the repository
    repo = Repository.info({'id': repo['id']})
    assert repo['gpg-key'].get('name') != gpg_key['name']
Beispiel #40
0
    def test_positive_delete_key_for_repo_from_product_with_repo(self):
        """Create gpg key with valid name and valid gpg key via file
        import then associate it to repository from custom product that has
        one repository then delete the key

        :id: 3658e04d-fc63-499f-a22d-b512941cc96b

        :expectedresults: gpg key is associated with the single repository but
            not the product during creation and was removed from repository
            after deletion

        :CaseLevel: Integration
        """
        # Create product, repository and gpg key
        product = make_product({'organization-id': self.org['id']})
        repo = make_repository({'product-id': product['id']})
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        # Associate gpg key with a repository
        Repository.update({
            'gpg-key': gpg_key['name'],
            'id': repo['id'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was associated with the repository but not with the
        # product
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        repo = Repository.info({'id': repo['id']})
        self.assertNotEqual(product['gpg']['gpg-key'], gpg_key['name'])
        self.assertEqual(repo['gpg-key'].get('name'), gpg_key['name'])
        # Delete the gpg key
        GPGKey.delete({
            'name': gpg_key['name'],
            'organization-id': self.org['id'],
        })
        # Verify gpg key was actually deleted
        with self.assertRaises(CLIReturnCodeError):
            GPGKey.info({
                'id': gpg_key['id'],
                'organization-id': self.org['id'],
            })
        # Verify gpg key was disassociated from the repository
        repo = Repository.info({'id': repo['id']})
        self.assertNotEqual(repo['gpg-key'].get('name'), gpg_key['name'])
Beispiel #41
0
    def test_positive_create_background_update_to_immediate(self):
        """Update `background` download policy to `immediate`
        for a newly created YUM repository

        @id: cf4dca0c-36bd-4a3c-aa29-f435ac60b3f8

        @Assert: background download policy is updated to immediate
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'background'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'immediate'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'immediate')
Beispiel #42
0
    def test_positive_create_background_update_to_on_demand(self):
        """Update `background` download policy to `on_demand`
        for a newly created YUM repository

        @id: 0f943e3d-44b7-4b6e-9a7d-d33f7f4864d1

        @Assert: background download policy is updated to on_demand
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'background'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'on_demand'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'on_demand')
    def test_positive_create_background_update_to_immediate(self):
        """Update `background` download policy to `immediate`
        for a newly created YUM repository

        @id: cf4dca0c-36bd-4a3c-aa29-f435ac60b3f8

        @Assert: background download policy is updated to immediate
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'background'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'immediate'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'immediate')
Beispiel #44
0
    def test_positive_update_gpg_key(self):
        """Update the original gpg key

        @id: 367ff375-4f52-4a8c-b974-8c1c54e3fdd3

        @Assert: Repository gpg key is updated
        """
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        gpg_key_new = make_gpg_key({'organization-id': self.org['id']})
        new_repo = self._make_repository({
            u'gpg-key-id': gpg_key['id'],
        })
        Repository.update({
            u'id': new_repo['id'],
            u'gpg-key-id': gpg_key_new['id'],
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['gpg-key']['id'], gpg_key_new['id'])
Beispiel #45
0
    def test_positive_create_immediate_update_to_background(self):
        """Update `immediate` download policy to `background`
        for a newly created YUM repository

        @id: 7a9243eb-012c-40ad-9105-b078ed0a9eda

        @Assert: immediate download policy is updated to background
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'immediate'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'background'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'background')
Beispiel #46
0
    def test_positive_create_on_demand_update_to_immediate(self):
        """Update `on_demand` download policy to `immediate`
        for a newly created YUM repository

        @id: 1e8338af-32e5-4f92-9215-bfdc1973c8f7

        @Assert: on_demand download policy is updated to immediate
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'on_demand'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'immediate'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'immediate')
    def test_positive_create_immediate_update_to_on_demand(self):
        """Update `immediate` download policy to `on_demand`
        for a newly created YUM repository

        @id: 1a80d686-3f7b-475e-9d1a-3e1f51d55101

        @Assert: immediate download policy is updated to on_demand
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'immediate'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'on_demand'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'on_demand')
Beispiel #48
0
    def test_positive_create_immediate_update_to_on_demand(self):
        """Update `immediate` download policy to `on_demand`
        for a newly created YUM repository

        @id: 1a80d686-3f7b-475e-9d1a-3e1f51d55101

        @Assert: immediate download policy is updated to on_demand
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'immediate'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'on_demand'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'on_demand')
    def test_positive_create_immediate_update_to_background(self):
        """Update `immediate` download policy to `background`
        for a newly created YUM repository

        @id: 7a9243eb-012c-40ad-9105-b078ed0a9eda

        @Assert: immediate download policy is updated to background
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'immediate'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'background'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'background')
    def test_positive_create_on_demand_update_to_immediate(self):
        """Update `on_demand` download policy to `immediate`
        for a newly created YUM repository

        @id: 1e8338af-32e5-4f92-9215-bfdc1973c8f7

        @Assert: on_demand download policy is updated to immediate
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'on_demand'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'immediate'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'immediate')
    def test_positive_create_background_update_to_on_demand(self):
        """Update `background` download policy to `on_demand`
        for a newly created YUM repository

        @id: 0f943e3d-44b7-4b6e-9a7d-d33f7f4864d1

        @Assert: background download policy is updated to on_demand
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'background'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'on_demand'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'on_demand')
Beispiel #52
0
    def test_positive_create_on_demand_update_to_background(self):
        """Update `on_demand` download policy to `background`
        for a newly created YUM repository

        @id: da600200-5bd4-4cb8-a891-37cd2233803e

        @Assert: on_demand download policy is updated to background
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'on_demand'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'background'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'background')
    def test_positive_create_on_demand_update_to_background(self):
        """Update `on_demand` download policy to `background`
        for a newly created YUM repository

        @id: da600200-5bd4-4cb8-a891-37cd2233803e

        @Assert: on_demand download policy is updated to background
        """
        new_repo = self._make_repository({
            u'content-type': u'yum',
            u'download-policy': 'on_demand'
        })
        Repository.update({
            u'id': new_repo['id'],
            u'download-policy': 'background'
        })
        result = Repository.info({'id': new_repo['id']})
        self.assertEqual(result['download-policy'], 'background')
Beispiel #54
0
    def test_positive_update_checksum_type(self):
        """Create a YUM repository and update the checksum type

        @id: 42f14257-d860-443d-b337-36fd355014bc

        @Assert: A YUM repository is updated and contains the correct checksum
        type
        """
        content_type = u'yum'
        repository = self._make_repository({u'content-type': content_type})
        self.assertEqual(repository['content-type'], content_type)
        for checksum_type in u'sha1', u'sha256':
            with self.subTest(checksum_type):
                # Update the checksum
                Repository.update({
                    u'checksum-type': checksum_type,
                    u'id': repository['id'],
                })
                # Fetch it again
                result = Repository.info({'id': repository['id']})
                self.assertEqual(result['checksum-type'], checksum_type)
Beispiel #55
0
def test_positive_add_repo_from_product_with_repos(module_org):
    """Create gpg key via file import and associate with custom repo

    GPGKey should contain valid name and valid key and should be associated
    to one repository from custom product. Make sure custom product should
    have more than one repository.

    :id: e3019a61-ec32-4044-9087-e420b8db4e09

    :expectedresults: gpg key is associated with the repository

    :CaseLevel: Integration
    """
    product = make_product({'organization-id': module_org.id})
    repos = [
        make_repository({'product-id': product['id']})
        for _ in range(gen_integer(2, 5))
    ]
    gpg_key = make_content_credential({'organization-id': module_org.id})
    Repository.update({
        'gpg-key': gpg_key['name'],
        'id': repos[0]['id'],
        'organization-id': module_org.id
    })
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    assert product['gpg'].get('gpg-key-id') != gpg_key['id']
    # First repo should have a valid gpg key assigned
    repo = Repository.info({'id': repos.pop(0)['id']})
    assert repo['gpg-key']['id'] == gpg_key['id']
    # The rest of repos should not
    for repo in repos:
        repo = Repository.info({'id': repo['id']})
        assert repo['gpg-key'].get('id') != gpg_key['id']
Beispiel #56
0
    def test_positive_add_repo_from_product_with_repos(self):
        """Create gpg key via file import and associate with custom repo

        GPGKey should contain valid name and valid key and should be associated
        to one repository from custom product. Make sure custom product should
        have more than one repository.

        :id: 9796f6f0-e688-4f14-89ec-447feb4e4911

        :expectedresults: gpg key is associated with the repository

        :CaseLevel: Integration
        """
        product = make_product({'organization-id': self.org['id']})
        repos = [
            make_repository({'product-id': product['id']})
            for _ in range(gen_integer(2, 5))
        ]
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        Repository.update({
            'gpg-key': gpg_key['name'],
            'id': repos[0]['id'],
            'organization-id': self.org['id'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id'],
        })
        self.assertNotEqual(product['gpg'].get('gpg-key-id'), gpg_key['id'])
        # First repo should have a valid gpg key assigned
        repo = Repository.info({'id': repos.pop(0)['id']})
        self.assertEqual(repo['gpg-key']['id'], gpg_key['id'])
        # The rest of repos should not
        for repo in repos:
            repo = Repository.info({'id': repo['id']})
            self.assertNotEqual(repo['gpg-key'].get('id'), gpg_key['id'])
Beispiel #57
0
    def test_positive_update_4(self, checksum_type):
        """@Test: Create a YUM repository and update the checksum type

        @Feature: Repository

        @Assert: A YUM repository is updated and contains the correct checksum
        type

        @BZ: 1155237

        """
        content_type = u'yum'
        repository = self._make_repository({
            u'content-type': content_type,
        })

        self.assertEqual(repository['content-type'], content_type)
        self.assertEqual(repository['checksum-type'], '')

        # Update the url
        result = Repository.update({
            u'id': repository['id'],
            u'checksum-type': checksum_type,
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # Fetch it again
        result = Repository.info({'id': repository['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertNotEqual(
            result.stdout['checksum-type'],
            repository['checksum-type'],
        )
        self.assertEqual(
            result.stdout['checksum-type'],
            checksum_type,
        )
    def test_positive_export_rh_product(self):
        """Export a repository from the Red Hat product

        :id: e17898db-ca92-4121-a723-0d4b3cf120eb

        :expectedresults: Repository was successfully exported, rpm files are
            present on satellite machine

        :CaseLevel: System
        """
        # Enable RH repository
        with manifests.clone() as manifest:
            ssh.upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': self.org['id'],
        })
        RepositorySet.enable({
            'basearch': 'x86_64',
            'name': REPOSET['rhva6'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
        })
        repo = Repository.info({
            'name': REPOS['rhva6']['name'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
        })
        backend_identifier = entities.Repository(
            id=repo['id']).read().backend_identifier
        repo_export_dir = (
            '/mnt/{0}/{1}/{2}/{3}/content/dist/rhel/server/6/6Server/'
            'x86_64/rhev-agent/3/os'.format(
                self.export_dir,
                backend_identifier,
                self.org['label'],
                ENVIRONMENT,
            ))

        # Update the download policy to 'immediate'
        Repository.update({
            'download-policy': 'immediate',
            'id': repo['id'],
        })

        # Export the repository
        Repository.export({'id': repo['id']})

        # Verify export directory is empty
        result = ssh.command("find {} -name '*.rpm'".format(repo_export_dir))
        self.assertEqual(len(result.stdout), 0)

        # Synchronize the repository
        Repository.synchronize({'id': repo['id']})

        # Export the repository once again
        Repository.export({'id': repo['id']})

        # Verify RPMs were successfully exported
        result = ssh.command("find {} -name '*.rpm'".format(repo_export_dir))
        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)