Skip to content

Commit

Permalink
Merge pull request #20631 from Fryguy/legacy_miq_password
Browse files Browse the repository at this point in the history
Prefer ManageIQ::Password over legacy MiqPassword constant
  • Loading branch information
agrare authored Sep 30, 2020
2 parents 8b0ce63 + 938bfc3 commit bf28fa0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/miq_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def self.messaging_client_options
(messaging_options_from_env || messaging_options_from_file)&.merge(
:encoding => "json",
:protocol => messaging_protocol,
)&.tap { |h| h[:password] = MiqPassword.try_decrypt(h.delete(:password)) }
)&.tap { |h| h[:password] = ManageIQ::Password.try_decrypt(h.delete(:password)) }
end
private_class_method :messaging_client_options

Expand Down
2 changes: 1 addition & 1 deletion app/models/mixins/verify_credentials_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def encrypt_verify_credential_params!(options)
DDF.traverse(params_for_create) do |field|
key_path = field[:name].try(:split, '.')
if options.key_path?(key_path) && field[:type] == 'password'
options.store_path(key_path, MiqPassword.try_encrypt(options.fetch_path(key_path)))
options.store_path(key_path, ManageIQ::Password.try_encrypt(options.fetch_path(key_path)))
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/miq_queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def queue_items
end

it "with encrypted password" do
stub_const("ENV", env_vars.to_h.merge("MESSAGING_PASSWORD" => MiqPassword.encrypt("password")))
stub_const("ENV", env_vars.to_h.merge("MESSAGING_PASSWORD" => ManageIQ::Password.encrypt("password")))

expect(YAML).not_to receive(:load_file).with(MiqQueue::MESSAGING_CONFIG_FILE)

Expand Down Expand Up @@ -1058,7 +1058,7 @@ def queue_items

it "with encrypted password" do
allow(YAML).to receive(:load_file).and_call_original
expect(YAML).to receive(:load_file).with(MiqQueue::MESSAGING_CONFIG_FILE).and_return("test" => {"hostname" => "kafka.example.com", "port" => 9092, "username" => "user", "password" => MiqPassword.encrypt("password")})
expect(YAML).to receive(:load_file).with(MiqQueue::MESSAGING_CONFIG_FILE).and_return("test" => {"hostname" => "kafka.example.com", "port" => 9092, "username" => "user", "password" => ManageIQ::Password.encrypt("password")})

expect(MiqQueue.send(:messaging_client_options)).to eq(
:encoding => "json",
Expand Down

0 comments on commit bf28fa0

Please sign in to comment.