Example #1
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 #3578 <https://pulp.plan.io/issues/3578>`_
        * `Pulp #3769 <https://pulp.plan.io/issues/3769>`_
        * `Pulp Smash #494 <https://github.com/PulpQE/pulp-smash/issues/494>`_
        """
        if (self.cfg.pulp_version < Version('2.17')
                or not selectors.bug_is_fixed(3578, self.cfg.pulp_version)):
            self.skipTest('https://pulp.plan.io/issues/3578')
        if not selectors.bug_is_fixed(135, self.cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/135')
        if (utils.fips_is_supported(self.cfg)
                and utils.fips_is_enabled(self.cfg)
                and not selectors.bug_is_fixed(3769, self.cfg.pulp_version)):
            self.skipTest('https://pulp.plan.io/issues/3769')
        client = api.Client(self.cfg, api.json_handler)
        body = gen_repo()
        body['importer_config'] = {
            'feed': PYTHON_PYPI_FEED_URL,
            'package_names': 'shelf-reader',
        }
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        self.repos.append(repo)
        call_report = 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)
        publish_repo(self.cfg, repo)
Example #2
0
 def test_return_false(self):
     """Assert False is returned if the crypto.fips_enabled is not enabled in sysctl."""
     for stdout in ('-1\n', '0\n', '2\n', '10\n'):
         with self.subTest(stdout=stdout):
             with mock.patch.object(cli, 'Client') as client:
                 client.return_value.run.return_value.stdout = stdout
                 response = utils.fips_is_enabled(mock.Mock())
             self.assertFalse(response)
Example #3
0
 def test_return_false(self):
     """Assert False is returned if the crypto.fips_enabled is not enabled in sysctl."""
     for stdout in ('-1\n', '0\n', '2\n', '10\n'):
         with self.subTest(stdout=stdout):
             with mock.patch.object(cli, 'Client') as client:
                 client.return_value.run.return_value.stdout = stdout
                 response = utils.fips_is_enabled(mock.Mock())
             self.assertFalse(response)
Example #4
0
    def setUpClass(cls):
        """Skip this test if FIPS is supported and enabled.

        See `Pulp #3895 <https://pulp.plan.io/issues/3895>`_.
        """
        super().setUpClass()
        if utils.fips_is_supported(cls.cfg) and utils.fips_is_enabled(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3895')
Example #5
0
    def test_all(self):
        """Publish a repository with the repoview feature on and off."""
        cfg = config.get_config()
        if cfg.pulp_version < Version('2.9'):
            self.skipTest('https://pulp.plan.io/issues/189')
        if utils.fips_is_supported(cfg) and utils.fips_is_enabled(cfg):
            self.skipTest('https://pulp.plan.io/issues/3775')

        # Create a repo, and add content
        client = api.Client(cfg)
        body = gen_repo()
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body).json()
        self.addCleanup(client.delete, repo['_href'])
        rpm = utils.http_get(RPM_UNSIGNED_URL)
        upload_import_unit(cfg, rpm, {'unit_type_id': 'rpm'}, repo)

        # Get info about the repo distributor
        repo = client.get(repo['_href'], params={'details': True}).json()
        pub_path = urljoin('/pulp/repos/',
                           repo['distributors'][0]['config']['relative_url'])

        # Publish the repo
        publish_repo(cfg, repo)
        response = client.get(pub_path)
        with self.subTest(comment='first publish'):
            self.assertEqual(len(response.history), 0, response.history)

        # Publish the repo a second time
        publish_repo(
            cfg, repo, {
                'id': repo['distributors'][0]['id'],
                'override_config': {
                    'generate_sqlite': True,
                    'repoview': True
                },
            })
        response = client.get(pub_path)
        with self.subTest(comment='second publish'):
            self.assertEqual(len(response.history), 1, response.history)
            self.assertEqual(
                response.request.url,
                urljoin(response.history[0].request.url,
                        'repoview/index.html'))

        # Publish the repo a third time
        if not selectors.bug_is_fixed(2349, cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/2349')
        publish_repo(cfg, repo)
        response = client.get(pub_path)
        with self.subTest(comment='third publish'):
            self.assertEqual(len(response.history), 0, response.history)
Example #6
0
 def setUpClass(cls):
     """Create a Python repo. Upload a Python package into it twice."""
     super().setUpClass()
     if utils.fips_is_supported(cls.cfg) and utils.fips_is_enabled(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/3895')
     unit = utils.http_get(PYTHON_EGG_URL)
     import_params = {'unit_key': {}, 'unit_type_id': 'python_package'}
     if cls.cfg.pulp_version >= Version('2.11'):
         import_params['unit_key']['filename'] = (
             urlsplit(PYTHON_EGG_URL).path.split('/')[-1])
     repo = api.Client(cls.cfg).post(REPOSITORY_PATH, gen_repo()).json()
     cls.upload_import_unit_args = (cls.cfg, unit, import_params, repo)
     cls.resources.add(repo['_href'])
Example #7
0
 def test_return_true(self):
     """Assert true is returned if the crypto.fips_enabled is enabled in sysctl."""
     with mock.patch.object(cli, 'Client') as client:
         client.return_value.run.return_value.stdout = '1\n'
         response = utils.fips_is_enabled(mock.Mock())
     self.assertTrue(response)
Example #8
0
 def test_return_true(self):
     """Assert true is returned if the crypto.fips_enabled is enabled in sysctl."""
     with mock.patch.object(cli, 'Client') as client:
         client.return_value.run.return_value.stdout = '1\n'
         response = utils.fips_is_enabled(mock.Mock())
     self.assertTrue(response)