Skip to content

Commit

Permalink
Add a client cert spec for the http client
Browse files Browse the repository at this point in the history
  • Loading branch information
dafalcon-aka committed Nov 30, 2017
1 parent 59f463e commit 0e8f0f3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/jira/http_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
JIRA::HttpClient.new(options)
end

let(:basic_client_cert_client) do
options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(
:use_client_cert => true,
:cert => 'public certificate contents',
:key => 'private key contents'
)
JIRA::HttpClient.new(options)
end

let(:response) do
response = double("response")
allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(true)
Expand Down Expand Up @@ -170,6 +179,22 @@
expect(basic_client.http_conn(uri)).to eq(http_conn)
end

it 'can use client certificates' do
http_conn = double
uri = double
host = double
port = double
expect(Net::HTTP).to receive(:new).with(host, port).and_return(http_conn)
expect(uri).to receive(:host).and_return(host)
expect(uri).to receive(:port).and_return(port)
expect(http_conn).to receive(:use_ssl=).with(basic_client.options[:use_ssl])
expect(http_conn).to receive(:verify_mode=).with(basic_client.options[:ssl_verify_mode])
expect(http_conn).to receive(:read_timeout=).with(basic_client.options[:read_timeout])
expect(http_conn).to receive(:cert=).with(basic_client_cert_client.options[:cert])
expect(http_conn).to receive(:key=).with(basic_client_cert_client.options[:key])
expect(basic_client_cert_client.http_conn(uri)).to eq(http_conn)
end

it "returns a http connection" do
http_conn = double()
uri = double()
Expand Down

0 comments on commit 0e8f0f3

Please sign in to comment.