Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Cai <jcai@gitlab.com>2020-06-10 22:31:10 +0300
committerJohn Cai <jcai@gitlab.com>2020-06-11 00:37:08 +0300
commit1abbad2329abc43d29d87424d0024fa4fb08baa9 (patch)
treea6760e727138184b28d8a60872592445ce94eaa3
parent763e3f40a24f0339b7517076f0e04a241a47c330 (diff)
check for empty ca_filejc-depreate-gitlab-shell-yml
-rw-r--r--ruby/gitlab-shell/lib/http_helper.rb8
-rw-r--r--ruby/gitlab-shell/spec/http_helper_spec.rb24
2 files changed, 30 insertions, 2 deletions
diff --git a/ruby/gitlab-shell/lib/http_helper.rb b/ruby/gitlab-shell/lib/http_helper.rb
index deea8863a..f721e9ae6 100644
--- a/ruby/gitlab-shell/lib/http_helper.rb
+++ b/ruby/gitlab-shell/lib/http_helper.rb
@@ -105,15 +105,19 @@ module HTTPHelper
store.set_default_paths
ca_file = config.http_settings.ca_file
- store.add_file(ca_file) if ca_file
+ store.add_file(ca_file) if present?(ca_file)
ca_path = config.http_settings.ca_path
- store.add_path(ca_path) if ca_path
+ store.add_path(ca_path) if present?(ca_path)
store
end
end
+ def present?(str)
+ !str.nil? && !str.empty?
+ end
+
def secret_token
@secret_token ||= File.read config.secret_file
end
diff --git a/ruby/gitlab-shell/spec/http_helper_spec.rb b/ruby/gitlab-shell/spec/http_helper_spec.rb
new file mode 100644
index 000000000..5a1fe631e
--- /dev/null
+++ b/ruby/gitlab-shell/spec/http_helper_spec.rb
@@ -0,0 +1,24 @@
+require_relative 'spec_helper'
+require_relative '../lib/http_helper'
+
+class GitlabNet
+ include HTTPHelper
+
+ def client(uri)
+ http_client_for(uri)
+ end
+end
+
+describe HTTPHelper do
+ let(:config_data) { {'http_settings' => { 'user' => 'user_123', 'password' =>'password123', 'ca_file' => '', 'ca_path' => '', 'read_timeout' => 200, 'self_signed' => true } } }
+
+ before do
+ allow(ENV).to receive(:fetch).with('GITALY_GITLAB_SHELL_CONFIG', '{}').and_return(config_data.to_json)
+ end
+
+ it 'creates an https client when ca_file and ca_path are empty' do
+ gitlab_net = GitlabNet.new
+
+ expect { gitlab_net.client(URI('https://localhost:8080')) }.not_to raise_error
+ end
+end