bunny 2.6.4 → 2.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 805ab484c94b0c54cafc8d9a895b86b2e204ccbc
4
- data.tar.gz: 3982bbb9af0f8c6b4352535804c2fb00f01b8b5c
3
+ metadata.gz: 9646b786d482eb19ff72a0cca49d19b35133a3ee
4
+ data.tar.gz: 9eaee52c70d70e93ed1ccbc532305ddd67d028ef
5
5
  SHA512:
6
- metadata.gz: cd8285ba649b6868d7298f9695b45909753b8a477709e938d4a844365ad87a78644902ffc93105599bbccf56878e5dab4432bdd9ccca2b315ef44855fbe6f06a
7
- data.tar.gz: 828eb8792fccbbc8b624ba0a1b6abea3d44523089676479c6e5371c5505ef33ec32f4c3621db3fb93f5f81dfaf3043c87429c841544d4343eba6ad534e6e269f
6
+ metadata.gz: 907064ff90c3752d8e2a240d3a86558e6462984ed10a24c0b51eaded877fa2373cf6b278376fc34205b85742a0769d9838c906cf1fb6916debad58177dcd4db4
7
+ data.tar.gz: cab82513ced1682e9282c4595a79d531989954972c3a2f9179625c46d857251c8b50d7137501ae129eb6b58bd37f80e716989d7fd0be6e00dc291b9b9213401c
data/.gitignore CHANGED
@@ -21,6 +21,8 @@ debug/*
21
21
  *.dump
22
22
  deploy.docs.sh
23
23
  .ruby-version
24
+ .idea
25
+ *.srl
24
26
  spec/tls/*.pem
25
27
  spec/tls/*.pem~
26
28
  spec/tls/*.p12
@@ -24,7 +24,14 @@ Run the following command from the base directory of the gem:
24
24
  RABBITMQ_NODENAME=bunny RABBITMQ_CONFIG_FILE=./spec/config/rabbitmq RABBITMQ_ENABLED_PLUGINS_FILE=./spec/config/enabled_plugins rabbitmq-server
25
25
  ```
26
26
 
27
- The specs use the RabbitMQ management plugin and require a TLS port to be available. The config files in the spec/config directory enable these.
27
+ The specs use the RabbitMQ management plugin and require a TLS port to
28
+ be available. The config files in the spec/config directory enable
29
+ these. TLS (x509 PEM) certificates include a hostname-specific fields,
30
+ the tests allow for expecting hostname overriding using the `BUNNY_RABBITMQ_HOSTNAME`
31
+ environment variables (default value is `127.0.0.1`).
32
+
33
+ Server, CA and client certificates can be found under `spec/tls`. They are supposed to be
34
+ generated with [tls-gen](github.com/michaelklishin/tls-gen) or similar in the target environment.
28
35
 
29
36
  Next up you'll need to prepare your node for the specs (just once):
30
37
 
@@ -32,6 +39,12 @@ Next up you'll need to prepare your node for the specs (just once):
32
39
  RABBITMQ_NODENAME=bunny ./bin/ci/before_build
33
40
  ```
34
41
 
42
+ The script uses `rabbitmqctl` and `rabbitmq-plugins`
43
+ to set up RabbitMQ in a way that Bunny test suites expect. Two environment variables,
44
+ `RABBITMQCTL` and `RABBITMQ_PLUGINS`, are available to control what `rabbitmqctl` and
45
+ `rabbitmq-plugins` commands will be used. By default they are taken from `PATH`
46
+ and prefixed with `sudo`.
47
+
35
48
  And then run the core integration suite:
36
49
 
37
50
  ```
@@ -40,26 +53,26 @@ RABBITMQ_NODENAME=bunny CI=true rspec
40
53
 
41
54
  #### Running a RabbitMQ server in a Docker container
42
55
 
43
- First off you have to [install Docker](https://docs.docker.com/engine/installation/) (>= 1.9).
56
+ First off you have to [install Docker Compose](https://docker.github.io/compose/install/) (and by proxy Docker).
57
+ Version >= 1.6.0+ is required for compose version 2 syntax.
44
58
 
45
- After Docker has been installed (and the `docker` command is available on your command line path), run
59
+ After those have been installed (and the `docker-compose` command is available on your command line path), run
46
60
 
47
- ./bin/ci/start_rabbitmq
61
+ ```
62
+ docker-compose up
63
+ ```
48
64
 
49
65
  The first time you do this, it will take some time, since it has to download everything it needs
50
66
  to build the Docker image.
51
67
 
52
68
  The RabbitMQ server will run in the foreground in the terminal where you started it. You can stop
53
- it by pressing CTRL+C.
69
+ it by pressing CTRL+C. If you want to run it in the background, run `docker-compose up -d`.
54
70
 
55
71
  ### Running Test Suites
56
72
 
57
- Prior to running the tests, configure the RabbitMQ permissions
58
- by running `./bin/ci/before_build`. The script uses `rabbitmqctl` and `rabbitmq-plugins`
59
- to set up RabbitMQ in a way that Bunny test suites expect. Two environment variables,
60
- `RABBITMQCTL` and `RABBITMQ_PLUGINS`, are available to control what `rabbitmqctl` and
61
- `rabbitmq-plugins` commands will be used. By default they are taken from `PATH`
62
- and prefixed with `sudo`.
73
+ Prior to running the tests, configure the RabbitMQ permissions by running `./bin/ci/before_build`
74
+ if you have RabbitMQ locally installed, if you are running RabbitMQ via Docker as above this step
75
+ is not required as the setup is baked in.
63
76
 
64
77
  Make sure you have those two installed and then run integration tests:
65
78
 
@@ -1,4 +1,20 @@
1
- ## Changes between Bunny 2.6.3 and 2.6.4 (unreleased)
1
+ ## Changes between Bunny 2.6.4 and 2.6.5 (April 15th, 2017)
2
+
3
+ ### Absolute Windows File Paths are No Longer treated as Inline Certs
4
+
5
+ Contributed by Jared Smartt.
6
+
7
+ GitHub issue: [#492](https://github.com/ruby-amqp/bunny/issues/492).
8
+
9
+
10
+
11
+ ## Changes between Bunny 2.6.3 and 2.6.4 (March 4th, 2017)
12
+
13
+ ### `Bunny::ContinuationQueue#poll` Less Prone to Race Conditions
14
+
15
+ `Bunny::ContinuationQueue#poll` was reworked with feedback from Joseph Wong.
16
+
17
+ GitHub issue: [#462](https://github.com/ruby-amqp/bunny/issues/462)
2
18
 
3
19
  ### Recovery Attempt Counting Strategy Changed
4
20
 
@@ -16,6 +32,12 @@ a hell of a lot more logging.
16
32
 
17
33
  GitHub issue: [#408](https://github.com/ruby-amqp/bunny/issues/408)
18
34
 
35
+ ### Opening a Channel on an Intentionally Closed Connection Immediately Raises an Exception
36
+
37
+ Contributed by Alessandro Verlato.
38
+
39
+ GitHub issue: [#465](https://github.com/ruby-amqp/bunny/issues/465)
40
+
19
41
 
20
42
  ## Changes between Bunny 2.6.2 and 2.6.3 (January 19th, 2016)
21
43
 
data/README.md CHANGED
@@ -73,7 +73,7 @@ a stable public API.
73
73
 
74
74
  ### Most Recent Release
75
75
 
76
- [![Gem Version](https://badge.fury.io/rb/bunny.png)](http://badge.fury.io/rb/bunny)
76
+ [![Gem Version](https://badge.fury.io/rb/bunny.svg)](http://badge.fury.io/rb/bunny)
77
77
 
78
78
  ### With Rubygems
79
79
 
@@ -88,7 +88,7 @@ gem install bunny
88
88
  To use Bunny in a project managed with Bundler:
89
89
 
90
90
  ``` ruby
91
- gem "bunny", ">= 2.6.3"
91
+ gem "bunny", ">= 2.6.4"
92
92
  ```
93
93
 
94
94
 
@@ -167,9 +167,7 @@ to also join the [RabbitMQ mailing list](https://groups.google.com/forum/#!forum
167
167
 
168
168
  To subscribe for announcements of releases, important changes and so on, please follow [@rubyamqp](https://twitter.com/#!/rubyamqp) on Twitter.
169
169
 
170
- More detailed announcements can be found in the blogs
171
-
172
- * [RabbitMQ Ruby clients blog](http://blog.rubyrabbitmq.info)
170
+ More detailed announcements can be found in the [RabbitMQ Ruby clients blog](http://blog.rubyrabbitmq.info).
173
171
 
174
172
 
175
173
  ### Reporting Issues
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rspec/core/rake_task'
4
4
  RSpec::Core::RakeTask.new(:integration) do |t|
5
5
  # excludes unit tests as those involve many iterations
6
6
  # and sometimes suffer from obscure interference from integration tests (!)
7
- t.pattern = ["spec/higher_level_api/integration", "spec/lower_level_api/integration", "spec/issues", "spec/stress"].
7
+ t.pattern = ["spec/higher_level_api/integration", "spec/lower_level_api/integration", "spec/issues"].
8
8
  map { |dir| Dir.glob(File.join(dir, "**", "*_spec.rb")) }.reduce(&:+) - ["spec/higher_level_api/integration/tls_connection_spec.rb"]
9
9
 
10
10
  t.rspec_opts = "--format progress"
@@ -30,9 +30,17 @@ end
30
30
  RSpec::Core::RakeTask.new(:recovery_integration) do |t|
31
31
  # otherwise all examples will be skipped
32
32
  ENV.delete("CI")
33
- t.pattern = Dir.glob("spec/higher_level_api/integration/connection_recovery_spec.rb")
33
+ t.pattern = ["spec/higher_level_api/integration/connection_recovery_spec.rb"]
34
34
 
35
35
  t.rspec_opts = "--format progress --backtrace"
36
36
  end
37
37
 
38
+ RSpec::Core::RakeTask.new(:stress) do |t|
39
+ # excludes unit tests as those involve many iterations
40
+ # and sometimes suffer from obscure interference from integration tests (!)
41
+ t.pattern = ["spec/stress/**/*_spec.rb"]
42
+
43
+ t.rspec_opts = "--format progress"
44
+ end
45
+
38
46
  task :default => :integration
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.email = ["michael.s.klishin@gmail.com"]
25
25
 
