Skip to content

Commit

Permalink
Merge pull request #435 from lfu/encrypted_password_in_playbook_1602883
Browse files Browse the repository at this point in the history
Keep the encrypted value as is when creating service provision request.
  • Loading branch information
mkanoor authored Oct 1, 2018
2 parents 985acf2 + 5b95076 commit 09ad2ef
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def extra_vars
key_list = @handle.root.attributes.keys.select { |k| k.start_with?('dialog_param') }
key_list.each_with_object({}) do |key, hash|
match_data = ANSIBLE_DIALOG_VAR_REGEX.match(key)
hash["param_#{match_data[1]}"] = @handle.root[key] if match_data
next unless match_data
hash["param_#{match_data[1]}"] = @handle.root.encrypted?(key) ? @handle.root.encrypted_string(key) : @handle.root[key]
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

describe ManageIQ::Automate::System::Request::OrderAnsiblePlaybook do
let(:root_object) do
Spec::Support::MiqAeMockObject.new(attributes)
Spec::Support::MiqAeMockObject.new(attributes).tap do |root|
allow(root).to receive(:encrypted?).and_return(false)
end
end

let(:ae_service) do
Expand Down Expand Up @@ -193,4 +195,25 @@
expect { described_class.new(ae_service).main }.to raise_error(/IP address not specified for vm/)
end
end

context "with protected dialog fields" do
let(:extra_vars) do
{ :credential => nil,
:hosts => nil,
'param_password' => 'secret' }
end
let(:attributes) do
{ 'service_template_name' => svc_service_template.name,
'dialog_param_password' => 'encrypted_value',
'vmdb_object_type' => 'vm',
'vm' => svc_vm }
end

before do
allow(root_object).to receive(:encrypted?).and_return(true)
allow(root_object).to receive(:encrypted_string).and_return("secret")
end

it_behaves_like "order playbook"
end
end

0 comments on commit 09ad2ef

Please sign in to comment.