本文整理匯總了Python中yum_distributor.distributor.YumDistributor.process_repo_auth_certificate_bundle方法的典型用法代碼示例。如果您正苦於以下問題:Python YumDistributor.process_repo_auth_certificate_bundle方法的具體用法?Python YumDistributor.process_repo_auth_certificate_bundle怎麽用?Python YumDistributor.process_repo_auth_certificate_bundle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yum_distributor.distributor.YumDistributor
的用法示例。
在下文中一共展示了YumDistributor.process_repo_auth_certificate_bundle方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_publish
# 需要導入模塊: from yum_distributor.distributor import YumDistributor [as 別名]
# 或者: from yum_distributor.distributor.YumDistributor import process_repo_auth_certificate_bundle [as 別名]
def test_publish(self):
repo = mock.Mock(spec=Repository)
repo.working_dir = self.repo_working_dir
repo.id = "test_publish"
num_units = 10
relative_url = "rel_a/rel_b/rel_c/"
existing_units = self.get_units(count=num_units)
publish_conduit = distributor_mocks.get_publish_conduit(existing_units=existing_units, pkg_dir=self.pkg_dir)
config = distributor_mocks.get_basic_config(https_publish_dir=self.https_publish_dir, relative_url=relative_url,
http=False, https=True)
distributor = YumDistributor()
distributor.process_repo_auth_certificate_bundle = mock.Mock()
status, msg = distributor.validate_config(repo, config, None)
self.assertTrue(status)
report = distributor.publish_repo(repo, publish_conduit, config)
self.assertTrue(report.success_flag)
summary = report.summary
self.assertEqual(summary["num_package_units_attempted"], num_units)
self.assertEqual(summary["num_package_units_published"], num_units)
self.assertEqual(summary["num_package_units_errors"], 0)
# Verify we did not attempt to publish to http
expected_repo_http_publish_dir = os.path.join(self.http_publish_dir, relative_url)
self.assertFalse(os.path.exists(expected_repo_http_publish_dir))
expected_repo_https_publish_dir = os.path.join(self.https_publish_dir, relative_url).rstrip('/')
self.assertEqual(summary["https_publish_dir"], expected_repo_https_publish_dir)
self.assertTrue(os.path.exists(expected_repo_https_publish_dir))
details = report.details
self.assertEqual(len(details["errors"]), 0)
#
# Add a verification of the publish directory
#
self.assertTrue(os.path.exists(summary["https_publish_dir"]))
self.assertTrue(os.path.islink(summary["https_publish_dir"].rstrip("/")))
source_of_link = os.readlink(expected_repo_https_publish_dir.rstrip("/"))
self.assertEquals(source_of_link, repo.working_dir)
#
# Verify the expected units
#
for u in existing_units:
expected_link = os.path.join(expected_repo_https_publish_dir, u.metadata["relativepath"])
self.assertTrue(os.path.exists(expected_link))
actual_target = os.readlink(expected_link)
expected_target = u.storage_path
self.assertEqual(actual_target, expected_target)
#
# Now test flipping so https is disabled and http is enabled
#
config = distributor_mocks.get_basic_config(https_publish_dir=self.https_publish_dir,
http_publish_dir=self.http_publish_dir, relative_url=relative_url, http=True, https=False)
report = distributor.publish_repo(repo, publish_conduit, config)
self.assertTrue(report.success_flag)
# Verify we did publish to http
self.assertTrue(os.path.exists(expected_repo_http_publish_dir))
# Verify we did not publish to https
self.assertFalse(os.path.exists(expected_repo_https_publish_dir))
# Verify we cleaned up the misc dirs under the https dir
self.assertEquals(len(os.listdir(self.https_publish_dir)), 0)
示例2: test_basic_repo_publish_rel_path_conflict
# 需要導入模塊: from yum_distributor.distributor import YumDistributor [as 別名]
# 或者: from yum_distributor.distributor.YumDistributor import process_repo_auth_certificate_bundle [as 別名]
def test_basic_repo_publish_rel_path_conflict(self):
repo = mock.Mock(spec=Repository)
repo.working_dir = self.repo_working_dir
repo.id = "test_basic_repo_publish_rel_path_conflict"
num_units = 10
relative_url = "rel_a/rel_b/rel_a/"
config = distributor_mocks.get_basic_config(https_publish_dir=self.https_publish_dir,
relative_url=relative_url, http=False, https=True)
url_a = relative_url
config_a = PluginCallConfiguration({"relative_url":url_a}, {})
repo_a = RelatedRepository("repo_a_id", [config_a])
config_conduit = mock.Mock(spec=RepoConfigConduit)
conduit_return_cursor = MockCursor([{'repo_id': 'repo_a_id', 'config': {'relative_url': "rel_a/rel_b/rel_a/"}}])
config_conduit.get_repo_distributors_by_relative_url.return_value = conduit_return_cursor
# Simple check of direct conflict of a duplicate - varieties of duplicates are tested via the conduit tests
related_repos = [repo_a]
distributor = YumDistributor()
distributor.process_repo_auth_certificate_bundle = mock.Mock()
status, msg = distributor.validate_config(repo, config, config_conduit)
self.assertFalse(status)
expected_msg = "Relative url '%s' conflicts with existing relative_url of '%s' from repo '%s'" % \
(relative_url, url_a, repo_a.id)
self.assertEqual(expected_msg, msg)
# Ensure this test can handle a large number of repos
"""
示例3: test_yum_plugin_generate_yum_metadata_checksum_default
# 需要導入模塊: from yum_distributor.distributor import YumDistributor [as 別名]
# 或者: from yum_distributor.distributor.YumDistributor import process_repo_auth_certificate_bundle [as 別名]
def test_yum_plugin_generate_yum_metadata_checksum_default(self, mock_YumMetadataGenerator,
mock_distributor_manager):
repo = mock.Mock(spec=Repository)
repo.working_dir = self.repo_working_dir
repo.id = "test_publish"
num_units = 10
relative_url = "rel_a/rel_b/rel_c/"
existing_units = self.get_units(count=num_units)
publish_conduit = distributor_mocks.get_publish_conduit(type_id="rpm",
existing_units=existing_units,
checksum_type=None,
pkg_dir=self.pkg_dir)
config = distributor_mocks.get_basic_config(https_publish_dir=self.https_publish_dir,
relative_url=relative_url,
http=False, https=True)
distributor = YumDistributor()
distributor.process_repo_auth_certificate_bundle = mock.Mock()
config_conduit = mock.Mock(spec=RepoConfigConduit)
config_conduit.get_repo_distributors_by_relative_url.return_value = MockCursor([])
metadata.generate_yum_metadata(repo.id, repo.working_dir, publish_conduit, config)
mock_YumMetadataGenerator.assert_called_with(ANY, checksum_type=metadata.DEFAULT_CHECKSUM,
skip_metadata_types=ANY, is_cancelled=ANY,
group_xml_path=ANY,
updateinfo_xml_path=ANY,
custom_metadata_dict=ANY)
self.assertFalse(mock_distributor_manager.called)
示例4: test_yum_plugin_generate_yum_metadata_checksum_from_conduit_sha1_conversion
# 需要導入模塊: from yum_distributor.distributor import YumDistributor [as 別名]
# 或者: from yum_distributor.distributor.YumDistributor import process_repo_auth_certificate_bundle [as 別名]
def test_yum_plugin_generate_yum_metadata_checksum_from_conduit_sha1_conversion(self,
mock_YumMetadataGenerator,
mock_distributor_manager):
repo = mock.Mock(spec=Repository)
repo.working_dir = self.repo_working_dir
repo.id = "test_publish"
num_units = 10
relative_url = "rel_a/rel_b/rel_c/"
existing_units = self.get_units(count=num_units)
publish_conduit = distributor_mocks.get_publish_conduit(type_id="rpm", existing_units=existing_units, pkg_dir=self.pkg_dir)
publish_conduit.repo_id = 'foo'
publish_conduit.distributor_id = TYPE_ID_DISTRIBUTOR_YUM
config = distributor_mocks.get_basic_config(https_publish_dir=self.https_publish_dir, relative_url=relative_url,
http=False, https=True)
distributor = YumDistributor()
distributor.process_repo_auth_certificate_bundle = mock.Mock()
config_conduit = mock.Mock(spec=RepoConfigConduit)
config_conduit.get_repo_distributors_by_relative_url.return_value = MockCursor([])
metadata.generate_yum_metadata(repo.id, repo.working_dir, publish_conduit, config,
repo_scratchpad={'checksum_type': 'sha'})
mock_YumMetadataGenerator.assert_called_with(ANY, checksum_type='sha1',
skip_metadata_types=ANY, is_cancelled=ANY,
group_xml_path=ANY,
updateinfo_xml_path=ANY,
custom_metadata_dict=ANY)
mock_distributor_manager.return_value.update_distributor_config.\
assert_called_with(ANY, ANY, {'checksum_type': 'sha1'})
示例5: test_validate_config
# 需要導入模塊: from yum_distributor.distributor import YumDistributor [as 別名]
# 或者: from yum_distributor.distributor.YumDistributor import process_repo_auth_certificate_bundle [as 別名]
def test_validate_config(self):
repo = mock.Mock(spec=Repository)
repo.id = "testrepo"
distributor = YumDistributor()
distributor.process_repo_auth_certificate_bundle = mock.Mock()
# Confirm that required keys are successful
req_kwargs = {}
req_kwargs['http'] = True
req_kwargs['https'] = False
req_kwargs['relative_url'] = "sample_value"
config = distributor_mocks.get_basic_config(**req_kwargs)
state, msg = distributor.validate_config(repo, config, [])
self.assertTrue(state)
# Confirm required and optional are successful
optional_kwargs = dict(req_kwargs)
optional_kwargs['auth_ca'] = open(os.path.join(self.data_dir, "valid_ca.crt")).read()
optional_kwargs['https_ca'] = open(os.path.join(self.data_dir, "valid_ca.crt")).read()
optional_kwargs['protected'] = True
optional_kwargs['generate_metadata'] = True
optional_kwargs['checksum_type'] = "sha"
optional_kwargs['skip'] = []
optional_kwargs['auth_cert'] = open(os.path.join(self.data_dir, "cert.crt")).read()
config = distributor_mocks.get_basic_config(**optional_kwargs)
state, msg = distributor.validate_config(repo, config, [])
self.assertTrue(state)
# Test that config fails when a bad value for non_existing_dir is used
optional_kwargs["http_publish_dir"] = "non_existing_dir"
config = distributor_mocks.get_basic_config(**optional_kwargs)
state, msg = distributor.validate_config(repo, config, [])
self.assertFalse(state)
# Test config succeeds with a good value of https_publish_dir
optional_kwargs["http_publish_dir"] = self.temp_dir
config = distributor_mocks.get_basic_config(**optional_kwargs)
state, msg = distributor.validate_config(repo, config, [])
self.assertTrue(state)
del optional_kwargs["http_publish_dir"]
# Test that config fails when a bad value for non_existing_dir is used
optional_kwargs["https_publish_dir"] = "non_existing_dir"
config = distributor_mocks.get_basic_config(**optional_kwargs)
state, msg = distributor.validate_config(repo, config, [])
self.assertFalse(state)
# Test config succeeds with a good value of https_publish_dir
optional_kwargs["https_publish_dir"] = self.temp_dir
config = distributor_mocks.get_basic_config(**optional_kwargs)
state, msg = distributor.validate_config(repo, config, [])
self.assertTrue(state)
del optional_kwargs["https_publish_dir"]
# Confirm an extra key fails
optional_kwargs["extra_arg_not_used"] = "sample_value"
config = distributor_mocks.get_basic_config(**optional_kwargs)
state, msg = distributor.validate_config(repo, config, [])
self.assertFalse(state)
self.assertTrue("extra_arg_not_used" in msg)
# Confirm missing a required fails
del optional_kwargs["extra_arg_not_used"]
config = distributor_mocks.get_basic_config(**optional_kwargs)
state, msg = distributor.validate_config(repo, config, [])
self.assertTrue(state)
del optional_kwargs["relative_url"]
config = distributor_mocks.get_basic_config(**optional_kwargs)
state, msg = distributor.validate_config(repo, config, [])
self.assertFalse(state)
self.assertTrue("relative_url" in msg)
示例6: test_basic_repo_publish_rel_path_conflict
# 需要導入模塊: from yum_distributor.distributor import YumDistributor [as 別名]
# 或者: from yum_distributor.distributor.YumDistributor import process_repo_auth_certificate_bundle [as 別名]
def test_basic_repo_publish_rel_path_conflict(self):
repo = mock.Mock(spec=Repository)
repo.working_dir = self.repo_working_dir
repo.id = "test_basic_repo_publish_rel_path_conflict"
num_units = 10
relative_url = "rel_a/rel_b/rel_a/"
config = distributor_mocks.get_basic_config(https_publish_dir=self.https_publish_dir,
relative_url=relative_url, http=False, https=True)
url_a = relative_url
config_a = PluginCallConfiguration({"relative_url":url_a}, {})
repo_a = RelatedRepository("repo_a_id", [config_a])
# Simple check of direct conflict of a duplicate
related_repos = [repo_a]
distributor = YumDistributor()
distributor.process_repo_auth_certificate_bundle = mock.Mock()
status, msg = distributor.validate_config(repo, config, related_repos)
self.assertFalse(status)
expected_msg = "Relative url '%s' conflicts with existing relative_url of '%s' from repo '%s'" % (relative_url, url_a, repo_a.id)
self.assertEqual(expected_msg, msg)
# Check conflict with a subdir
url_b = "rel_a/rel_b/"
config_b = PluginCallConfiguration({"relative_url":url_b}, {})
repo_b = RelatedRepository("repo_b_id", [config_b])
related_repos = [repo_b]
distributor = YumDistributor()
distributor.process_repo_auth_certificate_bundle = mock.Mock()
status, msg = distributor.validate_config(repo, config, related_repos)
self.assertFalse(status)
expected_msg = "Relative url '%s' conflicts with existing relative_url of '%s' from repo '%s'" % (relative_url, url_b, repo_b.id)
self.assertEqual(expected_msg, msg)
# Check no conflict with a pieces of a common subdir
url_c = "rel_a/rel_b/rel_c"
config_c = PluginCallConfiguration({"relative_url":url_c}, {})
repo_c = RelatedRepository("repo_c_id", [config_c])
url_d = "rel_a/rel_b/rel_d"
config_d = PluginCallConfiguration({"relative_url":url_d}, {})
repo_d = RelatedRepository("repo_d_id", [config_d])
url_e = "rel_a/rel_b/rel_e/rel_e"
config_e = PluginCallConfiguration({"relative_url":url_e}, {})
repo_e = RelatedRepository("repo_e_id", [config_e])
# Add a repo with no relative_url
config_f = PluginCallConfiguration({"relative_url":None}, {})
repo_f = RelatedRepository("repo_f_id", [config_f])
related_repos = [repo_c, repo_d, repo_e, repo_f]
distributor = YumDistributor()
distributor.process_repo_auth_certificate_bundle = mock.Mock()
status, msg = distributor.validate_config(repo, config, related_repos)
self.assertTrue(status)
self.assertEqual(msg, None)
# Test with 2 repos and no relative_url
config_h = PluginCallConfiguration({}, {})
repo_h = RelatedRepository("repo_h_id", [config_h])
config_i = PluginCallConfiguration({}, {})
repo_i = RelatedRepository("repo_i_id", [config_i])
status, msg = distributor.validate_config(repo_i, config, [repo_h])
self.assertTrue(status)
self.assertEqual(msg, None)
# TODO: Test, repo_1 has no rel url, so repo_1_id is used
# Then 2nd repo is configured with rel_url of repo_1_id
# should result in a conflict
# Ensure this test can handle a large number of repos
test_repos = []
for index in range(0,10000):
test_url = "rel_a/rel_b/rel_e/repo_%s" % (index)
test_config = PluginCallConfiguration({"relative_url":test_url}, {})
r = RelatedRepository("repo_%s_id" % (index), [test_config])
test_repos.append(r)
related_repos = test_repos
distributor = YumDistributor()
distributor.process_repo_auth_certificate_bundle = mock.Mock()
status, msg = distributor.validate_config(repo, config, related_repos)
self.assertTrue(status)
self.assertEqual(msg, None)