26
26
  # Dependencies
27
- s.add_dependency "amq-protocol", ">= 2.0.1"
27
+ s.add_dependency "amq-protocol", ">= 2.1.0"
28
28
 
29
29
  # Files.
30
30
  s.has_rdoc = true
@@ -0,0 +1,18 @@
1
+ version: '2'
2
+ services:
3
+ rabbitmq:
4
+ build: ./docker
5
+ container_name: bunny_rabbitmq
6
+ environment:
7
+ RABBITMQ_NODENAME: bunny
8
+ # link to spec specific configuration
9
+ RABBITMQ_CONFIG_FILE: /spec/config/rabbitmq
10
+ RABBITMQ_ENABLED_PLUGINS_FILE: /spec/config/enabled_plugins
11
+ # send logs to stdout
12
+ RABBITMQ_LOGS: '-'
13
+ RABBITMQ_SASL_LOGS: '-'
14
+ ports:
15
+ - 5671-5672:5671-5672
16
+ - 15672:15672
17
+ volumes:
18
+ - ./spec:/spec:ro
@@ -4,7 +4,7 @@ RUN apt-get -q update && \
4
4
  apt-get install -yq --no-install-recommends wget ca-certificates
5
5
 
6
6
  RUN echo 'deb http://www.rabbitmq.com/debian/ testing main' > /etc/apt/sources.list.d/rabbitmq.list && \
