Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't unconditionally update verify_ssl #52

Merged
merged 1 commit into from
Jul 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/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/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