Skip to content

Commit

Permalink
Merge pull request ManageIQ#58 from jntullo/decrypt_password
Browse files Browse the repository at this point in the history
allow raw_connect to accept encrypted passwords
  • Loading branch information
aufi authored Jul 4, 2017
2 parents e87ed39 + 843b808 commit 9f612f0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gemspec
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

# We are using 'miq-module' from gems-pending
# We are using 'miq-module' and 'miq-password' from gems-pending
gem "manageiq-gems-pending", ">0", :require => 'manageiq-gems-pending', :git => "https://github.com/ManageIQ/manageiq-gems-pending.git", :branch => "master"

# Load Gemfile with dependencies from manageiq
Expand Down
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 9f612f0

Please sign in to comment.