Ejemplo n.º 1
0
    def setUpClass(cls):
        """Create an RPM repository with a valid feed and sync it.

        Do the following:

        1. Reset Pulp, including the Squid cache.
        2. Create a repository with the "background" download policy.
        3. Sync and publish the repository.
        4. Download an RPM from the repository.
        """
        super(BackgroundTestCase, cls).setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        if (selectors.bug_is_untestable(1905, cls.cfg.pulp_version)
                and os_is_rhel6(cls.cfg)):
            raise unittest.SkipTest('https://pulp.plan.io/issues/1905')

        # Required to ensure content is actually downloaded.
        utils.reset_squid(cls.cfg)
        utils.reset_pulp(cls.cfg)

        # Create, sync and publish a repository.
        repo = _create_repo(cls.cfg, 'background')
        cls.resources.add(repo['_href'])
        report = utils.sync_repo(cls.cfg, repo).json()

        # Record the tasks spawned when syncing the repository, and the state
        # of the repository itself after the sync.
        client = api.Client(cls.cfg)
        cls.repo = client.get(repo['_href'], params={'details': True}).json()
        cls.tasks = tuple(api.poll_spawned_tasks(cls.cfg, report))

        # Download an RPM.
        cls.rpm = get_unit(cls.cfg, cls.repo['distributors'][0], RPM)
