def test_signed_srpm(self):
     """Assert signature is stored for signed srpm during sync."""
     if check_issue_2620(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/2620')
     repo_href = self._create_sync_repo(SRPM_SIGNED_FEED_URL)
     unit = self._find_unit(repo_href, SRPM_SIGNED_URL)
     self._verify_pkg_key(unit, PULP_FIXTURES_KEY_ID)
 def test_unsigned_srpm(self):
     """Assert no signature is stored for unsigned srpm during sync."""
     if check_issue_2620(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/2620')
     repo_href = self._create_sync_repo(SRPM_UNSIGNED_FEED_URL)
     unit = self._find_unit(repo_href, SRPM_UNSIGNED_URL)
     self.assertNotIn('signing_key', unit['metadata'])
 def test_unsigned_srpm(self):
     """Import an unsigned SRPM into Pulp. Verify it has no signature."""
     if check_issue_2620(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/2620')
     repo_href = self._create_repo_import_unit(SRPM_UNSIGNED_URL)
     unit = self._find_unit(repo_href, SRPM_UNSIGNED_URL)
     self.assertNotIn('signing_key', unit['metadata'])
 def test_signed_srpm(self):
     """Import a signed SRPM into Pulp. Verify its signature."""
     if check_issue_2620(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/2620')
     repo_href = self._create_repo_import_unit(SRPM_SIGNED_URL)
     unit = self._find_unit(repo_href, SRPM_SIGNED_URL)
     self._verify_pkg_key(unit, PULP_FIXTURES_KEY_ID)
Beispiel #5
0
    def test_all(self):
        """Recursively copy a "chimpanzee" unit from one repository to another.

        "chimpanzee" depends on "walrus," and there are multiple versions of
        "walrus" in the source repository. Verify that one "walrus" unit has
        been copied to the target repository, and that the newer one has been
        copied.
        """
        cfg = config.get_config()
        if check_issue_2620(cfg):
            self.skipTest('https://pulp.plan.io/issues/2620')
        repo_id = self.create_repo(cfg)
        cli.Client(cfg).run(
            'pulp-admin rpm repo copy rpm --from-repo-id {} --to-repo-id {} '
            '--str-eq name=chimpanzee --recursive'.format(_REPO_ID,
                                                          repo_id).split())

        # Verify only one "walrus" unit has been copied
        dst_rpms = _get_rpm_names_versions(cfg, repo_id)
        self.assertIn('walrus', dst_rpms)
        self.assertEqual(len(dst_rpms['walrus']), 1, dst_rpms)

        # Verify the version of the "walrus" unit
        src_rpms = _get_rpm_names_versions(cfg, _REPO_ID)
        self.assertEqual(src_rpms['walrus'][-1], dst_rpms['walrus'][0])
Beispiel #6
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')
Beispiel #7
0
 def setUpClass(cls):
     """Create and sync a repository."""
     if inspect.getmro(cls)[0] == BaseSearchTestCase:
         raise unittest.SkipTest('Abstract base class.')
     super(BaseSearchTestCase, cls).setUpClass()
     if check_issue_2620(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
     body = gen_repo()
     body['importer_config']['feed'] = cls.get_feed_url()
     cls.repo = api.Client(cls.cfg).post(REPOSITORY_PATH, body).json()
     cls.resources.add(cls.repo['_href'])
     utils.sync_repo(cls.cfg, cls.repo)
Beispiel #8
0
    def test_all(self):
        """Test whether Pulp can re-sync content into a repository."""
        cfg = config.get_config()
        if check_issue_2620(cfg):
            self.skipTest('https://pulp.plan.io/issues/2620')
        repo_id = utils.uuid4()
        client = cli.Client(cfg)
        client.run((
            'pulp-admin',
            'rpm',
            'repo',
            'create',
            '--repo-id',
            repo_id,
            '--feed',
            RPM_UNSIGNED_FEED_URL,
        ))
        self.addCleanup(client.run, (
            'pulp-admin',
            'rpm',
            'repo',
            'delete',
            '--repo-id',
            repo_id,
        ))
        sync_repo(cfg, repo_id)
        unit_name = random.choice(get_rpm_names(cfg, repo_id))

        # remove a content unit from the repository
        client.run((
            'pulp-admin',
            'rpm',
            'repo',
            'remove',
            'rpm',
            '--repo-id',
            repo_id,
            '--str-eq',
            'name={}'.format(unit_name),
        ))
        with self.subTest(comment='verify the rpm has been removed'):
            self.assertNotIn(unit_name, get_rpm_names(cfg, repo_id))

        # add a content unit to the repository
        proc = sync_repo(cfg, repo_id)
        for stream in ('stdout', 'stderr'):
            with self.subTest(stream=stream):
                self.assertNotIn('Invalid properties:', getattr(proc, stream))
        with self.subTest(comment='verify the rpm has been restored'):
            self.assertIn(unit_name, get_rpm_names(cfg, repo_id))
Beispiel #9
0
    def test_all(self):
        """Copy a "chimpanzee" unit from one repository to another.

        Verify that only the "chimpanzee" unit is in the target repository.
        """
        cfg = config.get_config()
        if check_issue_2620(cfg):
            self.skipTest('https://pulp.plan.io/issues/2620')
        repo_id = self.create_repo(cfg)
        cli.Client(cfg).run(
            'pulp-admin rpm repo copy rpm --from-repo-id {} --to-repo-id {} '
            '--str-eq name=chimpanzee'.format(_REPO_ID, repo_id).split())
        rpms = _get_rpm_names_versions(cfg, repo_id)
        self.assertEqual(list(rpms.keys()), ['chimpanzee'])
        self.assertEqual(len(rpms['chimpanzee']), 1, rpms)
Beispiel #10
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)
    def setUpClass(cls):
        """Import a SRPM into a repository and search it for content units.

        Specifically, this method does the following:

        1. Create a yum repository.
        2. Upload a SRPM into the repository.
        3. Search for all content units in the repository.
        """
        super(UploadSrpmTestCase, cls).setUpClass()
        if check_issue_2620(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
        client = api.Client(cls.cfg)
        repo = client.post(REPOSITORY_PATH, gen_repo()).json()
        cls.resources.add(repo['_href'])
        srpm = utils.http_get(SRPM_UNSIGNED_URL)
        utils.upload_import_unit(cls.cfg, srpm, {'unit_type_id': 'srpm'}, repo)
        cls.units = utils.search_units(cls.cfg, repo, {}, api.safe_handler)
 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 = []
Beispiel #13
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)
 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
def setUpModule():  # pylint:disable=invalid-name
    """Maybe skip this module of tests."""
    set_up_module()
    if check_issue_2620(config.get_config()):
        raise unittest.SkipTest('https://pulp.plan.io/issues/2620')