7
- wget -O- https://www.rabbitmq.com/rabbitmq-signing-key-public.asc | apt-key add -
7
+ wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | apt-key add -
8
8
 
9
9
  RUN apt-get -q update && \
10
10
  apt-get install -yq --no-install-recommends rabbitmq-server
@@ -12,3 +12,5 @@ RUN apt-get -q update && \
12
12
  COPY docker-entrypoint.sh /
13
13
 
14
14
  ENTRYPOINT /docker-entrypoint.sh
15
+
16
+ EXPOSE 5671 5672 15672
@@ -1,9 +1,10 @@
1
1
  #!/bin/sh
2
2
  server=rabbitmq-server
3
3
  ctl=rabbitmqctl
4
- plugins=rabbitmq-plugins
5
4
  delay=3
6
5
 
6
+ echo "[Configuration] $(eval cat $RABBITMQ_CONFIG_FILE.config)"
7
+
7
8
  echo '[Configuration] Starting RabbitMQ in detached mode.'
8
9
 
9
10
  $server -detached
@@ -12,10 +13,6 @@ echo "[Configuration] Waiting $delay seconds for RabbitMQ to start."
12
13
 
13
14
  sleep $delay
14
15
 
15
- echo '*** Enabling plugins ***'
16
- $plugins enable --online rabbitmq_management
17
- $plugins enable --online rabbitmq_consistent_hash_exchange
18
-
19
16
  echo '*** Creating users ***'
20
17
  $ctl add_user bunny_gem bunny_password
21
18
  $ctl add_user bunny_reader reader_password
@@ -308,7 +308,7 @@ module Bunny
308
308
  # @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions to AMQP 0.9.1 guide
309
309
  # @api public
310
310
  def fanout(name, opts = {})
311
- Exchange.new(self, :fanout, name, opts)
311
+ find_exchange(name) || Exchange.new(self, :fanout, name, opts)
312
312
  end
313
313
 
