Skip to content

RUBY-889 Only use ssl options if :ssl is true #595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/mongo/server/connectable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ def timeout

private

attr_reader :socket, :ssl_options
attr_reader :socket

def ssl_options
@ssl_options[:ssl] == true ? @ssl_options : {}
end

def ensure_connected
ensure_same_process!
Expand Down
33 changes: 33 additions & 0 deletions spec/mongo/server/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,39 @@
end
end

context 'when ssl is false' do

context 'when ssl options are provided' do

let(:ssl_options) do
{ :ssl => false, :ssl_key => 'file', :ssl_key_pass_phrase => 'iamaphrase' }
end

let(:connection) do
described_class.new(server, ssl_options)
end

it 'does not set the ssl options' do
expect(connection.send(:ssl_options)).to be_empty
end
end

context 'when ssl options are not provided' do

let(:ssl_options) do
{ :ssl => false }
end

let(:connection) do
described_class.new(server, ssl_options)
end

it 'does not set the ssl options' do
expect(connection.send(:ssl_options)).to be_empty
end
end
end

context 'when authentication options are provided' do

let(:connection) do
Expand Down