From bd9484359ae12b4bcb4b12866142d07896a9e840 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Thu, 12 Oct 2023 12:21:25 -0400 Subject: [PATCH] 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..a8dc94770 100644 --- a/db/migrate/20180606155924_move_ansible_container_secrets_into_database.rb +++ b/db/migrate/20180606155924_move_ansible_container_secrets_into_database.rb @@ -85,10 +85,14 @@ def update_or_create_authentication!(find_args, update_args) auth.update!(update_args) end + def self.read_token(file) + File.read(file) + end + 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",