diff --git a/.rubocop.yml b/.rubocop.yml index b20228a965b..1c928f5054f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -31,7 +31,7 @@ AllCops: - '**/*.rb' - app/views/**/*.rabl - '**/*.rake' - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.7 Metrics/MethodLength: Description: 'Avoid methods longer than 30 lines of code.' diff --git a/app/lib/actions/katello/content_view/publish.rb b/app/lib/actions/katello/content_view/publish.rb index d41914c66f8..d0257a6690e 100644 --- a/app/lib/actions/katello/content_view/publish.rb +++ b/app/lib/actions/katello/content_view/publish.rb @@ -13,7 +13,7 @@ class Publish < Actions::EntryAction def plan(content_view, description = "", options = {importing: false, syncable: false}) # rubocop:disable Metrics/PerceivedComplexity action_subject(content_view) - content_view.check_ready_to_publish!(options.slice(:importing, :syncable)) + content_view.check_ready_to_publish!(**options.slice(:importing, :syncable)) unless options[:importing] || options[:syncable] ::Katello::Util::CandlepinRepositoryChecker.check_repositories_for_publish!(content_view) end @@ -57,7 +57,7 @@ def plan(content_view, description = "", options = {importing: false, syncable: separated_repo_map = separated_repo_mapping(repository_mapping, content_view.solve_dependencies) if options[:importing] - handle_import(version, options.slice(:path, :metadata)) + handle_import(version, **options.slice(:path, :metadata)) elsif separated_repo_map[:pulp3_yum_multicopy].keys.flatten.present? plan_action(Repository::MultiCloneToVersion, separated_repo_map[:pulp3_yum_multicopy], version) end @@ -203,7 +203,7 @@ def find_environments(environment_ids) def handle_import(version, path:, metadata:) sequence do - plan_action(::Actions::Pulp3::Orchestration::ContentViewVersion::Import, version, path: path, metadata: metadata) + plan_action(::Actions::Pulp3::Orchestration::ContentViewVersion::Import, version, { path: path, metadata: metadata }) concurrence do version.importable_repositories.pluck(:id).each do |id| # need to force full_indexing for these version repositories diff --git a/app/lib/actions/katello/content_view_version/auto_create_products.rb b/app/lib/actions/katello/content_view_version/auto_create_products.rb index 98e21c7b7ed..21edfd13dd2 100644 --- a/app/lib/actions/katello/content_view_version/auto_create_products.rb +++ b/app/lib/actions/katello/content_view_version/auto_create_products.rb @@ -2,14 +2,14 @@ module Actions module Katello module ContentViewVersion class AutoCreateProducts < Actions::Base - def plan(import:) + def plan(opts = {}) helper = ::Katello::Pulp3::ContentViewVersion::ImportableProducts. - new(organization: import.organization, - metadata_products: import.metadata_map.products) + new(organization: opts[:import].organization, + metadata_products: opts[:import].metadata_map.products) helper.generate! concurrence do helper.creatable.each do |product| - plan_action(::Actions::Katello::Product::Create, product[:product], import.organization) + plan_action(::Actions::Katello::Product::Create, product[:product], opts[:import].organization) end helper.updatable.each do |product| plan_action(::Actions::Katello::Product::Update, product[:product], product[:options]) diff --git a/app/lib/actions/katello/content_view_version/auto_create_redhat_repositories.rb b/app/lib/actions/katello/content_view_version/auto_create_redhat_repositories.rb index 105a1d86917..e36b41eaf2e 100644 --- a/app/lib/actions/katello/content_view_version/auto_create_redhat_repositories.rb +++ b/app/lib/actions/katello/content_view_version/auto_create_redhat_repositories.rb @@ -2,12 +2,12 @@ module Actions module Katello module ContentViewVersion class AutoCreateRedhatRepositories < Actions::Base - def plan(import:, path:) + def plan(opts = {}) helper = ::Katello::Pulp3::ContentViewVersion::ImportableRepositories.new( - organization: import.organization, - metadata_repositories: import.metadata_map.repositories.select { |r| r.redhat }, - syncable_format: import.metadata_map.syncable_format?, - path: path + organization: opts[:import].organization, + metadata_repositories: opts[:import].metadata_map.repositories.select { |r| r.redhat }, + syncable_format: opts[:import].metadata_map.syncable_format?, + path: opts[:path] ) helper.generate! diff --git a/app/lib/actions/katello/content_view_version/auto_create_repositories.rb b/app/lib/actions/katello/content_view_version/auto_create_repositories.rb index 2a0727bda3d..e90e3cfa562 100644 --- a/app/lib/actions/katello/content_view_version/auto_create_repositories.rb +++ b/app/lib/actions/katello/content_view_version/auto_create_repositories.rb @@ -2,12 +2,12 @@ module Actions module Katello module ContentViewVersion class AutoCreateRepositories < Actions::Base - def plan(import:, path:) + def plan(opts = {}) helper = ::Katello::Pulp3::ContentViewVersion::ImportableRepositories.new( - organization: import.organization, - metadata_repositories: import.metadata_map.repositories.select { |r| !r.redhat }, - syncable_format: import.metadata_map.syncable_format?, - path: path + organization: opts[:import].organization, + metadata_repositories: opts[:import].metadata_map.repositories.select { |r| !r.redhat }, + syncable_format: opts[:import].metadata_map.syncable_format?, + path: opts[:path] ) helper.generate! diff --git a/app/lib/actions/katello/content_view_version/import.rb b/app/lib/actions/katello/content_view_version/import.rb index efe0b889ed5..a7c2cc4e719 100644 --- a/app/lib/actions/katello/content_view_version/import.rb +++ b/app/lib/actions/katello/content_view_version/import.rb @@ -2,45 +2,46 @@ module Actions module Katello module ContentViewVersion class Import < Actions::EntryAction - def plan(organization:, path:, metadata:) - metadata_map = ::Katello::Pulp3::ContentViewVersion::MetadataMap.new(metadata: metadata) + def plan(opts = {}) + metadata_map = ::Katello::Pulp3::ContentViewVersion::MetadataMap.new(metadata: opts[:metadata]) import = ::Katello::Pulp3::ContentViewVersion::Import.new( - organization: organization, + organization: opts[:organization], metadata_map: metadata_map, - path: path, + path: opts[:path], smart_proxy: SmartProxy.pulp_primary! ) import.check! gpg_helper = ::Katello::Pulp3::ContentViewVersion::ImportGpgKeys. - new(organization: organization, + new(organization: opts[:organization], metadata_gpg_keys: metadata_map.gpg_keys) gpg_helper.import! sequence do - plan_action(AutoCreateProducts, import: import) - plan_action(AutoCreateRepositories, import: import, path: path) - plan_action(AutoCreateRedhatRepositories, import: import, path: path) + plan_action(AutoCreateProducts, { import: import }) + plan_action(AutoCreateRepositories, { import: import, path: opts[:path] }) + plan_action(AutoCreateRedhatRepositories, { import: import, path: opts[:path] }) if metadata_map.syncable_format? plan_action(::Actions::BulkAction, ::Actions::Katello::Repository::Sync, import.intersecting_repos_library_and_metadata.exportable(format: metadata_map.format), - skip_candlepin_check: true + { skip_candlepin_check: true } ) end if import.content_view - plan_action(ResetContentViewRepositoriesFromMetadata, import: import) + plan_action(ResetContentViewRepositoriesFromMetadata, { import: import }) plan_action(::Actions::Katello::ContentView::Publish, import.content_view, metadata_map.content_view_version.description, - path: path, - metadata: metadata, + { path: opts[:path], + metadata: opts[:metadata], importing: !metadata_map.syncable_format?, syncable: metadata_map.syncable_format?, major: metadata_map.content_view_version.major, - minor: metadata_map.content_view_version.minor) + minor: metadata_map.content_view_version.minor + }) plan_self(content_view_id: import.content_view.id) end end diff --git a/app/lib/actions/katello/content_view_version/import_library.rb b/app/lib/actions/katello/content_view_version/import_library.rb index 6cd8acdfc4c..9d98185479b 100644 --- a/app/lib/actions/katello/content_view_version/import_library.rb +++ b/app/lib/actions/katello/content_view_version/import_library.rb @@ -2,11 +2,11 @@ module Actions module Katello module ContentViewVersion class ImportLibrary < Actions::EntryAction - def plan(organization, path:, metadata:) + def plan(organization, opts = {}) action_subject(organization) - plan_action(::Actions::Katello::ContentViewVersion::Import, organization: organization, - path: path, - metadata: metadata) + plan_action(::Actions::Katello::ContentViewVersion::Import, { organization: organization, + path: opts[:path], + metadata: opts[:metadata] }) end def humanized_name diff --git a/app/lib/actions/katello/content_view_version/import_repository.rb b/app/lib/actions/katello/content_view_version/import_repository.rb index bc38d5d3901..f99e910cf7b 100644 --- a/app/lib/actions/katello/content_view_version/import_repository.rb +++ b/app/lib/actions/katello/content_view_version/import_repository.rb @@ -2,13 +2,13 @@ module Actions module Katello module ContentViewVersion class ImportRepository < Actions::EntryAction - def plan(organization, path:, metadata:) + def plan(organization, opts = {}) action_subject(organization) sequence do plan_action(::Actions::Katello::ContentViewVersion::Import, organization: organization, - path: path, - metadata: metadata) + path: opts[:path], + metadata: opts[:metadata]) end end diff --git a/app/lib/actions/katello/content_view_version/reset_content_view_repositories_from_metadata.rb b/app/lib/actions/katello/content_view_version/reset_content_view_repositories_from_metadata.rb index 6ca7f4ea578..8c743e97b0c 100644 --- a/app/lib/actions/katello/content_view_version/reset_content_view_repositories_from_metadata.rb +++ b/app/lib/actions/katello/content_view_version/reset_content_view_repositories_from_metadata.rb @@ -2,8 +2,8 @@ module Actions module Katello module ContentViewVersion class ResetContentViewRepositoriesFromMetadata < Actions::Base - def plan(import:) - import.reset_content_view_repositories! + def plan(opts = {}) + opts[:import].reset_content_view_repositories! end end end diff --git a/app/lib/actions/katello/organization/manifest_delete.rb b/app/lib/actions/katello/organization/manifest_delete.rb index fc3787ac9b8..b5f7630921b 100644 --- a/app/lib/actions/katello/organization/manifest_delete.rb +++ b/app/lib/actions/katello/organization/manifest_delete.rb @@ -10,7 +10,7 @@ def plan(organization) action_subject(organization) sequence do - plan_action(Candlepin::Owner::DestroyImports, label: organization.label) + plan_action(Candlepin::Owner::DestroyImports, { label: organization.label }) repositories = ::Katello::Repository.in_default_view.in_product(::Katello::Product.redhat.in_org(organization)) repositories.each do |repo| diff --git a/app/lib/actions/katello/organization/manifest_refresh.rb b/app/lib/actions/katello/organization/manifest_refresh.rb index 52c74940db9..0afe1a1c21a 100644 --- a/app/lib/actions/katello/organization/manifest_refresh.rb +++ b/app/lib/actions/katello/organization/manifest_refresh.rb @@ -19,26 +19,26 @@ def plan(organization) :organization_name => organization.name ) upstream_update = plan_action(Candlepin::Owner::UpstreamUpdate, - :organization_id => organization.id, - :upstream => upstream) + { :organization_id => organization.id, + :upstream => upstream }) export_action = plan_action(Candlepin::Owner::StartUpstreamExport, - :organization_id => organization.id, - :upstream => upstream, - :path => path, - :dependency => upstream_update.output) + { :organization_id => organization.id, + :upstream => upstream, + :path => path, + :dependency => upstream_update.output }) retrieved_export = plan_action(Candlepin::Owner::RetrieveUpstreamExport, - :export_id => export_action.output[:task]['resultData']['exportId'], - :organization_id => organization.id, - :upstream => upstream, - :path => path, - :dependency => export_action.output) + { :export_id => export_action.output[:task]['resultData']['exportId'], + :organization_id => organization.id, + :upstream => upstream, + :path => path, + :dependency => export_action.output }) owner_import = plan_action(Candlepin::Owner::Import, - :label => organization.label, - :path => path, - :dependency => retrieved_export.output) + { :label => organization.label, + :path => path, + :dependency => retrieved_export.output }) import_products = plan_action(Candlepin::Owner::ImportProducts, - :organization_id => organization.id, - :dependency => owner_import.output) + { :organization_id => organization.id, + :dependency => owner_import.output }) plan_action(Katello::Organization::EnvironmentContentsRefresh, organization) if manifest_update diff --git a/app/lib/actions/pulp3/orchestration/content_view_version/export.rb b/app/lib/actions/pulp3/orchestration/content_view_version/export.rb index 43547d7fde9..2d45c35744b 100644 --- a/app/lib/actions/pulp3/orchestration/content_view_version/export.rb +++ b/app/lib/actions/pulp3/orchestration/content_view_version/export.rb @@ -18,30 +18,35 @@ class Export < Actions::EntryAction param :export_path, String end - def plan(content_view_version:, destination_server: nil, - chunk_size: nil, from_history: nil, - validate_incremental: true, - fail_on_missing_content: false, - format: ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE) + def plan(opts = {}) + options = { + content_view_version: nil, destination_server: nil, + chunk_size: nil, from_history: nil, + validate_incremental: true, + fail_on_missing_content: false, + format: ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE + }.merge(opts) + content_view_version = options[:content_view_version] + format = options[:format] smart_proxy = SmartProxy.pulp_primary! - from_content_view_version = from_history&.content_view_version + from_content_view_version = options[:from_history]&.content_view_version export_service = ::Katello::Pulp3::ContentViewVersion::Export.create( smart_proxy: smart_proxy, content_view_version: content_view_version, - destination_server: destination_server, + destination_server: options[:destination_server], from_content_view_version: from_content_view_version, format: format) - export_service.validate!(fail_on_missing_content: fail_on_missing_content, - validate_incremental: validate_incremental, - chunk_size: chunk_size) + export_service.validate!(fail_on_missing_content: options[:fail_on_missing_content], + validate_incremental: options[:validate_incremental], + chunk_size: options[:chunk_size]) if format == ::Katello::Pulp3::ContentViewVersion::Export::SYNCABLE sequence do export_output = plan_action(SyncableExport, content_view_version: content_view_version, - from_content_view_version: from_history&.content_view_version, + from_content_view_version: options[:from_history]&.content_view_version, smart_proxy: smart_proxy, - destination_server: destination_server).output + destination_server: options[:destination_server]).output plan_self(export_history_id: export_output[:export_history_id], export_path: export_output[:export_path]) end @@ -52,14 +57,14 @@ def plan(content_view_version:, destination_server: nil, action_output = plan_action(::Actions::Pulp3::ContentViewVersion::CreateExporter, content_view_version_id: content_view_version.id, smart_proxy_id: smart_proxy.id, - destination_server: destination_server, + destination_server: options[:destination_server], format: format).output plan_action(::Actions::Pulp3::ContentViewVersion::Export, content_view_version_id: content_view_version.id, smart_proxy_id: smart_proxy.id, exporter_data: action_output[:exporter_data], - chunk_size: chunk_size, + chunk_size: options[:chunk_size], from_content_view_version_id: from_content_view_version&.id, format: format) @@ -70,7 +75,7 @@ def plan(content_view_version:, destination_server: nil, pulp_href: action_output[:exporter_data][:pulp_href], content_view_version_id: content_view_version.id, from_content_view_version_id: from_content_view_version&.id, - destination_server: destination_server, + destination_server: options[:destination_server], format: format ).output diff --git a/app/lib/actions/pulp3/orchestration/content_view_version/export_library.rb b/app/lib/actions/pulp3/orchestration/content_view_version/export_library.rb index 352e4ecd86a..b04675c67a0 100644 --- a/app/lib/actions/pulp3/orchestration/content_view_version/export_library.rb +++ b/app/lib/actions/pulp3/orchestration/content_view_version/export_library.rb @@ -3,30 +3,33 @@ module Pulp3 module Orchestration module ContentViewVersion class ExportLibrary < Actions::EntryAction - def plan(organization, destination_server: nil, - chunk_size: nil, - from_history: nil, - fail_on_missing_content: false, - format: ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE) + def plan(organization, opts = {}) + options = { + destination_server: nil, + chunk_size: nil, + from_history: nil, + fail_on_missing_content: false, + format: ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE + }.merge(opts) action_subject(organization) - validate_repositories_immediate!(organization) if fail_on_missing_content - content_view = ::Katello::Pulp3::ContentViewVersion::Export.find_library_export_view(destination_server: destination_server, + validate_repositories_immediate!(organization) if options[:fail_on_missing_content] + content_view = ::Katello::Pulp3::ContentViewVersion::Export.find_library_export_view(destination_server: options[:destination_server], organization: organization, create_by_default: true, - format: format) - repo_ids_in_library = organization.default_content_view_version.repositories.exportable(format: format).immediate_or_none.pluck(:id) + format: options[:format]) + repo_ids_in_library = organization.default_content_view_version.repositories.exportable(format: options[:format]).immediate_or_none.pluck(:id) content_view.update!(repository_ids: repo_ids_in_library) sequence do publish_action = plan_action(::Actions::Katello::ContentView::Publish, content_view, '') export_action = plan_action(Actions::Katello::ContentViewVersion::Export, content_view_version: publish_action.version, - destination_server: destination_server, - chunk_size: chunk_size, - from_history: from_history, + destination_server: options[:destination_server], + chunk_size: options[:chunk_size], + from_history: options[:from_history], validate_incremental: false, - fail_on_missing_content: fail_on_missing_content, - format: format) + fail_on_missing_content: options[:fail_on_missing_content], + format: options[:format]) plan_self(export_action_output: export_action.output) end end diff --git a/app/lib/actions/pulp3/orchestration/content_view_version/import.rb b/app/lib/actions/pulp3/orchestration/content_view_version/import.rb index cc3759c92ce..6af38f113fb 100644 --- a/app/lib/actions/pulp3/orchestration/content_view_version/import.rb +++ b/app/lib/actions/pulp3/orchestration/content_view_version/import.rb @@ -3,7 +3,7 @@ module Pulp3 module Orchestration module ContentViewVersion class Import < Actions::EntryAction - def plan(content_view_version, path:, metadata:) + def plan(content_view_version, opts = {}) action_subject(content_view_version) sequence do smart_proxy = SmartProxy.pulp_primary! @@ -11,8 +11,8 @@ def plan(content_view_version, path:, metadata:) ::Actions::Pulp3::ContentViewVersion::CreateImporter, content_view_version_id: content_view_version.id, smart_proxy_id: smart_proxy.id, - path: path, - metadata: metadata + path: opts[:path], + metadata: opts[:metadata] ).output plan_action( @@ -20,8 +20,8 @@ def plan(content_view_version, path:, metadata:) organization_id: content_view_version.content_view.organization_id, smart_proxy_id: smart_proxy.id, importer_data: importer_output[:importer_data], - path: path, - metadata: metadata + path: opts[:path], + metadata: opts[:metadata] ) concurrence do content_view_version.importable_repositories.each do |repo| @@ -31,20 +31,20 @@ def plan(content_view_version, path:, metadata:) plan_action( ::Actions::Pulp3::ContentViewVersion::CreateImportHistory, content_view_version_id: content_view_version.id, - path: path, - metadata: metadata, + path: opts[:path], + metadata: opts[:metadata], content_view_name: content_view_version.name ) plan_action(::Actions::Pulp3::ContentViewVersion::DestroyImporter, organization_id: content_view_version.content_view.organization_id, smart_proxy_id: smart_proxy.id, - path: path, - metadata: metadata, + path: opts[:path], + metadata: opts[:metadata], importer_data: importer_output[:importer_data]) plan_self( content_view_name: content_view_version.name, - metadata: metadata, - path: path, + metadata: opts[:metadata], + path: opts[:path], content_view_version_id: content_view_version.id ) end diff --git a/app/lib/katello/lazy_accessor.rb b/app/lib/katello/lazy_accessor.rb index ed6821cd35b..7dd454aba32 100644 --- a/app/lib/katello/lazy_accessor.rb +++ b/app/lib/katello/lazy_accessor.rb @@ -56,21 +56,21 @@ def changed_remote_attributes=(val) @changed_remote_attributes = val end - def save(*) - if (status = super) + def save(...) + if (status = super(...)) changed_remote_attributes.clear end status end - def save!(*) - super.tap do + def save!(...) + super(...).tap do changed_remote_attributes.clear end end - def reload(*) - super.tap do + def reload(...) + super(...).tap do changed_remote_attributes.clear end end diff --git a/app/services/katello/pulp3/content_view_version/export.rb b/app/services/katello/pulp3/content_view_version/export.rb index aca1565f409..7fff6c1406c 100644 --- a/app/services/katello/pulp3/content_view_version/export.rb +++ b/app/services/katello/pulp3/content_view_version/export.rb @@ -10,9 +10,9 @@ class Export attr_reader :smart_proxy, :content_view_version, :destination_server, :from_content_view_version, :repository, :base_path def self.create(options) if options.delete(:format) == SYNCABLE - SyncableFormatExport.new(options) + SyncableFormatExport.new(**options) else - self.new(options) + self.new(**options) end end diff --git a/katello.gemspec b/katello.gemspec index 5b23fc1f33f..27034686a0f 100644 --- a/katello.gemspec +++ b/katello.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |gem| gem.homepage = "http://www.katello.org" gem.summary = "Content and Subscription Management plugin for Foreman" gem.description = "Katello adds Content and Subscription Management to Foreman. For this it relies on Candlepin and Pulp." - gem.required_ruby_version = '~> 2.5' + gem.required_ruby_version = '>= 2.7', '< 4' gem.files = Dir["{app,webpack,vendor,lib,db,ca,config,locale}/**/*"] + Dir['LICENSE.txt', 'README.md', 'package.json'] @@ -49,7 +49,9 @@ Gem::Specification.new do |gem| # Pulp gem.add_dependency "anemone" - + # required by anemone: https://github.com/chriskite/anemone/blob/next/lib/anemone/page.rb#L3 + # webrick is no longer a part of Ruby's stdlib: https://bugs.ruby-lang.org/issues/17303 + gem.add_dependency "webrick" #pulp3 gem.add_dependency "pulpcore_client", ">= 3.39.0", "< 3.40.0" gem.add_dependency "pulp_file_client", ">= 1.15.0", "< 1.16.0" diff --git a/test/actions/katello/content_view_version/import_library_test.rb b/test/actions/katello/content_view_version/import_library_test.rb index 713cef595f9..cffa4559293 100644 --- a/test/actions/katello/content_view_version/import_library_test.rb +++ b/test/actions/katello/content_view_version/import_library_test.rb @@ -98,7 +98,7 @@ def setup_proxy assert_nil ::Katello::ContentView.where(organization: organization, name: ::Katello::ContentView::IMPORT_LIBRARY).first action_class.any_instance.expects(:action_subject).with(organization) - plan_action(action, organization, path: path, metadata: import_metadata) + plan_action(action, organization, { path: path, metadata: import_metadata }) assert_action_planned_with(action, ::Actions::Katello::ContentViewVersion::Import) do |options| options = options.first if options.is_a? Array assert_equal options[:organization], organization @@ -111,7 +111,7 @@ def setup_proxy ::Katello::ContentViewManager.expects(:create_candlepin_environment).returns ::Katello::Pulp3::ContentViewVersion::Import.any_instance.expects(:check!).returns - tree = plan_action_tree(action_class, organization, path: path, metadata: import_metadata) + tree = plan_action_tree(action_class, organization, { path: path, metadata: import_metadata }) assert_empty tree.errors assert_tree_planned_with(tree, Actions::Pulp3::Repository::CopyContent) do |input| diff --git a/test/actions/katello/content_view_version/import_repository_test.rb b/test/actions/katello/content_view_version/import_repository_test.rb index 7f34e53ccd9..411001dabb0 100644 --- a/test/actions/katello/content_view_version/import_repository_test.rb +++ b/test/actions/katello/content_view_version/import_repository_test.rb @@ -83,7 +83,7 @@ def setup_proxy describe 'Import Repository' do it 'should plan properly' do action_class.any_instance.expects(:action_subject).with(organization) - plan_action(action, organization, path: path, metadata: import_metadata) + plan_action(action, organization, { path: path, metadata: import_metadata }) assert_action_planned_with(action, ::Actions::Katello::ContentViewVersion::Import) do |options| options = options.first if options.is_a? Array assert_equal options[:organization], organization @@ -96,7 +96,7 @@ def setup_proxy ::Katello::Pulp3::ContentViewVersion::Import.any_instance.expects(:check!).returns ::Katello::ContentViewManager.expects(:create_candlepin_environment).returns - tree = plan_action_tree(action_class, organization, path: path, metadata: import_metadata) + tree = plan_action_tree(action_class, organization, { path: path, metadata: import_metadata }) assert_empty tree.errors assert_tree_planned_with(tree, Actions::Pulp3::Repository::CopyContent) do |input| assert input[:copy_all] diff --git a/test/actions/katello/content_view_version/import_test.rb b/test/actions/katello/content_view_version/import_test.rb index e1fe857b353..c3e4192ac6f 100644 --- a/test/actions/katello/content_view_version/import_test.rb +++ b/test/actions/katello/content_view_version/import_test.rb @@ -166,7 +166,7 @@ class ImportTest < TestBase ::Katello::ContentViewManager.expects(:create_candlepin_environment).returns import_metadata[:content_view_version][:major] += 10 generated_cvv = nil - tree = plan_action_tree(action_class, organization: organization, path: path, metadata: import_metadata) + tree = plan_action_tree(action_class, { organization: organization, path: path, metadata: import_metadata }) assert_empty tree.errors assert_tree_planned_steps(tree, Actions::Katello::ContentView::AddToEnvironment) diff --git a/test/actions/pulp3/content_view_version/export_library_test.rb b/test/actions/pulp3/content_view_version/export_library_test.rb index b96f76589e2..0ac391fced1 100644 --- a/test/actions/pulp3/content_view_version/export_library_test.rb +++ b/test/actions/pulp3/content_view_version/export_library_test.rb @@ -39,7 +39,7 @@ class ExportLibraryTest < ActiveSupport::TestCase assert content_view.generated_for_library? end - assert_action_planned_with(action, Actions::Katello::ContentViewVersion::Export) do |**options| + assert_action_planned_with(action, Actions::Katello::ContentViewVersion::Export) do |options, _| assert_equal version, options[:content_view_version] assert_equal destination_server, options[:destination_server] end diff --git a/test/actions/pulp3/content_view_version/export_repository_test.rb b/test/actions/pulp3/content_view_version/export_repository_test.rb index f46ba5372f2..49c416eec8b 100644 --- a/test/actions/pulp3/content_view_version/export_repository_test.rb +++ b/test/actions/pulp3/content_view_version/export_repository_test.rb @@ -34,7 +34,7 @@ class ExportRepositoryTest < ActiveSupport::TestCase assert content_view.generated_for_repository? end - assert_action_planned_with(action, Actions::Katello::ContentViewVersion::Export) do |**options| + assert_action_planned_with(action, Actions::Katello::ContentViewVersion::Export) do |options, _| assert_equal version, options[:content_view_version] end end diff --git a/test/actions/pulp3/orchestration/export_test.rb b/test/actions/pulp3/orchestration/export_test.rb index 293a49c5cfa..3e5c6ba5d1d 100644 --- a/test/actions/pulp3/orchestration/export_test.rb +++ b/test/actions/pulp3/orchestration/export_test.rb @@ -61,9 +61,9 @@ def test_destroy_exporter def test_export Actions::Katello::ContentViewVersion::Export.any_instance.expects(:action_subject).with(@content_view_version) output = ForemanTasks.sync_task(Actions::Katello::ContentViewVersion::Export, - content_view_version: @content_view_version, - destination_server: "foo", - chunk_size: 0.1).output + { content_view_version: @content_view_version, + destination_server: "foo", + chunk_size: 0.1 }).output export_history = Katello::ContentViewVersionExportHistory.find_by(content_view_version_id: @content_view_version.id, destination_server: 'foo') assert export_history.metadata refute_empty output[:export_path] diff --git a/test/controllers/api/v2/api_controller_test.rb b/test/controllers/api/v2/api_controller_test.rb index ba60a39bb98..41ee6a3e5f6 100644 --- a/test/controllers/api/v2/api_controller_test.rb +++ b/test/controllers/api/v2/api_controller_test.rb @@ -73,8 +73,8 @@ def test_with_reduced_perms User.current = users(:restricted) key = katello_activation_keys(:simple_key) - setup_current_user_with_permissions(:name => "view_activation_keys", - :search => "environment = #{key.environment}") + setup_current_user_with_permissions({ :name => "view_activation_keys", + :search => "environment = #{key.environment}" }) @options = { :resource_class => Katello::ActivationKey } keys = @controller.scoped_search(ActivationKey.readable, @default_sort[0], @default_sort[1], @options) diff --git a/test/models/authorization/activation_key_authorization_test.rb b/test/models/authorization/activation_key_authorization_test.rb index 077fa362b54..03fd3f33f12 100644 --- a/test/models/authorization/activation_key_authorization_test.rb +++ b/test/models/authorization/activation_key_authorization_test.rb @@ -83,8 +83,8 @@ def test_all_editable? clause = keys.map { |key| "name=\"#{key.name}\"" }.join(" or ") - setup_current_user_with_permissions(:name => "edit_activation_keys", - :search => clause) + setup_current_user_with_permissions({ :name => "edit_activation_keys", + :search => clause }) assert ActivationKey.all_editable?(ak.content_view, ak.environment) end end diff --git a/test/models/authorization/lifecycle_environment_authorization_test.rb b/test/models/authorization/lifecycle_environment_authorization_test.rb index 53fe99434e9..7b345cbe7e8 100644 --- a/test/models/authorization/lifecycle_environment_authorization_test.rb +++ b/test/models/authorization/lifecycle_environment_authorization_test.rb @@ -75,8 +75,8 @@ def setup def test_readables environment = katello_environments(:staging_path1) - setup_current_user_with_permissions(:name => "view_lifecycle_environments", - :search => "name=\"#{environment.name}\"") + setup_current_user_with_permissions({ :name => "view_lifecycle_environments", + :search => "name=\"#{environment.name}\"" }) assert_equal([environment.id], KTEnvironment.readable.pluck(:id)) assert environment.readable? refute environment.prior.readable? @@ -84,8 +84,8 @@ def test_readables def test_promotables environment = katello_environments(:staging_path1) - setup_current_user_with_permissions(:name => "promote_or_remove_content_views_to_environments", - :search => "name=\"#{environment.name}\"") + setup_current_user_with_permissions({ :name => "promote_or_remove_content_views_to_environments", + :search => "name=\"#{environment.name}\"" }) assert_equal([environment.id], KTEnvironment.promotable.pluck(:id)) assert environment.promotable_or_removable? refute environment.prior.promotable_or_removable? diff --git a/test/models/authorization/organization_authorization_test.rb b/test/models/authorization/organization_authorization_test.rb index 1d1eb815f9d..386a075f19a 100644 --- a/test/models/authorization/organization_authorization_test.rb +++ b/test/models/authorization/organization_authorization_test.rb @@ -42,8 +42,8 @@ def test_read_promotion_paths def test_read_promotion_paths_one environment = katello_environments(:staging_path1) - setup_current_user_with_permissions(:name => "view_lifecycle_environments", - :search => "name=\"#{environment.name}\"") + setup_current_user_with_permissions({ :name => "view_lifecycle_environments", + :search => "name=\"#{environment.name}\"" }) refute_equal(@org.promotion_paths, @org.readable_promotion_paths) assert_equal(1, @org.readable_promotion_paths.size) @@ -51,8 +51,8 @@ def test_read_promotion_paths_one def test_promotable_promotion_paths_one environment = katello_environments(:staging_path1) - setup_current_user_with_permissions(:name => "promote_or_remove_content_views_to_environments", - :search => "name=\"#{environment.name}\"") + setup_current_user_with_permissions({ :name => "promote_or_remove_content_views_to_environments", + :search => "name=\"#{environment.name}\"" }) refute_equal(@org.promotion_paths, @org.promotable_promotion_paths) assert_equal(1, @org.promotable_promotion_paths.size) diff --git a/test/models/authorization/product_authorization_test.rb b/test/models/authorization/product_authorization_test.rb index 24419cc3156..c47c92c4129 100644 --- a/test/models/authorization/product_authorization_test.rb +++ b/test/models/authorization/product_authorization_test.rb @@ -101,8 +101,8 @@ def test_readable_repositories_with_ids def test_readable_repositories_with_search repo = @fedora_17_x86_64 - setup_current_user_with_permissions(:name => "view_products", - :search => "name=\"#{repo.product.name}\"") + setup_current_user_with_permissions({ :name => "view_products", + :search => "name=\"#{repo.product.name}\"" }) assert_equal([repo], Product.readable_repositories([repo.id])) assert_empty(Product.readable_repositories( diff --git a/test/models/authorization/repository_authorization_test.rb b/test/models/authorization/repository_authorization_test.rb index 4d0ab927af2..16411045eb8 100644 --- a/test/models/authorization/repository_authorization_test.rb +++ b/test/models/authorization/repository_authorization_test.rb @@ -100,25 +100,25 @@ def test_readable def test_readable_with_product refute_includes Repository.readable, @fedora_17_x86_64 - setup_current_user_with_permissions(:name => "view_products", :search => nil) + setup_current_user_with_permissions({ :name => "view_products", :search => nil }) assert_includes Repository.readable, @fedora_17_x86_64 end def test_readable_with_content_view refute_includes Repository.readable, @fedora_17_x86_64 - setup_current_user_with_permissions(:name => "view_content_views", :search => nil) + setup_current_user_with_permissions({ :name => "view_content_views", :search => nil }) assert_includes Repository.readable, @fedora_17_x86_64 end def test_readable_with_versions refute_includes Repository.readable, @fedora_17_x86_64_dev - setup_current_user_with_permissions(:name => "view_content_views", :search => "name = \"#{@fedora_17_x86_64_dev.content_view_version.content_view.name}\"") + setup_current_user_with_permissions({ :name => "view_content_views", :search => "name = \"#{@fedora_17_x86_64_dev.content_view_version.content_view.name}\"" }) assert_includes Repository.readable, @fedora_17_x86_64_dev end def test_readable_with_environment refute_includes Repository.readable, @fedora_17_x86_64 - setup_current_user_with_permissions(:name => "view_lifecycle_environments", :search => "name = \"#{@fedora_17_x86_64.environment.name}\"") + setup_current_user_with_permissions({ :name => "view_lifecycle_environments", :search => "name = \"#{@fedora_17_x86_64.environment.name}\"" }) repos = Repository.readable refute_empty repos assert repos.all? { |repo| repo.environment_id == @fedora_17_x86_64.environment_id } diff --git a/test/services/katello/registration_manager_test.rb b/test/services/katello/registration_manager_test.rb index ab71df39461..e1259afbeea 100644 --- a/test/services/katello/registration_manager_test.rb +++ b/test/services/katello/registration_manager_test.rb @@ -42,14 +42,14 @@ def setup def test_different_org org2 = taxonomies(:organization2) - error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(hosts, org2, nil, host_uuid_overridden: nil) } + error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(hosts, org2, nil, nil, host_uuid_overridden: nil) } assert_match(/different org/, error.message) end def test_multiple_hosts assert ::Host.all.size > 1 - error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(::Host.all, @org, nil, host_uuid_overridden: nil) } + error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(::Host.all, @org, nil, nil, host_uuid_overridden: nil) } assert_match(/matches other registered/, error.message) end @@ -57,7 +57,7 @@ def test_new_host_existing_uuid existing_uuid = 'existing_system_uuid' @host.subscription_facet.update(dmi_uuid: existing_uuid) - error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(hosts, @org, 'new_host_name', host_uuid_overridden: existing_uuid) } + error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(hosts, @org, 'new_host_name', existing_uuid, host_uuid_overridden: existing_uuid) } assert_match(/matches other registered/, error.message) end @@ -65,7 +65,7 @@ def test_existing_host_mismatch_uuid @host.subscription_facet.update(dmi_uuid: 'existing_system_uuid') Setting[:host_profile_assume] = false - error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(hosts, @org, @host.name, host_uuid_overridden: 'different-uuid') } + error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(hosts, @org, @host.name, 'different-uuid', host_uuid_overridden: false) } assert_match(/DMI UUID that differs/, error.message) # if a registering client is matched by hostname to an existing profile @@ -80,7 +80,7 @@ def test_host_profile_assume_build_mode_only_not_in_build Setting[:host_profile_assume] = false Setting[:host_profile_assume_build_can_change] = true refute @host.build - error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(hosts, @org, @host.name, host_uuid_overridden: 'different-uuid') } + error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(hosts, @org, @host.name, 'different-uuid', host_uuid_overridden: false) } assert_match(/DMI UUID that differs/, error.message) end @@ -92,7 +92,7 @@ def test_host_profile_assume_build_mode_only_in_build # if a registering client is matched by hostname to an existing profile # but its UUID has changed *and* is still unique, also it is in build mode # then allow the registration when enabled - assert @klass.validate_hosts(hosts, @org, @host.name, host_uuid_overridden: 'different-uuid') + assert @klass.validate_hosts(hosts, @org, @host.name, 'different-uuid', host_uuid_overridden: true) end def test_re_register_build_mode @@ -101,11 +101,11 @@ def test_re_register_build_mode refute @host.build Setting[:host_re_register_build_only] = true - error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(hosts, @org, @host.name, host_uuid_overridden: nil) } + error = assert_raises(Katello::Errors::RegistrationError) { @klass.validate_hosts(hosts, @org, @host.name, @host.uuid, host_uuid_overridden: nil) } assert_match(/currently registered/, error.message) @host.update(build: true) - assert @klass.validate_hosts(hosts, @org, @host.name, host_uuid_overridden: 'existing_system_uuid') + assert @klass.validate_hosts(hosts, @org, @host.name, 'existing_system_uuid', host_uuid_overridden: true) end def test_existing_uuid_and_name @@ -118,7 +118,7 @@ def test_build_matching_hostname_new_uuid @host = FactoryBot.create(:host, :with_subscription, :managed, organization: @org, build: true) @host.subscription_facet.update(dmi_uuid: SecureRandom.uuid) - assert @klass.validate_hosts(hosts, @org, @host.name, host_uuid_overridden: 'different-uuid') + assert @klass.validate_hosts(hosts, @org, @host.name, 'different-uuid', host_uuid_overridden: true) end def test_existing_host_null_uuid @@ -126,7 +126,7 @@ def test_existing_host_null_uuid # and *then* registers to it with subscription-manager assert_empty @host.fact_values - assert @klass.validate_hosts(hosts, @org, @host.name, host_uuid_overridden: 'different-uuid') + assert @klass.validate_hosts(hosts, @org, @host.name, 'different-uuid', host_uuid_overridden: true) end end diff --git a/test/support/controller_support.rb b/test/support/controller_support.rb index 7cb205921d4..dea1a1f1d30 100644 --- a/test/support/controller_support.rb +++ b/test/support/controller_support.rb @@ -67,11 +67,11 @@ def assert_protected_object(action_name, allowed_perms, denied_perms = [], def assert_authorized(params) check_params = params.merge(authorized: true) - check_permission(check_params) + check_permission(**check_params) end def refute_authorized(params) check_params = params.merge(authorized: false) - check_permission(check_params) + check_permission(**check_params) end end diff --git a/test/support/export_support.rb b/test/support/export_support.rb index e4287162693..02eb0cbc9a3 100644 --- a/test/support/export_support.rb +++ b/test/support/export_support.rb @@ -3,12 +3,14 @@ module ExportSupport def fetch_exporter(smart_proxy:, content_view_version:, destination_server: nil, from_content_view_version: nil, format: ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE) - export = ::Katello::Pulp3::ContentViewVersion::Export.create(smart_proxy: smart_proxy, - content_view_version: content_view_version, - destination_server: destination_server, - from_content_view_version: from_content_view_version, - format: format - ) + export = ::Katello::Pulp3::ContentViewVersion::Export.create( + { smart_proxy: smart_proxy, + content_view_version: content_view_version, + destination_server: destination_server, + from_content_view_version: from_content_view_version, + format: format + } + ) version_repositories = content_view_version.archived_repos.yum_type version_repositories.each_with_index do |repo, index| repo.update!(version_href: index)