Skip to content

Commit

Permalink
Merge pull request #396 from agrare/fix_verify_credentials_existing_p…
Browse files Browse the repository at this point in the history
…rovider

Fix verify_credentials for an existing EMS
  • Loading branch information
Fryguy authored Oct 5, 2023
2 parents 59dc8f7 + a12d414 commit b4d78d4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/manageiq/providers/lenovo/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def verify_credentials(args)
userid, password = authentication&.values_at("userid", "password")

password = ManageIQ::Password.try_decrypt(password)
password ||= find(args["id"]).authentication_password(endpoint_name) if args["id"]
password ||= find(args["id"]).authentication_password("default") if args["id"]

!!raw_connect(userid, password, hostname, port, "token", false, Vmdb::Appliance.USER_AGENT, true)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,36 @@
it "description should be 'Lenovo XClarity'" do
expect(described_class.description).to eq("Lenovo XClarity")
end

describe ".verify_credentials" do
let(:params_for_create) do
{
"endpoints" => {"default" => {"hostname" => "xclarity.localdomain", "port" => 443}},
"authentications" => {"default" => {"userid" => "admin", "password" => "password"}}
}
end

it "calls validate_configuration on xclarity client" do
expect(described_class).to receive(:validate_connection)

described_class.verify_credentials(params_for_create)
end

context "with an existing provider" do
let(:ems) { FactoryBot.create(:physical_infra_with_authentication) }
let(:params_for_create) do
{
"id" => ems.id,
"endpoints" => {"default" => {"hostname" => "xclarity.localdomain", "port" => 443}},
"authentications" => {"default" => {"userid" => "admin"}}
}
end

it "uses the existing password if another isn't specified" do
expect(described_class).to receive(:validate_connection)

described_class.verify_credentials(params_for_create)
end
end
end
end

0 comments on commit b4d78d4

Please sign in to comment.