Skip to content

Commit d6064fe

Browse files
committed
add specs
1 parent 7aade40 commit d6064fe

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/httparty/connection_adapter.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ def attach_ssl_certificates(http, options)
233233
end
234234

235235
# Include full certificate chain
236-
if options[:extra_chain_cert] && options[:p12]
236+
# Only Ruby 3.0+
237+
if options[:extra_chain_cert] && options[:p12] && http.respond_to?(:extra_chain_cert=)
237238
http.extra_chain_cert = [p12.certificate] + p12.ca_certs
238239
end
239240
end

spec/httparty/connection_adapter_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,15 @@
628628
expect(subject.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
629629
end
630630
end
631+
632+
context "when using extra_chain_cert and p12 on Ruby 3.0+" do
633+
let(:options) { {p12: p12, p12_password: "password", extra_chain_cert: true} }
634+
635+
it "sets extra_chain_cert on http object" do
636+
allow(pkcs12).to receive(:ca_certs).and_return([double("OpenSSL::X509::Certificate")])
637+
expect(subject.extra_chain_cert).to eq([cert] + pkcs12.ca_certs)
638+
end
639+
end
631640
end
632641

633642
context "when scheme is not https" do

spec/httparty_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
end
3636
end
3737

38+
describe "extra_chain_cert" do
39+
it 'should set the extra_chain_cert option' do
40+
@klass.extra_chain_cert true
41+
expect(@klass.default_options[:extra_chain_cert]).to eq(true)
42+
end
43+
end
44+
3845
describe 'ssl_version' do
3946
it 'should set the ssl_version content' do
4047
@klass.ssl_version :SSLv3

0 commit comments

Comments
 (0)