Skip to content

Commit

Permalink
Check for the existence of credentials.
Browse files Browse the repository at this point in the history
  • Loading branch information
lfu committed Apr 18, 2018
1 parent 14b83a3 commit 236806f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def build_parameter_list(options)

%i(credential vault_credential cloud_credential network_credential).each do |credential|
cred_sym = "#{credential}_id".to_sym
params[credential] = Authentication.find(options[cred_sym]).manager_ref if options[cred_sym]
params[credential] = Authentication.find(options[cred_sym]).manager_ref if options[cred_sym].present?
end

params.compact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,21 @@
.to receive(:raw_create_in_provider).with(instance_of(manager.class), option_matcher)
subject.raw_create_job_template(options)
end

it 'works with empty credential id' do
options = {:inventory => 'inv', :extra_vars => {'a' => 'x'}, :credential_id => ''}
option_matcher = hash_including(
:inventory => 'inv',
:extra_vars => '{"a":"x"}',
:playbook => subject.name,
:project => 'mref'
)

allow(subject).to receive(:configuration_script_source).and_return(double(:manager_ref => 'mref'))
expect(SecureRandom).to receive(:uuid).and_return('random-uuid')
expect(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript)
.to receive(:raw_create_in_provider).with(instance_of(manager.class), option_matcher)
subject.raw_create_job_template(options)
end
end
end

0 comments on commit 236806f

Please sign in to comment.