bunny 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fec40c94f09ec1a59ff65e902db263a81659bf06
4
- data.tar.gz: ecabd798af455fb73487bf088f2f34953d3e6a72
3
+ metadata.gz: 53c74a39ad4bc726f41f1c2db1f6ad7e7ebdefb8
4
+ data.tar.gz: 4ede7c5896c820ab5895963f1da741dda42e9fe7
5
5
  SHA512:
6
- metadata.gz: c4a1714e037cf752a4785f0890c373e8cd26b12f4cdeba8f4587d6667fa0d5ae51423540747be59bface7dee44899f3720521ddc832c2a3cb8334d563d8f7b30
7
- data.tar.gz: fb7074e6da4484b740d6e4a057d4a6f7ed0f9d4845a77d3e386cdde9f6dadc931087609adac51139e1cfbac9aee99d86afa95ada0a532b43e71e837547958fa1
6
+ metadata.gz: 14e4fbe2d2aca163498882cb49ee7d6ec90756a7c0c6e419b5c73e3afc31673451e4b75a4f47f1c49e5525dd91b5b792d074fa7edef18aa18957a542896bb02c
7
+ data.tar.gz: d750d4af8cf6fd512a60422865b4e8df3e0dcd6c6f72eb95ed671bd73ba053e3fca8dea7d853517502de59f0f43e0b3e7531f13f7a23d622050e98aaea2b552f
@@ -21,10 +21,8 @@ module Bunny
21
21
 
22
22
  # Default TCP connection timeout
23
23
  DEFAULT_CONNECTION_TIMEOUT = 5.0
24
- # Default TLS protocol version to use.
25
- # Currently SSLv3, same as in RabbitMQ Java client
26
- DEFAULT_TLS_PROTOCOL = "SSLv3"
27
-
24
+ DEFAULT_READ_TIMEOUT = 5.0
25
+ DEFAULT_WRITE_TIMEOUT = 5.0
28
26
 
29
27
  attr_reader :session, :host, :port, :socket, :connect_timeout, :read_write_timeout, :disconnect_timeout
30
28
  attr_reader :tls_context
@@ -315,7 +313,7 @@ module Bunny
315
313
  @tls_ca_certificates = opts.fetch(:tls_ca_certificates, default_tls_certificates)
316
314
  @verify_peer = opts[:verify_ssl] || opts[:verify_peer]
317
315
 
318
- @tls_context = initialize_tls_context(OpenSSL::SSL::SSLContext.new)
316
+ @tls_context = initialize_tls_context(OpenSSL::SSL::SSLContext.new, opts)
319
317
  end
320
318
 
321
319
  def wrap_in_tls_socket(socket)
@@ -349,7 +347,7 @@ module Bunny
349
347
  end
350
348
  end
351
349
 
352
- def initialize_tls_context(ctx)
350
+ def initialize_tls_context(ctx, opts={})
353
351
  ctx.cert = OpenSSL::X509::Certificate.new(@tls_certificate) if @tls_certificate
354
352
  ctx.key = OpenSSL::PKey::RSA.new(@tls_key) if @tls_key
355
353
  ctx.cert_store = if @tls_certificate_store
@@ -368,17 +366,15 @@ module Bunny
368
366
  @logger.warn "Using TLS but no client private key is provided!"
369
367
  end
370
368
 
371
- # setting TLS/SSL version only works correctly when done
372
- # vis set_params. MK.
373
- ctx.set_params(:ssl_version => @opts.fetch(:tls_protocol, DEFAULT_TLS_PROTOCOL))
374
-
375
369
  verify_mode = if @verify_peer
376
370
  OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
377
371
  else
378
372
  OpenSSL::SSL::VERIFY_NONE
379
373
  end
374
+ ctx.verify_mode = verify_mode
380
375
 
