From fe092d558baba2ad001c79d5d3780cf9f5e45512 Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Mon, 10 Jan 2022 18:53:53 +0000 Subject: [PATCH 1/7] Upgrade to Ruby 3 and update dependencies Authored-by: Seth Boyles --- .ruby-version | 2 +- Gemfile | 4 +- Gemfile.lock | 136 +++++++++++++++++++++++++++++++------------------- 3 files changed, 87 insertions(+), 55 deletions(-) diff --git a/.ruby-version b/.ruby-version index 37c2961c243..75a22a26ac4 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.2 +3.0.3 diff --git a/Gemfile b/Gemfile index aa1b6936255..1c2b89c50f9 100644 --- a/Gemfile +++ b/Gemfile @@ -36,7 +36,7 @@ gem 'rfc822' gem 'rubyzip', '>= 1.3.0' gem 'sequel', '~> 5.52' gem 'sequel_pg', require: 'sequel' -gem 'sinatra', '~> 2.0' +gem 'sinatra', '~> 2.1' gem 'sinatra-contrib' gem 'statsd-ruby', '~> 1.4.0' gem 'steno' @@ -58,7 +58,7 @@ gem 'bits_service_client', '~> 3.3', '>= 3.3.0' gem 'fog-aliyun' gem 'fog-aws' gem 'fog-azure-rm', git: 'https://github.com/fog/fog-azure-rm.git', branch: 'fog-arm-cf' -gem 'fog-google' +gem 'fog-google', '~> 1.17' gem 'fog-local' gem 'fog-openstack' diff --git a/Gemfile.lock b/Gemfile.lock index 2095bfedc46..b8af3537f99 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,11 +7,12 @@ GIT GIT remote: https://github.com/fog/fog-azure-rm.git - revision: 79a738331538c6bdba806774cb11af8977979f8e + revision: f21a4685d56db415b45728eeb2a688195909852b branch: fog-arm-cf specs: fog-azure-rm (0.4.7) - azure-storage (>= 0.11.5.preview, < 1.0) + azure-storage-blob (~> 1.1) + azure-storage-common (~> 1.1) azure_mgmt_compute (~> 0.9.0) azure_mgmt_dns (~> 0.9.0) azure_mgmt_key_vault (~> 0.9.0) @@ -20,8 +21,8 @@ GIT azure_mgmt_sql (~> 0.9.0) azure_mgmt_storage (~> 0.9.0) azure_mgmt_traffic_manager (~> 0.9.0) - fog-core (~> 1.43) - fog-json (~> 1.0.2) + fog-core (>= 1.43) + fog-json (>= 1.0.2) mime-types (~> 3.0) vhd (= 0.0.4) @@ -66,7 +67,7 @@ GEM i18n ast (2.4.2) awesome_print (1.9.2) - azure-core (0.1.14) + azure-core (0.1.15) faraday (~> 0.9) faraday_middleware (~> 0.10) nokogiri (~> 1.6) @@ -75,6 +76,13 @@ GEM faraday (~> 0.9) faraday_middleware (~> 0.10) nokogiri (~> 1.6, >= 1.6.8) + azure-storage-blob (1.1.0) + azure-core (~> 0.1.13) + azure-storage-common (~> 1.0) + nokogiri (~> 1.6, >= 1.6.8) + azure-storage-common (1.1.0) + azure-core (~> 0.1.13) + nokogiri (~> 1.6, >= 1.6.8) azure_mgmt_compute (0.9.0) ms_rest_azure (~> 0.7.0) azure_mgmt_dns (0.9.0) @@ -92,10 +100,9 @@ GEM azure_mgmt_traffic_manager (0.9.0) ms_rest_azure (~> 0.7.0) backport (1.2.0) - backports (3.18.1) beefcake (1.0.0) benchmark (0.2.0) - bit-struct (0.16) + bit-struct (0.17) bits_service_client (3.4.0) activesupport statsd-ruby (~> 1.4.0) @@ -124,8 +131,7 @@ GEM debase (0.2.5.beta2) debase-ruby_core_source (>= 0.10.12) debase-ruby_core_source (0.10.12) - declarative (0.0.10) - declarative-option (0.1.0) + declarative (0.0.20) delayed_job (4.1.9) activesupport (>= 3.0, < 6.2) diff-lcs (1.4.4) @@ -144,12 +150,12 @@ GEM erubi (1.10.0) eventmachine (1.2.7) excon (0.90.0) - faraday (0.15.4) + faraday (0.17.4) multipart-post (>= 1.2, < 3) - faraday-cookie_jar (0.0.6) - faraday (>= 0.7.4) + faraday-cookie_jar (0.0.7) + faraday (>= 0.8.0) http-cookie (~> 1.0.0) - faraday_middleware (0.12.2) + faraday_middleware (0.14.0) faraday (>= 0.7.4, < 1.0) ffi (1.15.5) ffi-compiler (1.0.1) @@ -172,13 +178,20 @@ GEM builder excon (~> 0.58) formatador (~> 0.2) - fog-google (1.7.1) + fog-google (1.17.0) + fog-core (<= 2.1.0) + fog-json (~> 1.2) + fog-xml (~> 0.1.0) + google-apis-compute_v1 (~> 0.14) + google-apis-dns_v1 (~> 0.12) + google-apis-iamcredentials_v1 (~> 0.6) + google-apis-monitoring_v3 (~> 0.12) + google-apis-pubsub_v1 (~> 0.7) + google-apis-sqladmin_v1beta4 (~> 0.13) + google-apis-storage_v1 (~> 0.6) + google-cloud-env (~> 1.2) + fog-json (1.2.0) fog-core - fog-json - fog-xml - google-api-client (~> 0.23.0) - fog-json (1.0.2) - fog-core (~> 1.0) multi_json (~> 1.10) fog-local (0.6.0) fog-core (>= 1.27, < 3.0) @@ -189,15 +202,32 @@ GEM fog-xml (0.1.3) fog-core nokogiri (>= 1.5.11, < 2.0.0) - formatador (0.2.5) - google-api-client (0.23.9) + formatador (0.3.0) + google-apis-compute_v1 (0.23.0) + google-apis-core (>= 0.4, < 2.a) + google-apis-core (0.4.1) addressable (~> 2.5, >= 2.5.1) - googleauth (>= 0.5, < 0.7.0) - httpclient (>= 2.8.1, < 3.0) - mime-types (~> 3.0) + googleauth (>= 0.16.2, < 2.a) + httpclient (>= 2.8.1, < 3.a) + mini_mime (~> 1.0) representable (~> 3.0) - retriable (>= 2.0, < 4.0) - signet (~> 0.9) + retriable (>= 2.0, < 4.a) + rexml + webrick + google-apis-dns_v1 (0.17.0) + google-apis-core (>= 0.4, < 2.a) + google-apis-iamcredentials_v1 (0.10.0) + google-apis-core (>= 0.4, < 2.a) + google-apis-monitoring_v3 (0.19.0) + google-apis-core (>= 0.4, < 2.a) + google-apis-pubsub_v1 (0.12.0) + google-apis-core (>= 0.4, < 2.a) + google-apis-sqladmin_v1beta4 (0.22.0) + google-apis-core (>= 0.4, < 2.a) + google-apis-storage_v1 (0.11.0) + google-apis-core (>= 0.4, < 2.a) + google-cloud-env (1.5.0) + faraday (>= 0.17.3, < 2.0) google-protobuf (3.19.2) google-protobuf (3.19.2-x86_64-darwin) google-protobuf (3.19.2-x86_64-linux) @@ -207,13 +237,13 @@ GEM grpc (~> 1.27) googleapis-common-protos-types (1.3.0) google-protobuf (~> 3.14) - googleauth (0.6.7) - faraday (~> 0.12) + googleauth (1.1.0) + faraday (>= 0.17.3, < 2.0) jwt (>= 1.4, < 3.0) memoist (~> 0.16) multi_json (~> 1.11) os (>= 0.9, < 2.0) - signet (~> 0.7) + signet (>= 0.16, < 2.a) grpc (1.42.0) google-protobuf (~> 3.18) googleapis-common-protos-types (~> 1.0) @@ -250,7 +280,7 @@ GEM json_pure (2.6.1) jsonpath (1.1.0) multi_json - jwt (2.2.1) + jwt (2.3.0) kramdown (2.3.1) rexml kramdown-parser-gfm (1.1.0) @@ -274,12 +304,13 @@ GEM nokogiri (>= 1.5.9) machinist (1.0.6) membrane (1.1.0) - memoist (0.16.0) + memoist (0.16.2) method_source (1.0.0) middleware (0.1.0) mime-types (3.4.1) mime-types-data (~> 3.2015) - mime-types-data (3.2021.1115) + mime-types-data (3.2022.0105) + mini_mime (1.1.2) mini_portile2 (2.7.1) minitest (5.15.0) ms_rest (0.6.4) @@ -292,7 +323,7 @@ GEM faraday-cookie_jar (~> 0.0.6) ms_rest (~> 0.6.3) msgpack (1.4.2) - multi_json (1.12.2) + multi_json (1.15.0) multipart-parser (0.1.1) multipart-post (2.1.1) mustache (1.1.1) @@ -311,7 +342,7 @@ GEM nokogiri (1.13.1-x86_64-linux) racc (~> 1.4) oj (3.13.11) - os (1.0.1) + os (1.1.4) palm_civet (1.1.0) parallel (1.21.0) parallel_tests (3.7.3) @@ -334,7 +365,7 @@ GEM public_suffix (4.0.6) racc (1.6.0) rack (2.2.3) - rack-protection (2.0.8.1) + rack-protection (2.1.0) rack rack-test (1.1.0) rack (>= 1.0, < 3) @@ -356,9 +387,9 @@ GEM ffi (~> 1.0) recursive-open-struct (1.1.3) regexp_parser (2.2.0) - representable (3.0.4) + representable (3.1.1) declarative (< 0.1.0) - declarative-option (< 0.2.0) + trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) @@ -421,7 +452,7 @@ GEM ruby-debug-ide (0.7.3) rake (>= 0.8.1) ruby-progressbar (1.11.0) - ruby2_keywords (0.0.2) + ruby2_keywords (0.0.5) ruby_parser (3.8.3) sexp_processor (~> 4.1) rubyzip (2.3.2) @@ -430,9 +461,9 @@ GEM pg (>= 0.18.0, != 1.2.0) sequel (>= 4.38.0) sexp_processor (4.7.0) - signet (0.11.0) - addressable (~> 2.3) - faraday (~> 0.9) + signet (0.16.0) + addressable (~> 2.8) + faraday (>= 0.17.3, < 2.0) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) simplecov (0.13.0) @@ -440,17 +471,16 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - sinatra (2.0.8.1) + sinatra (2.1.0) mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.8.1) + rack (~> 2.2) + rack-protection (= 2.1.0) tilt (~> 2.0) - sinatra-contrib (2.0.8.1) - backports (>= 2.8.2) + sinatra-contrib (2.1.0) multi_json mustermann (~> 1.0) - rack-protection (= 2.0.8.1) - sinatra (= 2.0.8.1) + rack-protection (= 2.1.0) + sinatra (= 2.1.0) tilt (~> 2.0) solargraph (0.44.2) backport (~> 1.2) @@ -486,7 +516,8 @@ GEM thread_safe (0.3.6) tilt (2.0.10) timecop (0.9.4) - timeliness (0.3.10) + timeliness (0.4.4) + trailblazer-option (0.1.2) tzinfo (2.0.4) concurrent-ruby (~> 1.0) uber (0.1.0) @@ -501,6 +532,7 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.7.0) xml-simple (1.1.5) yajl-ruby (1.4.1) yard (0.9.26) @@ -535,7 +567,7 @@ DEPENDENCIES fog-aliyun fog-aws fog-azure-rm! - fog-google + fog-google (~> 1.17) fog-local fog-openstack googleapis-common-protos (>= 1.3.12) @@ -584,7 +616,7 @@ DEPENDENCIES rubyzip (>= 1.3.0) sequel (~> 5.52) sequel_pg - sinatra (~> 2.0) + sinatra (~> 2.1) sinatra-contrib solargraph spork! @@ -602,4 +634,4 @@ DEPENDENCIES yajl-ruby BUNDLED WITH - 2.1.4 + 2.2.32 From b88b81eb8bfa6a59d169e951b01ccc1429bc8c56 Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Wed, 12 Jan 2022 23:53:20 +0000 Subject: [PATCH 2/7] Update keyword arguments for Ruby 3.0 Co-authored-by: Seth Boyles Co-authored-by: Mona Mohebbi --- .../v3/service_plan_visibility_controller.rb | 2 +- lib/cloud_controller/clock/scheduler.rb | 6 +- lib/cloud_controller/seeds.rb | 2 +- .../service_brokers/v2/response_parser.rb | 16 +-- middleware/rate_limiter.rb | 14 +-- .../documentation/buildpack_cache_api_spec.rb | 2 +- .../packages_controller_index_spec.rb | 4 +- spec/request/domains_spec.rb | 2 +- ...erify_old_lrps_can_download_assets_spec.rb | 2 +- spec/request/packages_spec.rb | 2 +- spec/request/service_brokers_spec.rb | 6 +- spec/request_spec_shared_examples.rb | 4 +- spec/support/bootstrap/test_config.rb | 2 +- .../controllers/resource_pool.rb | 2 +- .../jobs/create_binding_job.rb | 6 +- .../jobs/delete_binding_job.rb | 6 +- spec/unit/actions/task_create_spec.rb | 4 +- .../download_droplets_controller_spec.rb | 4 +- .../staging_completion_controller_spec.rb | 4 +- .../app_bits_upload_controller_spec.rb | 2 +- .../runtime/apps_controller_spec.rb | 4 +- .../runtime/buildpack_bits_controller_spec.rb | 2 +- .../resource_matches_controller_spec.rb | 2 +- .../runtime/spaces_controller_spec.rb | 2 +- .../runtime/stagings_controller_spec.rb | 10 +- .../service_update_validator_spec.rb | 62 ++++++------ .../v3/packages_controller_spec.rb | 4 +- spec/unit/jobs/enqueuer_spec.rb | 2 +- .../runtime/buildpack_cache_cleanup_spec.rb | 2 +- .../service_binding_state_fetch_spec.rb | 6 +- .../service_instance_state_fetch_spec.rb | 2 +- .../jobs/v3/buildpack_cache_cleanup_spec.rb | 2 +- .../v3/create_service_instance_job_spec.rb | 6 +- .../v3/delete_service_instance_job_spec.rb | 6 +- .../v3/update_service_instance_job_spec.rb | 6 +- .../cloud_controller/bits_expiration_spec.rb | 8 +- .../lib/cloud_controller/clock/clock_spec.rb | 8 +- .../cloud_controller/clock/scheduler_spec.rb | 8 +- .../dependency_locator_spec.rb | 98 +++++++++---------- .../lifecycle_bundle_uri_generator_spec.rb | 2 +- ...task_completion_callback_generator_spec.rb | 2 +- .../install_buildpacks_spec.rb | 2 +- spec/unit/lib/cloud_controller/seeds_spec.rb | 16 +-- .../kubernetes/kube_client_builder_spec.rb | 4 +- .../service_brokers/v2/client_spec.rb | 2 +- .../service_brokers/v2/http_client_spec.rb | 4 +- .../v2/response_parser_spec.rb | 16 +-- spec/unit/middleware/rate_limiter_spec.rb | 14 +-- spec/unit/models/runtime/app_model_spec.rb | 8 +- .../constraints/health_check_policy_spec.rb | 2 +- .../unit/models/runtime/package_model_spec.rb | 2 +- .../unit/models/runtime/process_model_spec.rb | 12 +-- .../unit/models/runtime/shared_domain_spec.rb | 10 +- .../v3/service_broker_presenter_spec.rb | 6 +- 54 files changed, 214 insertions(+), 220 deletions(-) diff --git a/app/controllers/v3/service_plan_visibility_controller.rb b/app/controllers/v3/service_plan_visibility_controller.rb index a58071af7ef..2003e872bc7 100644 --- a/app/controllers/v3/service_plan_visibility_controller.rb +++ b/app/controllers/v3/service_plan_visibility_controller.rb @@ -67,7 +67,7 @@ def update_visibility(opts={}) message = ServicePlanVisibilityUpdateMessage.new(hashed_params[:body]) bad_request!(message.errors.full_messages) unless message.valid? - updated_service_plan = V3::ServicePlanVisibilityUpdate.new.update(service_plan, message, opts) + updated_service_plan = V3::ServicePlanVisibilityUpdate.new.update(service_plan, message, **opts) event_repository.record_service_plan_update_visibility_event(service_plan, message.audit_hash) updated_service_plan rescue V3::ServicePlanVisibilityUpdate::UnprocessableRequest => e diff --git a/lib/cloud_controller/clock/scheduler.rb b/lib/cloud_controller/clock/scheduler.rb index 2aafc4f6b7a..4ef941d5c4e 100644 --- a/lib/cloud_controller/clock/scheduler.rb +++ b/lib/cloud_controller/clock/scheduler.rb @@ -57,7 +57,7 @@ def start_inline_jobs interval: @config.get(:diego_sync, :frequency_in_seconds), timeout: @timeout_calculator.calculate(:diego_sync), } - @clock.schedule_frequent_inline_job(clock_opts) do + @clock.schedule_frequent_inline_job(**clock_opts) do Jobs::Diego::Sync.new end end @@ -68,7 +68,7 @@ def start_frequent_jobs name: job_config[:name], interval: @config.get(job_config[:name].to_sym, :frequency_in_seconds), } - @clock.schedule_frequent_worker_job(clock_opts) do + @clock.schedule_frequent_worker_job(**clock_opts) do klass = job_config[:class] klass.new(@config.get(job_config[:name].to_sym, :expiration_in_seconds)) end @@ -83,7 +83,7 @@ def start_daily_jobs priority: cleanup_config[:priority] || Clock::HIGH_PRIORITY } - @clock.schedule_daily_job(clock_opts) do + @clock.schedule_daily_job(**clock_opts) do klass = cleanup_config[:class] if cleanup_config[:arg_from_config] diff --git a/lib/cloud_controller/seeds.rb b/lib/cloud_controller/seeds.rb index ebc4efe3ed7..dd8e2a65789 100644 --- a/lib/cloud_controller/seeds.rb +++ b/lib/cloud_controller/seeds.rb @@ -93,7 +93,7 @@ def create_seed_domains(config, system_org) router_group_guid: find_routing_guid(domain), internal: domain['internal'] } - SharedDomain.find_or_create(attrs.compact) + SharedDomain.find_or_create(**attrs.compact) end if CloudController::DomainDecorator.new(system_domain).has_sub_domain?(test_domains: domains.map { |domain_hash| domain_hash['name'] }) diff --git a/lib/services/service_brokers/v2/response_parser.rb b/lib/services/service_brokers/v2/response_parser.rb index b53ff9992cf..7efc0ecf4dd 100644 --- a/lib/services/service_brokers/v2/response_parser.rb +++ b/lib/services/service_brokers/v2/response_parser.rb @@ -35,7 +35,7 @@ def parse_provision(path, response) end validator = CommonErrorValidator.new(validator) - validator.validate(unvalidated_response.to_hash) + validator.validate(**unvalidated_response.to_hash) end def parse_bind(path, response, opts={}) @@ -65,7 +65,7 @@ def parse_bind(path, response, opts={}) end validator = CommonErrorValidator.new(validator) - validator.validate(unvalidated_response.to_hash) + validator.validate(**unvalidated_response.to_hash) end def parse_unbind(path, response) @@ -93,7 +93,7 @@ def parse_unbind(path, response) end validator = CommonErrorValidator.new(validator) - validator.validate(unvalidated_response.to_hash) + validator.validate(**unvalidated_response.to_hash) end def parse_deprovision(path, response) @@ -122,7 +122,7 @@ def parse_deprovision(path, response) end validator = CommonErrorValidator.new(validator) - validator.validate(unvalidated_response.to_hash) + validator.validate(**unvalidated_response.to_hash) end def parse_catalog(path, response) @@ -140,7 +140,7 @@ def parse_catalog(path, response) end validator = CommonErrorValidator.new(validator) - validator.validate(unvalidated_response.to_hash) + validator.validate(**unvalidated_response.to_hash) end def parse_update(path, response) @@ -167,7 +167,7 @@ def parse_update(path, response) end validator = CommonErrorValidator.new(validator) - validator.validate(unvalidated_response.to_hash) + validator.validate(**unvalidated_response.to_hash) end def parse_fetch_state(path, response) @@ -195,7 +195,7 @@ def parse_fetch_state(path, response) CommonErrorValidator.new(FailingValidator.new(Errors::ServiceBrokerBadResponse)) end - validator.validate(unvalidated_response.to_hash) + validator.validate(**unvalidated_response.to_hash) end def parse_fetch_parameters(path, response, schema) @@ -211,7 +211,7 @@ def parse_fetch_parameters(path, response, schema) validator = CommonErrorValidator.new(validator) - validator.validate(unvalidated_response.to_hash) + validator.validate(**unvalidated_response.to_hash) end def parse_fetch_instance_parameters(path, response) diff --git a/middleware/rate_limiter.rb b/middleware/rate_limiter.rb index fc022df561a..9afb4d5459e 100644 --- a/middleware/rate_limiter.rb +++ b/middleware/rate_limiter.rb @@ -49,14 +49,14 @@ def create_new_request_count(user_guid, reset_interval_in_minutes) class RateLimiter include CloudFoundry::Middleware::ClientIp - def initialize(app, logger:, per_process_general_limit:, global_general_limit:, per_process_unauthenticated_limit:, global_unauthenticated_limit:, interval:) + def initialize(app, opts) @app = app - @logger = logger - @per_process_general_limit = per_process_general_limit - @global_general_limit = global_general_limit - @per_process_unauthenticated_limit = per_process_unauthenticated_limit - @global_unauthenticated_limit = global_unauthenticated_limit - @interval = interval + @logger = opts[:logger] + @per_process_general_limit = opts[:per_process_general_limit] + @global_general_limit = opts[:global_general_limit] + @per_process_unauthenticated_limit = opts[:per_process_unauthenticated_limit] + @global_unauthenticated_limit = opts[:global_unauthenticated_limit] + @interval = opts[:interval] @request_counter = RequestCounter.instance end diff --git a/spec/api/documentation/buildpack_cache_api_spec.rb b/spec/api/documentation/buildpack_cache_api_spec.rb index f1476100ee2..0ad1c9d4a47 100644 --- a/spec/api/documentation/buildpack_cache_api_spec.rb +++ b/spec/api/documentation/buildpack_cache_api_spec.rb @@ -30,7 +30,7 @@ end before do - TestConfig.override(blobstore_config) + TestConfig.override(**blobstore_config) end after do diff --git a/spec/performance/packages_controller_index_spec.rb b/spec/performance/packages_controller_index_spec.rb index a7a4e7391da..a678aed1cd5 100644 --- a/spec/performance/packages_controller_index_spec.rb +++ b/spec/performance/packages_controller_index_spec.rb @@ -17,12 +17,12 @@ let(:n) { 10 } before do - TestConfig.override({ + TestConfig.override( db: { log_level: 'debug', } # logging.level: 'debug2' - }) + ) allow_user_read_access_for(user, spaces: user_spaces) n.times do |i| app = VCAP::CloudController::AppModel.make(space: user_spaces.sample, guid: "app-guid-#{i}") diff --git a/spec/request/domains_spec.rb b/spec/request/domains_spec.rb index 4c427a35d14..15211ff6e38 100644 --- a/spec/request/domains_spec.rb +++ b/spec/request/domains_spec.rb @@ -1073,7 +1073,7 @@ context 'when the domain is in the list of reserved private domains' do before do - TestConfig.override({ reserved_private_domains: File.join(Paths::FIXTURES, 'config/reserved_private_domains.dat') }) + TestConfig.override(reserved_private_domains: File.join(Paths::FIXTURES, 'config/reserved_private_domains.dat')) end it 'returns a 422 with a error message about reserved domains' do diff --git a/spec/request/knowledge_bombs/verify_old_lrps_can_download_assets_spec.rb b/spec/request/knowledge_bombs/verify_old_lrps_can_download_assets_spec.rb index 214ca471fbd..7b5adb24060 100644 --- a/spec/request/knowledge_bombs/verify_old_lrps_can_download_assets_spec.rb +++ b/spec/request/knowledge_bombs/verify_old_lrps_can_download_assets_spec.rb @@ -20,7 +20,7 @@ end before do - TestConfig.override(staging_config) + TestConfig.override(**staging_config) allow(VCAP::CloudController::BlobDispatcher).to receive(:new).and_return(blob_dispatcher) end diff --git a/spec/request/packages_spec.rb b/spec/request/packages_spec.rb index e074dbfe8ae..58c976d5d5b 100644 --- a/spec/request/packages_spec.rb +++ b/spec/request/packages_spec.rb @@ -822,7 +822,7 @@ before do space.organization.add_user(user) space.add_developer(user) - TestConfig.override(test_config_overrides) + TestConfig.override(**test_config_overrides) end shared_examples :upload_bits_successfully do diff --git a/spec/request/service_brokers_spec.rb b/spec/request/service_brokers_spec.rb index 79740f74d00..f1a69f8552c 100644 --- a/spec/request/service_brokers_spec.rb +++ b/spec/request/service_brokers_spec.rb @@ -704,7 +704,7 @@ def expect_empty_list(user_headers) context 'when job succeeds with warnings' do context 'when warning is a UAA problem' do let(:broker) do - TestConfig.override({ uaa_client_name: nil, uaa_client_secret: nil }) + TestConfig.override(uaa_client_name: nil, uaa_client_secret: nil) create_broker_successfully(global_broker_request_body, with: admin_headers, execute_all_jobs: true) end @@ -729,7 +729,7 @@ def expect_empty_list(user_headers) context 'when warning is a catalog problem (deactivated plan, but there is a service instance)' do let!(:broker) do - TestConfig.override({}) + TestConfig.override create_broker_successfully(global_broker_request_body, with: admin_headers, execute_all_jobs: true) end @@ -1138,7 +1138,7 @@ def expect_empty_list(user_headers) context 'when job succeeds with warnings' do context 'when warning is a UAA problem' do before do - TestConfig.override({ uaa_client_name: nil, uaa_client_secret: nil }) + TestConfig.override(uaa_client_name: nil, uaa_client_secret: nil) create_broker_successfully(global_broker_request_body, with: admin_headers) execute_all_jobs(expected_successes: 1, expected_failures: 0) end diff --git a/spec/request_spec_shared_examples.rb b/spec/request_spec_shared_examples.rb index 56f729301f7..1c80f17ba8c 100644 --- a/spec/request_spec_shared_examples.rb +++ b/spec/request_spec_shared_examples.rb @@ -103,7 +103,7 @@ def expect_filtered_resources(endpoint, filter, list) it 'returns the correct response status and resources' do email = Sham.email user_name = Sham.name - headers = set_user_with_header_as_role({ + headers = set_user_with_header_as_role( role: role, org: org, space: space, @@ -111,7 +111,7 @@ def expect_filtered_resources(endpoint, filter, list) scopes: expected_codes_and_responses[role][:scopes], user_name: user_name, email: email, - }) + ) api_call.call(headers) diff --git a/spec/support/bootstrap/test_config.rb b/spec/support/bootstrap/test_config.rb index d6c35866f0b..5f9ffeabc85 100644 --- a/spec/support/bootstrap/test_config.rb +++ b/spec/support/bootstrap/test_config.rb @@ -19,7 +19,7 @@ def override(**overrides) end def reset - override({}) + override end def config diff --git a/spec/support/shared_examples/controllers/resource_pool.rb b/spec/support/shared_examples/controllers/resource_pool.rb index d1a53b35f38..760889f4215 100644 --- a/spec/support/shared_examples/controllers/resource_pool.rb +++ b/spec/support/shared_examples/controllers/resource_pool.rb @@ -59,7 +59,7 @@ before do @resource_pool = VCAP::CloudController::ResourcePool.new( - VCAP::CloudController::Config.new(resource_pool: resource_pool_config) + VCAP::CloudController::Config.new({ resource_pool: resource_pool_config }) ) allow(VCAP::CloudController::ResourcePool).to receive(:instance).and_return(@resource_pool) end diff --git a/spec/support/shared_examples/jobs/create_binding_job.rb b/spec/support/shared_examples/jobs/create_binding_job.rb index a1bfae05a66..2207ac2e751 100644 --- a/spec/support/shared_examples/jobs/create_binding_job.rb +++ b/spec/support/shared_examples/jobs/create_binding_job.rb @@ -58,9 +58,9 @@ context 'asynchronous response' do context 'computes the maximum duration' do before do - TestConfig.override({ + TestConfig.override( broker_client_max_async_poll_duration_minutes: 90009 - }) + ) subject.perform end @@ -141,7 +141,7 @@ context 'the maximum duration' do it 'recomputes the value' do subject.maximum_duration_seconds = 90009 - TestConfig.override({ broker_client_max_async_poll_duration_minutes: 8088 }) + TestConfig.override(broker_client_max_async_poll_duration_minutes: 8088) subject.perform expect(subject.maximum_duration_seconds).to eq(8088.minutes) end diff --git a/spec/support/shared_examples/jobs/delete_binding_job.rb b/spec/support/shared_examples/jobs/delete_binding_job.rb index 46076375548..b0f25c8c7d7 100644 --- a/spec/support/shared_examples/jobs/delete_binding_job.rb +++ b/spec/support/shared_examples/jobs/delete_binding_job.rb @@ -58,9 +58,9 @@ context 'computes the maximum duration' do before do - TestConfig.override({ + TestConfig.override( broker_client_max_async_poll_duration_minutes: 90009 - }) + ) subject.perform end @@ -130,7 +130,7 @@ context 'the maximum duration' do it 'recomputes the value' do subject.maximum_duration_seconds = 90009 - TestConfig.override({ broker_client_max_async_poll_duration_minutes: 8088 }) + TestConfig.override(broker_client_max_async_poll_duration_minutes: 8088) subject.perform expect(subject.maximum_duration_seconds).to eq(8088.minutes) end diff --git a/spec/unit/actions/task_create_spec.rb b/spec/unit/actions/task_create_spec.rb index f050af5a939..09119ba6245 100644 --- a/spec/unit/actions/task_create_spec.rb +++ b/spec/unit/actions/task_create_spec.rb @@ -5,11 +5,11 @@ module VCAP::CloudController RSpec.describe TaskCreate do subject(:task_create_action) { TaskCreate.new(config) } let(:config) do - Config.new( + Config.new({ maximum_app_disk_in_mb: 4096, default_app_memory: 1024, default_app_disk_in_mb: 1024 - ) + }) end describe '#create' do diff --git a/spec/unit/controllers/internal/download_droplets_controller_spec.rb b/spec/unit/controllers/internal/download_droplets_controller_spec.rb index 1566044c463..78b598a7987 100644 --- a/spec/unit/controllers/internal/download_droplets_controller_spec.rb +++ b/spec/unit/controllers/internal/download_droplets_controller_spec.rb @@ -35,7 +35,7 @@ module VCAP::CloudController before do Fog.unmock! - TestConfig.override(staging_config) + TestConfig.override(**staging_config) end after { FileUtils.rm_rf(workspace) } @@ -152,7 +152,7 @@ def upload_droplet before do Fog.unmock! - TestConfig.override(staging_config) + TestConfig.override(**staging_config) end after { FileUtils.rm_rf(workspace) } diff --git a/spec/unit/controllers/internal/staging_completion_controller_spec.rb b/spec/unit/controllers/internal/staging_completion_controller_spec.rb index 0f280aff856..c0713b921ac 100644 --- a/spec/unit/controllers/internal/staging_completion_controller_spec.rb +++ b/spec/unit/controllers/internal/staging_completion_controller_spec.rb @@ -41,7 +41,7 @@ module VCAP::CloudController let(:one_hour_in_nanoseconds) { (1.hour.to_i * 1e9).to_i } before do - TestConfig.override({ kubernetes: nil }) + TestConfig.override(kubernetes: nil) allow(VCAP::CloudController::Metrics::StatsdUpdater).to receive(:new).and_return(statsd_updater) end @@ -190,7 +190,7 @@ module VCAP::CloudController describe 'authentication' do context 'when running in Kubernetes' do before do - TestConfig.override({ kubernetes: { host_url: 'example.com' } }) + TestConfig.override(kubernetes: { host_url: 'example.com' }) end context 'when missing authentication' do diff --git a/spec/unit/controllers/runtime/app_bits_upload_controller_spec.rb b/spec/unit/controllers/runtime/app_bits_upload_controller_spec.rb index b2a60f77d6e..fdd20100870 100644 --- a/spec/unit/controllers/runtime/app_bits_upload_controller_spec.rb +++ b/spec/unit/controllers/runtime/app_bits_upload_controller_spec.rb @@ -10,7 +10,7 @@ module VCAP::CloudController describe 'PUT /v2/app/:id/bits' do before do TestConfig.override( - config_override.merge( + **config_override.merge( directories: { tmpdir: File.dirname(valid_zip.path) }, kubernetes: {} ) diff --git a/spec/unit/controllers/runtime/apps_controller_spec.rb b/spec/unit/controllers/runtime/apps_controller_spec.rb index f05176aae48..30ef40adf9f 100644 --- a/spec/unit/controllers/runtime/apps_controller_spec.rb +++ b/spec/unit/controllers/runtime/apps_controller_spec.rb @@ -372,7 +372,7 @@ module VCAP::CloudController context 'when custom buildpacks are disabled and the buildpack attribute is being changed' do before do - TestConfig.override({ disable_custom_buildpacks: true }) + TestConfig.override(disable_custom_buildpacks: true) set_current_user(admin_user, admin: true) end @@ -871,7 +871,7 @@ def update_app context 'when custom buildpacks are disabled and the buildpack attribute is being changed' do before do - TestConfig.override({ disable_custom_buildpacks: true }) + TestConfig.override(disable_custom_buildpacks: true) set_current_user(admin_user, admin: true) process.app.lifecycle_data.update(buildpacks: [Buildpack.make.name]) end diff --git a/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb b/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb index b0f1c8ab404..010d668566b 100644 --- a/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb +++ b/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb @@ -301,7 +301,7 @@ module VCAP::CloudController end before do - TestConfig.override(staging_config) + TestConfig.override(**staging_config) VCAP::CloudController::Buildpack.create_from_hash({ name: 'get_binary_buildpack', stack: nil, key: 'xyz', position: 0 }) end diff --git a/spec/unit/controllers/runtime/resource_matches_controller_spec.rb b/spec/unit/controllers/runtime/resource_matches_controller_spec.rb index 668ada74ffe..fb1319adeb4 100644 --- a/spec/unit/controllers/runtime/resource_matches_controller_spec.rb +++ b/spec/unit/controllers/runtime/resource_matches_controller_spec.rb @@ -104,7 +104,7 @@ def resource_match_request(verb, path, matches, non_matches) let(:resources) { [{ sha1: '12345' }, { sha1: '56789' }] } before do - TestConfig.override(bits_service_config) + TestConfig.override(**bits_service_config) set_current_user_as_admin end diff --git a/spec/unit/controllers/runtime/spaces_controller_spec.rb b/spec/unit/controllers/runtime/spaces_controller_spec.rb index fef696fa47e..489ccb794c1 100644 --- a/spec/unit/controllers/runtime/spaces_controller_spec.rb +++ b/spec/unit/controllers/runtime/spaces_controller_spec.rb @@ -1007,7 +1007,7 @@ def decoded_guids context 'when the async job times out' do before do - TestConfig.override({ jobs: { global: { timeout_in_seconds: 0.1 } } }) + TestConfig.override(jobs: { global: { timeout_in_seconds: 0.1 } }) stub_deprovision(service_instance, accepts_incomplete: true) do sleep 0.11 { status: 200, body: {}.to_json } diff --git a/spec/unit/controllers/runtime/stagings_controller_spec.rb b/spec/unit/controllers/runtime/stagings_controller_spec.rb index 2af3697147e..47be8663e27 100644 --- a/spec/unit/controllers/runtime/stagings_controller_spec.rb +++ b/spec/unit/controllers/runtime/stagings_controller_spec.rb @@ -181,7 +181,7 @@ module VCAP::CloudController before do Fog.unmock! - TestConfig.override(staging_config) + TestConfig.override(**staging_config) set_current_user_as_admin(user: User.make(guid: '1234'), email: 'joe@joe.com', user_name: 'briggs') end @@ -223,7 +223,7 @@ def create_test_blob context 'when using with nginx' do before do - TestConfig.override(staging_config) + TestConfig.override(**staging_config) blob = create_test_blob allow(blob).to receive(:internal_download_url).and_return("/cc-packages/gu/id/#{package.guid}") package_blobstore = instance_double(CloudController::Blobstore::Client, blob: blob, local?: true) @@ -240,7 +240,7 @@ def create_test_blob context 'when not using with nginx' do before do - TestConfig.override(staging_config.merge(nginx: { use_nginx: false })) + TestConfig.override(**staging_config.merge(nginx: { use_nginx: false })) package_blobstore = instance_double(CloudController::Blobstore::Client, blob: create_test_blob, local?: true) allow(CloudController::DependencyLocator.instance).to receive(:package_blobstore).and_return(package_blobstore) end @@ -480,7 +480,7 @@ def upload_droplet end context 'when using with nginx' do - before { TestConfig.override(staging_config) } + before { TestConfig.override(**staging_config) } it 'succeeds for valid droplets' do upload_droplet @@ -494,7 +494,7 @@ def upload_droplet end context 'when not using with nginx' do - before { TestConfig.override(staging_config.merge(nginx: { use_nginx: false })) } + before { TestConfig.override(**staging_config.merge(nginx: { use_nginx: false })) } it 'succeeds for valid droplets' do encoded_expected_body = Base64.encode64(upload_droplet) diff --git a/spec/unit/controllers/services/validators/service_update_validator_spec.rb b/spec/unit/controllers/services/validators/service_update_validator_spec.rb index 232b232396a..0a84356e255 100644 --- a/spec/unit/controllers/services/validators/service_update_validator_spec.rb +++ b/spec/unit/controllers/services/validators/service_update_validator_spec.rb @@ -25,14 +25,14 @@ module VCAP::CloudController context 'when the update to the service instance is valid' do it 'returns true' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to eq(true) + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to eq(true) end context 'and when plan update requested on a service that allows update' do let(:update_attrs) { { 'service_plan_guid' => new_service_plan.guid } } it 'returns true' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to eq(true) + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to eq(true) end end @@ -40,7 +40,7 @@ module VCAP::CloudController let(:update_attrs) { { 'maintenance_info' => { 'version' => '2.0.0' } } } it 'returns true' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to eq(true) + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to eq(true) end end @@ -57,7 +57,7 @@ module VCAP::CloudController end it 'always allows the update' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to be true + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to be true end end @@ -71,7 +71,7 @@ module VCAP::CloudController let(:public) { true } it 'allows the update' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to be true + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to be true end end @@ -84,7 +84,7 @@ module VCAP::CloudController end it 'allows the update' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to be true + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to be true end end end @@ -97,7 +97,7 @@ module VCAP::CloudController it 'raises a validation error' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /Cannot update space/) end end @@ -113,7 +113,7 @@ module VCAP::CloudController it 'raises a validation error with the specific message' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /You have exceeded your space's services limit./) end end @@ -132,14 +132,14 @@ module VCAP::CloudController it 'raises a validation error' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /cannot switch to non-bindable/) end end context 'and service bindings do not exist' do it 'returns true' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to eq(true) + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to eq(true) end end end @@ -153,7 +153,7 @@ module VCAP::CloudController it 'raises a validation error if the plan changes' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /service does not support changing plans/) end @@ -161,7 +161,7 @@ module VCAP::CloudController let(:update_attrs) { { 'service_plan_guid' => old_service_plan.guid } } it 'returns true' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to eq(true) + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to eq(true) end end @@ -171,7 +171,7 @@ module VCAP::CloudController end it 'returns true' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to eq(true) + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to eq(true) end end @@ -182,7 +182,7 @@ module VCAP::CloudController it 'raises a validation error' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /service does not support changing plans/) end end @@ -197,7 +197,7 @@ module VCAP::CloudController it 'raises a validation error' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /service does not support changing plans/) end end @@ -207,7 +207,7 @@ module VCAP::CloudController it 'raises a validation error' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /Plan/) end end @@ -220,7 +220,7 @@ module VCAP::CloudController it 'raises a validation error' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /Plan/) end end @@ -237,7 +237,7 @@ module VCAP::CloudController it 'raises a validation error' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /shared cannot be renamed/) end end @@ -246,7 +246,7 @@ module VCAP::CloudController let(:update_attrs) { { 'name' => service_instance.name } } it 'succeeds' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to eq(true) + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to eq(true) end end end @@ -255,7 +255,7 @@ module VCAP::CloudController let(:update_attrs) { { 'maintenance_info' => { 'version' => '1.0.0' } } } it 'succeeds' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to eq(true) + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to eq(true) end end @@ -265,7 +265,7 @@ module VCAP::CloudController it 'errors' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error( CloudController::Errors::ApiError, 'The service broker does not support upgrades for service instances created from this plan.' @@ -278,7 +278,7 @@ module VCAP::CloudController it 'errors' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error( CloudController::Errors::ApiError, 'maintenance_info.version should be a semantic version.' @@ -294,7 +294,7 @@ module VCAP::CloudController it 'errors' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error( CloudController::Errors::ApiError, 'maintenance_info should not be changed when switching to different plan.' @@ -329,7 +329,7 @@ module VCAP::CloudController it 'errors' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /paid service plans are not allowed/) end end @@ -339,11 +339,11 @@ module VCAP::CloudController let(:update_attrs) { { 'service_plan_guid' => new_service_plan.guid } } it 'succeeds' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to eq(true) + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to eq(true) end it 'does not update the plan on the service instance' do - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) expect(service_instance.service_plan).to eq(old_service_plan) expect(service_instance.reload.service_plan).to eq(old_service_plan) end @@ -355,13 +355,13 @@ module VCAP::CloudController it 'errors' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /paid service plans are not allowed/) end it 'does not update the plan on the service instance' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError) expect(service_instance.service_plan).to eq(old_service_plan) @@ -375,7 +375,7 @@ module VCAP::CloudController let(:update_attrs) { { 'service_plan_guid' => new_service_plan.guid } } it 'succeeds for paid plans' do - expect(ServiceUpdateValidator.validate!(service_instance, args)).to eq(true) + expect(ServiceUpdateValidator.validate!(service_instance, **args)).to eq(true) end end end @@ -399,7 +399,7 @@ module VCAP::CloudController it 'raises a validation error' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /Cannot update parameters of a service instance that belongs to inaccessible plan/) end end @@ -410,7 +410,7 @@ module VCAP::CloudController it 'raises a validation error' do expect { - ServiceUpdateValidator.validate!(service_instance, args) + ServiceUpdateValidator.validate!(service_instance, **args) }.to raise_error(CloudController::Errors::ApiError, /Cannot update parameters of a service instance that belongs to inaccessible plan/) end end diff --git a/spec/unit/controllers/v3/packages_controller_spec.rb b/spec/unit/controllers/v3/packages_controller_spec.rb index cd089643d72..d935c51e538 100644 --- a/spec/unit/controllers/v3/packages_controller_spec.rb +++ b/spec/unit/controllers/v3/packages_controller_spec.rb @@ -313,7 +313,7 @@ context 'when the package is stored in an image registry' do before do - TestConfig.override({ packages: { image_registry: { base_path: 'hub.example.com/user' } } }) + TestConfig.override(packages: { image_registry: { base_path: 'hub.example.com/user' } }) end it 'returns 422' do @@ -1306,7 +1306,7 @@ context 'when the package is stored in an image registry' do before do - TestConfig.override({ packages: { image_registry: { base_path: 'hub.example.com/user' } } }) + TestConfig.override(packages: { image_registry: { base_path: 'hub.example.com/user' } }) end it 'returns 422' do diff --git a/spec/unit/jobs/enqueuer_spec.rb b/spec/unit/jobs/enqueuer_spec.rb index baf60ac8b0f..1ef302dc0b8 100644 --- a/spec/unit/jobs/enqueuer_spec.rb +++ b/spec/unit/jobs/enqueuer_spec.rb @@ -18,7 +18,7 @@ module VCAP::CloudController::Jobs let(:global_timeout) { 5.hours } before do - TestConfig.override(config_override) + TestConfig.override(**config_override) end shared_examples_for 'a job enqueueing method' do diff --git a/spec/unit/jobs/runtime/buildpack_cache_cleanup_spec.rb b/spec/unit/jobs/runtime/buildpack_cache_cleanup_spec.rb index 8718014ec82..609b4c0c4bb 100644 --- a/spec/unit/jobs/runtime/buildpack_cache_cleanup_spec.rb +++ b/spec/unit/jobs/runtime/buildpack_cache_cleanup_spec.rb @@ -35,7 +35,7 @@ module Jobs::Runtime end before do - TestConfig.override(blobstore_config) + TestConfig.override(**blobstore_config) end let(:blobstore) do diff --git a/spec/unit/jobs/services/service_binding_state_fetch_spec.rb b/spec/unit/jobs/services/service_binding_state_fetch_spec.rb index db567474e79..b4016794824 100644 --- a/spec/unit/jobs/services/service_binding_state_fetch_spec.rb +++ b/spec/unit/jobs/services/service_binding_state_fetch_spec.rb @@ -28,10 +28,10 @@ module Services end before do - TestConfig.override({ + TestConfig.override( broker_client_default_async_poll_interval_seconds: default_polling_interval, broker_client_max_async_poll_duration_minutes: max_duration, - }) + ) end def run_job(job) @@ -408,7 +408,7 @@ def run_job(job) context 'when the last_operation is replaced with delete in progress' do before do - service_binding.save_with_new_operation(type: 'delete', state: 'in progress') + service_binding.save_with_new_operation({ type: 'delete', state: 'in progress' }) end it 'is able to run the job again' do diff --git a/spec/unit/jobs/services/service_instance_state_fetch_spec.rb b/spec/unit/jobs/services/service_instance_state_fetch_spec.rb index 02e1cf17705..dea185f8a2e 100644 --- a/spec/unit/jobs/services/service_instance_state_fetch_spec.rb +++ b/spec/unit/jobs/services/service_instance_state_fetch_spec.rb @@ -69,7 +69,7 @@ def run_job(job) broker_client_default_async_poll_interval_seconds: default_polling_interval, broker_client_max_async_poll_duration_minutes: max_duration, } - TestConfig.override(config_override) + TestConfig.override(**config_override) end context 'when the caller does not provide the maximum number of attempts' do diff --git a/spec/unit/jobs/v3/buildpack_cache_cleanup_spec.rb b/spec/unit/jobs/v3/buildpack_cache_cleanup_spec.rb index 598a3c0fa92..ca45e8a7e46 100644 --- a/spec/unit/jobs/v3/buildpack_cache_cleanup_spec.rb +++ b/spec/unit/jobs/v3/buildpack_cache_cleanup_spec.rb @@ -35,7 +35,7 @@ module Jobs::V3 end before do - TestConfig.override(blobstore_config) + TestConfig.override(**blobstore_config) end let(:blobstore) do diff --git a/spec/unit/jobs/v3/create_service_instance_job_spec.rb b/spec/unit/jobs/v3/create_service_instance_job_spec.rb index 90ffec9d42f..720083cfdf7 100644 --- a/spec/unit/jobs/v3/create_service_instance_job_spec.rb +++ b/spec/unit/jobs/v3/create_service_instance_job_spec.rb @@ -128,9 +128,9 @@ module V3 context 'computes the maximum duration' do before do - TestConfig.override({ + TestConfig.override( broker_client_max_async_poll_duration_minutes: 90009 - }) + ) job.perform end @@ -251,7 +251,7 @@ def test_retry_after(value, expected) context 'the maximum duration' do it 'recomputes the value' do job.maximum_duration_seconds = 90009 - TestConfig.override({ broker_client_max_async_poll_duration_minutes: 8088 }) + TestConfig.override(broker_client_max_async_poll_duration_minutes: 8088) job.perform diff --git a/spec/unit/jobs/v3/delete_service_instance_job_spec.rb b/spec/unit/jobs/v3/delete_service_instance_job_spec.rb index c61c3acab35..64d1f0ec09a 100644 --- a/spec/unit/jobs/v3/delete_service_instance_job_spec.rb +++ b/spec/unit/jobs/v3/delete_service_instance_job_spec.rb @@ -64,9 +64,9 @@ module V3 context 'computes the maximum duration' do before do - TestConfig.override({ + TestConfig.override( broker_client_max_async_poll_duration_minutes: 90009 - }) + ) job.perform end @@ -124,7 +124,7 @@ module V3 context 'the maximum duration' do it 'recomputes the value' do job.maximum_duration_seconds = 90009 - TestConfig.override({ broker_client_max_async_poll_duration_minutes: 8088 }) + TestConfig.override(broker_client_max_async_poll_duration_minutes: 8088) job.perform expect(job.maximum_duration_seconds).to eq(8088.minutes) end diff --git a/spec/unit/jobs/v3/update_service_instance_job_spec.rb b/spec/unit/jobs/v3/update_service_instance_job_spec.rb index 1060193e829..04fced1dabd 100644 --- a/spec/unit/jobs/v3/update_service_instance_job_spec.rb +++ b/spec/unit/jobs/v3/update_service_instance_job_spec.rb @@ -149,9 +149,9 @@ module V3 context 'computes the maximum duration' do before do - TestConfig.override({ + TestConfig.override( broker_client_max_async_poll_duration_minutes: 90009 - }) + ) job.perform end @@ -268,7 +268,7 @@ def test_retry_after(value, expected) context 'the maximum duration' do it 'recomputes the value' do job.maximum_duration_seconds = 90009 - TestConfig.override({ broker_client_max_async_poll_duration_minutes: 8088 }) + TestConfig.override(broker_client_max_async_poll_duration_minutes: 8088) job.perform diff --git a/spec/unit/lib/cloud_controller/bits_expiration_spec.rb b/spec/unit/lib/cloud_controller/bits_expiration_spec.rb index 7cba95a8ff8..a1257b44a5a 100644 --- a/spec/unit/lib/cloud_controller/bits_expiration_spec.rb +++ b/spec/unit/lib/cloud_controller/bits_expiration_spec.rb @@ -12,17 +12,17 @@ module VCAP::CloudController end let(:config) do - Config.new( + Config.new({ packages: { max_valid_packages_stored: 5 }, droplets: { max_staged_droplets_stored: 5 } - ) + }) end let(:changed_config) do - Config.new( + Config.new({ packages: { max_valid_packages_stored: 10 }, droplets: { max_staged_droplets_stored: 10 } - ) + }) end it 'is configurable' do diff --git a/spec/unit/lib/cloud_controller/clock/clock_spec.rb b/spec/unit/lib/cloud_controller/clock/clock_spec.rb index 2511578fdb7..e5dbe1b70da 100644 --- a/spec/unit/lib/cloud_controller/clock/clock_spec.rb +++ b/spec/unit/lib/cloud_controller/clock/clock_spec.rb @@ -37,7 +37,7 @@ def initialize(*args); end at: time, priority: priority } - clock.schedule_daily_job(clock_opts) { some_job_class.new } + clock.schedule_daily_job(**clock_opts) { some_job_class.new } expected_job_opts = { queue: job_name, priority: 0 } expect(Jobs::Enqueuer).to have_received(:new).with(instance_of(some_job_class), expected_job_opts) @@ -66,7 +66,7 @@ def initialize(*args); end at: time, priority: priority } - clock.schedule_daily_job(clock_opts) { some_job_class.new } + clock.schedule_daily_job(**clock_opts) { some_job_class.new } expected_job_opts = { queue: job_name, priority: priority } expect(Jobs::Enqueuer).to have_received(:new).with(instance_of(some_job_class), expected_job_opts) @@ -93,7 +93,7 @@ def initialize(*args); end name: job_name, interval: interval, } - clock.schedule_frequent_worker_job(clock_opts) { some_job_class.new } + clock.schedule_frequent_worker_job(**clock_opts) { some_job_class.new } expected_job_opts = { queue: job_name } expect(Jobs::Enqueuer).to have_received(:new).with(instance_of(some_job_class), expected_job_opts) @@ -123,7 +123,7 @@ def initialize(*args); end interval: interval, timeout: timeout, } - clock.schedule_frequent_inline_job(clock_opts) { some_job_class.new } + clock.schedule_frequent_inline_job(**clock_opts) { some_job_class.new } expected_job_opts = { queue: job_name } expect(Jobs::Enqueuer).to have_received(:new).with(instance_of(some_job_class), expected_job_opts) diff --git a/spec/unit/lib/cloud_controller/clock/scheduler_spec.rb b/spec/unit/lib/cloud_controller/clock/scheduler_spec.rb index ab93647b86a..ba0b90bdd8b 100644 --- a/spec/unit/lib/cloud_controller/clock/scheduler_spec.rb +++ b/spec/unit/lib/cloud_controller/clock/scheduler_spec.rb @@ -12,7 +12,7 @@ module VCAP::CloudController before do allow(Clock).to receive(:new).with(no_args).and_return(clock) allow(Clockwork).to receive(:run) - TestConfig.override({ + TestConfig.override( jobs: { global: { timeout_in_seconds: global_timeout }, }, @@ -27,7 +27,7 @@ module VCAP::CloudController max_retained_deployments_per_app: 15, max_retained_builds_per_app: 15, max_retained_revisions_per_app: 15, - }) + ) end it 'configures Clockwork with a logger' do @@ -176,9 +176,9 @@ module VCAP::CloudController context 'when the diego sync frequency is zero' do before do - TestConfig.override({ + TestConfig.override( diego_sync: { frequency_in_seconds: 0 }, - }) + ) end it 'does not run diego sync' do diff --git a/spec/unit/lib/cloud_controller/dependency_locator_spec.rb b/spec/unit/lib/cloud_controller/dependency_locator_spec.rb index b48ab67e4b5..1728e1d515e 100644 --- a/spec/unit/lib/cloud_controller/dependency_locator_spec.rb +++ b/spec/unit/lib/cloud_controller/dependency_locator_spec.rb @@ -18,12 +18,12 @@ describe '#droplet_blobstore' do let(:config) do - VCAP::CloudController::Config.new( + VCAP::CloudController::Config.new({ droplets: { fog_connection: 'fog_connection', droplet_directory_key: 'key', }, - ) + }) end it 'creates blob store' do @@ -33,13 +33,13 @@ end context('when bits service is enabled') do - let(:config) do VCAP::CloudController::Config.new( + let(:config) do VCAP::CloudController::Config.new({ droplets: { fog_connection: 'fog_connection', droplet_directory_key: 'key', }, bits_service: bits_service_config - ) + }) end it 'creates the client with the right arguments' do @@ -52,12 +52,12 @@ describe '#buildpack_cache_blobstore' do let(:config) do - VCAP::CloudController::Config.new( + VCAP::CloudController::Config.new({ droplets: { fog_connection: 'fog_connection', droplet_directory_key: 'key', } - ) + }) end it 'creates blob store' do @@ -71,13 +71,13 @@ context('when bits service is enabled') do let(:config) do - VCAP::CloudController::Config.new( + VCAP::CloudController::Config.new({ droplets: { fog_connection: 'fog_connection', droplet_directory_key: 'key', }, bits_service: bits_service_config - ) +}) end it 'creates the client with the right arguments' do @@ -90,12 +90,12 @@ describe '#package_blobstore' do let(:config) do - VCAP::CloudController::Config.new( + VCAP::CloudController::Config.new({ packages: { fog_connection: 'fog_connection', app_package_directory_key: 'key', } - ) + }) end it 'creates blob store' do @@ -106,12 +106,12 @@ context('when bits service is enabled') do let(:config) do - VCAP::CloudController::Config.new( + VCAP::CloudController::Config.new({ packages: { app_package_directory_key: 'key' }, bits_service: bits_service_config - ) + }) end it 'creates the client with the right arguments' do @@ -124,12 +124,12 @@ describe '#legacy_global_app_bits_cache' do let(:config) do - VCAP::CloudController::Config.new( + VCAP::CloudController::Config.new({ resource_pool: { fog_connection: 'fog_connection', resource_directory_key: 'key', } - ) + }) end it 'creates blob store' do @@ -143,12 +143,12 @@ describe '#global_app_bits_cache' do let(:config) do - VCAP::CloudController::Config.new( + VCAP::CloudController::Config.new({ resource_pool: { fog_connection: 'fog_connection', resource_directory_key: 'key', } - ) + }) end it 'creates blob store with a app_bits_cache as root_dir' do @@ -178,7 +178,7 @@ end before do - TestConfig.override(my_config) + TestConfig.override(**my_config) end it 'creates blobstore_url_generator with the internal_service_hostname, port, and blobstores' do @@ -210,7 +210,7 @@ end before do - TestConfig.override(my_config) + TestConfig.override(**my_config) end it 'creates droplet_url_generator with the internal_service_hostname, ports, and diego flag' do @@ -491,9 +491,7 @@ it 'returns the tc-decorated client without TLS' do TestConfig.override( - { - logcache_tls: nil - } + logcache_tls: nil ) expect(locator.traffic_controller_compatible_logcache_client).to be_an_instance_of(Logcache::TrafficControllerDecorator) expect(Logcache::Client).to have_received(:new).with( @@ -508,17 +506,15 @@ it 'returns the tc-decorated client with TLS certificates' do TestConfig.override( - { - logcache: { - host: 'some-logcache-host', - port: 1234, - }, - logcache_tls: { - ca_file: 'logcache-ca', - cert_file: 'logcache-client-ca', - key_file: 'logcache-client-key', - subject_name: 'some-tls-cert-san' - } + logcache: { + host: 'some-logcache-host', + port: 1234, + }, + logcache_tls: { + ca_file: 'logcache-ca', + cert_file: 'logcache-client-ca', + key_file: 'logcache-client-key', + subject_name: 'some-tls-cert-san' } ) expect(locator.traffic_controller_compatible_logcache_client).to be_an_instance_of(Logcache::TrafficControllerDecorator) @@ -538,15 +534,13 @@ before do TestConfig.override( - { - copilot: { - enabled: true, - host: 'some-host', - port: 1234, - client_ca_file: 'some-client-ca-file', - client_key_file: 'some-client-key-file', - client_chain_file: 'some-client-chain-file' - } + copilot: { + enabled: true, + host: 'some-host', + port: 1234, + client_ca_file: 'some-client-ca-file', + client_key_file: 'some-client-key-file', + client_chain_file: 'some-client-chain-file' } ) end @@ -568,10 +562,10 @@ host = 'test-host' port = 1234 - TestConfig.override({ + TestConfig.override( statsd_host: host, statsd_port: port, - }) + ) expected_client = double(Statsd) @@ -599,13 +593,13 @@ context 'opi staging is enabled' do before do - TestConfig.override({ + TestConfig.override( opi: { enabled: true, url: 'http://custom-opi-url.service.cf.internal', opi_staging: true } - }) + ) end it 'uses opi' do @@ -633,7 +627,7 @@ context 'opi is enabled' do before do - TestConfig.override({ + TestConfig.override(**{ opi: { enabled: true, url: 'http://custom-opi-url.service.cf.internal' @@ -651,7 +645,7 @@ context 'experimental crds are enabled' do before do - TestConfig.override({ + TestConfig.override(**{ opi: { enabled: true, experimental_enable_crds: true, @@ -685,12 +679,12 @@ context 'opi is enabled' do before do - TestConfig.override({ + TestConfig.override( opi: { enabled: true, url: 'http://custom-opi-url.service.cf.internal' } - }) + ) allow(::Diego::Client).to receive(:new) end @@ -724,12 +718,12 @@ context 'opi is enabled' do before do - TestConfig.override({ + TestConfig.override( opi: { enabled: true, url: 'http://custom-opi-url.service.cf.internal' } - }) + ) allow(::Diego::Client).to receive(:new) end @@ -758,7 +752,7 @@ token_file.write('token') token_file.close - TestConfig.override(generate_test_kubeconfig) + TestConfig.override(**generate_test_kubeconfig) end it 'creates a k8s client from config' do diff --git a/spec/unit/lib/cloud_controller/diego/lifecycle_bundle_uri_generator_spec.rb b/spec/unit/lib/cloud_controller/diego/lifecycle_bundle_uri_generator_spec.rb index 9774b9b1b51..89a29cf8c7f 100644 --- a/spec/unit/lib/cloud_controller/diego/lifecycle_bundle_uri_generator_spec.rb +++ b/spec/unit/lib/cloud_controller/diego/lifecycle_bundle_uri_generator_spec.rb @@ -4,7 +4,7 @@ module VCAP::CloudController module Diego RSpec.describe LifecycleBundleUriGenerator do before do - TestConfig.override({ diego: { file_server_url: 'https://file-server.example.com:1234' } }) + TestConfig.override(diego: { file_server_url: 'https://file-server.example.com:1234' }) end it 'creates a file server url for a bundle path' do diff --git a/spec/unit/lib/cloud_controller/diego/task_completion_callback_generator_spec.rb b/spec/unit/lib/cloud_controller/diego/task_completion_callback_generator_spec.rb index 284f90d0dab..fd0cf1d46e7 100644 --- a/spec/unit/lib/cloud_controller/diego/task_completion_callback_generator_spec.rb +++ b/spec/unit/lib/cloud_controller/diego/task_completion_callback_generator_spec.rb @@ -19,7 +19,7 @@ module Diego end before do - TestConfig.override(task_config) + TestConfig.override(**task_config) end context 'when CC is responsible for syncing with Diego' do diff --git a/spec/unit/lib/cloud_controller/install_buildpacks_spec.rb b/spec/unit/lib/cloud_controller/install_buildpacks_spec.rb index 1216103005f..7b9d8e04bad 100644 --- a/spec/unit/lib/cloud_controller/install_buildpacks_spec.rb +++ b/spec/unit/lib/cloud_controller/install_buildpacks_spec.rb @@ -22,7 +22,7 @@ module VCAP::CloudController let(:enqueued_job2) { double(:enqueued_job2, perform: nil) } before do - TestConfig.override(install_buildpack_config) + TestConfig.override(**install_buildpack_config) allow(Buildpacks::StackNameExtractor).to receive(:extract_from_file) allow(installer.logger).to receive(:error) diff --git a/spec/unit/lib/cloud_controller/seeds_spec.rb b/spec/unit/lib/cloud_controller/seeds_spec.rb index bd7d83cfc0c..fb47fa45ad3 100644 --- a/spec/unit/lib/cloud_controller/seeds_spec.rb +++ b/spec/unit/lib/cloud_controller/seeds_spec.rb @@ -42,7 +42,7 @@ module VCAP::CloudController context 'and the name changes' do it 'sets the name of the shared segment to the new value' do expect { - Seeds.create_seed_shared_isolation_segment(Config.new(shared_isolation_segment_name: 'original-name')) + Seeds.create_seed_shared_isolation_segment(Config.new({ shared_isolation_segment_name: 'original-name' })) }.to_not change { IsolationSegmentModel.count } shared_isolation_segment_model = IsolationSegmentModel.first @@ -57,7 +57,7 @@ module VCAP::CloudController # redeploy with what the old 'shared' isolation segment name it 'raises some kind of error TBD' do expect { - Seeds.create_seed_shared_isolation_segment(Config.new(shared_isolation_segment_name: isolation_segment_model.name)) + Seeds.create_seed_shared_isolation_segment(Config.new({ shared_isolation_segment_name: isolation_segment_model.name })) }.to raise_error(Sequel::ValidationFailed, /must be unique/) end end @@ -67,7 +67,7 @@ module VCAP::CloudController describe '.create_seed_quota_definitions' do let(:config) do - Config.new( + Config.new({ quota_definitions: { 'small' => { non_basic_services_allowed: false, @@ -85,7 +85,7 @@ module VCAP::CloudController }, }, default_quota_definition: 'default', - ) + }) end before do @@ -218,7 +218,7 @@ module VCAP::CloudController describe '.create_seed_domains' do let(:config) do - Config.new( + Config.new({ app_domains: app_domains, system_domain: system_domain, system_domain_organization: 'the-system-org', @@ -231,7 +231,7 @@ module VCAP::CloudController }, }, default_quota_definition: 'default' - ) + }) end let(:system_org) { Organization.find(name: 'the-system-org') } let(:system_domain) { 'system.example.com' } @@ -412,7 +412,7 @@ module VCAP::CloudController describe '.create_seed_security_groups' do let(:config) do - Config.new( + Config.new({ security_group_definitions: [ { 'name' => 'staging_default', @@ -429,7 +429,7 @@ module VCAP::CloudController ], default_staging_security_groups: ['staging_default'], default_running_security_groups: ['running_default'] - ) + }) end context 'when there are no security groups configured in the system' do diff --git a/spec/unit/lib/kubernetes/kube_client_builder_spec.rb b/spec/unit/lib/kubernetes/kube_client_builder_spec.rb index 48eef889e9d..4d189031a68 100644 --- a/spec/unit/lib/kubernetes/kube_client_builder_spec.rb +++ b/spec/unit/lib/kubernetes/kube_client_builder_spec.rb @@ -12,7 +12,7 @@ end it 'loads kubernetes creds from the config' do - client = Kubernetes::KubeClientBuilder.build(kubernetes_creds) + client = Kubernetes::KubeClientBuilder.build(**kubernetes_creds) expect(client.ssl_options).to eq({ ca: 'k8s_node_ca' @@ -36,7 +36,7 @@ } it 'raises an error' do - expect { Kubernetes::KubeClientBuilder.build(kubernetes_creds) }.to raise_error(Kubernetes::KubeClientBuilder::MissingCredentialsError) + expect { Kubernetes::KubeClientBuilder.build(**kubernetes_creds) }.to raise_error(Kubernetes::KubeClientBuilder::MissingCredentialsError) end end end diff --git a/spec/unit/lib/services/service_brokers/v2/client_spec.rb b/spec/unit/lib/services/service_brokers/v2/client_spec.rb index fd92bfd6c3b..0af5b22a958 100644 --- a/spec/unit/lib/services/service_brokers/v2/client_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/client_spec.rb @@ -1710,7 +1710,7 @@ module VCAP::Services::ServiceBrokers::V2 it 'propagates the error and does not issue an unbind' do expect { - client.bind(binding, arbitrary_parameters) + client.bind(binding, **arbitrary_parameters) }.to raise_error(Errors::ConcurrencyError) expect(orphan_mitigator).not_to have_received(:cleanup_failed_bind) diff --git a/spec/unit/lib/services/service_brokers/v2/http_client_spec.rb b/spec/unit/lib/services/service_brokers/v2/http_client_spec.rb index 3680bf89800..4a971d57212 100644 --- a/spec/unit/lib/services/service_brokers/v2/http_client_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/http_client_spec.rb @@ -118,7 +118,7 @@ module VCAP::Services::ServiceBrokers::V2 let(:ssl_config) { double(:ssl_config, :verify_mode= => nil) } before do - TestConfig.override(config) + TestConfig.override(**config) allow(HTTPClient).to receive(:new).and_return(http_client) allow(http_client).to receive(http_method) allow(ssl_config).to receive(:set_default_paths) @@ -270,7 +270,7 @@ module VCAP::Services::ServiceBrokers::V2 shared_examples 'timeout behavior' do before do - TestConfig.override(config) + TestConfig.override(**config) allow(HTTPClient).to receive(:new).and_return(http_client) allow(http_client).to receive(http_method) end diff --git a/spec/unit/lib/services/service_brokers/v2/response_parser_spec.rb b/spec/unit/lib/services/service_brokers/v2/response_parser_spec.rb index 42e16feb11f..0e8d38ae25e 100644 --- a/spec/unit/lib/services/service_brokers/v2/response_parser_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/response_parser_spec.rb @@ -13,7 +13,7 @@ module V2 end class InnerValidator - def validate(_broker_response) + def validate(**_broker_response) raise NotImpementedError.new('implement this in the spec') end end @@ -45,15 +45,15 @@ def validate(_broker_response) context 'when the broker response body is valid' do let(:broker_response_body) { '{}' } it 'does not raise' do - expect { json_validator.validate(broker_response.to_hash) }.not_to raise_error + expect { json_validator.validate(**broker_response.to_hash) }.not_to raise_error end it 'returns the inner validator result' do - expect(json_validator.validate(broker_response.to_hash)).to eql('inner-validator-result') + expect(json_validator.validate(**broker_response.to_hash)).to eql('inner-validator-result') end it 'calls the inner validator with the same parameters it was passed' do - json_validator.validate(broker_response.to_hash) + json_validator.validate(**broker_response.to_hash) expect(inner_validator).to have_received(:validate).with(broker_response.to_hash) end end @@ -63,7 +63,7 @@ def validate(_broker_response) context "and the response body is #{body}" do let(:broker_response_body) { body } it 'raises' do - expect { json_validator.validate(broker_response.to_hash) }.to raise_error(Errors::ServiceBrokerResponseMalformed) do |e| + expect { json_validator.validate(**broker_response.to_hash) }.to raise_error(Errors::ServiceBrokerResponseMalformed) do |e| expect(e.to_h['description']).to eq( "The service broker returned an invalid response: expected valid JSON object in body, broker returned '#{body}'") expect(e.response_code).to eq(502) @@ -78,7 +78,7 @@ def validate(_broker_response) let(:broker_response_body) { 'invalid' } it 'logs the error' do begin - json_validator.validate(broker_response.to_hash) + json_validator.validate(**broker_response.to_hash) rescue # this is tested above end @@ -114,7 +114,7 @@ def validate(_broker_response) } it 'raises a ServiceBrokerResponseMalformed error' do - expect { json_validator.validate(broker_response.to_hash) }.to raise_error(Errors::ServiceBrokerResponseMalformed) do |e| + expect { json_validator.validate(**broker_response.to_hash) }.to raise_error(Errors::ServiceBrokerResponseMalformed) do |e| description_lines = e.to_h['description'].split("\n") expect(description_lines[0]).to eq('The service broker returned an invalid response: ') expect(description_lines.drop(1)).to contain_exactly("The property '#/' did not contain a required property of 'prop2'") @@ -132,7 +132,7 @@ def validate(_broker_response) } it 'raises a ServiceBrokerResponseMalformed error' do - expect { json_validator.validate(broker_response.to_hash) }.to raise_error(Errors::ServiceBrokerResponseMalformed) do |e| + expect { json_validator.validate(**broker_response.to_hash) }.to raise_error(Errors::ServiceBrokerResponseMalformed) do |e| description_lines = e.to_h['description'].split("\n") expect(description_lines[0]).to eq('The service broker returned an invalid response: ') expect(description_lines.drop(1)).to contain_exactly( diff --git a/spec/unit/middleware/rate_limiter_spec.rb b/spec/unit/middleware/rate_limiter_spec.rb index dc1c820f400..cf05f3eb62d 100644 --- a/spec/unit/middleware/rate_limiter_spec.rb +++ b/spec/unit/middleware/rate_limiter_spec.rb @@ -6,12 +6,14 @@ module Middleware let(:middleware) do RateLimiter.new( app, - logger: logger, - per_process_general_limit: per_process_general_limit, - global_general_limit: global_general_limit, - per_process_unauthenticated_limit: per_process_unauthenticated_limit, - global_unauthenticated_limit: global_unauthenticated_limit, - interval: interval, + { + logger: logger, + per_process_general_limit: per_process_general_limit, + global_general_limit: global_general_limit, + per_process_unauthenticated_limit: per_process_unauthenticated_limit, + global_unauthenticated_limit: global_unauthenticated_limit, + interval: interval, + } ) end let(:request_counter) { double } diff --git a/spec/unit/models/runtime/app_model_spec.rb b/spec/unit/models/runtime/app_model_spec.rb index 643e73cb2e3..8857dc2ed26 100644 --- a/spec/unit/models/runtime/app_model_spec.rb +++ b/spec/unit/models/runtime/app_model_spec.rb @@ -396,7 +396,7 @@ module VCAP::CloudController context 'when default_app_ssh_access is true' do before do - TestConfig.override({ default_app_ssh_access: true }) + TestConfig.override(default_app_ssh_access: true) end it 'sets enable_ssh to true' do @@ -407,7 +407,7 @@ module VCAP::CloudController context 'when default_app_ssh_access is false' do before do - TestConfig.override({ default_app_ssh_access: false }) + TestConfig.override(default_app_ssh_access: false) end it 'sets enable_ssh to false' do @@ -507,7 +507,7 @@ module VCAP::CloudController describe 'encryption' do context 'when not saving any encrypted fields, with db keys' do it 'still updates the encryption-key value' do - TestConfig.override({ database_encryption: { current_key_label: nil, keys: {} } }) + TestConfig.override(database_encryption: { current_key_label: nil, keys: {} }) app = AppModel.create(name: 'jimmy') expect(app.encryption_key_label).to be_nil @@ -516,7 +516,7 @@ module VCAP::CloudController app.reload expect(app.encryption_key_label).to be_nil - TestConfig.override({ database_encryption: { current_key_label: 'k2', keys: { k1: 'moose' } } }) + TestConfig.override(database_encryption: { current_key_label: 'k2', keys: { k1: 'moose' } }) app.environment_variables = app.environment_variables.merge({ 'building' => 'outhouse' }) app.save app.reload diff --git a/spec/unit/models/runtime/constraints/health_check_policy_spec.rb b/spec/unit/models/runtime/constraints/health_check_policy_spec.rb index 8be5e763070..fbc51a28f91 100644 --- a/spec/unit/models/runtime/constraints/health_check_policy_spec.rb +++ b/spec/unit/models/runtime/constraints/health_check_policy_spec.rb @@ -10,7 +10,7 @@ describe 'health_check_timeout' do before do - TestConfig.override({ maximum_health_check_timeout: max_health_check_timeout }) + TestConfig.override(maximum_health_check_timeout: max_health_check_timeout) end context 'when a health_check_timeout exceeds the maximum' do diff --git a/spec/unit/models/runtime/package_model_spec.rb b/spec/unit/models/runtime/package_model_spec.rb index 51ef083b0e1..d2fe465b203 100644 --- a/spec/unit/models/runtime/package_model_spec.rb +++ b/spec/unit/models/runtime/package_model_spec.rb @@ -28,7 +28,7 @@ module VCAP::CloudController context 'when using a package registry' do before do - TestConfig.override({ packages: { image_registry: { base_path: 'hub.example.com/user' } } }) + TestConfig.override(packages: { image_registry: { base_path: 'hub.example.com/user' } }) end it 'returns the image reference for the package' do diff --git a/spec/unit/models/runtime/process_model_spec.rb b/spec/unit/models/runtime/process_model_spec.rb index 25006966f81..7049f84707c 100644 --- a/spec/unit/models/runtime/process_model_spec.rb +++ b/spec/unit/models/runtime/process_model_spec.rb @@ -10,11 +10,11 @@ module VCAP::CloudController let(:route) { Route.make(domain: domain, space: space) } def enable_custom_buildpacks - TestConfig.override({ disable_custom_buildpacks: nil }) + TestConfig.override(disable_custom_buildpacks: nil) end def disable_custom_buildpacks - TestConfig.override({ disable_custom_buildpacks: true }) + TestConfig.override(disable_custom_buildpacks: true) end def expect_validator(validator_class) @@ -910,7 +910,7 @@ def act_as_cf_admin describe 'health_check_timeout' do before do - TestConfig.override({ maximum_health_check_timeout: 512 }) + TestConfig.override(maximum_health_check_timeout: 512) end context 'when the health_check_timeout was not specified' do @@ -1303,7 +1303,7 @@ def act_as_cf_admin describe 'default_app_memory' do before do - TestConfig.override({ default_app_memory: 200 }) + TestConfig.override(default_app_memory: 200) end it 'uses the provided memory' do @@ -1319,7 +1319,7 @@ def act_as_cf_admin describe 'default disk_quota' do before do - TestConfig.override({ default_app_disk_in_mb: 512 }) + TestConfig.override(default_app_disk_in_mb: 512) end it 'should use the provided quota' do @@ -1335,7 +1335,7 @@ def act_as_cf_admin describe 'instance_file_descriptor_limit' do before do - TestConfig.override({ instance_file_descriptor_limit: 200 }) + TestConfig.override(instance_file_descriptor_limit: 200) end it 'uses the instance_file_descriptor_limit config variable' do diff --git a/spec/unit/models/runtime/shared_domain_spec.rb b/spec/unit/models/runtime/shared_domain_spec.rb index 683afcc297b..3a154f6c7b6 100644 --- a/spec/unit/models/runtime/shared_domain_spec.rb +++ b/spec/unit/models/runtime/shared_domain_spec.rb @@ -223,7 +223,7 @@ module VCAP::CloudController context 'and the domain is internal' do it 'raises an error' do attrs = { name: 'some-domain.com', router_group_guid: 'some-guid', internal: true } - expect { SharedDomain.find_or_create(attrs) }.to raise_error do |e| + expect { SharedDomain.find_or_create(**attrs) }.to raise_error do |e| expect(e).to be_a(StandardError) expect(e.message).to eq('Error for shared domain name some-domain.com: router_group_guid cannot be specified for internal domains') end @@ -250,7 +250,7 @@ module VCAP::CloudController before_updated_at = existing_domain.updated_at expect { - SharedDomain.find_or_create(attrs.merge(internal: false)) + SharedDomain.find_or_create(**attrs.merge(internal: false)) }.not_to change { existing_domain.reload } expect(fake_logger).to have_received(:warn). with("Domain '#{domain_name}' already exists. Skipping updates of internal status") @@ -268,7 +268,7 @@ module VCAP::CloudController before_updated_at = existing_domain.updated_at expect { - SharedDomain.find_or_create(attrs.merge(internal: true)) + SharedDomain.find_or_create(**attrs.merge(internal: true)) }.not_to change { existing_domain.reload } expect(fake_logger).to have_received(:warn). with("Domain '#{domain_name}' already exists. Skipping updates of internal status") @@ -284,7 +284,7 @@ module VCAP::CloudController before_updated_at = existing_domain.updated_at expect { - SharedDomain.find_or_create(attrs.merge(router_group_guid: 'new rgg')) + SharedDomain.find_or_create(**attrs.merge(router_group_guid: 'new rgg')) }.not_to change { existing_domain.reload } expect(fake_logger).to have_received(:warn). with("Domain '#{domain_name}' already exists. Skipping updates of router_group_guid") @@ -299,7 +299,7 @@ module VCAP::CloudController before_updated_at = existing_domain.updated_at expect { - SharedDomain.find_or_create(attrs) + SharedDomain.find_or_create(**attrs) }.not_to change { existing_domain.reload } expect(existing_domain.updated_at).to eq(before_updated_at) expect(fake_logger).to have_received(:info).with("reusing default serving domain: #{domain_name}") diff --git a/spec/unit/presenters/v3/service_broker_presenter_spec.rb b/spec/unit/presenters/v3/service_broker_presenter_spec.rb index 9076852b374..baf71f7c8ef 100644 --- a/spec/unit/presenters/v3/service_broker_presenter_spec.rb +++ b/spec/unit/presenters/v3/service_broker_presenter_spec.rb @@ -10,10 +10,8 @@ module Presenters::V3 before do StubConfig.prepare( self, - { - external_protocol: 'http', - external_domain: 'api.example.org' - } + external_protocol: 'http', + external_domain: 'api.example.org' ) end From e4a024ff52a0e27722b544de61808dacf2907399 Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Wed, 12 Jan 2022 23:55:37 +0000 Subject: [PATCH 3/7] Create wrappers for regexes instead of singleton methods * In Ruby 3.0, regexes are immutable and can't have singleton methods defined Co-authored-by: Seth Boyles Co-authored-by: Mona Mohebbi --- lib/vcap/rest_api/message.rb | 68 +++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/lib/vcap/rest_api/message.rb b/lib/vcap/rest_api/message.rb index df31fb9a713..2746d4f89ad 100644 --- a/lib/vcap/rest_api/message.rb +++ b/lib/vcap/rest_api/message.rb @@ -4,42 +4,62 @@ module VCAP module RestAPI class Message < JsonMessage - # The schema validator used by class `JsonMessage` calls the `inspect` - # method on the regexp object to get a description of the regex. We tweak - # the regexp object so that the `inspect` method generates a readable - # description for us through `VCAP::RestAPI::Message#schema_doc` method. - def self.readable_regexp(regexp, description, default_error_message) - regexp.define_singleton_method(:inspect) do - description + class UrlDecorator < SimpleDelegator + def inspect + 'String /URL_REGEX/' + end + + alias_method :to_s, :inspect + def default_error_message + 'must be a valid URL' end + end - regexp.define_singleton_method(:to_s) do - inspect + class HttpsUrlDecorator < SimpleDelegator + def inspect + 'String /HTTPS_URL_REGEX/' end - regexp.define_singleton_method(:default_error_message) do - default_error_message + alias_method :to_s, :inspect + def default_error_message + 'must be a valid HTTPS URL' + end + end + + class EmailDecorator < SimpleDelegator + def inspect + 'String /EMAIL_REGEX/' end - regexp + alias_method :to_s, :inspect + def default_error_message + 'must be a valid email' + end end + class GitUrlDecorator < SimpleDelegator + def inspect + 'String /GIT_URL_REGEX/' + end + + alias_method :to_s, :inspect + + def default_error_message + 'must be a valid git URL' + end + end + # The schema validator used by class `JsonMessage` calls the `inspect` + # method on the regexp object to get a description of the regex. We tweak + # the regexp object so that the `inspect` method generates a readable + # description for us through `VCAP::RestAPI::Message#schema_doc` method. def self.schema_doc(schema) schema.deparse end - URL = readable_regexp(URI::DEFAULT_PARSER.make_regexp(%w(http https)), - 'String /URL_REGEX/', - 'must be a valid URL') - HTTPS_URL = readable_regexp(URI::DEFAULT_PARSER.make_regexp('https'), - 'String /HTTPS_URL_REGEX/', - 'must be a valid HTTPS URL') - EMAIL = readable_regexp(RFC822::EMAIL_REGEXP_WHOLE, - 'String /EMAIL_REGEX/', - 'must be a valid email') - GIT_URL = readable_regexp(URI::DEFAULT_PARSER.make_regexp(%w(http https git)), - 'String /GIT_URL_REGEX/', - 'must be a valid git URL') + URL = UrlDecorator.new(URI::DEFAULT_PARSER.make_regexp(%w(http https))) + HTTPS_URL = HttpsUrlDecorator.new(URI::DEFAULT_PARSER.make_regexp('https')) + EMAIL = EmailDecorator.new(RFC822::EMAIL_REGEXP_WHOLE) + GIT_URL = GitUrlDecorator.new(URI::DEFAULT_PARSER.make_regexp(%w(http https git))) # The block will be evaluated in the context of the schema validator used # by class `JsonMessage` viz. `Membrane`. From de3487a410a28355b8020bcabf7a176b5d48df0c Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Thu, 13 Jan 2022 00:40:37 +0000 Subject: [PATCH 4/7] Some more keyword argument fixes Co-authored-by: Seth Boyles Co-authored-by: Mona Mohebbi --- .../blobstore/fog/error_handling_client.rb | 2 +- middleware/block_v3_only_roles.rb | 4 ++-- middleware/service_broker_rate_limiter.rb | 4 ++-- spec/unit/controllers/v3/builds_controller_spec.rb | 12 +++++------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/cloud_controller/blobstore/fog/error_handling_client.rb b/lib/cloud_controller/blobstore/fog/error_handling_client.rb index 069bf19b96d..34288526078 100644 --- a/lib/cloud_controller/blobstore/fog/error_handling_client.rb +++ b/lib/cloud_controller/blobstore/fog/error_handling_client.rb @@ -43,7 +43,7 @@ def cp_r_to_blobstore(*args) error_handling { wrapped_client.cp_r_to_blobstore(*args) } end - def download_from_blobstore(*args) + def download_from_blobstore(*args, **kwargs) error_handling { wrapped_client.download_from_blobstore(*args) } end diff --git a/middleware/block_v3_only_roles.rb b/middleware/block_v3_only_roles.rb index c7e69162bde..1fb83bd0b62 100644 --- a/middleware/block_v3_only_roles.rb +++ b/middleware/block_v3_only_roles.rb @@ -3,9 +3,9 @@ module CloudFoundry module Middleware class BlockV3OnlyRoles - def initialize(app, logger:) + def initialize(app, opts) @app = app - @logger = logger + @logger = opts[:logger] end def call(env) diff --git a/middleware/service_broker_rate_limiter.rb b/middleware/service_broker_rate_limiter.rb index 1d8f1dbde72..6b0711d114e 100644 --- a/middleware/service_broker_rate_limiter.rb +++ b/middleware/service_broker_rate_limiter.rb @@ -23,9 +23,9 @@ def release(user_guid) end class ServiceBrokerRateLimiter - def initialize(app, logger:) + def initialize(app, opts) @app = app - @logger = logger + @logger = opts[:logger] @request_counter = ServiceBrokerRequestCounter.instance end diff --git a/spec/unit/controllers/v3/builds_controller_spec.rb b/spec/unit/controllers/v3/builds_controller_spec.rb index b6882ea526b..263dc929717 100644 --- a/spec/unit/controllers/v3/builds_controller_spec.rb +++ b/spec/unit/controllers/v3/builds_controller_spec.rb @@ -479,13 +479,11 @@ before do TestConfig.override( - { - staging: { - minimum_staging_memory_mb: 5, - minimum_staging_disk_mb: 5, - }, - maximum_app_disk_in_mb: 10, - } + staging: { + minimum_staging_memory_mb: 5, + minimum_staging_disk_mb: 5, + }, + maximum_app_disk_in_mb: 10, ) end From 3e55c7d10ce1c1ea8150f21e3a75d6f8c9435dec Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Thu, 13 Jan 2022 22:40:41 +0000 Subject: [PATCH 5/7] Fix equality assertion causing test error eql is primarily used as a mathematical equals. Using it here was causing a divison by 0 error due to some confusion. Co-authored-by: Seth Boyles Co-authored-by: Mona Mohebbi --- spec/unit/lib/sinatra/vcap_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/lib/sinatra/vcap_spec.rb b/spec/unit/lib/sinatra/vcap_spec.rb index 358acfef134..5d048465e99 100644 --- a/spec/unit/lib/sinatra/vcap_spec.rb +++ b/spec/unit/lib/sinatra/vcap_spec.rb @@ -58,7 +58,7 @@ def app shared_examples 'http header content type' do it 'should return json content type in the header' do - expect(last_response.headers['Content-Type']).to eql('application/json;charset=utf-8') + expect(last_response.headers['Content-Type']).to eq('application/json;charset=utf-8') end end From 85c0e25bebe9962fb919a629f2de4a4b67afb348 Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Fri, 21 Jan 2022 18:13:36 +0000 Subject: [PATCH 6/7] Update fog-local to 0.8 Authored-by: Seth Boyles --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index b8af3537f99..c8c85a3e127 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -193,7 +193,7 @@ GEM fog-json (1.2.0) fog-core multi_json (~> 1.10) - fog-local (0.6.0) + fog-local (0.8.0) fog-core (>= 1.27, < 3.0) fog-openstack (0.3.10) fog-core (>= 1.45, <= 2.1.0) From 6c63f997f18941526e512420e3cc7b0552e849b1 Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Fri, 21 Jan 2022 22:38:17 +0000 Subject: [PATCH 7/7] Use new way of overriding helpers in Sinatra apps Authored-by: Seth Boyles --- spec/unit/lib/sinatra/vcap_spec.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/unit/lib/sinatra/vcap_spec.rb b/spec/unit/lib/sinatra/vcap_spec.rb index 5d048465e99..8f4d4519bc0 100644 --- a/spec/unit/lib/sinatra/vcap_spec.rb +++ b/spec/unit/lib/sinatra/vcap_spec.rb @@ -13,13 +13,16 @@ def response_code class TestApp < Sinatra::Base register Sinatra::VCAP - vcap_configure logger_name: 'vcap_spec' - def in_test_mode? - false + module TestModeHelpers + def in_test_mode? + false + end end + helpers TestModeHelpers + get '/' do 'ok' end