Skip to content

Commit

Permalink
Keep the encrypted value as is when creating service provision request.
Browse files Browse the repository at this point in the history
Currently the encrypted value is sent to service provision request as "********" when called via custom button.

https://bugzilla.redhat.com/show_bug.cgi?id=1602883
  • Loading branch information
lfu committed Sep 28, 2018
1 parent 4f98a78 commit 5b95076
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
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
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 5b95076

Please sign in to comment.