381
- ctx.set_params(:verify_mode => verify_mode)
376
+ ssl_version = opts[:tls_protocol] || opts[:ssl_version]
377
+ ctx.ssl_version = ssl_version if ssl_version
382
378
 
383
379
  ctx
384
380
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bunny
4
4
  # @return [String] Version of the library
5
- VERSION = "1.5.0"
5
+ VERSION = "1.5.1"
6
6
  end
@@ -124,4 +124,51 @@ unless ENV["CI"]
124
124
 
125
125
  include_examples "successful TLS connection"
126
126
  end
127
+
128
+
129
+ describe "TLS connection to RabbitMQ with ssl_version SSLv3 specified" do
130
+ let(:connection) do
131
+ c = Bunny.new(:user => "bunny_gem",
132
+ :password => "bunny_password",
133
+ :vhost => "bunny_testbed",
134
+ :tls => true,
135
+ :ssl_version => :SSLv3,
136
+ :tls_ca_certificates => ["./spec/tls/cacert.pem"])
137
+ c.start
138
+ c
139
+ end
140
+
141
+ after :each do
142
+ connection.close
143
+ end
144
+
145
+ include_examples "successful TLS connection"
146
+
147
+ it "connects using SSLv3" do
148
+ connection.transport.socket.ssl_version.should == "SSLv3"
149
+ end
150
+ end
151
+
152
+ describe "TLS connection to RabbitMQ with tls_version TLSv1 specified" do
153
+ let(:connection) do
154
+ c = Bunny.new(:user => "bunny_gem",
155
+ :password => "bunny_password",
156
+ :vhost => "bunny_testbed",
157
+ :tls => true,
158
+ :tls_protocol => :TLSv1,
159
+ :tls_ca_certificates => ["./spec/tls/cacert.pem"])
160
+ c.start
161
+ c
162
+ end
163
+
164
+ after :each do
165
+ connection.close
166
+ end
167
+
168
+ include_examples "successful TLS connection"
169
+
170
+ it "connects using TLSv1" do
171
+ connection.transport.socket.ssl_version.should == "TLSv1"
172
+ end
173
+ end
127
174
  end
@@ -1,15 +1,21 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "Rapidly opening and closing lots of channels" do
4
- connection = Bunny.new(:automatic_recovery => false).tap do |c|
5
- c.start
4
+ before :all do
5
+ @connection = Bunny.new(:automatic_recovery => false).tap do |c|
6
+ c.start
7
+ end
8
+ end
9
+
10
+ after :all do
11
+ @connection.close
6
12
  end
7
13
 
8
14
  context "in a single-threaded scenario" do
9
15
  let(:n) { 500 }
10
16
 
11
17
  it "works correctly" do
12
- xs = Array.new(n) { connection.create_channel }
18
+ xs = Array.new(n) { @connection.create_channel }
13
19
  puts "Opened #{n} channels"
14
20
 
15
21
  xs.size.should == n
@@ -35,12 +41,12 @@ describe "Rapidly opening and closing lots of channels" do
35
41
 
36
42
  n.times do
37
43
  t = Thread.new do
38
- ch1 = connection.create_channel
44
+ ch1 = @connection.create_channel
39
45
  q = ch1.queue("", :exclusive => true)
40
46
  q.delete
41
47
  ch1.close
42
48
 
43
- ch2 = connection.create_channel
49
+ ch2 = @connection.create_channel
44
50
  ch2.close
45
51
  end
46
52
  t.abort_on_exception = true
@@ -62,7 +68,7 @@ describe "Rapidly opening and closing lots of channels" do
62
68
  n.times do
63
69
  t = Thread.new do
64
70
  3.times do
65
- ch = connection.create_channel
71
+ ch = @connection.create_channel
66
72
  x = ch.topic('bunny.stress.topics.t2', :durable => false)
67
73
  ch.close
68
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Duncan
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-10-09 00:00:00.000000000 Z
15
+ date: 2014-10-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: amq-protocol