314
314
  # Declares a direct exchange or looks it up in the cache of previously
@@ -326,7 +326,7 @@ module Bunny
326
326
  # @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions to AMQP 0.9.1 guide
327
327
  # @api public
328
328
  def direct(name, opts = {})
329
- Exchange.new(self, :direct, name, opts)
329
+ find_exchange(name) || Exchange.new(self, :direct, name, opts)
330
330
  end
331
331
 
332
332
  # Declares a topic exchange or looks it up in the cache of previously
@@ -344,7 +344,7 @@ module Bunny
344
344
  # @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions to AMQP 0.9.1 guide
345
345
  # @api public
346
346
  def topic(name, opts = {})
347
- Exchange.new(self, :topic, name, opts)
347
+ find_exchange(name) || Exchange.new(self, :topic, name, opts)
348
348
  end
349
349
 
350
350
  # Declares a headers exchange or looks it up in the cache of previously
@@ -362,7 +362,7 @@ module Bunny
362
362
  # @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions to AMQP 0.9.1 guide
363
363
  # @api public
364
364
  def headers(name, opts = {})
365
- Exchange.new(self, :headers, name, opts)
365
+ find_exchange(name) || Exchange.new(self, :headers, name, opts)
366
366
  end
367
367
 
368
368
  # Provides access to the default exchange
@@ -1384,7 +1384,7 @@ module Bunny
1384
1384
  # @see #nacked_set
1385
1385
  # @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions guide
1386
1386
  # @api public
1387
- def confirm_select(callback=nil)
1387
+ def confirm_select(callback = nil)
1388
1388
  raise_if_no_longer_open!
1389
1389
 
1390
1390
  if @next_publish_seq_no == 0
@@ -54,7 +54,7 @@ module Bunny
54
54
  @network_is_down = true
55
55
  @session_thread.raise(Bunny::NetworkFailure.new("caught an unexpected exception in the network loop: #{e.message}", e))
56
56
  end
57
- rescue Errno::EBADF => ebadf
57
+ rescue Errno::EBADF => _ebadf
58
58
  break if terminate?
59
59
  # ignored, happens when we loop after the transport has already been closed
60
60
  @mutex.synchronize { @stopping = true }
@@ -187,7 +187,8 @@ module Bunny
187
187
  @channel_max = @client_channel_max
188
188
  @client_heartbeat = self.heartbeat_from(opts)
189
189
 
190
- @client_properties = DEFAULT_CLIENT_PROPERTIES.merge(opts.fetch(:properties, {}))
190
+ client_props = opts[:properties] || opts[:client_properties] || {}
191
+ @client_properties = DEFAULT_CLIENT_PROPERTIES.merge(client_props)
191
192
  @mechanism = opts.fetch(:auth_mechanism, "PLAIN")
192
193
  @credentials_encoder = credentials_encoder_for(@mechanism)
193
194
  @locale = @opts.fetch(:locale, DEFAULT_LOCALE)
@@ -817,7 +818,7 @@ module Bunny
817
818
  shut_down_all_consumer_work_pools!
818
819
  maybe_shutdown_reader_loop
819
820
  maybe_shutdown_heartbeat_sender
820
- rescue ShutdownSignal => sse
821
+ rescue ShutdownSignal => _sse
821
822
  # no-op
822
823
  rescue Exception => e
823
824
  @logger.warn "Caught an exception when cleaning up after receiving connection.close: #{e.message}"
@@ -1208,7 +1209,7 @@ module Bunny
1208
1209
  begin
1209
1210
  shut_down_all_consumer_work_pools!
1210
1211
  maybe_shutdown_reader_loop
1211
- rescue ShutdownSignal => sse
1212
+ rescue ShutdownSignal => _sse
1212
1213
  # no-op
1213
1214
  rescue Exception => e
1214
1215
  @logger.warn "Caught an exception when cleaning up after receiving connection.close: #{e.message}"
@@ -4,7 +4,7 @@ require "monitor"
4
4
 
5
5
  begin
6
6
  require "openssl"
7
- rescue LoadError => le
7
+ rescue LoadError => _le
8
8
  $stderr.puts "Could not load OpenSSL"
9
9
  end
10
10
 
@@ -92,7 +92,7 @@ module Bunny
92
92
  end
93
93
 
94
94
  def connected?
95
- :not_connected == @status && open?
95
+ :connected == @status && open?
96
96
  end
97
97
 
98
98
  def configure_socket(&block)
@@ -263,7 +263,7 @@ module Bunny
263
263
  :connect_timeout => timeout)
264
264
 
265
265
  true
