Skip to content

Commit

Permalink
Update stubs to work with manageiq-password 1.2.0+
Browse files Browse the repository at this point in the history
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 ManageIQ/manageiq#22696
  • Loading branch information
jrafanie committed Oct 12, 2023
1 parent 26c9501 commit bd94843
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion manageiq-schema.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit bd94843

Please sign in to comment.