Skip to content

Commit

Permalink
Merge pull request #110 from xing/use_correct_value_for_ssl
Browse files Browse the repository at this point in the history
Use true and false for ssl option
  • Loading branch information
jojahner authored Aug 20, 2024
2 parents bdbce22 + 2f37e3a commit 665ddcc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/beetle/publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def new_bunny
:user => options[:user],
:pass => options[:pass],
:vhost => options[:vhost],
:ssl => options[:ssl],
:ssl => options[:ssl] || false,
:frame_max => @client.config.frame_max,
:channel_max => @client.config.channel_max,
:socket_timeout => @client.config.publishing_timeout,
Expand Down
2 changes: 1 addition & 1 deletion lib/beetle/queue_properties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def run_api_request(server, request_const, path, *request_args)
end

http = Net::HTTP.new(connection_options[:host], derived_api_port)
http.use_ssl = !!connection_options[:ssl]
http.use_ssl = connection_options[:ssl]
http.read_timeout = config.rabbitmq_api_read_timeout
http.write_timeout = config.rabbitmq_api_write_timeout if http.respond_to?(:write_timeout=)

Expand Down
8 changes: 4 additions & 4 deletions test/beetle/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ class ConnectionOptionsForServerTest < Minitest::Test
test "returns the options for the server provided" do
config = Configuration.new
config.servers = 'localhost:5672'
config.server_connection_options["localhost:5672"] = {host: 'localhost', port: 5672, user: "john", pass: "doe", vhost: "test", ssl: 0}
config.server_connection_options["localhost:5672"] = {host: 'localhost', port: 5672, user: "john", pass: "doe", vhost: "test", ssl: false}

config.connection_options_for_server("localhost:5672").tap do |options|
assert_equal "localhost", options[:host]
assert_equal 5672, options[:port]
assert_equal "john", options[:user]
assert_equal "doe", options[:pass]
assert_equal "test", options[:vhost]
assert_equal 0, options[:ssl]
assert_equal false, options[:ssl]
end
end

Expand All @@ -103,15 +103,15 @@ class ConnectionOptionsForServerTest < Minitest::Test
test "allows to set specific options while retaining defaults for the rest" do
config = Configuration.new
config.servers = 'localhost:5672'
config.server_connection_options["localhost:5672"] = { pass: "another_pass", ssl: 1 }
config.server_connection_options["localhost:5672"] = { pass: "another_pass", ssl: true }

config.connection_options_for_server("localhost:5672").tap do |options|
assert_equal "localhost", options[:host]
assert_equal 5672, options[:port]
assert_equal "guest", options[:user]
assert_equal "another_pass", options[:pass]
assert_equal "/", options[:vhost]
assert_equal 1, options[:ssl]
assert_equal true, options[:ssl]
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions test/beetle/publisher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup
:user => "guest",
:pass => "guest",
:vhost => "/",
:ssl => nil,
:ssl => false,
:socket_timeout => 0,
:connect_timeout => 5,
:frame_max => 131072,
Expand All @@ -38,7 +38,7 @@ def setup
test "new bunnies should be created using custom connection options and they should be started" do
config = Configuration.new
config.servers = 'localhost:5672'
config.server_connection_options["localhost:5672"] = { user: "john", pass: "doe", vhost: "test", ssl: 0 }
config.server_connection_options["localhost:5672"] = { user: "john", pass: "doe", vhost: "test", ssl: false }
client = Client.new(config)
pub = Publisher.new(client)

Expand All @@ -49,7 +49,7 @@ def setup
user: "john",
pass: "doe",
vhost: "test",
ssl: 0,
ssl: false,
socket_timeout: 0,
connect_timeout: 5,
frame_max: 131072,
Expand Down
6 changes: 3 additions & 3 deletions test/beetle/subscriber_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class ConnectionTest < Minitest::Test
def setup
@config = Beetle::Configuration.new
@config.servers = "mickey:42"
@config.server_connection_options["mickey:42"] = { user: "john", pass: "doe", vhost: "test", ssl: 0 }
@config.server_connection_options["mickey:42"] = { user: "john", pass: "doe", vhost: "test", ssl: false }

@client = Client.new(@config)
@sub = @client.send(:subscriber)
Expand Down Expand Up @@ -490,11 +490,11 @@ def setup
EM.expects(:run).yields
EM.expects(:reactor_running?).returns(true)

AMQP.expects(:connect).once.with(has_entries(host: "mickey", port: 42, user: "john", pass: "doe", ssl: 0)).yields(connection)
AMQP.expects(:connect).once.with(has_entries(host: "mickey", port: 42, user: "john", pass: "doe", ssl: false)).yields(connection)

@sub.listen_queues(["a_queue"])
end


test "channel opening, exchange creation, queue bindings and subscription" do
connection = mock("connection")
Expand Down

0 comments on commit 665ddcc

Please sign in to comment.