266
- rescue SocketError, Timeout::Error => e
266
+ rescue SocketError, Timeout::Error => _e
267
267
  false
268
268
  ensure
269
269
  s.close if s
@@ -318,7 +318,7 @@ module Bunny
318
318
  def tls_certificate_from(opts)
319
319
  begin
320
320
  read_client_certificate!
321
- rescue MissingTLSCertificateFile => e
321
+ rescue MissingTLSCertificateFile => _e
322
322
  inline_client_certificate_from(opts)
323
323
  end
324
324
  end
@@ -326,7 +326,7 @@ module Bunny
326
326
  def tls_key_from(opts)
327
327
  begin
328
328
  read_client_key!
329
- rescue MissingTLSKeyFile => e
329
+ rescue MissingTLSKeyFile => _e
330
330
  inline_client_key_from(opts)
331
331
  end
332
332
  end
@@ -364,6 +364,11 @@ module Bunny
364
364
  raise "cannot wrap a socket into TLS socket, @tls_context is nil. This is a Bunny bug." unless @tls_context
365
365
 
366
366
  s = Bunny::SSLSocketImpl.new(socket, @tls_context)
367
+
368
+ # always set the SNI server name if possible since RFC 3546 and RFC 6066 both state
369
+ # that TLS clients supporting the extensions can talk to TLS servers that do not
370
+ s.hostname = @host if s.respond_to?(:hostname)
371
+
367
372
  s.sync_close = true
368
373
  s
369
374
  end
@@ -450,9 +455,9 @@ but prone to man-in-the-middle attacks. Please set verify_peer: true in producti
450
455
  cert_files = []
451
456
  cert_inlines = []
452
457
  certs.each do |cert|
453
- # if it starts with / then it's a file path that may or may not
454
- # exists (e.g. a default OpenSSL path). MK.
455
- if File.readable?(cert) || cert =~ /^\//
458
+ # if it starts with / or C:/ then it's a file path that may or may not
459
+ # exist (e.g. a default OpenSSL path). MK.
460
+ if File.readable?(cert) || cert =~ /^([a-z]:?)?\//i
456
461
  cert_files.push(cert)
457
462
  else
458
463
  cert_inlines.push(cert)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bunny
4
4
  # @return [String] Version of the library
5
- VERSION = "2.6.4"
5
+ VERSION = "2.6.5"
6
6
  end
@@ -2,12 +2,13 @@
2
2
 
3
3
  {rabbit, [
4
4
  {ssl_listeners, [5671]},
5
- {ssl_options, [{cacertfile,"spec/tls/cacert.pem"},
6
- {certfile,"spec/tls/server_cert.pem"},
7
- {keyfile,"spec/tls/server_key.pem"},
5
+ {ssl_options, [{cacertfile,"/spec/tls/ca_certificate.pem"},
6
+ {certfile,"/spec/tls/server_certificate.pem"},
7
+ {keyfile,"/spec/tls/server_key.pem"},
8
8
  {verify,verify_none},
9
- {fail_if_no_peer_cert,false}]} ]
10
- },
9
+ {fail_if_no_peer_cert,false}]},
10
+ {loopback_users, []}
11
+ ] },
11
12
 
