Exemplo n.º 1
0
    def gen_pub_dist(self, repo):
        """Takes a repo and generates a publication and then distributes it"""
        publication = gen_python_publication(self.cfg, repository=repo)
        self.addCleanup(self.client.delete, publication["pulp_href"])

        body = gen_distribution()
        body["publication"] = publication["pulp_href"]
        distribution = self.client.using_handler(api.task_handler).post(
            PYTHON_DISTRIBUTION_PATH, body)
        return distribution
Exemplo n.º 2
0
    def test_01_all(self):
        """
        TODO: This needs to be broken up!

        Publication creation causes a publish task, which must also tested here.

            1. Create a repository with at least 2 repository versions.
            2. Create a publication by supplying the latest ``repository_version``.
            3. Assert that the publication ``repository_version`` attribute points
               to the latest repository version.
            4. Create a publication by supplying the non-latest
               ``repository_version``.
            5. Assert that the publication ``repository_version`` attribute points
               to the supplied repository version.
            6. Assert that an exception is raised when providing two different
               repository versions to be published at same time.
        """
        body = gen_python_remote(PYTHON_FIXTURES_URL)
        remote = self.client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        sync(self.cfg, remote, repo)

        # Step 1
        repo = self.client.get(repo['_href'])
        for python_content in get_content(repo)[PYTHON_CONTENT_NAME]:
            self.client.post(repo['_versions_href'],
                             {'add_content_units': [python_content['_href']]})
        versions = get_versions(repo)
        non_latest = choice(versions[:-1])

        # Step 2
        publication1 = gen_python_publication(self.cfg, repository=repo)

        # Step 3
        self.assertEqual(publication1['repository_version'],
                         versions[-1]['_href'])

        # Step 4
        publication2 = gen_python_publication(self.cfg,
                                              repository_version=non_latest)

        # Step 5
        self.assertEqual(publication2['repository_version'],
                         non_latest['_href'])

        # Step 6
        with self.assertRaises(HTTPError):
            gen_python_publication(
                self.cfg,
                repository_version=non_latest,
                repository=repo,
            )

        # TEST RETRIEVE
        """
        Read a publisher by its href.
        """
        publication_retrieved = self.client.get(publication1['_href'])
        for key, val in publication1.items():
            with self.subTest(key=key):
                self.assertEqual(publication_retrieved[key], val)

        # TODO TEST LIST
        # TODO TEST PARTIAL AND FULL UPDATE

        # TEST DELETE
        """
        Delete a publisher.
        """
        self.client.delete(publication1['_href'])
        with self.assertRaises(HTTPError):
            self.client.get(publication1['_href'])
Exemplo n.º 3
0
    def test_all(self):
        """
        Verify whether content served by pulp can be downloaded.

        The process of publishing content is more involved in Pulp 3 than it
        was under Pulp 2. Given a repository, the process is as follows:

        1. Create a publication from the repository. (The latest repository
           version is selected if no version is specified.) A publication is a
           repository version plus metadata.
        2. Create a distribution from the publication. The distribution defines
           at which URLs a publication is available, e.g.
           ``http://example.com/content/pub-name/`` and
           ``https://example.com/content/pub-name/``.

        Do the following:

        1. Create, populate, publish, and distribute a repository.
        2. Select a random content unit in the distribution. Download that
           content unit from Pulp, and verify that the content unit has the
           same checksum when fetched directly from Pulp-Fixtures.

        This test targets the following issues:

        * `Pulp #2895 <https://pulp.plan.io/issues/2895>`_
        * `Pulp Smash #872 <https://github.com/PulpQE/pulp-smash/issues/872>`_
        """
        cfg = config.get_config()
        client = api.Client(cfg, api.json_handler)

        repo = client.post(REPO_PATH, gen_repo())
        self.addCleanup(client.delete, repo['_href'])

        body = gen_python_remote(PYTHON_FIXTURES_URL)
        remote = client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(client.delete, remote['_href'])

        sync(cfg, remote, repo)
        repo = client.get(repo['_href'])

        # Create a publication
        publication = gen_python_publication(cfg, repository=repo)
        self.addCleanup(client.delete, publication['_href'])

        # Create a distribution.
        body = gen_distribution()
        body['publication'] = publication['_href']
        distribution = client.using_handler(api.task_handler).post(
            PYTHON_DISTRIBUTION_PATH, body)
        self.addCleanup(client.delete, distribution['_href'])

        # Pick a file, and download it from both Pulp Fixtures…
        unit_path = choice(get_python_content_paths(repo))
        fixtures_hash = hashlib.sha256(
            utils.http_get(
                urljoin(urljoin(PYTHON_FIXTURES_URL, 'packages/'),
                        unit_path))).hexdigest()

        # …and Pulp.
        content = download_content_unit(cfg, distribution, unit_path)
        pulp_hash = hashlib.sha256(content).hexdigest()

        self.assertEqual(fixtures_hash, pulp_hash)
Exemplo n.º 4
0
    def test_all(self):
        """
        Verify whether content served by pulp can be downloaded.

        The process of publishing content is more involved in Pulp 3 than it
        was under Pulp 2. Given a repository, the process is as follows:

        1. Create a publication from the repository. (The latest repository
           version is selected if no version is specified.) A publication is a
           repository version plus metadata.
        2. Create a distribution from the publication. The distribution defines
           at which URLs a publication is available, e.g.
           ``http://example.com/content/pub-name/`` and
           ``https://example.com/content/pub-name/``.

        Do the following:

        1. Create, populate, publish, and distribute a repository.
        2. Select a random content unit in the distribution. Download that
           content unit from Pulp, and verify that the content unit has the
           same checksum when fetched directly from Pulp-Fixtures.

        This test targets the following issues:

        * `Pulp #2895 <https://pulp.plan.io/issues/2895>`_
        * `Pulp Smash #872 <https://github.com/PulpQE/pulp-smash/issues/872>`_
        """
        cfg = config.get_config()
        client = api.Client(cfg, api.json_handler)

        repo = client.post(REPO_PATH, gen_repo())
        self.addCleanup(client.delete, repo['_href'])

        body = gen_python_remote(PYTHON_FIXTURES_URL)
        remote = client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(client.delete, remote['_href'])

        sync(cfg, remote, repo)
        repo = client.get(repo['_href'])

        # Create a publication
        publication = gen_python_publication(cfg, repository=repo)
        self.addCleanup(client.delete, publication['_href'])

        # Create a distribution.
        body = gen_distribution()
        body['publication'] = publication['_href']
        distribution = client.using_handler(api.task_handler).post(
            DISTRIBUTION_PATH,
            body
        )
        self.addCleanup(client.delete, distribution['_href'])

        # Pick a file, and download it from both Pulp Fixtures…
        unit_path = choice(get_python_content_paths(repo))
        fixtures_hash = hashlib.sha256(
            utils.http_get(urljoin(urljoin(PYTHON_FIXTURES_URL, 'packages/'), unit_path))
        ).hexdigest()

        # …and Pulp.
        content = download_content_unit(cfg, distribution, unit_path)
        pulp_hash = hashlib.sha256(content).hexdigest()

        self.assertEqual(fixtures_hash, pulp_hash)