Skip to content

Commit 6bcc9e2

Browse files
authored
Merge pull request #9610 from junaruga/wip/bundler-fix-bundle-config-set-ssl_ca_cert
Set `Bundler.settings[:ssl_ca_cert]` to download gems
2 parents 68f3150 + ad9f1c7 commit 6bcc9e2

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

bundler/lib/bundler/fetcher/gem_remote_fetcher.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ def initialize(*)
99
super
1010

1111
@pool_size = Bundler.settings.installation_parallelization
12+
ssl_ca_cert = Bundler.settings[:ssl_ca_cert]
13+
@cert_files << ssl_ca_cert if ssl_ca_cert
1214
end
1315

1416
def request(*args)

spec/bundler/fetcher/gem_remote_fetcher_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,36 @@
66
require "bundler/vendored_persistent.rb"
77

88
RSpec.describe Bundler::Fetcher::GemRemoteFetcher do
9+
describe "#initialize" do
10+
context "when ssl_ca_cert setting is not set" do
11+
before do
12+
allow(Bundler.settings).to receive(:[]).and_call_original
13+
allow(Bundler.settings).to receive(:[]).with(:ssl_ca_cert).and_return(nil)
14+
end
15+
16+
it "does not append the setting to @cert_files" do
17+
cert_files = subject.instance_variable_get(:@cert_files)
18+
gem_cert_files = Gem::Request.get_cert_files
19+
expect(cert_files).to eq(gem_cert_files)
20+
end
21+
end
22+
23+
context "when ssl_ca_cert setting is set" do
24+
let(:ca_cert_path) { "/path/to/ca_cert" }
25+
26+
before do
27+
allow(Bundler.settings).to receive(:[]).and_call_original
28+
allow(Bundler.settings).to receive(:[]).with(:ssl_ca_cert).and_return(ca_cert_path)
29+
end
30+
31+
it "appends the setting to @cert_files" do
32+
cert_files = subject.instance_variable_get(:@cert_files)
33+
gem_cert_files = Gem::Request.get_cert_files
34+
expect(cert_files).to eq(gem_cert_files + [ca_cert_path])
35+
end
36+
end
37+
end
38+
939
describe "Parallel download" do
1040
it "download using multiple connections from the pool" do
1141
unless Bundler.rubygems.provides?(">= 4.0.0.dev")

0 commit comments

Comments
 (0)