Skip to content

Commit

Permalink
allow raw_connect to accept encrypted passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
Jillian Tullo committed Jun 27, 2017
1 parent 22ed63a commit d6ddf0f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/manageiq/providers/openstack/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module ManageIQ::Providers::Openstack::ManagerMixin
module ClassMethods
def raw_connect(username, password, auth_url, service = "Compute")
require 'manageiq/providers/openstack/legacy/openstack_handle'
OpenstackHandle::Handle.raw_connect(username, password, auth_url, service)
OpenstackHandle::Handle.raw_connect(username, MiqPassword.try_decrypt(password), auth_url, service)
end

def auth_url(address, port = nil)
Expand Down
28 changes: 28 additions & 0 deletions spec/models/manageiq/providers/openstack/cloud_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,34 @@
end
end

describe ".raw_connect" do
before do
require 'manageiq/providers/openstack/legacy/openstack_handle/handle'
end

it "accepts and decrypts encrypted passwords" do
expect(OpenstackHandle::Handle).to receive(:raw_connect).with(
"dummy",
"dummy",
"http://address:5000/v2.0/tokens",
"Compute"
)

described_class.raw_connect("dummy", MiqPassword.encrypt("dummy"), "http://address:5000/v2.0/tokens", "Compute")
end

it "works with unencrypted passwords" do
expect(OpenstackHandle::Handle).to receive(:raw_connect).with(
"dummy",
"dummy",
"http://address:5000/v2.0/tokens",
"Compute"
)

described_class.raw_connect("dummy", "dummy", "http://address:5000/v2.0/tokens", "Compute")
end
end

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

0 comments on commit d6ddf0f

Please sign in to comment.