Skip to content

Commit

Permalink
Merge pull request #52 from mkanoor/miq_ae_git_import
Browse files Browse the repository at this point in the history
Don't unconditionally update verify_ssl
(cherry picked from commit 928f892b7e06f57082bb81557b292f0240d73101)

https://bugzilla.redhat.com/show_bug.cgi?id=1478554
  • Loading branch information
gmcculloug authored and simaishi committed Aug 4, 2017
1 parent 03d6f15 commit b28635d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/miq_automation_engine/models/miq_ae_git_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def repo_from_id

def create_repo
@git_repo = GitRepository.find_or_create_by(:url => @options['git_url'])
@git_repo.update_attributes(:verify_ssl => @options['verify_ssl'] || OpenSSL::SSL::VERIFY_PEER)
@git_repo.update_attributes(:verify_ssl => @options['verify_ssl']) if @options['verify_ssl']
if @options['userid'] && @options['password']
@git_repo.update_authentication(:default => @options.slice(*AUTH_KEYS).symbolize_keys)
end
Expand Down
11 changes: 10 additions & 1 deletion spec/lib/miq_automation_engine/models/miq_ae_git_import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
let(:tag_name) { "SomeTag1" }
let(:domain_name) { "BB8" }
let(:url) { "http://www.example.com/x/y" }
let(:verify_ssl_disabled) { 0 }
let(:domain) do
FactoryGirl.create(:miq_ae_git_domain,
:tenant => user.current_tenant,
:name => domain_name)
end
let(:repo) { FactoryGirl.create(:git_repository, :url => url) }
let(:repo) { FactoryGirl.create(:git_repository, :url => url, :verify_ssl => verify_ssl_disabled) }
let(:user) { FactoryGirl.create(:user_with_group) }
let(:branch_hash) do
{'ref' => branch_name, 'ref_type' => MiqAeGitImport::BRANCH}
Expand Down Expand Up @@ -168,6 +169,14 @@
expect(repo.authentications.first.userid).to eq('fred')
expect(repo.authentications.first.password).to eq('secret')
end

it "doesn't overwrite verify_ssl" do
expect(MiqAeYamlImportGitfs).to receive(:new).with(domain_name, import_options)
.and_return(miq_ae_yaml_import_gitfs)
allow(miq_ae_yaml_import_gitfs).to receive(:import).and_return(domain)
miq_ae_git_import.import
expect(repo.verify_ssl).to eq(verify_ssl_disabled)
end
end
end

Expand Down

0 comments on commit b28635d

Please sign in to comment.