diff options
author | Tristan Hill <tristan.hill@bbc.co.uk> | 2017-07-20 10:23:46 +0100 |
---|---|---|
committer | Tristan Hill <tristan.hill@bbc.co.uk> | 2017-07-24 16:50:41 +0100 |
commit | 4a55f61c549dce560fecc905168de5b83e4fb7a4 (patch) | |
tree | 98f9ed0c3716b2c43cbf6dc74f22eea83f12986c /spec/bundler | |
parent | 53dfec6917c9fd2795856cbd776cff2029a0416e (diff) | |
download | bundler-4a55f61c549dce560fecc905168de5b83e4fb7a4.tar.gz |
Use ssl client cert and ca cert settings from gem configuration as fallbacks
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/fetcher_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/bundler/fetcher_spec.rb b/spec/bundler/fetcher_spec.rb index 2746da3bd8..f9e52e09c0 100644 --- a/spec/bundler/fetcher_spec.rb +++ b/spec/bundler/fetcher_spec.rb @@ -85,6 +85,47 @@ RSpec.describe Bundler::Fetcher do end end end + + context "when no ssl configuration is set" do + it "no cert" do + expect(fetcher.send(:connection).cert).to be_nil + expect(fetcher.send(:connection).key).to be_nil + end + end + + context "when bunder ssl ssl configuration is set" do + before do + allow(Bundler.settings).to receive(:[]).and_return(nil) + allow(Bundler.settings).to receive(:[]).with(:ssl_client_cert).and_return("/cert") + expect(File).to receive(:read).with("/cert").and_return("") + expect(OpenSSL::X509::Certificate).to receive(:new).and_return("cert") + expect(OpenSSL::PKey::RSA).to receive(:new).and_return("key") + end + it "use bundler configuration" do + expect(fetcher.send(:connection).cert).to eq("cert") + expect(fetcher.send(:connection).key).to eq("key") + end + end + + context "when gem ssl configuration is set" do + before do + allow(Bundler.rubygems.configuration).to receive_messages( + :http_proxy => nil, + :ssl_client_cert => "cert", + :ssl_ca_cert => "ca" + ) + expect(File).to receive(:read).and_return("") + expect(OpenSSL::X509::Certificate).to receive(:new).and_return("cert") + expect(OpenSSL::PKey::RSA).to receive(:new).and_return("key") + store = double("ca store") + expect(store).to receive(:add_file) + expect(OpenSSL::X509::Store).to receive(:new).and_return(store) + end + it "use gem configuration" do + expect(fetcher.send(:connection).cert).to eq("cert") + expect(fetcher.send(:connection).key).to eq("key") + end + end end describe "#user_agent" do |