def test_all(self): """Test whether a particular repository version can be published. 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_rpm_remote() remote = self.client.post(RPM_REMOTE_PATH, body) self.addCleanup(self.client.delete, remote['pulp_href']) repo = self.client.post(REPO_PATH, gen_repo()) self.addCleanup(self.client.delete, repo['pulp_href']) sync(self.cfg, remote, repo) # Step 1 repo = self.client.get(repo['pulp_href']) for rpm_content in get_content(repo)[RPM_PACKAGE_CONTENT_NAME]: self.client.post( repo['versions_href'], {'add_content_units': [rpm_content['pulp_href']]} ) version_hrefs = tuple(ver['pulp_href'] for ver in get_versions(repo)) non_latest = choice(version_hrefs[:-1]) # Step 2 publication = publish(self.cfg, repo) # Step 3 self.assertEqual(publication['repository_version'], version_hrefs[-1]) # Step 4 publication = publish(self.cfg, repo, non_latest) # Step 5 self.assertEqual(publication['repository_version'], non_latest) # Step 6 with self.assertRaises(HTTPError): body = { 'repository': repo['pulp_href'], 'repository_version': non_latest } self.client.post(RPM_PUBLICATION_PATH, body)
def test_all(self): """Test whether a particular repository version can be published. 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_rpm_remote() remote = self.client.post(RPM_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 rpm_content in get_content(repo)[RPM_PACKAGE_CONTENT_NAME]: self.client.post( repo['_versions_href'], {'add_content_units': [rpm_content['_href']]} ) version_hrefs = tuple(ver['_href'] for ver in get_versions(repo)) non_latest = choice(version_hrefs[:-1]) # Step 2 publication = publish(self.cfg, repo) # Step 3 self.assertEqual(publication['repository_version'], version_hrefs[-1]) # Step 4 publication = publish(self.cfg, repo, non_latest) # Step 5 self.assertEqual(publication['repository_version'], non_latest) # Step 6 with self.assertRaises(HTTPError): body = { 'repository': repo['_href'], 'repository_version': non_latest } self.client.post(RPM_PUBLICATION_PATH, body)
def do_test(self, policy): """Verify whether package manager can consume content from Pulp.""" client = api.Client(self.cfg, api.json_handler) body = gen_rpm_remote(policy=policy) remote = client.post(RPM_REMOTE_PATH, body) self.addCleanup(client.delete, remote['pulp_href']) repo = client.post(RPM_REPO_PATH, gen_repo()) self.addCleanup(client.delete, repo['pulp_href']) sync(self.cfg, remote, repo) publication = publish(self.cfg, repo) self.addCleanup(client.delete, publication['pulp_href']) body = gen_distribution() body['publication'] = publication['pulp_href'] distribution = client.using_handler(api.task_handler).post( RPM_DISTRIBUTION_PATH, body) self.addCleanup(client.delete, distribution['pulp_href']) cli_client = cli.Client(self.cfg) cli_client.run(('sudo', 'dnf', 'config-manager', '--add-repo', distribution['base_url'])) repo_id = '*{}_'.format(distribution['base_path']) cli_client.run(('sudo', 'dnf', 'config-manager', '--save', '--setopt={}.gpgcheck=0'.format(repo_id), repo_id)) self.addCleanup( cli_client.run, ('sudo', 'dnf', 'config-manager', '--disable', repo_id)) rpm_name = 'walrus' self.pkg_mgr.install(rpm_name) self.addCleanup(self.pkg_mgr.uninstall, rpm_name) rpm = cli_client.run(('rpm', '-q', rpm_name)).stdout.strip().split('-') self.assertEqual(rpm_name, rpm[0])
def create_distribution(self, gpgcheck=0, repo_gpgcheck=0, has_signing_service=True): """Create a distribution with a repository that contains a signing service.""" repo_params = {} if has_signing_service: repo_params["metadata_signing_service"] = self.metadata_signing_service["pulp_href"] repo = self.api_client.post(RPM_REPO_PATH, gen_repo(**repo_params)) self.addCleanup(self.api_client.delete, repo["pulp_href"]) remote = self.api_client.post(RPM_REMOTE_PATH, gen_rpm_remote()) self.addCleanup(self.api_client.delete, remote["pulp_href"]) sync(self.cfg, remote, repo) repo = self.api_client.get(repo["pulp_href"]) self.assertIsNotNone(repo["latest_version_href"]) publication = publish(self.cfg, repo, gpgcheck=gpgcheck, repo_gpgcheck=repo_gpgcheck) self.addCleanup(self.api_client.delete, publication["pulp_href"]) body = gen_distribution() body["publication"] = publication["pulp_href"] distribution = self.api_client.using_handler(api.task_handler).post( RPM_DISTRIBUTION_PATH, body ) self.addCleanup(self.api_client.delete, distribution["pulp_href"]) return distribution
def test_all(self): """Sync/publish a repo that ``updateinfo.xml`` contains references. This test targets the following issue: `Pulp #3998 <https://pulp.plan.io/issues/3998>`_. """ repo = self.client.post(REPO_PATH, gen_repo()) self.addCleanup(self.client.delete, repo['_href']) body = gen_rpm_remote(url=RPM_REFERENCES_UPDATEINFO_URL) remote = self.client.post(RPM_REMOTE_PATH, body) self.addCleanup(self.client.delete, remote['_href']) sync(self.cfg, remote, repo) repo = self.client.get(repo['_href']) self.assertIsNotNone(repo['_latest_version_href']) content_summary = get_content_summary(repo) self.assertDictEqual(content_summary, RPM_FIXTURE_SUMMARY, content_summary) publication = publish(self.cfg, repo) self.addCleanup(self.client.delete, publication['_href'])
def do_test(self, policy): """Verify whether package manager can consume content from Pulp.""" client = api.Client(self.cfg, api.json_handler) body = gen_rpm_remote(policy=policy) remote = client.post(RPM_REMOTE_PATH, body) self.addCleanup(client.delete, remote['_href']) repo = client.post(REPO_PATH, gen_repo()) self.addCleanup(client.delete, repo['_href']) sync(self.cfg, remote, repo) publication = publish(self.cfg, repo) self.addCleanup(client.delete, publication['_href']) body = gen_distribution() body['publication'] = publication['_href'] distribution = client.using_handler(api.task_handler).post( RPM_DISTRIBUTION_PATH, body) self.addCleanup(client.delete, distribution['_href']) repo_path = gen_yum_config_file( self.cfg, baseurl=urljoin(self.cfg.get_content_host_base_url(), '//' + distribution['base_url']), name=repo['name'], repositoryid=repo['name']) cli_client = cli.Client(self.cfg) self.addCleanup(cli_client.run, ('rm', repo_path), sudo=True) rpm_name = 'walrus' self.pkg_mgr.install(rpm_name) self.addCleanup(self.pkg_mgr.uninstall, rpm_name) rpm = cli_client.run(('rpm', '-q', rpm_name)).stdout.strip().split('-') self.assertEqual(rpm_name, rpm[0])
def test_all(self): """Sync and publish an RPM repository and verify the checksum.""" # Step 1 repo = self.client.post(REPO_PATH, gen_repo()) self.addCleanup(self.client.delete, repo['_href']) remote = self.client.post(RPM_REMOTE_PATH, gen_rpm_remote()) self.addCleanup(self.client.delete, remote['_href']) # Step 2 sync(self.cfg, remote, repo) repo = self.client.get(repo['_href']) self.assertIsNotNone(repo['_latest_version_href']) # Step 3 publication = publish(self.cfg, repo) self.addCleanup(self.client.delete, publication['_href']) body = gen_distribution() body['publication'] = publication['_href'] distribution = self.client.using_handler(api.task_handler).post( RPM_DISTRIBUTION_PATH, body) self.addCleanup(self.client.delete, distribution['_href']) # Step 4 repo_md = ElementTree.fromstring( download_content_unit(self.cfg, distribution, 'repodata/repomd.xml')) update_info_content = ElementTree.fromstring( download_content_unit(self.cfg, distribution, self._get_updateinfo_xml_path(repo_md))) tags = {elem.tag for elem in update_info_content.iter()} self.assertNotIn('sum', tags, update_info_content)
def create_distribution(self): """Create a distribution with a repository that contains a signing service.""" repo = self.api_client.post( RPM_REPO_PATH, gen_repo(metadata_signing_service=self. metadata_signing_service['pulp_href'])) self.addCleanup(self.api_client.delete, repo['pulp_href']) remote = self.api_client.post(RPM_REMOTE_PATH, gen_rpm_remote()) self.addCleanup(self.api_client.delete, remote['pulp_href']) sync(self.cfg, remote, repo) repo = self.api_client.get(repo['pulp_href']) self.assertIsNotNone(repo['latest_version_href']) publication = publish(self.cfg, repo) self.addCleanup(self.api_client.delete, publication['pulp_href']) body = gen_distribution() body['publication'] = publication['pulp_href'] distribution = self.api_client.using_handler(api.task_handler).post( RPM_DISTRIBUTION_PATH, body) self.addCleanup(self.api_client.delete, distribution['pulp_href']) return distribution
def test_all(self): """Sync/publish a repo that ``updateinfo.xml`` contains references. This test targets the following issue: `Pulp #3998 <https://pulp.plan.io/issues/3998>`_. """ repo = self.client.post(REPO_PATH, gen_repo()) self.addCleanup(self.client.delete, repo['_href']) body = gen_rpm_remote(url=RPM_REFERENCES_UPDATEINFO_URL) remote = self.client.post(RPM_REMOTE_PATH, body) self.addCleanup(self.client.delete, remote['_href']) sync(self.cfg, remote, repo) repo = self.client.get(repo['_href']) self.assertIsNotNone(repo['_latest_version_href']) content_summary = get_content_summary(repo) self.assertDictEqual( content_summary, RPM_FIXTURE_SUMMARY, content_summary ) publication = publish(self.cfg, repo) self.addCleanup(self.client.delete, publication['_href'])
def do_publish(self, download_policy): """Publish repository synced with lazy ``download_policy``.""" repo = self.client.post(RPM_REPO_PATH, gen_repo()) self.addCleanup(self.client.delete, repo['pulp_href']) remote = self.client.post(RPM_REMOTE_PATH, gen_rpm_remote(policy=download_policy)) self.addCleanup(self.client.delete, remote['pulp_href']) sync(self.cfg, remote, repo) repo = self.client.get(repo['pulp_href']) publication = publish(self.cfg, repo) self.assertIsNotNone(publication['repository_version'], publication)
def test_all(self): """Verify whether package manager can consume content from Pulp. This test targets the following issue: `Pulp #3204 <https://pulp.plan.io/issues/3204>`_ """ cfg = config.get_config() pkg_mgr = cli.PackageManager(cfg) try: pkg_mgr.name except NoKnownPackageManagerError: raise unittest.SkipTest('This test requires dnf or yum.') client = api.Client(cfg, api.json_handler) body = gen_rpm_remote() remote = client.post(RPM_REMOTE_PATH, body) self.addCleanup(client.delete, remote['_href']) repo = client.post(REPO_PATH, gen_repo()) self.addCleanup(client.delete, repo['_href']) sync(cfg, remote, repo) publication = publish(cfg, repo) self.addCleanup(client.delete, publication['_href']) body = gen_distribution() body['publication'] = publication['_href'] distribution = client.using_handler(api.task_handler).post( DISTRIBUTION_PATH, body ) self.addCleanup(client.delete, distribution['_href']) repo_path = gen_yum_config_file( cfg, baseurl=urljoin( cfg.get_content_host_base_url(), '//' + distribution['base_url'] ), name=repo['name'], repositoryid=repo['name'] ) cli_client = cli.Client(cfg) self.addCleanup(cli_client.run, ('rm', repo_path), sudo=True) rpm_name = 'walrus' pkg_mgr.install(rpm_name) self.addCleanup(pkg_mgr.uninstall, rpm_name) rpm = cli_client.run(('rpm', '-q', rpm_name)).stdout.strip().split('-') self.assertEqual(rpm_name, rpm[0])
def do_test(self, url): """Sync and publish an RPM repository given a feed URL.""" repo = self.client.post(REPO_PATH, gen_repo()) self.addCleanup(self.client.delete, repo['_href']) remote = self.client.post(RPM_REMOTE_PATH, gen_rpm_remote(url=url)) self.addCleanup(self.client.delete, remote['_href']) sync(self.cfg, remote, repo) repo = self.client.get(repo['_href']) self.assertIsNotNone(repo['_latest_version_href']) publication = publish(self.cfg, repo) self.addCleanup(self.client.delete, publication['_href'])
def do_test(self, url): """Sync and publish an RPM repository given a feed URL.""" repo = self.client.post(REPO_PATH, gen_repo()) self.addCleanup(self.client.delete, repo['_href']) remote = self.client.post(RPM_REMOTE_PATH, gen_rpm_remote(url=url)) self.addCleanup(self.client.delete, remote['_href']) sync(self.cfg, remote, repo) repo = self.client.get(repo['_href']) self.assertIsNotNone(repo['_latest_version_href']) publication = publish(self.cfg, repo) self.addCleanup(self.client.delete, publication['_href'])
def do_publish(self, download_policy): """Publish repository synced with lazy ``download_policy``.""" repo = self.client.post(REPO_PATH, gen_repo()) self.addCleanup(self.client.delete, repo['_href']) remote = self.client.post( RPM_REMOTE_PATH, gen_rpm_remote(policy=download_policy) ) self.addCleanup(self.client.delete, remote['_href']) sync(self.cfg, remote, repo) repo = self.client.get(repo['_href']) publication = publish(self.cfg, repo) self.assertIsNotNone(publication['repository_version'], publication)
def test_all(self): """Verify whether package manager can consume content from Pulp. This test targets the following issue: `Pulp #3204 <https://pulp.plan.io/issues/3204>`_ """ cfg = config.get_config() pkg_mgr = cli.PackageManager(cfg) try: pkg_mgr.name except NoKnownPackageManagerError: raise unittest.SkipTest('This test requires dnf or yum.') client = api.Client(cfg, api.json_handler) body = gen_rpm_remote() remote = client.post(RPM_REMOTE_PATH, body) self.addCleanup(client.delete, remote['_href']) repo = client.post(REPO_PATH, gen_repo()) self.addCleanup(client.delete, repo['_href']) sync(cfg, remote, repo) publication = publish(cfg, repo) self.addCleanup(client.delete, publication['_href']) body = gen_distribution() body['publication'] = publication['_href'] distribution = client.using_handler(api.task_handler).post( DISTRIBUTION_PATH, body) self.addCleanup(client.delete, distribution['_href']) repo_path = gen_yum_config_file(cfg, baseurl=urljoin( cfg.get_content_host_base_url(), '//' + distribution['base_url']), name=repo['name'], repositoryid=repo['name']) cli_client = cli.Client(cfg) self.addCleanup(cli_client.run, ('rm', repo_path), sudo=True) rpm_name = 'walrus' pkg_mgr.install(rpm_name) self.addCleanup(pkg_mgr.uninstall, rpm_name) rpm = cli_client.run(('rpm', '-q', rpm_name)).stdout.strip().split('-') self.assertEqual(rpm_name, rpm[0])
def do_test(self, policy): """Verify whether package manager can consume content from Pulp.""" if not self._has_dnf(): self.skipTest("This test requires dnf") client = api.Client(self.cfg, api.json_handler) body = gen_rpm_remote(policy=policy) remote = client.post(RPM_REMOTE_PATH, body) self.addCleanup(client.delete, remote["pulp_href"]) repo = client.post(RPM_REPO_PATH, gen_repo()) self.addCleanup(client.delete, repo["pulp_href"]) sync(self.cfg, remote, repo) publication = publish(self.cfg, repo) self.addCleanup(client.delete, publication["pulp_href"]) body = gen_distribution() body["publication"] = publication["pulp_href"] distribution = client.using_handler(api.task_handler).post(RPM_DISTRIBUTION_PATH, body) self.addCleanup(client.delete, distribution["pulp_href"]) cli_client = cli.Client(self.cfg) cli_client.run(("sudo", "dnf", "config-manager", "--add-repo", distribution["base_url"])) repo_id = "*{}_".format(distribution["base_path"]) cli_client.run( ( "sudo", "dnf", "config-manager", "--save", "--setopt={}.gpgcheck=0".format(repo_id), repo_id, ) ) self.addCleanup(cli_client.run, ("sudo", "dnf", "config-manager", "--disable", repo_id)) rpm_name = "walrus" self.pkg_mgr.install(rpm_name) self.addCleanup(self.pkg_mgr.uninstall, rpm_name) rpm = cli_client.run(("rpm", "-q", rpm_name)).stdout.strip().split("-") self.assertEqual(rpm_name, rpm[0])
def test_all(self): """Sync and publish an RPM repository and verify the checksum.""" # Step 1 repo = self.client.post(REPO_PATH, gen_repo()) self.addCleanup(self.client.delete, repo['_href']) remote = self.client.post(RPM_REMOTE_PATH, gen_rpm_remote()) self.addCleanup(self.client.delete, remote['_href']) # Step 2 sync(self.cfg, remote, repo) repo = self.client.get(repo['_href']) self.assertIsNotNone(repo['_latest_version_href']) # Step 3 publication = publish(self.cfg, repo) self.addCleanup(self.client.delete, publication['_href']) body = gen_distribution() body['publication'] = publication['_href'] distribution = self.client.using_handler(api.task_handler).post( DISTRIBUTION_PATH, body ) self.addCleanup(self.client.delete, distribution['_href']) # Step 4 repo_md = ElementTree.fromstring( download_content_unit(self.cfg, distribution, 'repodata/repomd.xml') ) update_info_content = ElementTree.fromstring( download_content_unit( self.cfg, distribution, self._get_updateinfo_xml_path(repo_md) ) ) tags = {elem.tag for elem in update_info_content.iter()} self.assertNotIn('sum', tags, update_info_content)
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/foo/`` and ``http://example.com/content/bar/``. 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['pulp_href']) body = gen_rpm_remote() remote = client.post(RPM_REMOTE_PATH, body) self.addCleanup(client.delete, remote['pulp_href']) sync(cfg, remote, repo) repo = client.get(repo['pulp_href']) # Create a publication. publication = publish(cfg, repo) self.addCleanup(client.delete, publication['pulp_href']) # Create a distribution. body = gen_distribution() body['publication'] = publication['pulp_href'] distribution = client.using_handler(api.task_handler).post( RPM_DISTRIBUTION_PATH, body ) self.addCleanup(client.delete, distribution['pulp_href']) # Pick a content unit, and download it from both Pulp Fixtures… unit_path = choice(get_rpm_package_paths(repo)) fixtures_hash = hashlib.sha256( utils.http_get(urljoin(RPM_UNSIGNED_FIXTURE_URL, 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)
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/foo/`` and ``http://example.com/content/bar/``. 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_rpm_remote() remote = client.post(RPM_REMOTE_PATH, body) self.addCleanup(client.delete, remote['_href']) sync(cfg, remote, repo) repo = client.get(repo['_href']) # Create a publication. publication = publish(cfg, 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 content unit, and download it from both Pulp Fixtures… unit_path = choice(get_rpm_package_paths(repo)) fixtures_hash = hashlib.sha256( utils.http_get(urljoin(RPM_UNSIGNED_FIXTURE_URL, 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)