Ejemplo n.º 2
0
    def setUpClass(cls):
        """Generate, fetch and parse a ``repomd.xml`` file.

        Do the following:

        1. Create an RPM repository with a YUM distributor and publish it.
        2. Fetch the ``repomd.xml`` file from the distributor, and parse it.
        """
        super(RepoMDTestCase, cls).setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        if check_issue_2277(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2277')

        # Create a repository with a yum distributor and publish it.
        client = api.Client(cls.cfg, api.json_handler)
        body = gen_repo()
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        repo = client.get(repo['_href'], params={'details': True})
        cls.resources.add(repo['_href'])
        utils.publish_repo(cls.cfg, repo)

        # Fetch and parse repomd.xml
        client.response_handler = xml_handler
        path = urljoin(
            '/pulp/repos/',
            repo['distributors'][0]['config']['relative_url'],
        )
        path = urljoin(path, 'repodata/repomd.xml')
        cls.root_element = client.get(path)
Ejemplo n.º 3
0
    def setUpClass(cls):
        """Create an RPM repository with a valid feed and sync it.

        Do the following:

        1. Reset Pulp, including the Squid cache.
        2. Create a repository with the "on demand" download policy.
        3. Sync and publish the repository.
        4. Download an RPM from the published repository.
        5. Download the same RPM to ensure it is served by the cache.
        """
        super(OnDemandTestCase, cls).setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')

        # Ensure `locally_stored_units` is 0 before we start.
        utils.reset_squid(cls.cfg)
        utils.reset_pulp(cls.cfg)

        # Create, sync and publish a repository.
        repo = _create_repo(cls.cfg, 'on_demand')
        cls.resources.add(repo['_href'])
        utils.sync_repo(cls.cfg, repo)

        # Read the repository.
        client = api.Client(cls.cfg)
        cls.repo = client.get(repo['_href'], params={'details': True}).json()

        # Download the same RPM twice.
        cls.rpm = get_unit(cls.cfg, cls.repo['distributors'][0], RPM)
        cls.same_rpm = get_unit(cls.cfg, cls.repo['distributors'][0], RPM)
Ejemplo n.º 4
0
 def setUp(self):
     """Make sure Pulp and Squid are reset."""
     if check_issue_3104(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/3104')
     # Required to ensure content is actually downloaded.
     utils.reset_squid(self.cfg)
     utils.reset_pulp(self.cfg)
Ejemplo n.º 5
0
    def setUpClass(cls):
        """Create required entities for publishing a repository group.

        Do the following:

        1. Create a repository group and add the repository created by super
           call.
        2. Creates some distributors. Each distributor is configured with a
           valid checksum type.
        """
        super(RepoGroupExportChecksumTypeTestCase, cls).setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        body = gen_repo_group()
        body['repo_ids'] = [cls.repo['id']]
        cls.repo_group = api.Client(cls.cfg).post(
            REPOSITORY_GROUP_PATH, body).json()
        cls.resources.add(cls.repo_group['_href'])
        cls.distributors = [
            _create_distributor(
                cls.cfg,
                cls.repo_group['_href'],
                REPOSITORY_GROUP_EXPORT_DISTRIBUTOR,
                checksum_type
            )
            for checksum_type in ('md5', 'sha1', 'sha256')
        ]
Ejemplo n.º 6
0
    def setUpClass(cls):
        """Create, populate and publish a repository.

        Ensure at least two versions of an RPM are present in the repository.
        """
        cls.cfg = config.get_config()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        cls.repo_id = None
        cls.relative_url = utils.uuid4() + '/'
        utils.pulp_admin_login(cls.cfg)
        client = cli.Client(cls.cfg)
        repo_id = utils.uuid4()
        client.run((
            'pulp-admin', 'rpm', 'repo', 'create', '--repo-id', repo_id,
            '--feed', RPM_UNSIGNED_FEED_URL, '--relative-url', cls.relative_url
        ))
        cls.repo_id = repo_id
        del repo_id
        try:
            client.run((
                'pulp-admin', 'rpm', 'repo', 'sync', 'run', '--repo-id',
                cls.repo_id
            ))
            cls.content = client.run((
                'pulp-admin', 'rpm', 'repo', 'content', 'rpm', '--repo-id',
                cls.repo_id
            )).stdout
        except:  # noqa:E722
            cls.tearDownClass()
            raise
Ejemplo n.º 7
0
 def test_all(self):
     """Sync two repositories w/identical content but differing layouts."""
     cfg = config.get_config()
     if check_issue_3104(cfg):
         self.skipTest('https://pulp.plan.io/issues/3104')
     if check_issue_2798(cfg):
         self.skipTest('https://pulp.plan.io/issues/2798')
     if check_issue_2354(cfg):
         self.skipTest('https://pulp.plan.io/issues/2354')
     if (utils.os_is_f26(cfg)
             and selectors.bug_is_untestable(3036, cfg.pulp_version)):
         # Here, the calls to get_unit() cause pulp_streamer.service to die
         # without logging out anything. In Pulp #3036, certain actions
         # cause pulp_streamer.service to die while logging out a core dump.
         # Thus, this test failure might be unrelated to Pulp #3036.
         self.skipTest('https://pulp.plan.io/issues/3036')
     repos = [
         self.create_repo(cfg, feed, 'on_demand')
         for feed in (RPM_ALT_LAYOUT_FEED_URL, RPM_UNSIGNED_FEED_URL)
     ]
     for repo in repos:
         utils.sync_repo(cfg, repo)
     for repo in repos:
         utils.publish_repo(cfg, repo)
     rpms = []
     for repo in repos:
         with self.subTest(repo=repo):
             rpms.append(
                 get_unit(cfg, repo['distributors'][0], RPM).content)
     self.assertEqual(len(rpms), len(repos))
     self.assertEqual(rpms[0], rpms[1], repos)
Ejemplo n.º 8
0
    def setUpClass(cls):
        """Create an RPM repository, upload package groups, and publish."""
        super(UploadPackageGroupsTestCase, cls).setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')

        # Create a repository and add a distributor to it.
        client = api.Client(cls.cfg, api.json_handler)
        body = gen_repo()
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        cls.resources.add(repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})

        # Generate several package groups, import them into the repository, and
        # publish the repository.
        cls.package_groups = {
            'minimal': _gen_minimal_group(),
            'realistic': _gen_realistic_group(),
        }
        cls.tasks = {}
        for key, package_group in cls.package_groups.items():
            report = _upload_import_package_group(cls.cfg, repo, package_group)
            cls.tasks[key] = tuple(api.poll_spawned_tasks(cls.cfg, report))
        utils.publish_repo(cls.cfg, repo)

        # Fetch the generated repodata of type 'group' (a.k.a. 'comps')
        cls.root_element = (get_repodata(cls.cfg, repo['distributors'][0],
                                         'group'))
Ejemplo n.º 9
0
    def test_all(self):
        """Upload a package group to a repository twice."""
        cfg = config.get_config()
        if check_issue_3104(cfg):
            self.skipTest('https://pulp.plan.io/issues/3104')
        client = api.Client(cfg, api.json_handler)
        self.addCleanup(client.delete, ORPHANS_PATH)

        # Create a repository.
        body = gen_repo()
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])

        # Give the repository a package group, and publish the repository.
        package_group = {'id': utils.uuid4(), 'name': utils.uuid4()}
        _upload_import_package_group(cfg, repo, package_group)
        repo = client.get(repo['_href'], params={'details': True})
        utils.publish_repo(cfg, repo)

        # Update the repository's package group, and re-publish the repository.
        package_group['name'] = utils.uuid4()
        _upload_import_package_group(cfg, repo, package_group)
        utils.publish_repo(cfg, repo)

        # Fetch the generated repodata of type 'group' (a.k.a. 'comps'). Verify
        # the package group portion.
        root_element = get_repodata(cfg, repo['distributors'][0], 'group')
        groups = root_element.findall('group')
        self.assertEqual(len(groups), 1, ElementTree.tostring(root_element))
        for key, value in package_group.items():
            with self.subTest(key=key):
                self.assertEqual(groups[0].find(key).text, value)
