Skip to content

Commit

Permalink
Use DDF style parameters for Host verify_credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Dec 20, 2023
1 parent 7a3c4a6 commit 5fa84e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@ def verify_credentials_task(userid, auth_type = nil, options = {})
def verify_credentials?(auth_type = nil, options = {})
# Prevent the connection details, including the password, from being leaked into the logs
# and MiqQueue by only returning true/false
auth = options.delete(:credentials)
update_authentication(auth, :save => false) if auth.present?
auth = options.delete("authentications")
update_authentication(auth.deep_symbolize_keys, :save => false) if auth.present?

!!verify_credentials(auth_type, options)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/models/host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@

it "passes the new credentials" do
@host.update_authentication(old_creds)
@host.verify_credentials_task(FactoryBot.create(:user).userid, :default, :credentials => default_creds)
@host.verify_credentials_task(FactoryBot.create(:user).userid, :default, "authentications" => default_creds.deep_stringify_keys)

expect(MiqQueue.last).to have_attributes(
:args => [:default, {:credentials => default_creds}],
:args => [:default, {"authentications" => default_creds.deep_stringify_keys}],
:method_name => "verify_credentials?",
:instance_id => @host.id,
:class_name => @host.class.name,
Expand Down Expand Up @@ -277,7 +277,7 @@

it "updates credentials via validate_credential options" do
@host.update_authentication(old_creds)
assert_default_credentials_validated(:credentials => default_creds)
assert_default_credentials_validated("authentications" => default_creds)
end
end

Expand Down

0 comments on commit 5fa84e0

Please sign in to comment.