def test_get_repositories_strip_ssl_cert(self): # Setup repos = [{ 'id': 'matching', 'notes': { pulp_constants.REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_PKG, }, 'importers': [{ 'config': { 'ssl_client_cert': 'foo' } }], 'distributors': [] }, { 'id': 'non-rpm-repo', 'notes': {} }] self.server_mock.request.return_value = 200, repos # Test command = repo_list.RepoListCommand(self.context) repos = command.get_repositories({}) # Verify imp_config = repos[0]['importers'][0]['config'] self.assertTrue('ssl_client_cert' not in imp_config) self.assertTrue('feed_ssl_configured' in imp_config) self.assertEqual(imp_config['feed_ssl_configured'], 'True')
def initialize(context): structure.ensure_repo_structure(context.cli) upload_manager = _upload_manager(context) repo_section = structure.repo_section(context.cli) repo_section.add_command(repo_create_update.PkgRepoCreateCommand(context)) repo_section.add_command(repo_create_update.PkgRepoUpdateCommand(context)) repo_section.add_command(cudl.DeleteRepositoryCommand(context)) repo_section.add_command(repo_list.RepoListCommand(context)) repo_section.add_command( RepoSearchCommand(context, constants.REPO_NOTE_PKG)) copy_section = structure.repo_copy_section(context.cli) copy_section.add_command(copy_commands.MsiCopyCommand(context)) copy_section.add_command(copy_commands.MsmCopyCommand(context)) copy_section.add_command(copy_commands.AllCopyCommand(context)) remove_section = structure.repo_remove_section(context.cli) remove_section.add_command(remove.MsiRemoveCommand(context)) remove_section.add_command(remove.MsmRemoveCommand(context)) contents_section = structure.repo_contents_section(context.cli) contents_section.add_command(contents.SearchMsiCommand(context)) contents_section.add_command(contents.SearchMsmCommand(context)) uploads_section = structure.repo_uploads_section(context.cli) for cls_ in [ package.CreateMsiCommand, package.CreateMsmCommand, upload.ResumeCommand, upload.CancelCommand, upload.ListCommand ]: uploads_section.add_command(cls_(context, upload_manager)) sync_section = structure.repo_sync_section(context.cli) renderer = status.PackageStatusRenderer(context) sync_section.add_command( sync_publish.RunSyncRepositoryCommand(context, renderer)) sync_section.add_command(sync_publish.SyncStatusCommand(context, renderer)) publish_section = structure.repo_publish_section(context.cli) renderer = PublishStepStatusRenderer(context) distributor_id = ids.TYPE_ID_DISTRIBUTOR_WIN publish_section.add_command( sync_publish.RunPublishRepositoryCommand(context, renderer, distributor_id)) publish_section.add_command( sync_publish.PublishStatusCommand(context, renderer)) sync_schedules_section = structure.repo_sync_schedules_section(context.cli) sync_schedules_section.add_command( sync_schedules.PkgCreateScheduleCommand(context)) sync_schedules_section.add_command( sync_schedules.PkgUpdateScheduleCommand(context)) sync_schedules_section.add_command( sync_schedules.PkgDeleteScheduleCommand(context)) sync_schedules_section.add_command( sync_schedules.PkgListScheduleCommand(context)) sync_schedules_section.add_command( sync_schedules.PkgNextRunCommand(context))
def test_get_repositories(self): # Setup repos = [{ 'id': 'matching', 'notes': { pulp_constants.REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_PKG, }, 'importers': [{ 'config': {}, 'id': ids.TYPE_ID_IMPORTER_WIN }], 'distributors': [{ 'id': ids.TYPE_ID_DISTRIBUTOR_WIN }], }, { 'id': 'no-importers', 'notes': { pulp_constants.REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_PKG, }, 'importers': [], 'distributors': [{ 'id': ids.TYPE_ID_DISTRIBUTOR_WIN }], }, { 'id': 'non-rpm-repo', 'notes': {} }] self.server_mock.request.return_value = 200, repos distributor_list = [ids.TYPE_ID_DISTRIBUTOR_WIN] # Test command = repo_list.RepoListCommand(self.context) repos = command.get_repositories({}) # Verify self.assertEqual(2, len(repos)) self.assertEqual(repos[0]['id'], 'matching') self.assertEqual(repos[1]['id'], 'no-importers') # Check that the distributors and importer are present self.assertEqual(len(repos[0]['distributors']), 1) for distributor in repos[0]['distributors']: self.assertTrue(distributor['id'] in distributor_list) distributor_list.remove(distributor['id']) self.assertEqual(len(repos[0]['importers']), 1) self.assertEqual(repos[0]['importers'][0]['id'], ids.TYPE_ID_IMPORTER_WIN) # Check the importer is not present self.assertEqual(len(repos[1]['importers']), 0) self.assertRaises(IndexError, lambda: repos[1]['importers'][0])
def test_get_repositories_no_details(self): # Setup repos = [{ 'id': 'foo', 'display_name': 'bar', 'notes': { pulp_constants.REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_PKG, } }] self.server_mock.request.return_value = 200, repos # Test command = repo_list.RepoListCommand(self.context) repos = command.get_repositories({}) # Verify self.assertEqual(1, len(repos)) self.assertEqual(repos[0]['id'], 'foo') self.assertTrue('importers' not in repos[0]) self.assertTrue('distributors' not in repos[0])
def test_get_other_repositories(self): # Setup repos = [{ 'repo_id': 'matching', 'notes': { pulp_constants.REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_PKG }, 'distributors': [{ 'id': ids.TYPE_ID_DISTRIBUTOR_WIN }] }, { 'repo_id': 'non-rpm-repo-1', 'notes': {} }] self.server_mock.request.return_value = 200, repos # Test command = repo_list.RepoListCommand(self.context) repos = command.get_other_repositories({}) # Verify self.assertEqual(1, len(repos)) self.assertEqual(repos[0]['repo_id'], 'non-rpm-repo-1')