12
13
  {rabbitmq_management,
13
14
  [{listener,
@@ -316,6 +316,7 @@ describe "Connection recovery" do
316
316
  delivered = false
317
317
 
318
318
  ch = c.create_channel
319
+ ch.confirm_select
319
320
  q = ch.queue("", exclusive: true)
320
321
  q.subscribe do |_, _, _|
321
322
  delivered = true
@@ -325,13 +326,14 @@ describe "Connection recovery" do
325
326
  expect(ch).to be_open
326
327
 
327
328
  q.publish("")
329
+ ch.wait_for_confirms
328
330
 
329
331
  poll_until { delivered }
330
332
  end
331
333
  end
332
334
 
333
335
  it "recovers all consumers" do
334
- n = 1024
336
+ n = 32
335
337
 
336
338
  with_open do |c|
337
339
  ch = c.create_channel
@@ -347,7 +349,7 @@ describe "Connection recovery" do
347
349
  end
348
350
 
349
351
  it "recovers all queues" do
350
- n = 256
352
+ n = 32
351
353
 
352
354
  qs = []
353
355
 
@@ -385,6 +387,16 @@ describe "Connection recovery" do
385
387
  end
386
388
 
387
389
  def close_all_connections!
390
+ # let whatever actions were taken before
391
+ # this call a chance to propagate, e.g. to make
392
+ # sure that connections are accounted for in the
393
+ # stats DB.
394
+ #
395
+ # See bin/ci/before_build for management plugin
396
+ # pre-configuration.
397
+ #
398
+ # MK.
399
+ sleep 1.1
388
400
  connections.each do |conn_info|
389
401
  close_ignoring_permitted_exceptions(conn_info.name)
390
402
  end
@@ -401,14 +413,14 @@ describe "Connection recovery" do
401
413
  end
402
414
 
403
415
  def poll_while(&probe)
404
- Timeout::timeout(10) {
405
- sleep 0.1 while probe[]
416
+ Timeout.timeout(20) {
417
+ sleep 0.1 while probe.call
406
418
  }
407
419
  end
408
420
 
409
421
  def poll_until(&probe)
410
- Timeout::timeout(10) {
411
- sleep 0.1 until probe[]
422
+ Timeout.timeout(20) {
423
+ sleep 0.1 until probe.call
412
424
  }
413
425
  end
414
426
 
@@ -4,6 +4,16 @@ describe Bunny::Session do
4
4
  let(:http_client) { RabbitMQ::HTTP::Client.new("http://127.0.0.1:15672") }
5
5
 
6
6
  def close_connection(client_port)
7
+ # let whatever actions were taken before
8
+ # this call a chance to propagate, e.g. to make
9
+ # sure that connections are accounted for in the
10
+ # stats DB.
11
+ #
12
+ # See bin/ci/before_build for management plugin
13
+ # pre-configuration.
14
+ #
15
+ # MK.
16
+ sleep 1.1
7
17
  c = http_client.
8
18
  list_connections.
9
19
  find { |conn_info| conn_info && conn_info.peer_port.to_i == client_port }
@@ -12,7 +22,7 @@ describe Bunny::Session do
12
22
  end
13
23
 
14
24
  def wait_for_recovery
15
- sleep 0.5
25
+ sleep 1.5
16
26
  end
17
27
 
18
28
  it "can be closed" do
@@ -58,6 +68,7 @@ describe Bunny::Session do
58
68
  c.start
59
69
  ch = c.create_channel
60
70
 
71
+ sleep 1.5
61
72
  expect(c).to be_open
62
73
  sleep 1.5
63
74
  close_connection(c.local_port)
@@ -98,17 +98,18 @@ describe Bunny::Exchange do
98
98
 
99
99
  context "when declared with a different set of attributes" do
100
100
  it "raises an exception" do
101
- ch = connection.create_channel
101
+ ch1 = connection.create_channel
102
+ ch2 = connection.create_channel
102
103
 
103
- x = ch.fanout("bunny.tests.exchanges.fanout", auto_delete: true, durable: false)
104
+ x = ch1.fanout("bunny.tests.exchanges.fanout", auto_delete: true, durable: false)
104
105
  expect {
105
106
  # force re-declaration
106
- ch.exchange_declare("bunny.tests.exchanges.fanout", :direct, auto_delete: false, durable: true)
107
+ ch2.exchange_declare("bunny.tests.exchanges.fanout", :direct, auto_delete: false, durable: true)
107
108
  }.to raise_error(Bunny::PreconditionFailed)
108
109
 
109
- expect(ch).to be_closed
110
+ expect(ch2).to be_closed
110
111
  expect {
111
- ch.fanout("bunny.tests.exchanges.fanout", auto_delete: true, durable: false)
112
+ ch2.fanout("bunny.tests.exchanges.fanout", auto_delete: true, durable: false)
112
113
  }.to raise_error(Bunny::ChannelAlreadyClosed)
113
114
  end
114
115
  end
@@ -30,6 +30,44 @@ unless ENV["CI"]
30
30
  end
31
31
  end
32
32
 
33
+ def local_hostname
34
+ ENV.fetch("BUNNY_RABBITMQ_HOSTNAME", "127.0.0.1")
35
+ end
36
+
37
+ context "initialized with :tls => true" do
38
+ let(:subject) do
39
+ Bunny.new(:user => "bunny_gem",
40
+ :password => "bunny_password",
41
+ :vhost => "bunny_testbed",
42
+ :tls => true,
43
+ :verify_peer => verify_peer,
44
+ :tls_cert => "spec/tls/client_certificate.pem",
45
+ :tls_key => "spec/tls/client_key.pem",
46
+ :tls_ca_certificates => ["./spec/tls/ca_certificate.pem"])
47
+ end
48
+
49
+ context "peer verification is off" do
50
+ let(:verify_peer) { false }
51
+
52
+ it "uses TLS port" do
53
+ expect(subject.port).to eq AMQ::Protocol::TLS_PORT
54
+ end
55
+
56
+ it "sends the SNI details" do
57
+ # https://github.com/ruby-amqp/bunny/issues/440
58
+ subject.start
59
+ expect(subject.transport.socket.hostname).to_not be_empty
60
+ end
61
+ end
62
+
63
+ context "peer verification is on" do
64
+ let(:verify_peer) { true }
65
+
66
+ it "uses TLS port" do
67
+ expect(subject.port).to eq AMQ::Protocol::TLS_PORT
68
+ end
69
+ end
70
+ end
33
71
 
34
72
  describe "TLS connection to RabbitMQ with client certificates" do
35
73
  let(:connection) do
@@ -75,7 +113,7 @@ unless ENV["CI"]
75
113
 
76
114
  describe "TLS connection to RabbitMQ with a connection string" do
77
115
  let(:connection) do
78
- c = Bunny.new("amqps://bunny_gem:bunny_password@127.0.0.1/bunny_testbed",
116
+ c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname}/bunny_testbed",
79
117
  tls_cert: "spec/tls/client_certificate.pem",
80
118
  tls_key: "spec/tls/client_key.pem",
81
119
  tls_ca_certificates: ["./spec/tls/ca_certificate.pem"],
@@ -94,9 +132,9 @@ unless ENV["CI"]
94
132
 
95
133
  describe "TLS connection to RabbitMQ with a connection string and w/o client certificate and key" do
96
134
  let(:connection) do
97
- c = Bunny.new("amqps://bunny_gem:bunny_password@127.0.0.1/bunny_testbed",
135
+ c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname}/bunny_testbed",
98
136
  tls_ca_certificates: ["./spec/tls/ca_certificate.pem"],
99
- verify_peer: false)
137
+ verify_peer: verify_peer)
100
138
  c.start
101
139
  c
102
140
  end
@@ -105,7 +143,27 @@ unless ENV["CI"]
105
143
  connection.close
106
144
  end
107
145
 
108
- include_examples "successful TLS connection"
146
+ context "peer verification is off" do
147
+ let(:verify_peer) { false }
148
+
149
+ include_examples "successful TLS connection"
150
+
151
+ it "sends the SNI details" do
152
+ # https://github.com/ruby-amqp/bunny/issues/440
153
+ expect(connection.transport.socket.hostname).to_not be_empty
154
+ end
155
+ end
156
+
157
+ context "peer verification is on" do
158
+ let(:verify_peer) { true }
159
+
160
+ include_examples "successful TLS connection"
161
+
162
+ it "sends the SNI details" do
163
+ # https://github.com/ruby-amqp/bunny/issues/440
164
+ expect(connection.transport.socket.hostname).to_not be_empty
165
+ end
166
+ end
109
167
  end
110
168
 
111
169
 
@@ -5,7 +5,7 @@ unless ENV["CI"]
5
5
  describe "Concurrent consumers sharing a connection" do
6
6
  before :all do
7
7
  @connection = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
8
- automatic_recovery: false)
8
+ automatic_recovery: false, continuation_timeout: 45000)
9
9
  @connection.start
10
10
  end
11
11
 
@@ -20,7 +20,7 @@ unless ENV["CI"]
20
20
  context "when publishing thousands of messages over 128K in size" do
21
21
  let(:colors) { ["red", "blue", "white"] }
22
22
 
23
- let(:n) { 32 }
23
+ let(:n) { 16 }
24
24
  let(:m) { 5000 }
25
25
 
26
26
  it "successfully drain all queues" do
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+
3
+ DIRNAME=$(dirname "$0")
4
+
5
+ openssl req -sha256 -new -key $DIRNAME/server_key.pem -out $DIRNAME/server.csr -subj "/CN=mercurio" -config $DIRNAME/server-openssl.cnf
6
+ openssl x509 -sha256 -req -in $DIRNAME/server.csr -CA $DIRNAME/ca_certificate.pem -CAkey $DIRNAME/ca_key.pem -CAcreateserial -CAserial $DIRNAME/ca.srl -out $DIRNAME/server_certificate.pem -days 3650 -extensions v3_req -extfile $DIRNAME/server-openssl.cnf
7
+
8
+ echo "Written new server CSR and certificate"
@@ -0,0 +1,10 @@
1
+ [req]
2
+ req_extensions = v3_req
3
+ distinguished_name = req_distinguished_name
4
+ [req_distinguished_name]
5
+ [ v3_req ]
6
+ basicConstraints = CA:FALSE
7
+ keyUsage = nonRepudiation, digitalSignature, keyEncipherment
8
+ subjectAltName = @alt_names
9
+ [alt_names]
10
+ IP.1 = 127.0.0.1
@@ -0,0 +1,16 @@
1
+ -----BEGIN CERTIFICATE REQUEST-----
2
+ MIICkjCCAXoCAQAwEzERMA8GA1UEAwwIbWVyY3VyaW8wggEiMA0GCSqGSIb3DQEB
3
+ AQUAA4IBDwAwggEKAoIBAQCkvvzm5nB3CDqTFEYQnfOy8DwJLm34MvdrKQAThzDy
4
+ qa37sb4IC0YclBFbZfsw8+paK+Rpo2Vlhzclb66z0cGs9SvxuKkJ45w0fk0ctxMg
5
+ tvWISRGZR7LMw5u0q2m61dK0FTGSl+qzJohb5Dklb6BApoGoIPH+eYraVxHR29x2
6
+ x8hqzBt5TpiUW8bu7LPQJbX0mYGhKQDf86kao+sptRQ2045D7vB3jrkPhq0XZVJi
7
+ QymzOSSejYSN1oZ464DtT+dpLBYHEVJoJPu4r4kY/8A7v+93PWQaDERKBfvwWHfV
8
+ U44xn7R/aojSvNT7kQILsf2BnfJlMwoedWQLxPddmB3PAgMBAAGgOjA4BgkqhkiG
9
+ 9w0BCQ4xKzApMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgXgMA8GA1UdEQQIMAaHBH8A
10
+ AAEwDQYJKoZIhvcNAQELBQADggEBAFyfaotajM/h2dyodKJqO6stAIpxiQXTds8V
11
+ 5ZHDozBxzLZkeBIY+hsqh/owmqomk56swui+336WAKIBwIJyJrtIl8C/lupGaTbR
12
+ BouWWbyZOQAE2ExHcUgdGEOVoCN2ieBR4RVQ8Id4GAlHvlFGPqakaLMV6Zc7VqDh
13
+ vxdOLgATEE+MhebTo9yOHj14qdvzhi5w3ZEg1kdfOuGN9I4gJcv4PWwudBhn4wE7
14
+ oHAIP2nixROI7cZcZ9fBrimcdGQsXNZLTXiGzNra4utOXuQ7w5qoiEhHoxXalowE
15
+ KvEA9otLadjtULg6DRd3zYuIyrUiBIRUHZ1p2xSnd/lLekbMfCQ=
16
+ -----END CERTIFICATE REQUEST-----
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: 2.6.4
4
+ version: 2.6.5
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: 2017-03-04 00:00:00.000000000 Z
15
+ date: 2017-04-15 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: amq-protocol
@@ -20,14 +20,14 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.0.1
23
+ version: 2.1.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: 2.0.1
30
+ version: 2.1.0
31
31
  description: Easy to use, feature complete Ruby client for RabbitMQ 3.3 and later
32
32
  versions.
33
33
  email:
@@ -59,8 +59,8 @@ files:
59
59
  - benchmarks/synchronized_sorted_set.rb
60
60
  - benchmarks/write_vs_write_nonblock.rb
61
61
  - bin/ci/before_build
62
- - bin/ci/start_rabbitmq
63
62
  - bunny.gemspec
63
+ - docker-compose.yml
64
64
  - docker/Dockerfile
65
65
  - docker/docker-entrypoint.sh
66
66
  - examples/connection/authentication_failure.rb
@@ -199,6 +199,9 @@ files:
199
199
  - spec/tls/ca_key.pem
200
200
  - spec/tls/client_certificate.pem
201
201
  - spec/tls/client_key.pem
202
+ - spec/tls/generate-server-cert.sh
203
+ - spec/tls/server-openssl.cnf
204
+ - spec/tls/server.csr
202
205
  - spec/tls/server_certificate.pem
203
206
  - spec/tls/server_key.pem
204
207
  - spec/unit/bunny_spec.rb
@@ -228,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
231
  version: '0'
229
232
  requirements: []
230
233
  rubyforge_project:
231
- rubygems_version: 2.5.1
234
+ rubygems_version: 2.6.11
232
235
  signing_key:
233
236
  specification_version: 4
234
237
  summary: Popular easy to use Ruby client for RabbitMQ
@@ -297,6 +300,9 @@ test_files:
297
300
  - spec/tls/ca_key.pem
298
301
  - spec/tls/client_certificate.pem
299
302
  - spec/tls/client_key.pem
303
+ - spec/tls/generate-server-cert.sh
304
+ - spec/tls/server-openssl.cnf
305
+ - spec/tls/server.csr
300
306
  - spec/tls/server_certificate.pem
301
307
  - spec/tls/server_key.pem
302
308
  - spec/unit/bunny_spec.rb