Skip to content

Commit

Permalink
Add tests for verifying Openstack SSH keypair credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
mansam committed Jan 10, 2017
1 parent 3c80a31 commit 96c7e28
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/models/manageiq/providers/openstack/infra_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@
end
end

context "verifying SSH keypair credentials" do
it "verifies Openstack SSH credentials successfully when all hosts report that the credentials are valid" do
@ems = FactoryGirl.create(:ems_openstack_infra_with_authentication)
FactoryGirl.create(:host_openstack_infra, :ext_management_system => @ems, :state => "on")
allow_any_instance_of(ManageIQ::Providers::Openstack::InfraManager::Host).to receive(:verify_credentials).and_return(true)
expect(@ems.send(:verify_ssh_keypair_credentials, nil)).to be_truthy
end

it "fails to verify Openstack SSH credentials when any hosts report that the credentials are invalid" do
@ems = FactoryGirl.create(:ems_openstack_infra_with_authentication)
FactoryGirl.create(:host_openstack_infra, :ext_management_system => @ems, :state => "on")
allow_any_instance_of(ManageIQ::Providers::Openstack::InfraManager::Host).to receive(:verify_credentials).and_return(false)
expect(@ems.send(:verify_ssh_keypair_credentials, nil)).to be_falsey
end

it "disregards powered off hosts when verifying Openstack SSH credentials" do
@ems = FactoryGirl.create(:ems_openstack_infra_with_authentication)
FactoryGirl.create(:host_openstack_infra, :ext_management_system => @ems, :state => "off")
allow_any_instance_of(ManageIQ::Providers::Openstack::InfraManager::Host).to receive(:verify_credentials).and_return(false)
expect(@ems.send(:verify_ssh_keypair_credentials, nil)).to be_truthy
end
end

context "validation" do
before :each do
@ems = FactoryGirl.create(:ems_openstack_infra_with_authentication)
Expand Down

0 comments on commit 96c7e28

Please sign in to comment.