From c917be270e4586c40d37d79c5d5cf1269f7d43e5 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Thu, 12 Oct 2023 12:21:25 -0400 Subject: [PATCH 1/2] Update stubs to work with manageiq-password 1.2.0+ The new gem uses File.read and we were stubbing File.read here, so we need to be more precise in what we stub so we're now targetting just the migration class's implementation of reading the file. Part of https://github.com/ManageIQ/manageiq/issues/22696 --- ...06155924_move_ansible_container_secrets_into_database.rb | 6 +++++- manageiq-schema.gemspec | 2 +- ...924_move_ansible_container_secrets_into_database_spec.rb | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/db/migrate/20180606155924_move_ansible_container_secrets_into_database.rb b/db/migrate/20180606155924_move_ansible_container_secrets_into_database.rb index 22a894d93..f29bc312b 100644 --- a/db/migrate/20180606155924_move_ansible_container_secrets_into_database.rb +++ b/db/migrate/20180606155924_move_ansible_container_secrets_into_database.rb @@ -14,6 +14,10 @@ def up update_authentications end + def self.read_token(file) + File.read(file) + end + private def containerized? @@ -88,7 +92,7 @@ def update_or_create_authentication!(find_args, update_args) def request_params { 'Accept' => "application/json", - 'Authorization' => "Bearer #{File.read(TOKEN_FILE)}", + 'Authorization' => "Bearer #{self.class.read_token(TOKEN_FILE)}", :ssl_ca_cert => CA_CERT_FILE, :ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER } diff --git a/manageiq-schema.gemspec b/manageiq-schema.gemspec index c8c0243f6..3c9d24db9 100644 --- a/manageiq-schema.gemspec +++ b/manageiq-schema.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.add_dependency "ancestry" spec.add_dependency "activerecord-id_regions", "~> 0.3.2" spec.add_dependency "linux_admin", "~> 2.0" - spec.add_dependency "manageiq-password", "< 2" + spec.add_dependency "manageiq-password", ">= 1.2.0", "< 2" spec.add_dependency "more_core_extensions", ">= 3.5", "< 5" spec.add_dependency "pg" spec.add_dependency "rails", ">=6.0.4", "<7.0" diff --git a/spec/migrations/20180606155924_move_ansible_container_secrets_into_database_spec.rb b/spec/migrations/20180606155924_move_ansible_container_secrets_into_database_spec.rb index 04afc3db2..840b05872 100644 --- a/spec/migrations/20180606155924_move_ansible_container_secrets_into_database_spec.rb +++ b/spec/migrations/20180606155924_move_ansible_container_secrets_into_database_spec.rb @@ -111,7 +111,7 @@ end def expect_request - expect(File).to receive(:read).with(token_path).and_return("totally-a-token") + expect(described_class).to receive(:read_token).with(token_path).and_return("totally-a-token") response = double("RequestIO", :read => secret_json) expect(uri_stub).to receive(:open).with({ 'Accept' => "application/json", From d38a7c639a4e8ba0a30a2eedeea8d8ee0b287546 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Thu, 12 Oct 2023 15:15:52 -0400 Subject: [PATCH 2/2] For tests, use YAML.unsafe load in psych 4+ Part of https://github.com/ManageIQ/manageiq/issues/22696 --- spec/support/yaml_alias_load_as_unsafe_load.rb | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 spec/support/yaml_alias_load_as_unsafe_load.rb diff --git a/spec/support/yaml_alias_load_as_unsafe_load.rb b/spec/support/yaml_alias_load_as_unsafe_load.rb new file mode 100644 index 000000000..fbd7514d9 --- /dev/null +++ b/spec/support/yaml_alias_load_as_unsafe_load.rb @@ -0,0 +1,4 @@ +if Psych::VERSION >= "4.0" + require 'yaml' + YAML.singleton_class.alias_method :load, :unsafe_load +end