コード例 #1
0
 def test_all(self):
     """Test that uploading DRPM with checksumtype specified works."""
     if selectors.bug_is_untestable(1806, self.cfg.pulp_version):
         raise unittest.SkipTest('https://pulp.plan.io/issues/1806')
     if selectors.bug_is_untestable(2627, self.cfg.pulp_version):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2627')
     client = api.Client(self.cfg)
     repo = client.post(REPOSITORY_PATH, gen_repo()).json()
     self.addCleanup(client.delete, repo['_href'])
     drpm = utils.http_get(DRPM_UNSIGNED_URL)
     utils.upload_import_unit(
         self.cfg,
         drpm,
         {
             'unit_type_id': 'drpm',
             'unit_metadata': {
                 'checksumtype': 'sha256'
             },
         },
         repo,
     )
     units = utils.search_units(self.cfg, repo, {})
     self.assertEqual(len(units), 1, units)
     # Test if DRPM extracted correct metadata for creating filename.
     self.assertEqual(
         units[0]['metadata']['filename'],
         DRPM,
     )
コード例 #2
0
    def test_broker_reconnect(self):
        """Test Pulp's support for reconnecting to a broker that goes missing.

        Do the following:

        1. Start both the broker and several other services.
        2. Stop the broker, wait, and start it again.
        3. Test Pulp's health. Create an RPM repository, sync it, add a
           distributor, publish it, and download an RPM.

        This test targets:

        * `Pulp #1635 <https://pulp.plan.io/issues/1635>`_
        * `Pulp #2613 <https://pulp.plan.io/issues/2613>`_
        """
        if selectors.bug_is_untestable(1635, self.cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/1635')
        if (self.cfg.pulp_version >= Version('2.13')
                and selectors.bug_is_untestable(2613, self.cfg.pulp_version)):
            self.skipTest('https://pulp.plan.io/issues/2613')
        # We assume that the broker and other services are already running. As
        # a result, we skip step 1 and go straight to step 2.
        self.svc_mgr.stop(self.broker)
        time.sleep(30)
        self.svc_mgr.start(self.broker)
        self.health_check()  # Step 3.
コード例 #3
0
def setUpModule():  # pylint:disable=invalid-name
    """Conditionally skip tests."""
    if selectors.bug_is_untestable(1991, config.get_config().pulp_version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/1991')
    if selectors.bug_is_untestable(2242, config.get_config().pulp_version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/2242')
    set_up_module()
コード例 #4
0
    def setUpClass(cls):
        """Create and sync a docker repository with a v2 registry.

        After doing the above, read the repository's JSON app file, tags, and
        the manifest of the first tag.

        This method requires Pulp 2.8 and above, and will raise a ``SkipTest``
        exception if run against an earlier version of Pulp.
        """
        super(SyncPublishV2TestCase, cls).setUpClass()
        if cls.cfg.version < Version('2.8'):
            raise unittest.SkipTest('These tests require Pulp 2.8 or above.')
        if (cls.cfg.version >= Version('2.9') and
                selectors.bug_is_untestable(1909, cls.cfg.version)):
            raise unittest.SkipTest('https://pulp.plan.io/issues/1909')
        if (cls.cfg.version >= Version('2.10') and
                selectors.bug_is_untestable(2287, cls.cfg.version)):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2287')
        docker_utils.repo_create(
            cls.cfg,
            feed=DOCKER_V2_FEED_URL,
            repo_id=cls.repo_id,
            upstream_name=DOCKER_UPSTREAM_NAME,
        )
        cls.completed_proc = docker_utils.repo_sync(cls.cfg, cls.repo_id)
        cls.app_file = _get_app_file(cls.cfg, cls.repo_id)
        cls.tags = _get_tags(cls.cfg, cls.repo_id)
        cls.manifest = _get_manifest(cls.cfg, cls.repo_id, cls.tags['tags'][0])
コード例 #5
0
    def test_update_is_correct(self):
        """Assert the uploaded erratum is in ``updateinfo.xml`` and correct.

        Specificially, this method does the following:

        1. Select the "update" element in ``updateinfo.xml`` corresponding to
           the uploaded erratum.
        2. Build our own erratum from the selected "update" element.
        3. Compare the uploaded erratum to the generated erratum.

        .. WARNING:: This test may be erroneous. See
            :func:`parse_updateinfo_update`.
        """
        # Find our erratum in ``updateinfo.xml``.
        updates = [
            update for update in self.updateinfo.findall('update')
            if update.find('id').text == self.erratum['id']
        ]
        self.assertEqual(len(updates), 1)

        # Parse and verify the erratum. Simply asserting that the original
        # erratum and constructed erratum are equal produces awful failure
        # messages. Iterating like this lets us narrow things down a bit.
        old_erratum = self.erratum.copy()
        if selectors.bug_is_untestable(2021, self.cfg.version):
            del old_erratum['release']
        if selectors.bug_is_untestable(2042, self.cfg.version):
            for package_list in old_erratum['pkglist']:
                for package in package_list['packages']:
                    del package['sum']
        new_erratum = parse_updateinfo_update(updates[0])
        for key, value in old_erratum.items():
            with self.subTest(key=key):
                self.assertEqual(value, new_erratum[key])
コード例 #6
0
def setUpModule():  # pylint:disable=invalid-name
    """Conditionally skip tests."""
    if selectors.bug_is_untestable(1991, config.get_config().version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/1991')
    if selectors.bug_is_untestable(2242, config.get_config().version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/2242')
    set_up_module()
コード例 #7
0
ファイル: test_selectors.py プロジェクト: elyezer/pulp-smash
 def test_connection_error(self):
     """Make the dependent function raise a connection error."""
     ver = Version('0')
     with mock.patch.object(selectors, '_get_bug') as get_bug:
         get_bug.side_effect = requests.exceptions.ConnectionError
         with self.assertWarns(RuntimeWarning):
             selectors.bug_is_testable(None, ver)
         with self.assertWarns(RuntimeWarning):
             selectors.bug_is_untestable(None, ver)
コード例 #8
0
 def test_connection_error(self):
     """Make the dependent function raise a connection error."""
     ver = Version('0')
     with mock.patch.object(selectors, '_get_bug') as get_bug:
         get_bug.side_effect = requests.exceptions.ConnectionError
         with self.assertWarns(RuntimeWarning):
             selectors.bug_is_testable(None, ver)
         with self.assertWarns(RuntimeWarning):
             selectors.bug_is_untestable(None, ver)
コード例 #9
0
def setUpModule():  # pylint:disable=invalid-name
    """Skip tests if the RPM plugin is not installed."""
    set_up_module()
    cfg = config.get_config()
    if cfg.version < Version('2.8'):
        raise unittest.SkipTest('This module requires Pulp 2.8 or greater.')
    if selectors.bug_is_untestable(2272, cfg.version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/2272')
    if selectors.bug_is_untestable(2144, cfg.version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/2144')
コード例 #10
0
def setUpModule():  # pylint:disable=invalid-name
    """Skip tests if the RPM plugin is not installed."""
    set_up_module()
    cfg = config.get_config()
    if cfg.version < Version('2.8'):
        raise unittest.SkipTest('This module requires Pulp 2.8 or greater.')
    if selectors.bug_is_untestable(2272, cfg.version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/2272')
    if selectors.bug_is_untestable(2144, cfg.version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/2144')
コード例 #11
0
 def setUpClass(cls):
     """Create class-wide variables."""
     super().setUpClass()
     cls.cfg = config.get_config()
     cls.repo = {}
     if (utils.os_is_f26(cls.cfg)
             and selectors.bug_is_untestable(3036, cls.cfg.pulp_version)):
         raise unittest.SkipTest('https://pulp.plan.io/issues/3036')
     if selectors.bug_is_untestable(2384, cls.cfg.pulp_version):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2384')
コード例 #12
0
ファイル: test_updateinfo.py プロジェクト: PulpQE/pulp-smash
    def test_reboot_not_suggested(self):
        """Assert the update info tree does not suggest a spurious reboot.

        The ``import_typical`` erratum does not suggest that a reboot be
        applied. As a result, the relevant ``<update>`` element in the
        ``updateinfo.xml`` file should not have a ``<reboot_suggested>`` tag.
        Verify that this is so. See `Pulp #2032`_.

        .. NOTE:: In previous versions of Pulp, if no reboot should be applied,
            a ``<reboot_suggested>False</reboot_suggested>`` element would be
            present. See `Pulp #1782`_.

        .. _Pulp #1782: https://pulp.plan.io/issues/1782
        .. _Pulp #2032: https://pulp.plan.io/issues/2032
        """
        if selectors.bug_is_untestable(2032, self.cfg.version):
            self.skipTest('https://pulp.plan.io/issues/2032')
        erratum_id = self.errata['import_typical']['id']
        update_element = _get_updates_by_id(self.root_element)[erratum_id]
        reboot_elements = update_element.findall('reboot_suggested')
        self.assertEqual(
            len(reboot_elements),
            0,
            [ElementTree.tostring(elem) for elem in reboot_elements],
        )
コード例 #13
0
    def test_01_first_repo(self):
        """Create, sync content into and publish a Python repository.

        See:

        * `Pulp #135 <https://pulp.plan.io/issues/135>`_
        * `Pulp Smash #494 <https://github.com/PulpQE/pulp-smash/issues/494>`_
        """
        if (self.cfg.pulp_version < Version('2.13')
                or selectors.bug_is_untestable(135, self.cfg.pulp_version)):
            self.skipTest('https://pulp.plan.io/issues/135')
        client = api.Client(self.cfg, api.json_handler)
        body = gen_repo()
        body['importer_config'] = {
            'feed': constants.PYTHON_PYPI_FEED_URL,
            'package_names': 'shelf-reader',
        }
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        self.repos.append(repo)
        call_report = utils.sync_repo(self.cfg, repo)
        with self.subTest(comment='verify the sync succeeded'):
            self.verify_sync(self.cfg, call_report)
        with self.subTest(comment='verify content units are present'):
            self.verify_package_types(self.cfg, repo)
        repo = get_details(self.cfg, repo)
        utils.publish_repo(self.cfg, repo)
コード例 #14
0
    def test_publish_override_config(self):
        """Use the ``packages_directory`` publish override option.

        Create a distributor with default options, and use it to publish the
        repository. Specify the ``packages_directory`` option during the
        publish as an override option. Verify packages end up in the specified
        directory, relative to the published repository's root.
        """
        if selectors.bug_is_untestable(1976, self.cfg.version):
            self.skipTest('https://pulp.plan.io/issues/1976')
        client = api.Client(self.cfg, api.json_handler)
        distributor = client.post(
            urljoin(self.repo_href, 'distributors/'),
            gen_distributor(),
        )
        packages_dir = utils.uuid4()
        client.post(urljoin(self.repo_href, 'actions/publish/'), {
            'id': distributor['id'],
            'override_config': {'packages_directory': packages_dir},
        })
        primary_xml = get_parse_repodata_primary_xml(self.cfg, distributor)
        package_hrefs = get_package_hrefs(primary_xml)
        self.assertGreater(len(package_hrefs), 0)
        for package_href in package_hrefs:
            with self.subTest(package_href=package_href):
                self.assertEqual(os.path.dirname(package_href), packages_dir)
コード例 #15
0
    def test_all(self):
        """Create and sync a puppet repository with no feed."""
        cfg = config.get_config()
        if selectors.bug_is_untestable(2628, cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/2628')

        # Create a repository.
        client = api.Client(cfg, api.json_handler)
        repo = client.post(REPOSITORY_PATH, gen_repo())
        self.addCleanup(client.delete, repo['_href'])

        # Sync the repository. An error *should* occur. We just want the error
        # to be sane.
        with self.assertRaises(exceptions.TaskReportError) as err:
            utils.sync_repo(cfg, repo)
        with self.subTest(comment='check task "error" field'):
            self.assertIsNotNone(err.exception.task['error'])
            self.assertNotEqual(
                err.exception.task['error']['description'],
                "'NoneType' object has no attribute 'endswith'")
            self.assertNotEqual(err.exception.task['error']['code'], 'PLP0000')
        with self.subTest(comment='check task "exception" field'):
            self.assertIsNone(err.exception.task['exception'])
        with self.subTest(comment='check task "traceback" field'):
            self.assertIsNone(err.exception.task['traceback'])
コード例 #16
0
ファイル: test_crud.py プロジェクト: BrnoPCmaniak/pulp-smash
 def test_failures(self):
     """Verify Pulp doesn't create distributors when given bad rel paths."""
     if selectors.bug_is_untestable(1106, self.cfg.version):
         self.skipTest('https://pulp.plan.io/issues/1106')
     for i, response in enumerate(self.responses[3:]):
         with self.subTest(i=i):
             self.assertEqual(response.status_code, 400)
コード例 #17
0
ファイル: test_iso_crud.py プロジェクト: pcreech/pulp-smash
    def setUpClass(cls):
        """Create a repository and add an importer and distributor to it.

        Do the following:

        1. Create a repository.
        2. Read the repository's importers and distributors.
        3. Add an importer and distributor to the repo.
        4. Re-read the repository's importers and distributors.
        """
        super(AddImporterDistributorTestCase, cls).setUpClass()
        if cls.cfg.version >= Version("2.10") and selectors.bug_is_untestable(2082, cls.cfg.version):
            raise SkipTest("https://pulp.plan.io/issues/2082")

        # Steps 1 and 2.
        client = api.Client(cls.cfg, api.json_handler)
        href = client.post(REPOSITORY_PATH, {"id": utils.uuid4()})["_href"]
        cls.resources.add(href)
        cls.pre_imp = client.get(urljoin(href, "importers/"))
        cls.pre_dist = client.get(urljoin(href, "distributors/"))

        # Steps 3 and 4.
        client.response_handler = api.safe_handler
        cls.add_imp = client.post(urljoin(href, "importers/"), {"importer_type_id": "iso_importer"})
        cls.add_dist = client.post(
            urljoin(href, "distributors/"),
            {"distributor_config": {}, "distributor_id": utils.uuid4(), "distributor_type_id": "iso_distributor"},
        )
        client.response_handler = api.json_handler
        cls.post_imp = client.get(urljoin(href, "importers/"))
        cls.post_dist = client.get(urljoin(href, "distributors/"))
コード例 #18
0
    def test_02_get_manifest_v1(self):
        """Issue an HTTP GET request to ``/v2/{repo_id}/manifests/latest``.

        Pass each of the followng headers in turn:

        * (none)
        * ``accept:application/json``
        * ``accept:application/vnd.docker.distribution.manifest.v1+json``

        Assert the response matches :data:`MANIFEST_V1`.

        This test targets `Pulp #2336 <https://pulp.plan.io/issues/2336>`_.
        """
        if selectors.bug_is_untestable(2336, self.cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/2336')
        client = api.Client(self.cfg, api.json_handler)
        client.request_kwargs['url'] = self.adjust_url(
            client.request_kwargs['url'])
        headers_iter = (
            {},
            {
                'accept': 'application/json'
            },
            {
                'accept':
                'application/vnd.docker.distribution.manifest.v1+json'
            },
        )
        for headers in headers_iter:
            with self.subTest(headers=headers):
                manifest = client.get(
                    '/v2/{}/manifests/latest'.format(self.repo['id']),
                    headers=headers,
                )
                validate(manifest, MANIFEST_V1)
コード例 #19
0
 def test_display_order_occurences(self):
     """Assert ``display_order`` occurs once if omitted from the unit."""
     if selectors.bug_is_untestable(1787, self.cfg.version):
         self.skipTest('https://pulp.plan.io/issues/1787')
     input_id = self.package_groups['minimal']['id']
     output = _get_groups_by_id(self.root_element)[input_id]
     self.assertEqual(len(output.findall('display_order')), 1)
コード例 #20
0
 def test_unsigned_drpm(self):
     """Import an unsigned DRPM into Pulp. Verify it has no signature."""
     if selectors.bug_is_untestable(1806, self.cfg.pulp_version):
         self.skipTest('https://pulp.plan.io/issues/1806')
     repo_href = self._create_repo_import_unit(DRPM_UNSIGNED_URL)
     unit = self._find_unit(repo_href, DRPM_UNSIGNED_URL)
     self.assertNotIn('signing_key', unit['metadata'])
コード例 #21
0
    def test_02_copy_manifest_lists(self):
        """Copy manifest lists from one repository to another.

        Assert the same number of manifest lists are present in both
        repositories. This test targets:

        * `Pulp #2384 <https://pulp.plan.io/issues/2384>`_
        * `Pulp #2385 <https://pulp.plan.io/issues/2385>`_
        """
        for issue_id in (2384, 2385):
            if selectors.bug_is_untestable(issue_id, self.cfg.pulp_version):
                self.skipTest(
                    'https://pulp.plan.io/issues/{}'.format(issue_id))
        client = api.Client(self.cfg, api.json_handler)
        repo = client.post(REPOSITORY_PATH, gen_repo())
        self.addCleanup(client.delete, repo['_href'])
        client.post(
            urljoin(repo['_href'], 'actions/associate/'), {
                'criteria': {
                    'filters': {},
                    'type_ids': ['docker_manifest_list']
                },
                'source_repo_id': self.repo['id'],
            })
        repo = client.get(repo['_href'], params={'details': True})
        self.assertEqual(
            self.repo['content_unit_counts']['docker_manifest_list'],
            repo['content_unit_counts'].get('docker_manifest_list', 0),
        )
コード例 #22
0
ファイル: test_sync.py プロジェクト: PulpQE/pulp-smash
    def test_force_sync(self):
        """Test whether one can force Pulp to perform a full sync."""
        cfg = config.get_config()
        if selectors.bug_is_untestable(1982, cfg.version):
            self.skipTest("https://pulp.plan.io/issues/1982")

        # Create and sync a repository.
        client = cli.Client(cfg)
        repo_id = utils.uuid4()
        client.run("pulp-admin rpm repo create --repo-id {} --feed {}".format(repo_id, RPM_SIGNED_FEED_URL).split())
        self.addCleanup(client.run, "pulp-admin rpm repo delete --repo-id {}".format(repo_id).split())
        sync_repo(cfg, repo_id)

        # Delete a random RPM
        rpms = self._list_rpms(cfg)
        client.run("{} rm -rf {}".format("sudo" if not is_root(cfg) else "", random.choice(rpms)).split())
        with self.subTest(comment="Verify the RPM was removed."):
            self.assertEqual(len(self._list_rpms(cfg)), len(rpms) - 1)

        # Sync the repository *without* force_sync.
        sync_repo(cfg, repo_id)
        with self.subTest(comment="Verify the RPM has not been restored."):
            self.assertEqual(len(self._list_rpms(cfg)), len(rpms) - 1)

        # Sync the repository again
        sync_repo(cfg, repo_id, force_sync=True)
        with self.subTest(comment="Verify the RPM has been restored."):
            self.assertEqual(len(self._list_rpms(cfg)), len(rpms))
コード例 #23
0
    def test_all(self):
        """Add a content unit to a repo in the middle of several publishes."""
        cfg = config.get_config()
        if selectors.bug_is_untestable(2532, cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/2532')
        rpms = (utils.http_get(RPM_UNSIGNED_URL),
                utils.http_get(RPM2_UNSIGNED_URL))

        # Create a user and a repository.
        ssh_user, priv_key = self.make_user(cfg)
        ssh_identity_file = self.write_private_key(cfg, priv_key)
        repo = self.make_repo(
            cfg, {
                'remote': {
                    'host': urlparse(cfg.get_base_url()).hostname,
                    'root': '/home/' + ssh_user,
                    'ssh_identity_file': ssh_identity_file,
                    'ssh_user': ssh_user,
                }
            })

        # Add content, publish w/yum, add more content, publish w/rsync.
        dists = get_dists_by_type_id(cfg, repo)
        for i, key in enumerate(('yum_distributor', 'rpm_rsync_distributor')):
            utils.upload_import_unit(cfg, rpms[i], {'unit_type_id': 'rpm'},
                                     repo)
            utils.publish_repo(cfg, repo, {'id': dists[key]['id']})
        self.verify_remote_units_path(cfg, dists['rpm_rsync_distributor'], 1)

        # Publish with yum and rsync, respectively.
        for key in 'yum_distributor', 'rpm_rsync_distributor':
            utils.publish_repo(cfg, repo, {'id': dists[key]['id']})
        self.verify_remote_units_path(cfg, dists['rpm_rsync_distributor'], 1)
コード例 #24
0
def setUpModule():  # pylint:disable=invalid-name
    """Conditionally skip tests. Cache packages to be uploaded to repos.

    Skip the tests in this module if:

    * The RPM plugin is unsupported.
    * `Pulp #1991 <https://pulp.plan.io/issues/1991>`_ is untestable for the
      version of Pulp under test.
    """
    cfg = config.get_config()
    if selectors.bug_is_untestable(1991, cfg.version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/1991')
    set_up_module()
    try:
        _SIGNED_PACKAGES['rpm'] = utils.http_get(RPM_URL)
        _SIGNED_PACKAGES['srpm'] = utils.http_get(SRPM_URL)
        _UNSIGNED_PACKAGES['rpm'] = utils.http_get(RPM_UNSIGNED_URL)
        _UNSIGNED_PACKAGES['srpm'] = utils.http_get(SRPM_UNSIGNED_URL)
        if selectors.bug_is_testable(1806, cfg.version):
            _SIGNED_PACKAGES['drpm'] = utils.http_get(DRPM_URL)
            _UNSIGNED_PACKAGES['drpm'] = utils.http_get(DRPM_UNSIGNED_URL)
    except:
        _SIGNED_PACKAGES.clear()
        _UNSIGNED_PACKAGES.clear()
        raise
コード例 #25
0
 def test_signed_drpm(self):
     """Import a signed DRPM into Pulp. Verify its signature."""
     if selectors.bug_is_untestable(1806, self.cfg.pulp_version):
         self.skipTest('https://pulp.plan.io/issues/1806')
     repo_href = self._create_repo_import_unit(DRPM_SIGNED_URL)
     unit = self._find_unit(repo_href, DRPM_SIGNED_URL)
     self._verify_pkg_key(unit, PULP_FIXTURES_KEY_ID)
コード例 #26
0
    def setUpClass(cls):
        """Create and sync a docker repository with a v2 registry."""
        super(CopyAllTagsTestCase, cls).setUpClass()
        if (cls.cfg.version >= Version('2.9')
                and selectors.bug_is_untestable(1909, cls.cfg.version)):
            raise unittest.SkipTest('https://pulp.plan.io/issues/1909')

        # Create a pair of repositories.
        docker_utils.repo_create(
            cls.cfg,
            enable_v1='false',
            enable_v2='true',
            feed=DOCKER_V2_FEED_URL,
            repo_id=cls.repo_ids[0],
            upstream_name=_UPSTREAM_NAME,
        )
        docker_utils.repo_create(cls.cfg, repo_id=cls.repo_ids[1])

        # Sync the first and copy some content units to the second.
        docker_utils.repo_sync(cls.cfg, cls.repo_ids[0])
        cls.copy = docker_utils.repo_copy(
            cls.cfg,
            unit_type='tag',
            from_repo_id=cls.repo_ids[0],
            to_repo_id=cls.repo_ids[1],
        )
コード例 #27
0
    def test_blob_digests(self):
        """Assert that the checksum embedded in each blob's URL is correct.

        For each of the "fsLayers" in the repository manifest, download and
        checksum its blob, and compare this checksum to the one embedded in the
        blob's URL.
        """
        # Issue 1781 only affects RHEL 6.
        if (selectors.bug_is_untestable(1781, self.cfg.version) and
                cli.Client(self.cfg, cli.echo_handler).run((
                    'grep',
                    '-i',
                    'red hat enterprise linux server release 6',
                    '/etc/redhat-release',
                )).returncode == 0):
            self.skipTest('https://pulp.plan.io/issues/1781')

        for fs_layer in self.manifest['fsLayers']:
            with self.subTest(fs_layer=fs_layer):
                blob_sum = fs_layer['blobSum']
                blob = api.Client(self.cfg).get(
                    '/pulp/docker/v2/{}/blobs/{}'
                    .format(self.repo_id, blob_sum)
                ).content
                algo, expected_digest = blob_sum.split(':')
                hasher = getattr(hashlib, algo)()
                hasher.update(blob)
                self.assertEqual(expected_digest, hasher.hexdigest())
def setUpModule():  # pylint:disable=invalid-name
    """Conditionally skip tests. Cache packages to be uploaded to repos.

    Skip the tests in this module if:

    * The RPM plugin is unsupported.
    * `Pulp #1991 <https://pulp.plan.io/issues/1991>`_ is untestable for the
      version of Pulp under test.
    """
    cfg = config.get_config()
    if selectors.bug_is_untestable(1991, cfg.version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/1991')
    set_up_module()
    try:
        _SIGNED_PACKAGES['rpm'] = utils.http_get(RPM_SIGNED_URL)
        _SIGNED_PACKAGES['srpm'] = utils.http_get(SRPM_SIGNED_URL)
        _UNSIGNED_PACKAGES['rpm'] = utils.http_get(RPM_UNSIGNED_URL)
        _UNSIGNED_PACKAGES['srpm'] = utils.http_get(SRPM_UNSIGNED_URL)
        if selectors.bug_is_testable(1806, cfg.version):
            _SIGNED_PACKAGES['drpm'] = utils.http_get(DRPM_SIGNED_URL)
            _UNSIGNED_PACKAGES['drpm'] = utils.http_get(DRPM_UNSIGNED_URL)
    except:
        _SIGNED_PACKAGES.clear()
        _UNSIGNED_PACKAGES.clear()
        raise
コード例 #29
0
 def test_failures(self):
     """Assert each invalid update cannot be read back."""
     if selectors.bug_is_untestable(1106, self.cfg.version):
         self.skipTest('https://pulp.plan.io/issues/1106')
     for i in range(2, len(self.written_paths)):
         with self.subTest(i=i):
             self.assertNotEqual(self.written_paths[i], self.read_paths[i])
コード例 #30
0
def setUpModule():  # pylint:disable=invalid-name
    """Conditionally skip tests. Create repositories with fixture data."""
    cfg = config.get_config()
    if selectors.bug_is_untestable(1991, cfg.pulp_version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/1991')
    set_up_module()

    # Fetch RPMs.
    _SIGNED_PACKAGES['rpm'] = utils.http_get(RPM_SIGNED_URL)
    _SIGNED_PACKAGES['srpm'] = utils.http_get(SRPM_SIGNED_URL)
    _UNSIGNED_PACKAGES['rpm'] = utils.http_get(RPM_UNSIGNED_URL)
    _UNSIGNED_PACKAGES['srpm'] = utils.http_get(SRPM_UNSIGNED_URL)
    if selectors.bug_is_testable(1806, cfg.pulp_version):
        _SIGNED_PACKAGES['drpm'] = utils.http_get(DRPM_SIGNED_URL)
        _UNSIGNED_PACKAGES['drpm'] = utils.http_get(DRPM_UNSIGNED_URL)

    # Create repos, and upload RPMs to them.
    client = api.Client(cfg, api.json_handler)
    try:
        repo = client.post(REPOSITORY_PATH, gen_repo())
        _REPOS['signed'] = repo
        for type_id, pkg in _SIGNED_PACKAGES.items():
            utils.upload_import_unit(cfg, pkg, {'unit_type_id': type_id}, repo)

        repo = client.post(REPOSITORY_PATH, gen_repo())
        _REPOS['unsigned'] = repo
        for type_id, pkg in _UNSIGNED_PACKAGES.items():
            utils.upload_import_unit(cfg, pkg, {'unit_type_id': type_id}, repo)
    except:  # noqa:E722
        _SIGNED_PACKAGES.clear()
        _UNSIGNED_PACKAGES.clear()
        for _ in range(len(_REPOS)):
            client.delete(_REPOS.popitem()[1]['_href'])
        raise
コード例 #31
0
    def test_all(self):
        """Publish the rpm rsync distributor before the yum distributor."""
        cfg = config.get_config()
        if selectors.bug_is_untestable(2187, cfg.version):
            self.skipTest('https://pulp.plan.io/issues/2187')

        # Create a user and a repository.
        ssh_user, priv_key = self.make_user(cfg)
        ssh_identity_file = self.write_private_key(cfg, priv_key)
        repo_href = self.make_repo(
            cfg, {
                'remote': {
                    'host': urlparse(cfg.base_url).netloc,
                    'root': '/home/' + ssh_user,
                    'ssh_identity_file': ssh_identity_file,
                    'ssh_user': ssh_user,
                }
            })

        # Publish with the rsync distributor.
        distribs = _get_dists_by_type_id(cfg, repo_href)
        self.verify_publish_is_skip(
            cfg,
            api.Client(cfg).post(urljoin(repo_href, 'actions/publish/'), {
                'id': distribs['rpm_rsync_distributor']['id']
            }).json())

        # Verify that the rsync distributor hasn't placed files
        sudo = '' if utils.is_root(cfg) else 'sudo '
        cmd = (sudo + 'ls -1 /home/{}'.format(ssh_user)).split()
        dirs = set(cli.Client(cfg).run(cmd).stdout.strip().split('\n'))
        self.assertNotIn('content', dirs)
コード例 #32
0
ファイル: test_crud.py プロジェクト: BrnoPCmaniak/pulp-smash
 def test_failures(self):
     """Assert each invalid update cannot be read back."""
     if selectors.bug_is_untestable(1106, self.cfg.version):
         self.skipTest('https://pulp.plan.io/issues/1106')
     for i in range(2, len(self.written_paths)):
         with self.subTest(i=i):
             self.assertNotEqual(self.written_paths[i], self.read_paths[i])
コード例 #33
0
 def test_failures(self):
     """Verify Pulp doesn't create distributors when given bad rel paths."""
     if selectors.bug_is_untestable(1106, self.cfg.version):
         self.skipTest('https://pulp.plan.io/issues/1106')
     for i, response in enumerate(self.responses[3:]):
         with self.subTest(i=i):
             self.assertEqual(response.status_code, 400)
コード例 #34
0
 def test_display_order_occurences(self):
     """Assert ``display_order`` occurs once if omitted from the unit."""
     if selectors.bug_is_untestable(1787, self.cfg.version):
         self.skipTest('https://pulp.plan.io/issues/1787')
     input_id = self.package_groups['minimal']['id']
     output = _get_groups_by_id(self.root_element)[input_id]
     self.assertEqual(len(output.findall('display_order')), 1)
コード例 #35
0
def setUpModule():  # pylint:disable=invalid-name
    """Conditionally skip tests. Cache packages to be uploaded to repos.

    Skip the tests in this module if:

    * The RPM plugin is unsupported.
    * `Pulp #1991 <https://pulp.plan.io/issues/1991>`_ is untestable for the
      version of Pulp under test.
    """
    if selectors.bug_is_untestable(1991, config.get_config().version):
        raise unittest2.SkipTest('https://pulp.plan.io/issues/1991')
    set_up_module()
    global _PACKAGES  # pylint:disable=global-statement
    try:
        _PACKAGES = {
            'signed drpm': utils.http_get(DRPM_URL),
            'signed rpm': utils.http_get(RPM_URL),
            'signed srpm': utils.http_get(SRPM_URL),
            'unsigned drpm': utils.http_get(DRPM_UNSIGNED_URL),
            'unsigned rpm': utils.http_get(RPM_UNSIGNED_URL),
            'unsigned srpm': utils.http_get(SRPM_UNSIGNED_URL),
        }
    except:
        _PACKAGES = None
        raise
コード例 #36
0
    def test_invalid_v3(self):
        """Update a distributor's relative path with an invalid value.

        Prepend a slash to an existing relative path. For example, if an
        existing relative path is ``foo/bar``, then this relative path would be
        ``/foo/bar``.
        """
        if (self.cfg.pulp_version >= Version('2.14')
                and selectors.bug_is_untestable(2769, self.cfg.pulp_version)):
            self.skipTest('https://pulp.plan.io/issues/2769')

        # update
        client = api.Client(self.cfg, api.json_handler)
        old_path = self.repos[1]['distributors'][0]['config']['relative_path']
        new_path = (
            '/' + self.repos[0]['distributors'][0]['config']['relative_path'])
        with self.assertRaises(exceptions.TaskReportError):
            client.put(self.repos[1]['distributors'][0]['_href'],
                       {'distributor_config': {
                           'relative_path': new_path
                       }})

        # verify
        repo = client.get(self.repos[1]['_href'], params={'details': True})
        self.assertEqual(repo['distributors'][0]['config']['relative_path'],
                         old_path)
コード例 #37
0
ファイル: test_copy.py プロジェクト: PulpQE/pulp-smash
    def setUpClass(cls):
        """Create and sync a docker repository with a v2 registry."""
        super(CopyAllTagsTestCase, cls).setUpClass()
        if (cls.cfg.version >= Version('2.9') and
                selectors.bug_is_untestable(1909, cls.cfg.version)):
            raise unittest.SkipTest('https://pulp.plan.io/issues/1909')

        # Create a pair of repositories.
        docker_utils.repo_create(
            cls.cfg,
            enable_v1='false',
            enable_v2='true',
            feed=DOCKER_V2_FEED_URL,
            repo_id=cls.repo_ids[0],
            upstream_name=_UPSTREAM_NAME,
        )
        docker_utils.repo_create(cls.cfg, repo_id=cls.repo_ids[1])

        # Sync the first and copy some content units to the second.
        docker_utils.repo_sync(cls.cfg, cls.repo_ids[0])
        cls.copy = docker_utils.repo_copy(
            cls.cfg,
            unit_type='tag',
            from_repo_id=cls.repo_ids[0],
            to_repo_id=cls.repo_ids[1],
        )
コード例 #38
0
    def test_02_second_repo(self):
        """Create a second Python repository, and sync it from the first.

        See:

        * `Pulp #140 <https://pulp.plan.io/issues/140>`_
        * `Pulp Smash #493 <https://github.com/PulpQE/pulp-smash/issues/493>`_

        Note that, for `Pulp #140`_ to be fully tested, an additional test case
        should be created wherein one Pulp application syncs from another
        completely independent Pulp application.
        """
        if (self.cfg.pulp_version < Version('2.13')
                or selectors.bug_is_untestable(140, self.cfg.pulp_version)):
            self.skipTest('https://pulp.plan.io/issues/140')
        client = api.Client(self.cfg, api.json_handler)
        body = gen_repo()
        body['importer_config'] = {
            'feed': get_repo_path(self.cfg, self.repos[0]),
            'package_names': 'shelf-reader',
        }
        repo = client.post(REPOSITORY_PATH, body)
        self.repos.append(repo)
        call_report = utils.sync_repo(self.cfg, repo)
        with self.subTest(comment='verify the sync succeeded'):
            self.verify_sync(self.cfg, call_report)
        with self.subTest(comment='verify content units are present'):
            self.verify_package_types(self.cfg, repo)
コード例 #39
0
 def test_signed_drpm(self):
     """Import a signed DRPM into Pulp. Verify its signature."""
     if selectors.bug_is_untestable(1806, self.cfg.version):
         self.skipTest('https://pulp.plan.io/issues/1806')
     repo_href = self._create_repo_import_unit(DRPM_URL)
     unit = self._find_unit(repo_href, DRPM_URL)
     self._verify_pkg_key(unit, PULP_FIXTURES_KEY_ID)
コード例 #40
0
def setUpModule():  # pylint:disable=invalid-name
    """Conditionally skip tests. Create repositories with fixture data."""
    cfg = config.get_config()
    if selectors.bug_is_untestable(1991, cfg.version):
        raise unittest.SkipTest('https://pulp.plan.io/issues/1991')
    set_up_module()

    # Fetch RPMs.
    _SIGNED_PACKAGES['rpm'] = utils.http_get(RPM_URL)
    _SIGNED_PACKAGES['srpm'] = utils.http_get(SRPM_URL)
    _UNSIGNED_PACKAGES['rpm'] = utils.http_get(RPM_UNSIGNED_URL)
    _UNSIGNED_PACKAGES['srpm'] = utils.http_get(SRPM_UNSIGNED_URL)
    if selectors.bug_is_testable(1806, cfg.version):
        _SIGNED_PACKAGES['drpm'] = utils.http_get(DRPM_URL)
        _UNSIGNED_PACKAGES['drpm'] = utils.http_get(DRPM_UNSIGNED_URL)

    # Create repos, and upload RPMs to them.
    client = api.Client(cfg, api.json_handler)
    try:
        repo = client.post(REPOSITORY_PATH, gen_repo())
        _REPOS['signed'] = repo
        for type_id, pkg in _SIGNED_PACKAGES.items():
            utils.upload_import_unit(cfg, pkg, type_id, repo['_href'])

        repo = client.post(REPOSITORY_PATH, gen_repo())
        _REPOS['unsigned'] = repo
        for type_id, pkg in _UNSIGNED_PACKAGES.items():
            utils.upload_import_unit(cfg, pkg, type_id, repo['_href'])
    except:
        _SIGNED_PACKAGES.clear()
        _UNSIGNED_PACKAGES.clear()
        for _ in range(len(_REPOS)):
            client.delete(_REPOS.popitem()[1]['_href'])
        raise
コード例 #41
0
 def test_unsigned_drpm(self):
     """Import an unsigned DRPM into Pulp. Verify it has no signature."""
     if selectors.bug_is_untestable(1806, self.cfg.version):
         self.skipTest('https://pulp.plan.io/issues/1806')
     repo_href = self._create_repo_import_unit(DRPM_UNSIGNED_URL)
     unit = self._find_unit(repo_href, DRPM_UNSIGNED_URL)
     self.assertNotIn('signing_key', unit['metadata'])
コード例 #42
0
    def test_sync_downloaded_content(self):
        """Create two repositories with the same feed, and sync them serially.

        More specifically, this test creates two puppet repositories with
        identical feeds, syncs them serially, and verifies that both have equal
        non-zero content unit counts.
        """
        cfg = config.get_config()
        if selectors.bug_is_untestable(1937, cfg.version):
            self.skipTest('https://pulp.plan.io/issues/1937')
        utils.pulp_admin_login(cfg)

        # Create two repos, schedule them for deletion, and sync them.
        client = cli.Client(cfg)
        repo_ids = [utils.uuid4() for _ in range(2)]
        for repo_id in repo_ids:
            client.run((
                'pulp-admin puppet repo create '
                '--repo-id {} --feed {} --queries {}'
            ).format(repo_id, PUPPET_FEED, PUPPET_QUERY).split())
            self.addCleanup(client.run, (
                'pulp-admin puppet repo delete --repo-id {}'
            ).format(repo_id).split())
            client.run((
                'pulp-admin puppet repo sync run --repo-id {}'
            ).format(repo_id).split())

        # Verify the number of puppet modules in each repository.
        unit_counts = [
            get_num_units_in_repo(cfg, repo_id) for repo_id in repo_ids
        ]
        for i, unit_count in enumerate(unit_counts):
            with self.subTest(i=i):
                self.assertGreater(unit_count, 0)
        self.assertEqual(unit_counts[0], unit_counts[1])
コード例 #43
0
    def test_all(self):
        """Test whether one can upload an RPM with non-utf-8 metadata."""
        cfg = config.get_config()
        if selectors.bug_is_untestable(1903, cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/1903')
        client = cli.Client(cfg)

        # Get the RPM
        rpm = client.run(('mktemp',)).stdout.strip()
        self.addCleanup(client.run, ('rm', rpm))
        client.run(('curl', '--output', rpm, RPM_WITH_NON_UTF_8_URL))

        # Create a repo.
        repo_id = utils.uuid4()
        client.run((
            'pulp-admin', 'rpm', 'repo', 'create', '--repo-id', repo_id
        ))
        self.addCleanup(
            client.run,
            ('pulp-admin', 'rpm', 'repo', 'delete', '--repo-id', repo_id)
        )

        # Upload an RPM.
        response = client.run((
            'pulp-admin', 'rpm', 'repo', 'uploads', 'rpm', '--repo-id',
            repo_id, '--file', rpm
        ))
        for stream in (response.stdout, response.stderr):
            self.assertNotIn('Task Failed', stream)
コード例 #44
0
    def test_force_sync(self):
        """Test whether one can force Pulp to perform a full sync."""
        cfg = config.get_config()
        if selectors.bug_is_untestable(1982, cfg.version):
            self.skipTest('https://pulp.plan.io/issues/1982')

        # Create and sync a repository.
        client = cli.Client(cfg)
        repo_id = utils.uuid4()
        client.run('pulp-admin rpm repo create --repo-id {} --feed {}'.format(
            repo_id, RPM_SIGNED_FEED_URL).split())
        self.addCleanup(
            client.run,
            'pulp-admin rpm repo delete --repo-id {}'.format(repo_id).split())
        sync_repo(cfg, repo_id)

        # Delete a random RPM
        rpms = self._list_rpms(cfg)
        client.run('{} rm -rf {}'.format(
            'sudo' if not is_root(cfg) else '',
            random.choice(rpms),
        ).split())
        with self.subTest(comment='Verify the RPM was removed.'):
            self.assertEqual(len(self._list_rpms(cfg)), len(rpms) - 1)

        # Sync the repository *without* force_sync.
        sync_repo(cfg, repo_id)
        with self.subTest(comment='Verify the RPM has not been restored.'):
            self.assertEqual(len(self._list_rpms(cfg)), len(rpms) - 1)

        # Sync the repository again
        sync_repo(cfg, repo_id, force_sync=True)
        with self.subTest(comment='Verify the RPM has been restored.'):
            self.assertEqual(len(self._list_rpms(cfg)), len(rpms))
コード例 #45
0
def setUpModule():  # pylint:disable=invalid-name
    """Maybe skip this module of tests."""
    set_up_module()
    cfg = config.get_config()
    if (cfg.pulp_version >= Version('2.15.1') and
            selectors.bug_is_untestable(3310, cfg.pulp_version)):
        raise unittest.SkipTest('https://pulp.plan.io/issues/3310')
コード例 #46
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 (selectors.bug_is_untestable(1905, cls.cfg.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['_href']).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.
        path = urljoin('/pulp/repos/', repo['id'] + '/')
        path = urljoin(path, RPM)
        cls.rpm = client.get(path)
コード例 #47
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 (selectors.bug_is_untestable(1905, cls.cfg.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['_href']).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.
        path = urljoin('/pulp/repos/', repo['id'] + '/')
        path = urljoin(path, RPM)
        cls.rpm = client.get(path)
コード例 #48
0
 def test_01_add_unit(self):
     """Add a content unit to the repository. Publish the repository."""
     repo_before = self.get_repo()
     rpm = utils.http_get(RPM_UNSIGNED_URL)
     utils.upload_import_unit(
         self.cfg,
         rpm,
         {'unit_type_id': 'rpm'},
         self.repo,
     )
     utils.publish_repo(self.cfg, repo_before)
     repo_after = self.get_repo()
     with self.subTest(comment='last_unit_added'):
         if selectors.bug_is_untestable(1847, self.cfg.pulp_version):
             self.skipTest('https://pulp.plan.io/issues/1847')
         pre = repo_before['last_unit_added']
         post = repo_after['last_unit_added']
         self.assertIsNone(pre)
         self.assertIsNotNone(post)
     with self.subTest(comment='last_unit_removed'):
         pre = repo_before['last_unit_removed']
         post = repo_after['last_unit_removed']
         self.assertIsNone(pre)
         self.assertIsNone(post)
     with self.subTest(comment='last_publish'):
         pre = repo_before['distributors'][0]['last_publish']
         post = repo_after['distributors'][0]['last_publish']
         self.assertIsNone(pre)
         self.assertIsNotNone(post)
コード例 #49
0
    def test_all(self):
        """Publish the rpm rsync distributor before the yum distributor."""
        cfg = config.get_config()
        if selectors.bug_is_untestable(2187, cfg.version):
            self.skipTest('https://pulp.plan.io/issues/2187')

        # Create a user and a repository.
        ssh_user, priv_key = self.make_user(cfg)
        ssh_identity_file = self.write_private_key(cfg, priv_key)
        repo = self.make_repo(cfg, {'remote': {
            'host': urlparse(cfg.base_url).netloc,
            'root': '/home/' + ssh_user,
            'ssh_identity_file': ssh_identity_file,
            'ssh_user': ssh_user,
        }})

        # Publish with the rsync distributor.
        distribs = _get_dists_by_type_id(cfg, repo['_href'])
        self.verify_publish_is_skip(cfg, utils.publish_repo(
            cfg,
            repo,
            {'id': distribs['rpm_rsync_distributor']['id']}
        ).json())

        # Verify that the rsync distributor hasn't placed files
        sudo = '' if utils.is_root(cfg) else 'sudo '
        cmd = (sudo + 'ls -1 /home/{}'.format(ssh_user)).split()
        dirs = set(cli.Client(cfg).run(cmd).stdout.strip().split('\n'))
        self.assertNotIn('content', dirs)
コード例 #50
0
    def test_sync_downloaded_content(self):
        """Create two repositories with the same feed, and sync them serially.

        More specifically, this test creates two puppet repositories with
        identical feeds, syncs them serially, and verifies that both have equal
        non-zero content unit counts.
        """
        cfg = config.get_config()
        if selectors.bug_is_untestable(1937, cfg.version):
            self.skipTest('https://pulp.plan.io/issues/1937')
        utils.pulp_admin_login(cfg)

        # Create two repos, schedule them for deletion, and sync them.
        client = cli.Client(cfg)
        repo_ids = [utils.uuid4() for _ in range(2)]
        for repo_id in repo_ids:
            client.run(('pulp-admin puppet repo create '
                        '--repo-id {} --feed {} --queries {}').format(
                            repo_id, PUPPET_FEED, PUPPET_QUERY).split())
            self.addCleanup(client.run,
                            ('pulp-admin puppet repo delete --repo-id {}'
                             ).format(repo_id).split())
            client.run(('pulp-admin puppet repo sync run --repo-id {}'
                        ).format(repo_id).split())

        # Verify the number of puppet modules in each repository.
        unit_counts = [
            get_num_units_in_repo(cfg, repo_id) for repo_id in repo_ids
        ]
        for i, unit_count in enumerate(unit_counts):
            with self.subTest(i=i):
                self.assertGreater(unit_count, 0)
        self.assertEqual(unit_counts[0], unit_counts[1])
コード例 #51
0
ファイル: test_login.py プロジェクト: BrnoPCmaniak/pulp-smash
 def test_body(self):
     """Assert that the response is valid JSON and has correct keys."""
     # The `version` attribute should correspond to the version of the Pulp
     # server under test. This block of code says "if bug 1412 is not fixed
     # in Pulp version X, then skip this test."
     if selectors.bug_is_untestable(1412, self.cfg.version):
         self.skipTest('https://pulp.plan.io/issues/1412')
     self.assertEqual(frozenset(self.response.json().keys()), ERROR_KEYS)
コード例 #52
0
    def check_issue_2363(self, cfg):
        """Skip the current test method if Pulp `issue #2363`_ affects us.

        .. _issue #2363: https://pulp.plan.io/issues/2363
        """
        if (cfg.version >= Version('2.11') and
                selectors.bug_is_untestable(2363, cfg.version)):
            self.skipTest('https://pulp.plan.io/issues/2363')
コード例 #53
0
 def setUpClass(cls):
     """Create a shared client."""
     if inspect.getmro(cls)[0] == _BaseTestCase:
         raise unittest.SkipTest('Abstract base class.')
     cls.cfg = config.get_config()
     if selectors.bug_is_untestable(1156, cls.cfg.version):
         raise unittest.SkipTest('https://pulp.plan.io/issues/1156')
     cls.client = api.Client(cls.cfg, api.json_handler)
コード例 #54
0
 def test_root(self):
     """Pass a relative path to the ``root`` configuration option."""
     if selectors.bug_is_untestable(2192, self.cfg.version):
         raise self.skipTest('https://pulp.plan.io/issues/2192')
     remote = self.remote.copy()
     remote['root'] = remote['root'][1:]
     with self.assertRaises(HTTPError, msg=remote):
         self.make_repo(self.cfg, {'remote': remote})
コード例 #55
0
 def test_exception_keys_json(self):
     """Assert the JSON body returned contains the correct keys."""
     for body, response in zip(self.bodies, self.responses):
         with self.subTest(body=body):
             if bug_is_untestable(1413, self.cfg.version):
                 self.skipTest('https://pulp.plan.io/issues/1413')
             response_keys = frozenset(response.json().keys())
             self.assertEqual(response_keys, ERROR_KEYS)
コード例 #56
0
 def test_task_error_traceback(self):
     """Assert each task's "error" and "traceback" fields are non-null."""
     if selectors.bug_is_untestable(1455, self.cfg.version):
         self.skipTest("https://pulp.plan.io/issues/1455")
     for i, task in enumerate(self.tasks):
         for key in {"error", "traceback"}:
             with self.subTest((i, key)):
                 self.assertIsNotNone(task[key])
コード例 #57
0
 def test_task_error_traceback(self):
     """Assert each task's "error" and "traceback" fields are null."""
     if (self.cfg.version >= Version('2.8') and
             selectors.bug_is_untestable(1455)):
         self.skipTest('https://pulp.plan.io/issues/1455')
     for i, task in enumerate(self.tasks):
         for key in {'error', 'traceback'}:
             with self.subTest((i, key)):
                 self.assertIsNone(task[key])
コード例 #58
0
ファイル: test_selectors.py プロジェクト: elyezer/pulp-smash
 def test_untestable_status(self):
     """Assert the method correctly handles "untestable" bug statuses."""
     ver = Version('0')
     for bug_status in selectors._UNTESTABLE_BUGS:
         bug = selectors._Bug(bug_status, ver)
         with mock.patch.object(selectors, '_get_bug', return_value=bug):
             with self.subTest(bug_status=bug_status):
                 self.assertFalse(selectors.bug_is_testable(None, ver))
                 self.assertTrue(selectors.bug_is_untestable(None, ver))