diff --git a/.ruby-version b/.ruby-version index 34cde5690e1..4d9d11cf505 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.6 +3.4.2 diff --git a/Gemfile b/Gemfile index 81803eb5fea..7914d8fae22 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,7 @@ gem 'loggregator_emitter', '~> 5.0' gem 'membrane', '~> 1.0' gem 'mime-types', '~> 3.6' gem 'multipart-parser' +gem 'mutex_m' gem 'netaddr', '>= 2.0.4' gem 'net-ssh' gem 'newrelic_rpm' @@ -39,10 +40,10 @@ gem 'sinatra-contrib' gem 'sshkey' gem 'statsd-ruby', '~> 1.5.0' gem 'steno' +gem 'syslog' gem 'talentbox-delayed_job_sequel', '~> 4.3.0' gem 'thin' gem 'vmstat', '~> 2.3' - # Rails Components gem 'actionpack', '~> 7.2.2' gem 'actionview', '~> 7.2.1' @@ -59,6 +60,8 @@ gem 'fog-google', '~> 1.24.1' gem 'fog-local' gem 'fog-openstack' +gem 'google-protobuf', '~> 3.25' + gem 'cf-uaa-lib', '~> 4.0.8' group :db do diff --git a/Gemfile.lock b/Gemfile.lock index 8b6eab2e516..205d633cd14 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -224,14 +224,12 @@ GEM google-apis-core (>= 0.11.0, < 2.a) google-cloud-env (1.6.0) faraday (>= 0.17.3, < 3.0) - google-protobuf (3.25.5) - google-protobuf (3.25.5-x86_64-darwin) - google-protobuf (3.25.5-x86_64-linux) + google-protobuf (3.25.6) googleapis-common-protos (1.6.0) google-protobuf (>= 3.18, < 5.a) googleapis-common-protos-types (~> 1.7) grpc (~> 1.41) - googleapis-common-protos-types (1.15.0) + googleapis-common-protos-types (1.19.0) google-protobuf (>= 3.18, < 5.a) googleauth (1.8.1) faraday (>= 0.17.3, < 3.a) @@ -239,14 +237,14 @@ GEM multi_json (~> 1.11) os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) - grpc (1.64.0) - google-protobuf (~> 3.25) + grpc (1.71.0) + google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) - grpc (1.64.0-x86_64-darwin) - google-protobuf (~> 3.25) + grpc (1.71.0-x86_64-darwin) + google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) - grpc (1.64.0-x86_64-linux) - google-protobuf (~> 3.25) + grpc (1.71.0-x86_64-linux) + google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) hashdiff (1.1.2) honeycomb-beeline (3.1.0) @@ -554,6 +552,7 @@ GEM fluent-logger yajl-ruby (~> 1.0) stringio (3.1.2) + syslog (0.1.1) talentbox-delayed_job_sequel (4.3.0) delayed_job (~> 4.1.0) sequel (>= 3.38, < 6.0) @@ -617,6 +616,7 @@ DEPENDENCIES fog-google (~> 1.24.1) fog-local fog-openstack + google-protobuf (~> 3.25) googleapis-common-protos (>= 1.3.12) hashdiff honeycomb-beeline @@ -631,6 +631,7 @@ DEPENDENCIES mime-types (~> 3.6) mock_redis multipart-parser + mutex_m mysql2 (~> 0.5.6) net-ssh netaddr (>= 2.0.4) @@ -676,6 +677,7 @@ DEPENDENCIES sshkey statsd-ruby (~> 1.5.0) steno + syslog talentbox-delayed_job_sequel (~> 4.3.0) thin timecop @@ -683,4 +685,4 @@ DEPENDENCIES webmock (> 2.3.1) BUNDLED WITH - 2.4.10 + 2.6.6 diff --git a/db/migrations/20220601183937_create_asg_lastest_updates.rb b/db/migrations/20220601183937_create_asg_lastest_updates.rb index 750aa7cdc08..239bd4e04ed 100644 --- a/db/migrations/20220601183937_create_asg_lastest_updates.rb +++ b/db/migrations/20220601183937_create_asg_lastest_updates.rb @@ -1,7 +1,7 @@ Sequel.migration do change do create_table :asg_timestamps do - primary_key name: :id + primary_key :id, name: :id Timestamp :last_update end end diff --git a/db/migrations/20221003231438_correct_asg_latest_update_id_column_name.rb b/db/migrations/20221003231438_correct_asg_latest_update_id_column_name.rb index 6e0644db96b..bc13ee75c96 100644 --- a/db/migrations/20221003231438_correct_asg_latest_update_id_column_name.rb +++ b/db/migrations/20221003231438_correct_asg_latest_update_id_column_name.rb @@ -1,7 +1,9 @@ Sequel.migration do - change do - alter_table :asg_timestamps do - rename_column :'{:name=>:id}', :id - end + up do + # no op + end + + down do + # no op end end diff --git a/docs/v3/Gemfile b/docs/v3/Gemfile index f53b702f181..2b5e1481277 100644 --- a/docs/v3/Gemfile +++ b/docs/v3/Gemfile @@ -1,5 +1,6 @@ source 'http://rubygems.org' +gem 'bigdecimal' gem 'json', '>= 2.3.0' gem 'middleman', '~> 4.5' gem 'middleman-autoprefixer', '~> 3.0', '>= 3.0.0' @@ -8,6 +9,7 @@ gem 'middleman-livereload', '>= 3.4.7' gem 'middleman-sprockets', '~> 4.1', '>= 4.1.1' gem 'middleman-syntax', '3.4.0' gem 'mini_racer' +gem 'mutex_m' gem 'nokogiri', '~> 1.18.3' gem 'rake', '>= 12.3.3' gem 'redcarpet', '~> 3.6.1' diff --git a/docs/v3/Gemfile.lock b/docs/v3/Gemfile.lock index 54dfdd6849a..93a7ac7b6e0 100644 --- a/docs/v3/Gemfile.lock +++ b/docs/v3/Gemfile.lock @@ -10,7 +10,7 @@ GEM public_suffix (>= 2.0.2, < 6.0) autoprefixer-rails (10.4.7.0) execjs (~> 2) - backports (3.25.0) + bigdecimal (3.1.9) coffee-script (2.4.1) coffee-script-source execjs @@ -21,9 +21,9 @@ GEM em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) - erubis (2.7.0) + erubi (1.13.1) eventmachine (1.2.7) - execjs (2.9.1) + execjs (2.10.0) fast_blank (1.0.1) fastimage (2.3.1) ffi (1.16.3) @@ -48,41 +48,41 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) memoist (0.16.2) - middleman (4.5.1) - coffee-script (~> 2.2) - haml (>= 4.0.5) - kramdown (>= 2.3.0) - middleman-cli (= 4.5.1) - middleman-core (= 4.5.1) + middleman (4.6.0) + middleman-cli (= 4.6.0) + middleman-core (= 4.6.0) middleman-autoprefixer (3.0.0) autoprefixer-rails (~> 10.0) middleman-core (>= 4.0.0) - middleman-cli (4.5.1) + middleman-cli (4.6.0) thor (>= 0.17.0, < 1.3.0) - middleman-core (4.5.1) - activesupport (>= 6.1, < 7.1) + middleman-core (4.6.0) + activesupport (>= 6.1) addressable (~> 2.4) - backports (~> 3.6) bundler (~> 2.0) - contracts (~> 0.13, < 0.17) + coffee-script (~> 2.2) + contracts dotenv - erubis + erubi execjs (~> 2.0) fast_blank fastimage (~> 2.0) + haml (>= 4.0.5) hamster (~> 3.0) - hashie (~> 3.4) - i18n (~> 1.6.0) + hashie (>= 3.4, < 6.0) + i18n (>= 1.6, < 1.15) + kramdown (~> 2.4) listen (~> 3.0) memoist (~> 0.14) padrino-helpers (~> 0.15.0) parallel - rack (>= 1.4.5, < 3) + rack (>= 3) + rackup sassc (~> 2.0) servolux - tilt (~> 2.0.9) + tilt (~> 2.2) toml - uglifier (~> 3.0) + uglifier (>= 3, < 5) webrick middleman-gh-pages (0.4.1) rake (> 0.9.3) @@ -100,6 +100,7 @@ GEM mini_racer (0.16.0) libv8-node (~> 18.19.0.0) minitest (5.23.1) + mutex_m (0.3.0) nokogiri (1.18.3) mini_portile2 (~> 2.8.2) racc (~> 1.4) @@ -118,9 +119,11 @@ GEM parslet (2.0.0) public_suffix (5.0.5) racc (1.8.1) - rack (2.2.13) + rack (3.1.12) rack-livereload (0.3.17) rack + rackup (2.2.1) + rack (>= 3) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) @@ -136,17 +139,17 @@ GEM sassc (2.4.0) ffi (~> 1.9) servolux (0.13.0) - sprockets (3.7.2) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) + rack (>= 2.2.4, < 4) temple (0.10.3) thor (1.2.2) - tilt (2.0.11) + tilt (2.6.0) toml (0.3.0) parslet (>= 1.8.0, < 3.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uglifier (3.2.0) + uglifier (4.2.1) execjs (>= 0.3.0, < 3) webrick (1.8.2) @@ -157,6 +160,7 @@ PLATFORMS x86_64-linux DEPENDENCIES + bigdecimal json (>= 2.3.0) middleman (~> 4.5) middleman-autoprefixer (~> 3.0, >= 3.0.0) @@ -165,10 +169,11 @@ DEPENDENCIES middleman-sprockets (~> 4.1, >= 4.1.1) middleman-syntax (= 3.4.0) mini_racer + mutex_m nokogiri (~> 1.18.3) rake (>= 12.3.3) redcarpet (~> 3.6.1) sass BUNDLED WITH - 2.4.10 + 2.6.6 diff --git a/spec/request/admin_actions_spec.rb b/spec/request/admin_actions_spec.rb index 270e45ae617..78adc157a52 100644 --- a/spec/request/admin_actions_spec.rb +++ b/spec/request/admin_actions_spec.rb @@ -14,6 +14,7 @@ h = Hash.new( { code: 403 }.freeze ) + h['admin'] = { code: 202 } diff --git a/spec/request/app_features_spec.rb b/spec/request/app_features_spec.rb index e475dade2ef..6e80477b4f2 100644 --- a/spec/request/app_features_spec.rb +++ b/spec/request/app_features_spec.rb @@ -60,6 +60,7 @@ let(:expected_codes_and_responses) do h = Hash.new({ code: 404 }.freeze) + %w[admin admin_read_only global_auditor space_developer space_manager space_auditor org_manager space_supporter].each do |r| h[r] = { code: 200, response_object: features_response_object } @@ -78,6 +79,7 @@ describe 'GET /v3/apps/:guid/features/:name' do let(:expected_codes_and_responses) do h = Hash.new({ code: 404 }.freeze) + %w[admin admin_read_only global_auditor space_developer space_manager space_auditor org_manager space_supporter].each do |r| h[r] = { code: 200, response_object: feature_response_object } @@ -161,6 +163,7 @@ let(:expected_codes_and_responses) do h = Hash.new({ code: 403, errors: CF_NOT_AUTHORIZED }.freeze) + %w[no_role org_auditor org_billing_manager].each { |r| h[r] = { code: 404 } } %w[admin space_developer].each { |r| h[r] = { code: 200, response_object: feature_response_object } } h diff --git a/spec/support/shared_examples/v3_service_binding_delete.rb b/spec/support/shared_examples/v3_service_binding_delete.rb index af3fce21e82..79fa1a9c81f 100644 --- a/spec/support/shared_examples/v3_service_binding_delete.rb +++ b/spec/support/shared_examples/v3_service_binding_delete.rb @@ -72,7 +72,7 @@ class BadError < StandardError; end VCAP::Services::ServiceBrokers::V2::Errors::ConcurrencyError.new( 'foo', :delete, - double(code: '500', reason: '', body: '') + double({ code: '500', reason: '', body: '' }) ) ) dbl diff --git a/spec/unit/actions/v3/service_instance_create_managed_spec.rb b/spec/unit/actions/v3/service_instance_create_managed_spec.rb index 39e416e7e8e..5b2d7555fc0 100644 --- a/spec/unit/actions/v3/service_instance_create_managed_spec.rb +++ b/spec/unit/actions/v3/service_instance_create_managed_spec.rb @@ -567,7 +567,7 @@ module V3 context 'when http error is raised' do let(:fake_logger) { instance_double(Steno::Logger, error: nil, info: nil) } let(:err) do - response = VCAP::Services::ServiceBrokers::V2::HttpResponse.new(code: 412, body: {}) + response = VCAP::Services::ServiceBrokers::V2::HttpResponse.new({ code: 412, body: {} }) HttpResponseError.new('oops', 'GET', response) end diff --git a/spec/unit/controllers/v3/sidecars_controller_spec.rb b/spec/unit/controllers/v3/sidecars_controller_spec.rb index 28d79e0d2f8..5c63c19c9c9 100644 --- a/spec/unit/controllers/v3/sidecars_controller_spec.rb +++ b/spec/unit/controllers/v3/sidecars_controller_spec.rb @@ -30,7 +30,7 @@ it 'fails to map a route' do expect do get :index_by_process - end.to raise_error(ActionController::UrlGenerationError, /No route matches \{:action=>"index_by_process", :controller=>"sidecars"\}/) + end.to raise_error(ActionController::UrlGenerationError, /No route matches \{action: "index_by_process", controller: "sidecars"\}/) end end diff --git a/spec/unit/jobs/pollable_job_wrapper_spec.rb b/spec/unit/jobs/pollable_job_wrapper_spec.rb index 0db1f850068..064192191b1 100644 --- a/spec/unit/jobs/pollable_job_wrapper_spec.rb +++ b/spec/unit/jobs/pollable_job_wrapper_spec.rb @@ -283,7 +283,7 @@ class BigException < StandardError context 'with a big message' do # postgres complains with 15,826 - # mysql complains with 15,828, so test for failure at that point + # mysql complains with 15,829, so test for failure at that point it 'squeezes just right one in' do expect do @@ -295,7 +295,7 @@ class BigException < StandardError pg_error = /value too long for type character varying/ mysql_error = /Data too long for column 'cf_api_error'/ expect do - pollable_job.error(job, BigException.new(message: 'x' * 15_828)) + pollable_job.error(job, BigException.new(message: 'x' * 15_829)) end.to raise_error(::Sequel::DatabaseError, /#{pg_error}|#{mysql_error}/) end end 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 6652ab80e8e..2906d294914 100644 --- a/spec/unit/jobs/services/service_binding_state_fetch_spec.rb +++ b/spec/unit/jobs/services/service_binding_state_fetch_spec.rb @@ -636,7 +636,7 @@ def run_job(job) context 'when calling last operation responds with an error HttpResponseError' do before do - response = VCAP::Services::ServiceBrokers::V2::HttpResponse.new(code: 412, body: {}) + response = VCAP::Services::ServiceBrokers::V2::HttpResponse.new({ code: 412, body: {} }) err = HttpResponseError.new('oops', 'GET', response) allow(client).to receive(:fetch_service_binding_last_operation).and_raise(err) 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 18d11aba276..cc4502738c0 100644 --- a/spec/unit/jobs/services/service_instance_state_fetch_spec.rb +++ b/spec/unit/jobs/services/service_instance_state_fetch_spec.rb @@ -432,7 +432,7 @@ def run_job(job) context 'due to an HttpResponseError' do before do - response = VCAP::Services::ServiceBrokers::V2::HttpResponse.new(code: 412, body: {}) + response = VCAP::Services::ServiceBrokers::V2::HttpResponse.new({ code: 412, body: {} }) err = HttpResponseError.new('oops', 'GET', response) allow(client).to receive(:fetch_service_instance_last_operation).and_raise(err) end diff --git a/spec/unit/lib/cloud_controller/config_spec.rb b/spec/unit/lib/cloud_controller/config_spec.rb index c44b5ebb1d3..af5bc795ebf 100644 --- a/spec/unit/lib/cloud_controller/config_spec.rb +++ b/spec/unit/lib/cloud_controller/config_spec.rb @@ -155,7 +155,7 @@ module VCAP::CloudController it "can't handle an unescaped @" do expect do DatabasePartsParser.database_parts_from_connection(uri) - end.to raise_error(URI::InvalidURIError, "bad URI(is not URI?): \"#{uri}\"") + end.to raise_error(URI::InvalidURIError, "bad URI (is not URI?): \"#{uri}\"") end end diff --git a/spec/unit/lib/cloud_controller/database_parts_parser_spec.rb b/spec/unit/lib/cloud_controller/database_parts_parser_spec.rb index e9cc8b01a00..059c61a679f 100644 --- a/spec/unit/lib/cloud_controller/database_parts_parser_spec.rb +++ b/spec/unit/lib/cloud_controller/database_parts_parser_spec.rb @@ -40,7 +40,7 @@ uri = 'mysql://user:p4s sw0rd@example.com:1234/databasename' expect do VCAP::CloudController::DatabasePartsParser.database_parts_from_connection(uri) - end.to raise_error(URI::InvalidURIError, "bad URI(is not URI?): \"#{uri}\"") + end.to raise_error(URI::InvalidURIError, "bad URI (is not URI?): \"#{uri}\"") 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 2f2122b98ee..36b984d5271 100644 --- a/spec/unit/lib/services/service_brokers/v2/client_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/client_spec.rb @@ -92,7 +92,7 @@ module VCAP::Services::ServiceBrokers::V2 end let(:path) { '/v2/catalog' } - let(:catalog_response) { HttpResponse.new(code: code, body: catalog_response_body, message: message) } + let(:catalog_response) { HttpResponse.new({ code: code, body: catalog_response_body, message: message }) } let(:catalog_response_body) { response_data.to_json } let(:code) { 200 } let(:message) { 'OK' } @@ -135,7 +135,7 @@ module VCAP::Services::ServiceBrokers::V2 end let(:path) { "/v2/service_instances/#{instance.guid}" } - let(:response) { HttpResponse.new(code: code, body: response_body, message: message) } + let(:response) { HttpResponse.new({ code: code, body: response_body, message: message }) } let(:response_body) { response_data.to_json } let(:code) { 201 } let(:message) { 'Created' } @@ -356,7 +356,7 @@ module VCAP::Services::ServiceBrokers::V2 context 'when provision fails' do let(:uri) { 'some-uri.com/v2/service_instances/some-guid' } - let(:response) { HttpResponse.new(code: nil, body: nil, message: nil) } + let(:response) { HttpResponse.new({ code: nil, body: nil, message: nil }) } context 'due to an http client error' do let(:http_client) { instance_double(HttpClient) } @@ -434,7 +434,7 @@ module VCAP::Services::ServiceBrokers::V2 end context 'when the status code was a 200' do - let(:response) { HttpResponse.new(code: 200, body: nil, message: nil) } + let(:response) { HttpResponse.new({ code: 200, body: nil, message: nil }) } it 'does not initiate orphan mitigation' do expect do @@ -467,7 +467,7 @@ module VCAP::Services::ServiceBrokers::V2 end let(:path) { "/v2/service_instances/#{instance.guid}" } - let(:response) { HttpResponse.new(code: code, message: message, body: response_body) } + let(:response) { HttpResponse.new({ code: code, message: message, body: response_body }) } let(:response_body) { response_data.to_json } let(:code) { 200 } let(:message) { 'OK' } @@ -634,7 +634,7 @@ module VCAP::Services::ServiceBrokers::V2 end context 'when the broker returns headers' do - let(:response) { HttpResponse.new(code: code, message: message, body: response_body, headers: { 'Retry-After' => 10 }) } + let(:response) { HttpResponse.new({ code: code, message: message, body: response_body, headers: { 'Retry-After' => 10 } }) } it 'returns the retry after header in the result' do attrs = client.fetch_service_instance_last_operation(instance) @@ -673,7 +673,7 @@ module VCAP::Services::ServiceBrokers::V2 let(:response_data) { {} } before do - response = HttpResponse.new(code: code, body: response_body, message: message) + response = HttpResponse.new({ code: code, body: response_body, message: message }) allow(http_client).to receive(:patch).and_return(response) instance.service_instance_operation = last_operation end @@ -1770,7 +1770,7 @@ module VCAP::Services::ServiceBrokers::V2 end context 'when the status code was a 200' do - let(:response) { HttpResponse.new(code: 200, body: nil, message: nil) } + let(:response) { HttpResponse.new({ code: 200, body: nil, message: nil }) } it 'does not initiate orphan mitigation' do expect do @@ -1804,7 +1804,7 @@ module VCAP::Services::ServiceBrokers::V2 let(:response_data) { {} } let(:path) { "/v2/service_instances/#{binding.service_instance.guid}/service_bindings/#{binding.guid}" } - let(:response) { HttpResponse.new(code: code, body: response_body, message: message) } + let(:response) { HttpResponse.new({ code: code, body: response_body, message: message }) } let(:response_body) { response_data.to_json } let(:code) { 200 } let(:message) { 'OK' } @@ -1955,7 +1955,7 @@ module VCAP::Services::ServiceBrokers::V2 let(:response_data) { {} } let(:path) { "/v2/service_instances/#{instance.guid}" } - let(:response) { HttpResponse.new(code: code, body: response_body, message: message) } + let(:response) { HttpResponse.new({ code: code, body: response_body, message: message }) } let(:response_body) { response_data.to_json } let(:code) { 200 } let(:message) { 'OK' } @@ -2144,7 +2144,7 @@ module VCAP::Services::ServiceBrokers::V2 ) end - let(:broker_response) { HttpResponse.new(code: 200, body: { foo: 'bar' }.to_json) } + let(:broker_response) { HttpResponse.new({ code: 200, body: { foo: 'bar' }.to_json }) } before do allow(http_client).to receive(:get).and_return(broker_response) @@ -2178,7 +2178,7 @@ module VCAP::Services::ServiceBrokers::V2 describe '#fetch_service_instance' do let(:instance) { VCAP::CloudController::ManagedServiceInstance.make } - let(:broker_response) { HttpResponse.new(code: 200, body: { foo: 'bar' }.to_json) } + let(:broker_response) { HttpResponse.new({ code: 200, body: { foo: 'bar' }.to_json }) } before do allow(http_client).to receive(:get).and_return(broker_response) @@ -2219,7 +2219,7 @@ module VCAP::Services::ServiceBrokers::V2 end let(:service_binding) { VCAP::CloudController::ServiceBinding.make } let(:binding_operation) { VCAP::CloudController::ServiceBindingOperation.make } - let(:broker_response) { HttpResponse.new(code: code, body: response_body) } + let(:broker_response) { HttpResponse.new({ code: code, body: response_body }) } let(:response_body) { response_data.to_json } let(:code) { 200 } @@ -2320,7 +2320,7 @@ module VCAP::Services::ServiceBrokers::V2 end context 'when the broker returns headers' do - let(:broker_response) { HttpResponse.new(code: 200, body: response_body, headers: { 'Retry-After' => 10 }) } + let(:broker_response) { HttpResponse.new({ code: 200, body: response_body, headers: { 'Retry-After' => 10 } }) } it 'returns the retry after header in the result' do attrs = client.fetch_service_binding_last_operation(service_binding) @@ -2341,7 +2341,7 @@ module VCAP::Services::ServiceBrokers::V2 let(:code) { 200 } let(:response_body) { response_data.to_json } - let(:broker_response) { HttpResponse.new(code: code, body: response_body) } + let(:broker_response) { HttpResponse.new({ code: code, body: response_body }) } before do service_binding.service_binding_operation = binding_operation @@ -2427,12 +2427,12 @@ module VCAP::Services::ServiceBrokers::V2 end errors = [ - Errors::ServiceBrokerBadResponse.new('some-uri.com', :get, HttpResponse.new(code: nil, body: nil, message: nil)), - Errors::ServiceBrokerApiAuthenticationFailed.new('some-uri.com', :get, HttpResponse.new(code: nil, body: nil, message: nil)), - Errors::ServiceBrokerApiTimeout.new('some-uri.com', :get, HttpResponse.new(code: nil, body: nil, message: nil)), - Errors::ServiceBrokerRequestRejected.new('some-uri.com', :get, HttpResponse.new(code: nil, body: nil, message: nil)), - Errors::ServiceBrokerResponseMalformed.new('some-uri.com', :get, HttpResponse.new(code: nil, body: nil, message: nil), 'some desc'), - HttpResponseError.new('some failure', :get, HttpResponse.new(code: nil, body: nil, message: nil)) + Errors::ServiceBrokerBadResponse.new('some-uri.com', :get, HttpResponse.new({ code: nil, body: nil, message: nil })), + Errors::ServiceBrokerApiAuthenticationFailed.new('some-uri.com', :get, HttpResponse.new({ code: nil, body: nil, message: nil })), + Errors::ServiceBrokerApiTimeout.new('some-uri.com', :get, HttpResponse.new({ code: nil, body: nil, message: nil })), + Errors::ServiceBrokerRequestRejected.new('some-uri.com', :get, HttpResponse.new({ code: nil, body: nil, message: nil })), + Errors::ServiceBrokerResponseMalformed.new('some-uri.com', :get, HttpResponse.new({ code: nil, body: nil, message: nil }), 'some desc'), + HttpResponseError.new('some failure', :get, HttpResponse.new({ code: nil, body: nil, message: nil })) ] errors.each do |error| @@ -2509,7 +2509,7 @@ module VCAP::Services::ServiceBrokers::V2 end context 'when the broker returns headers' do - let(:broker_response) { HttpResponse.new(code: 200, body: response_body, headers: { 'Retry-After' => 10 }) } + let(:broker_response) { HttpResponse.new({ code: 200, body: response_body, headers: { 'Retry-After' => 10 } }) } it 'returns the retry after header in the result' do attrs = client.fetch_and_handle_service_binding_last_operation(service_binding) diff --git a/spec/unit/lib/services/service_brokers/v2/errors/maintenance_info_conflict_spec.rb b/spec/unit/lib/services/service_brokers/v2/errors/maintenance_info_conflict_spec.rb index 12e3a067c5d..8f514e66d1d 100644 --- a/spec/unit/lib/services/service_brokers/v2/errors/maintenance_info_conflict_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/errors/maintenance_info_conflict_spec.rb @@ -6,7 +6,7 @@ module V2 module Errors RSpec.describe MaintenanceInfoConflict do let(:uri) { 'http://www.example.com/' } - let(:response) { double(code: 422, body: response_body) } + let(:response) { double({ code: 422, body: response_body }) } let(:method) { 'PATCH' } let(:response_body) do { diff --git a/spec/unit/lib/services/service_brokers/v2/errors/service_broker_api_authentication_failed_spec.rb b/spec/unit/lib/services/service_brokers/v2/errors/service_broker_api_authentication_failed_spec.rb index 21d14138b90..037de0be0d9 100644 --- a/spec/unit/lib/services/service_brokers/v2/errors/service_broker_api_authentication_failed_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/errors/service_broker_api_authentication_failed_spec.rb @@ -11,7 +11,7 @@ module Errors describe ServiceBrokerApiAuthenticationFailed do let(:response_body) { 'foo' } - let(:response) { double(code: 401, reason: 'Auth Error', body: response_body) } + let(:response) { double({ code: 401, reason: 'Auth Error', body: response_body }) } it 'initializes the base class correctly' do exception = ServiceBrokerApiAuthenticationFailed.new(uri, method, response) diff --git a/spec/unit/lib/services/service_brokers/v2/errors/service_broker_bad_response_spec.rb b/spec/unit/lib/services/service_brokers/v2/errors/service_broker_bad_response_spec.rb index b907d985347..7fed19bf35c 100644 --- a/spec/unit/lib/services/service_brokers/v2/errors/service_broker_bad_response_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/errors/service_broker_bad_response_spec.rb @@ -6,7 +6,7 @@ module V2 module Errors RSpec.describe ServiceBrokerBadResponse do let(:uri) { 'http://www.example.com/' } - let(:response) { double(code: 500, message: 'Internal Server Error', body: response_body) } + let(:response) { double({ code: 500, message: 'Internal Server Error', body: response_body }) } let(:method) { 'PUT' } context 'with a description in the body' do diff --git a/spec/unit/lib/services/service_brokers/v2/errors/service_broker_conflict_spec.rb b/spec/unit/lib/services/service_brokers/v2/errors/service_broker_conflict_spec.rb index e60dfe67afa..096b2c5c9c2 100644 --- a/spec/unit/lib/services/service_brokers/v2/errors/service_broker_conflict_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/errors/service_broker_conflict_spec.rb @@ -7,7 +7,7 @@ module Errors RSpec.describe 'ServiceBrokerConflict' do let(:error_message) { 'error message' } let(:response_body) { "{\"description\": \"#{error_message}\"}" } - let(:response) { double(code: 409, reason: 'Conflict', body: response_body) } + let(:response) { double({ code: 409, reason: 'Conflict', body: response_body }) } let(:uri) { 'http://uri.example.com' } let(:method) { 'POST' } diff --git a/spec/unit/lib/services/service_brokers/v2/errors/service_broker_request_rejected_spec.rb b/spec/unit/lib/services/service_brokers/v2/errors/service_broker_request_rejected_spec.rb index 9bc59a1bc9b..80be8a09c3d 100644 --- a/spec/unit/lib/services/service_brokers/v2/errors/service_broker_request_rejected_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/errors/service_broker_request_rejected_spec.rb @@ -6,7 +6,7 @@ module V2 module Errors RSpec.describe ServiceBrokerRequestRejected do let(:uri) { 'http://www.example.com/' } - let(:response) { double(code: 400, message: 'status message', body: response_body) } + let(:response) { double({ code: 400, message: 'status message', body: response_body }) } let(:method) { 'PUT' } context 'with a description in the body' do diff --git a/spec/unit/lib/services/service_brokers/v2/errors/service_broker_response_malformed_spec.rb b/spec/unit/lib/services/service_brokers/v2/errors/service_broker_response_malformed_spec.rb index 1d5586dc72d..fd959de56e4 100644 --- a/spec/unit/lib/services/service_brokers/v2/errors/service_broker_response_malformed_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/errors/service_broker_response_malformed_spec.rb @@ -9,7 +9,7 @@ module Errors let(:method) { 'POST' } let(:error) { StandardError.new } let(:response_body) { 'foo' } - let(:response) { double(code: 200, reason: 'OK', body: response_body) } + let(:response) { double({ code: 200, reason: 'OK', body: response_body }) } let(:description) { 'this is the error description' } it 'initializes the base class correctly' do 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 cb1b6bcfd16..44605f20f93 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 @@ -82,12 +82,12 @@ module VCAP::Services::ServiceBrokers::V2 it 'logs the default headers' do make_request - expect(fake_logger).to have_received(:debug).with(match(%r{Accept"=>"application/json})) - expect(fake_logger).to have_received(:debug).with(match(/X-VCAP-Request-ID"=>"[[:alnum:]-]+/)) - expect(fake_logger).to have_received(:debug).with(match(/X-Broker-API-Request-Identity"=>"[[:alnum:]-]+/)) - expect(fake_logger).to have_received(:debug).with(match(/X-Broker-Api-Version"=>"2\.15/)) + expect(fake_logger).to have_received(:debug).with(match(%r{Accept" => "application/json})) + expect(fake_logger).to have_received(:debug).with(match(/X-VCAP-Request-ID" => "[[:alnum:]-]+/)) + expect(fake_logger).to have_received(:debug).with(match(/X-Broker-API-Request-Identity" => "[[:alnum:]-]+/)) + expect(fake_logger).to have_received(:debug).with(match(/X-Broker-Api-Version" => "2\.15/)) api_info_path = TestConfig.config[:temporary_enable_v2] ? '/v2/info' : '/' - expect(fake_logger).to have_received(:debug).with(match(/X-Api-Info-Location"=>"api2\.vcap\.me#{api_info_path}/)) + expect(fake_logger).to have_received(:debug).with(match(/X-Api-Info-Location" => "api2\.vcap\.me#{api_info_path}/)) end context 'when an https URL is used' do @@ -357,12 +357,12 @@ def expect_timeout_to_be(timeout) it 'redacts credentials from response body' do make_request - expect(fake_logger).to have_received(:debug).with(/"credentials"=>"\[REDACTED\]"/) + expect(fake_logger).to have_received(:debug).with(/"credentials" => "\[REDACTED\]"/) end it 'does not redact other keys' do make_request - expect(fake_logger).to have_received(:debug).with(%r{"syslog_drain_url"=>"example.com/1234"}) + expect(fake_logger).to have_received(:debug).with(%r{"syslog_drain_url" => "example.com/1234"}) end context 'non-json responses' do @@ -507,7 +507,7 @@ def expect_timeout_to_be(timeout) it 'logs the Content-Type Header' do make_request - expect(fake_logger).to have_received(:debug).with(match(%r{"Content-Type"=>"application/json"})) + expect(fake_logger).to have_received(:debug).with(match(%r{"Content-Type" => "application/json"})) end it 'has a content body' do @@ -584,7 +584,7 @@ def expect_timeout_to_be(timeout) it 'logs the Content-Type Header' do make_request - expect(fake_logger).to have_received(:debug).with(match(%r{"Content-Type"=>"application/json"})) + expect(fake_logger).to have_received(:debug).with(match(%r{"Content-Type" => "application/json"})) end it 'has a content body' do 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 19a6c8096a6..07a31b5a63b 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 @@ -299,7 +299,7 @@ def self.test_case(operation, code, body, opts={}) before do @method, @path = get_method_and_path(operation) - allow(fake_response).to receive_messages(code: code, body: body, message: 'message') + allow(fake_response).to receive_messages({ code: code, body: body, message: 'message' }) allow(Steno).to receive(:logger).and_return(logger) end diff --git a/spec/unit/presenters/error_presenter_spec.rb b/spec/unit/presenters/error_presenter_spec.rb index 809aa3e8dbc..27c33b1cb33 100644 --- a/spec/unit/presenters/error_presenter_spec.rb +++ b/spec/unit/presenters/error_presenter_spec.rb @@ -39,7 +39,7 @@ def response_code let(:error) { StandardError.new } it 'logs the response code and unsanitized error hash' do - expect(presenter.log_message).to eq('Request failed: 500: {"fake"=>"insane"}') + expect(presenter.log_message).to eq('Request failed: 500: {"fake" => "insane"}') end end diff --git a/spec/unit/support/matchers/be_a_response_like_spec.rb b/spec/unit/support/matchers/be_a_response_like_spec.rb index 36fd2bd6253..e3bacf107d8 100644 --- a/spec/unit/support/matchers/be_a_response_like_spec.rb +++ b/spec/unit/support/matchers/be_a_response_like_spec.rb @@ -70,13 +70,13 @@ it 'fails when hash values within arrays do not match' do expect do expect({ 'a' => [{ 'b' => 1 }] }).to be_a_response_like({ 'a' => [{ 'b' => 2 }] }) - end.to raise_expectation_not_met_with_key_change(expected: '- a[0]: {"b"=>2}', actual: '+ a[0]: {"b"=>1}') + end.to raise_expectation_not_met_with_key_change(expected: '- a[0]: {"b" => 2}', actual: '+ a[0]: {"b" => 1}') end it 'fails when hash keys within arrays do not match' do expect do expect({ 'a' => [{ 'b' => 1 }] }).to be_a_response_like({ 'a' => [{ 'c' => 1 }] }) - end.to raise_expectation_not_met_with_key_change(expected: '- a[0]: {"c"=>1}', actual: '+ a[0]: {"b"=>1}') + end.to raise_expectation_not_met_with_key_change(expected: '- a[0]: {"c" => 1}', actual: '+ a[0]: {"b" => 1}') end it 'fails when actual is empty but expected is an empty array' do @@ -88,14 +88,14 @@ it 'fails when actual as a non-empty but expected is an empty array' do expect do expect({ 'a' => [{ 'b' => 1 }] }).to be_a_response_like({ 'a' => [] }) - end.to raise_expectation_not_met_with_summary(/\+ a\[0\]: \{"b"=>1\}/) + end.to raise_expectation_not_met_with_summary(/\+ a\[0\]: \{"b" => 1\}/) end it 'fails on deeply nested value mismatches' do expect do expect({ 'a' => [{ 'a' => { 'a' => [{ 'a' => 1 }, { 'b' => 2 }] } }] }).to be_a_response_like({ 'a' => [{ 'a' => { 'a' => [{ 'a' => 1 }, { 'b' => 1 }] } }] }) - end.to raise_expectation_not_met_with_key_change(expected: '- a[0].a.a[1]: {"b"=>1}', - actual: '+ a[0].a.a[1]: {"b"=>2}') + end.to raise_expectation_not_met_with_key_change(expected: '- a[0].a.a[1]: {"b" => 1}', + actual: '+ a[0].a.a[1]: {"b" => 2}') end def raise_expectation_not_met_with_summary(ptn) diff --git a/spec/unit/support/matchers/match_json_response_spec.rb b/spec/unit/support/matchers/match_json_response_spec.rb index e3ed7cfaba6..1482a0a4b3b 100644 --- a/spec/unit/support/matchers/match_json_response_spec.rb +++ b/spec/unit/support/matchers/match_json_response_spec.rb @@ -70,13 +70,13 @@ it 'fails when hash values within arrays do not match' do expect do expect({ 'a' => [{ 'b' => 1 }] }).to match_json_response({ a: [{ b: 2 }] }) - end.to raise_expectation_not_met_with_key_change(expected: '- a[0]: {:b=>2}', actual: '+ a[0]: {:b=>1}') + end.to raise_expectation_not_met_with_key_change(expected: '- a[0]: {b: 2}', actual: '+ a[0]: {b: 1}') end it 'fails when hash keys within arrays do not match' do expect do expect({ 'a' => [{ 'b' => 1 }] }).to match_json_response({ a: [{ c: 1 }] }) - end.to raise_expectation_not_met_with_key_change(expected: '- a[0]: {:c=>1}', actual: '+ a[0]: {:b=>1}') + end.to raise_expectation_not_met_with_key_change(expected: '- a[0]: {c: 1}', actual: '+ a[0]: {b: 1}') end it 'fails when actual is empty but expected is an empty array' do @@ -88,14 +88,14 @@ it 'fails when actual as a non-empty but expected is an empty array' do expect do expect({ 'a' => [{ 'b' => 1 }] }).to match_json_response({ a: [] }) - end.to raise_expectation_not_met_with_summary(/\+ a\[0\]: \{:b=>1\}/) + end.to raise_expectation_not_met_with_summary(/\+ a\[0\]: \{b: 1\}/) end it 'fails on deeply nested value mismatches' do expect do expect({ 'a' => [{ 'a' => { 'a' => [{ 'a' => 1 }, { 'b' => 2 }] } }] }).to match_json_response({ a: [{ a: { a: [{ a: 1 }, { b: 1 }] } }] }) - end.to raise_expectation_not_met_with_key_change(expected: '- a[0].a.a[1]: {:b=>1}', - actual: '+ a[0].a.a[1]: {:b=>2}') + end.to raise_expectation_not_met_with_key_change(expected: '- a[0].a.a[1]: {b: 1}', + actual: '+ a[0].a.a[1]: {b: 2}') end it 'outputs submatcher error message when it errors' do