Ejemplo n.º 10
0
 def setUpClass(cls):
     """Initialize class-wide variables."""
     cls.cfg = config.get_config()
     cls.repos = {}  # Each inner dict has info about a repository.
     if check_issue_3104(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
     if check_issue_2277(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2277')
     if check_issue_2620(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
Ejemplo n.º 11
0
    def test_all(self):
        """Sync a repo whose updateinfo file has multiple pkglist sections.

        Specifically, do the following:

        1. Create, sync and publish an RPM repository whose feed is set to
           :data:`pulp_smash.constants.RPM_PKGLISTS_UPDATEINFO_FEED_URL`.
        2. Fetch and parse the published repository's ``updateinfo.xml`` file.

        Verify that the ``updateinfo.xml`` file has three packages whose
        ``<filename>`` elements have the following text:

        * penguin-0.9.1-1.noarch.rpm
        * shark-0.1-1.noarch.rpm
        * walrus-5.21-1.noarch.rpm

        Note that Pulp is free to change the structure of a source repository
        at will. For example, the source repository has three ``<collection>``
        elements, the published repository can have one, two or three
        ``<collection>`` elements. Assertions are not made about these details.
        """
        cfg = config.get_config()
        if check_issue_3104(cfg):
            self.skipTest('https://pulp.plan.io/issues/3104')
        if selectors.bug_is_untestable(2227, cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/2277')

        # Create, sync and publish a repository.
        client = api.Client(cfg, api.json_handler)
        body = gen_repo()
        body['importer_config']['feed'] = RPM_PKGLISTS_UPDATEINFO_FEED_URL
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})
        utils.sync_repo(cfg, repo)
        utils.publish_repo(cfg, repo)

        # Fetch and parse ``updateinfo.xml``.
        updates_element = (get_repodata(cfg, repo['distributors'][0],
                                        'updateinfo'))

        # Verify the ``updateinfo.xml`` file.
        debug = ElementTree.tostring(updates_element)
        filename_elements = (updates_element.findall(
            'update/pkglist/collection/package/filename'))
        filenames = [
            filename_element.text for filename_element in filename_elements
        ]
        filenames.sort()
        self.assertEqual(filenames, [
            'penguin-0.9.1-1.noarch.rpm',
            'shark-0.1-1.noarch.rpm',
            'walrus-5.21-1.noarch.rpm',
        ], debug)
Ejemplo n.º 12
0
 def setUp(self):
     """Provide a server config and Pulp services to stop and start."""
     self.cfg = config.get_config()
     if check_issue_3104(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/3104')
     if check_issue_2277(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/2277')
     if check_issue_2387(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/2387')
     self.broker = (utils.get_broker(self.cfg), )
     self.svc_mgr = cli.GlobalServiceManager(self.cfg)
Ejemplo n.º 13
0
 def test_all(self):
     """Execute the test case business logic."""
     cfg = config.get_config()
     if check_issue_3104(cfg):
         self.skipTest('https://pulp.plan.io/issues/3104')
     self.check_issue_2277(cfg)
     self.check_issue_2321(cfg)
     repo = self.create_repo(cfg, RPM_MIRRORLIST_MIXED, _gen_rel_url())
     utils.sync_repo(cfg, repo)
     utils.publish_repo(cfg, repo)
     actual_rpm = get_unit(cfg, repo['distributors'][0], RPM).content
     target_rpm = utils.http_get(RPM_UNSIGNED_URL)
     self.assertEqual(actual_rpm, target_rpm)
Ejemplo n.º 14
0
 def setUpClass(cls):
     """Create an RPM repository with a feed and distributor."""
     super().setUpClass()
     if check_issue_3104(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
     client = api.Client(cls.cfg, api.json_handler)
     body = gen_repo()
     body['importer_config']['feed'] = RPM_SIGNED_FEED_URL
     body['distributors'] = [gen_distributor()]
     try:
         repo = client.post(REPOSITORY_PATH, body)
         cls.resources.add(repo['_href'])
         cls.repo = client.get(repo['_href'], params={'details': True})
     except:  # noqa:E722
         cls.tearDownClass()
         raise
Ejemplo n.º 15
0
    def setUpClass(cls):
        """Create some distributors.

        Each distributor is configured with a valid checksum type.
        """
        super(ExportChecksumTypeTestCase, cls).setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        cls.distributors = [
            _create_distributor(
                cls.cfg, cls.repo['_href'],
                REPOSITORY_EXPORT_DISTRIBUTOR,
                checksum_type
            )
            for checksum_type in ('md5', 'sha1', 'sha256')
        ]
Ejemplo n.º 16
0
    def do_test(self, feed):
        """Verify ``checksum_type`` is updated on the repo metadata."""
        cfg = config.get_config()
        if check_issue_3104(cfg):
            self.skipTest('https://pulp.plan.io/issues/3104')
        client = api.Client(cfg, api.json_handler)

        # Create and sync a repository.
        body = gen_repo()
        body['importer_config']['feed'] = feed
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])
        utils.sync_repo(cfg, repo)
        repo = client.get(repo['_href'], params={'details': True})
        distributor = repo['distributors'][0]

        # Update checksum type to be "sha256" and publish the repository.
        client.put(distributor['_href'], {
            'distributor_config': {'checksum_type': 'sha256'}
        })
        utils.publish_repo(cfg, repo)
        with self.subTest(comment='primary.xml'):
            self.verify_primary_xml(cfg, distributor, 'sha256')
        with self.subTest(comment='filelists.xml'):
            self.verify_filelists_xml(cfg, distributor, 'sha256')
        with self.subTest(comment='other.xml'):
            self.verify_other_xml(cfg, distributor, 'sha256')
        if feed == DRPM_UNSIGNED_FEED_URL:
            with self.subTest(comment='prestodelta.xml'):
                self.verify_presto_delta_xml(cfg, distributor, 'sha256')

        # Update the checksum type to "sha1", and re-publish the repository.
        client.put(distributor['_href'], {
            'distributor_config': {'checksum_type': 'sha1', 'force_full': True}
        })
        utils.publish_repo(cfg, repo)
        with self.subTest(comment='primary.xml'):
            self.verify_primary_xml(cfg, distributor, 'sha1')
        with self.subTest(comment='filelists.xml'):
            self.verify_filelists_xml(cfg, distributor, 'sha1')
        with self.subTest(comment='other.xml'):
            self.verify_other_xml(cfg, distributor, 'sha1')
        if feed == DRPM_UNSIGNED_FEED_URL:
            with self.subTest(comment='prestodelta.xml'):
                self.verify_presto_delta_xml(cfg, distributor, 'sha1')
Ejemplo n.º 17
0
    def test_all(self):
        """Update an RPM in a repository and on a host."""
        cfg = config.get_config()
        if check_issue_3104(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        if check_issue_2277(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2277')
        if check_issue_2620(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
        client = cli.Client(cfg)
        pkg_mgr = cli.PackageManager(cfg)
        sudo = '' if is_root(cfg) else 'sudo '
        verify = cfg.get_systems('api')[0].roles['api'].get('verify')

        # Create the second repository.
        repo_id = self.create_repo(cfg)

        # Pick an RPM with two versions.
        rpm_name = 'walrus'
        rpm_versions = _get_rpm_names_versions(cfg, _REPO_ID)[rpm_name]

        # Copy the older RPM to the second repository, and publish it.
        self._copy_and_publish(cfg, rpm_name, rpm_versions[0], repo_id)

        # Install the RPM on a host.
        repo_path = gen_yum_config_file(
            cfg,
            baseurl=urljoin(cfg.get_base_url(), 'pulp/repos/' + repo_id),
            enabled=1,
            gpgcheck=0,
            metadata_expire=0,  # force metadata to load every time
            repositoryid=repo_id,
            sslverify='yes' if verify else 'no',
        )
        self.addCleanup(client.run, '{}rm {}'.format(sudo, repo_path).split())
        pkg_mgr.install(rpm_name)
        self.addCleanup(pkg_mgr.uninstall, rpm_name)
        client.run(['rpm', '-q', rpm_name])

        # Copy the newer RPM to the second repository, and publish it.
        self._copy_and_publish(cfg, rpm_name, rpm_versions[1], repo_id)

        # Update the installed RPM on the host.
        proc = pkg_mgr.upgrade(rpm_name)
        self.assertNotIn('Nothing to do.', proc.stdout)
Ejemplo n.º 18
0
 def setUpClass(cls):
     """Create and sync a repository."""
     cls.cfg = config.get_config()
     if check_issue_3104(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
     if check_issue_2620(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
     client = api.Client(cls.cfg, api.json_handler)
     body = gen_repo()
     body['distributors'] = [gen_distributor()]
     body['importer_config']['feed'] = RPM_UNSIGNED_FEED_URL
     cls.repo = client.post(REPOSITORY_PATH, body)
     try:
         cls.repo = client.get(cls.repo['_href'], params={'details': True})
     except:  # noqa:E722
         cls.tearDownClass()
         raise
     cls.updateinfo_xml_hrefs = []
Ejemplo n.º 19
0
    def setUpClass(cls):
        """Publish a repository, change it, and publish it again."""
        super(ChangeRepoTestCase, cls).setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        client = api.Client(cls.cfg)
        relative_url = cls.repo['distributors'][0]['config']['relative_url']

        # Publish, remove a unit, and publish again
        cls.call_reports.append(utils.publish_repo(cls.cfg, cls.repo).json())
        cls.repomd_xmls.append(client.get(get_repomd_xml_path(relative_url)))
        client.post(urljoin(cls.repo['_href'], 'actions/unassociate/'),
                    {'criteria': {
                        'type_ids': ['rpm'],
                        'limit': 1
                    }})
        cls.call_reports.append(utils.publish_repo(cls.cfg, cls.repo).json())
        cls.repomd_xmls.append(client.get(get_repomd_xml_path(relative_url)))
Ejemplo n.º 20
0
    def setUpClass(cls):
        """Create, populate and publish a repository.

        More specifically, do the following:

        1. Create an RPM repository with a distributor.
        2. Populate the repository with an RPM and two errata, where one
           erratum references the RPM, and the other does not.
        3. Publish the repository Fetch and parse its ``updateinfo.xml`` file.
        """
        super(UpdateInfoTestCase, cls).setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        cls.errata = {key: _gen_errata() for key in ('full', 'partial')}
        del cls.errata['partial']['pkglist']
        cls.tasks = {}

        # Create a repo.
        client = api.Client(cls.cfg, api.json_handler)
        body = gen_repo()
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        cls.resources.add(repo['_href'])

        try:
            # Populate and publish the repo.
            repo = client.get(repo['_href'], params={'details': True})
            unit = utils.http_get(RPM_UNSIGNED_URL)
            utils.upload_import_unit(cls.cfg, unit, {'unit_type_id': 'rpm'},
                                     repo)
            for key, erratum in cls.errata.items():
                report = utils.upload_import_erratum(cls.cfg, erratum,
                                                     repo['_href'])
                cls.tasks[key] = tuple(api.poll_spawned_tasks(cls.cfg, report))
            utils.publish_repo(cls.cfg, repo)

            # Fetch and parse updateinfo.xml.
            cls.updates_element = (get_repodata(cls.cfg,
                                                repo['distributors'][0],
                                                'updateinfo'))
        except:  # noqa:E722
            cls.tearDownClass()
            raise
Ejemplo n.º 21
0
    def test_all(self):
        """Sync a repository, change its feed, and sync it again."""
        if check_issue_3104(self.cfg):
            self.skipTest('https://pulp.plan.io/issues/3104')

        # Create, sync and publish repositories A and B.
        repos = []
        for _ in range(2):
            body = gen_repo()
            body['importer_config']['feed'] = RPM_UNSIGNED_FEED_URL
            body['distributors'] = [gen_distributor()]
            repos.append(self.create_sync_publish_repo(body))

        # Create repository C, let it sync from repository A, and publish it.
        body = gen_repo()
        body['importer_config']['feed'] = self.get_feed(repos[0])
        body['importer_config']['ssl_validation'] = False
        body['distributors'] = [gen_distributor()]
        repo = self.create_sync_publish_repo(body)

        # Update repository C.
        client = api.Client(self.cfg, api.json_handler)
        feed = self.get_feed(repos[1])
        client.put(repo['importers'][0]['_href'],
                   {'importer_config': {
                       'feed': feed
                   }})
        repo = client.get(repo['_href'], params={'details': True})
        self.assertEqual(repo['importers'][0]['config']['feed'], feed)

        # Sync and publish repository C.
        utils.sync_repo(self.cfg, repo)
        utils.publish_repo(self.cfg, repo)

        rpm = utils.http_get(RPM_UNSIGNED_URL)
        response = get_unit(self.cfg, repo['distributors'][0], RPM)
        with self.subTest():
            self.assertIn(response.headers['content-type'],
                          ('application/octet-stream', 'application/x-rpm'))
        with self.subTest():
            self.assertEqual(rpm, response.content)
Ejemplo n.º 22
0
    def test_all(self):
        """Republish a repository after removing content."""
        cfg = config.get_config()
        if check_issue_3104(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        if check_issue_2277(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2277')
        if check_issue_2620(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2620')

        # Create, sync and publish a repository.
        client = api.Client(cfg, api.json_handler)
        body = gen_repo()
        body['importer_config']['feed'] = RPM_UNSIGNED_FEED_URL
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})
        utils.sync_repo(cfg, repo)
        utils.publish_repo(cfg, repo)

        # Pick a random content unit and verify it's accessible.
        unit = random.choice(
            utils.search_units(cfg, repo, {'type_ids': ('rpm', )}))
        filename = unit['metadata']['filename']
        get_unit(cfg, repo['distributors'][0], filename)

        # Remove the content unit and verify it's inaccessible.
        client.post(
            urljoin(repo['_href'], 'actions/unassociate/'),
            {'criteria': {
                'filters': {
                    'unit': {
                        'filename': filename
                    }
                }
            }},
        )
        utils.publish_repo(cfg, repo)
        with self.assertRaises(KeyError):
            get_unit(cfg, repo['distributors'][0], filename)
Ejemplo n.º 23
0
 def setUpClass(cls):
     """Create a pair of RPM repositories."""
     cls.cfg = config.get_config()
     if check_issue_3104(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
     if check_issue_2620(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
     cls.rpm = utils.http_get(RPM_UNSIGNED_URL)
     client = api.Client(cls.cfg, api.json_handler)
     cls.repos = []
     try:
         for _ in range(2):
             body = gen_repo()
             body['distributors'] = [gen_distributor()]
             repo = client.post(REPOSITORY_PATH, body)
             cls.repos.append(repo)
             # Info about repo distributors is needed when publishing.
             repo = client.get(repo['_href'], params={'details': True})
             cls.repos[-1] = repo
     except:  # noqa:E722
         cls.tearDownClass()
         raise
Ejemplo n.º 24
0
    def setUpClass(cls):
        """Create, populate and publish a repository.

        Ensure at least two versions of an RPM are present in the repository.
        """
        super().setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        client = api.Client(cls.cfg, api.json_handler)
        body = gen_repo()
        body['importer_config']['feed'] = RPM_UNSIGNED_FEED_URL
        body['distributors'] = [gen_distributor()]
        cls.repo = client.post(REPOSITORY_PATH, body)
        cls.resources.add(cls.repo['_href'])
        try:
            cls.repo = client.get(cls.repo['_href'], params={'details': True})
            utils.sync_repo(cls.cfg, cls.repo)
            utils.publish_repo(cls.cfg, cls.repo)
            cls.repo = client.get(cls.repo['_href'], params={'details': True})
        except:  # noqa:E722
            cls.tearDownClass()
            raise
Ejemplo n.º 25
0
    def setUpClass(cls):
        """Create, sync and publish a repository. Fetch its ``comps.xml``."""
        super(SyncRepoTestCase, cls).setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        client = api.Client(cls.cfg, api.json_handler)

        # Create a repo.
        body = gen_repo()
        body['importer_config']['feed'] = RPM_SIGNED_FEED_URL
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        cls.resources.add(repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})

        # Sync and publish the repo.
        utils.sync_repo(cls.cfg, repo)
        utils.publish_repo(cls.cfg, repo)

        # Fetch and parse comps.xml.
        cls.root_element = (get_repodata(cls.cfg, repo['distributors'][0],
                                         'group'))
        cls.xml_as_str = ElementTree.tostring(cls.root_element)