bunny 2.8.1 → 2.9.0

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: 4b498f37cb4c91500ac5b66e0abeb8d650112b2e
4
- data.tar.gz: 4edc1a872bc9806c64ab1d8307c9730af9edada0
3
+ metadata.gz: bddad506ff3cf646d188ee710760ba6264f892e2
4
+ data.tar.gz: 8633350680a481c8244acc6c847994e087f0d278
5
5
  SHA512:
6
- metadata.gz: 76f472696876ab6912b0244a1c234bea819d1538d6483156eb7ba9f099eac7fcc2437320c1a1e7ccde887ba2a42fd871d5a472d7499b4744d44b9d2449f4fd98
7
- data.tar.gz: 5f2d9d2743555ac1f147b0887b0e989741bbcc9b559ef5354dc929374bf6e4ab63ee9ef82c3f64a62244b43b23c2c3c209f9b828fff58c45099ef89f68f474a3
6
+ metadata.gz: c38e6e5ba79c33cd79bc2e8fea5c2be0a1f23dce82816e3962f22965f6e98ac51ff30aad75c6f59e8fc165629878dc00d83cf74fdba51deb4bbe7b0874f34bcb
7
+ data.tar.gz: ca7f75991cec9ffa875c5e8a8870cba2e94433d63fe253971b21c0b3201a555046b0a6e68a416248b8c4ccdded30dc2aed2ed8e875fcec6a0960c8c142b5a766
@@ -39,7 +39,8 @@ running a RabbitMQ server in a Docker container.
39
39
 
40
40
  #### Using a locally installed RabbitMQ server
41
41
 
42
- Run the following command from the base directory of the gem:
42
+ It is possible to start a local RabbitMQ node from the repository root. It is not necessarily
43
+ optimal but can be a good starting point but is a useful example:
43
44
 
44
45
  ```
45
46
  RABBITMQ_NODENAME=bunny RABBITMQ_CONFIG_FILE=./spec/config/rabbitmq RABBITMQ_ENABLED_PLUGINS_FILE=./spec/config/enabled_plugins rabbitmq-server
@@ -51,10 +52,17 @@ these. TLS (x509 PEM) certificates include a hostname-specific fields,
51
52
  the tests allow for expecting hostname overriding using the `BUNNY_RABBITMQ_HOSTNAME`
52
53
  environment variables (default value is `127.0.0.1`).
53
54
 
54
- Server, CA and client certificates can be found under `spec/tls`.
55
- The location can be overridden via the `BUNNY_CERTIFICATE_DIR` environment variable.
55
+ By default there's a set of CA, server, and client certificates pre-generated at `spec/tls`. Since x509 certificates
56
+ contain a hardcoded CN and your hostname is unlikely to match it,
57
+ the location can be overridden via the `BUNNY_CERTIFICATE_DIR` environment variable.
56
58
  It is supposed to target [tls-gen](https://github.com/michaelklishin/tls-gen)'s basic profile
57
- output (result) directory on the host where specs are to be executed.
59
+ output (result) directory on the host where specs are to be executed. Combine it with `BUNNY_RABBITMQ_HOSTNAME`
60
+ when running TLS connection tests:
61
+
62
+ ```
63
+ BUNNY_CERTIFICATE_DIR="/path/to/tls-gen/basic/result" BUNNY_RABBITMQ_HOSTNAME="mayflower" bundle exec rspec
64
+
65
+ ```
58
66
 
59
67
  Next up you'll need to prepare your node for the specs (just once):
60
68
 
@@ -104,8 +112,8 @@ Make sure you have those two installed and then run integration tests:
104
112
 
105
113
  It is possible to run all tests:
106
114
 
107
- bundle exec rspec -c
115
+ bundle exec rspec
108
116
 
109
117
  It is possible to run only integration and regression tests but exclude unit and stress tests:
110
118
 
111
- CI=true bundle exec rspec -c spec/higher_level_api/ spec/lower_level_api spec/issues && bundle exec rspec -c spec/higher_level_api/integration/connection_recovery_spec.rb
119
+ CI=true bundle exec rspec spec/higher_level_api/ spec/lower_level_api spec/issues spec/higher_level_api/integration/connection_recovery_spec.rb
@@ -1,19 +1,18 @@
1
- ## Changes between Bunny 2.8.1 and 2.8.2 (unreleased)
1
+ ## Changes between Bunny 2.8.0 and 2.9.0 (Jan 8th, 2018)
2
2
 
3
- No changes yet.
3
+ ### Ruby 2.2 Requirement
4
4
 
5
+ Bunny now requires Ruby 2.2.
5
6
 
6
7
 
7
- ## Changes between Bunny 2.8.0 and 2.8.1 (Jan 9th, 2018)
8
+ ### Support for Additional URI Query Parameters
8
9
 
9
- ### amq-protocol Dependency
10
+ GitHub issue: [#534](https://github.com/ruby-amqp/bunny/pull/534).
10
11
 
11
- This version depends on amq-protocol `2.2.x`.
12
+ Contributed by Andrew Babichev.
12
13
 
13
- GitHub issue: [#538](https://github.com/ruby-amqp/bunny/issues/538).
14
14
 
15
-
16
- ## Changes between Bunny 2.7.0 and 2.8.0 (Dec 18th, 2017)
15
+ ## Changes between Bunny 2.7.0 and 2.8.0 (Dec 18th, 2018)
17
16
 
18
17
  This release has **minor breaking public API changes**.
19
18
 
@@ -32,7 +31,7 @@ A JRuby 9K compatibility issue was corrected by Marian Posăceanu.
32
31
  Note that JRuby users are recommended to use [March Hare](http://rubymarchhare.info/), a JRuby-oriented client, instead
33
32
  of Bunny.
34
33
 
35
- GitHub issue: [bunny#529](https://github.com/ruby-amqp/bunny/pull/529)
34
+ GitHub issue: [#529](https://github.com/ruby-amqp/bunny/pull/529)
36
35
 
37
36
  ### Connection Exceptions are Logged as Warning with Automatic Recovery
38
37
 
@@ -41,7 +40,7 @@ and not errors.
41
40
 
42
41
  Contributed by Merten Falk.
43
42
 
44
- GitHub issue: [bunny#531](https://github.com/ruby-amqp/bunny/pull/531)
43
+ GitHub issue: [#531](https://github.com/ruby-amqp/bunny/pull/531)
45
44
 
46
45
  ### Server Heartbeat Value as a String
47
46
 
@@ -50,7 +49,7 @@ a symbol. This makes it easier to load settings from YAML files.
50
49
 
51
50
  Contributed by Tyrone Wilson.
52
51
 
53
- GitHub issue: [bunny#524](https://github.com/ruby-amqp/bunny/pull/524)
52
+ GitHub issue: [#524](https://github.com/ruby-amqp/bunny/pull/524)
54
53
 
55
54
 
56
55
  ## Changes between Bunny 2.7.0 and 2.7.1 (Sep 25th, 2017)
data/Gemfile CHANGED
@@ -33,7 +33,7 @@ end
33
33
 
34
34
  group :test do
35
35
  gem "rspec", "~> 3.5.0"
36
- gem "rabbitmq_http_api_client", "~> 1.9.1"
36
+ gem "rabbitmq_http_api_client", "~> 1.9.1", require: "rabbitmq/http/client"
37
37
  end
38
38
 
39
39
  gemspec
@@ -43,11 +43,11 @@ gemspec
43
43
  def custom_gem(name, options = Hash.new)
44
44
  local_path = File.expand_path("../vendor/#{name}", __FILE__)
45
45
  if File.exist?(local_path)
46
- # puts "Using #{name} from #{local_path}..."
46
+ puts "Using #{name} from #{local_path}..."
47
47
  gem name, options.merge(:path => local_path).delete_if { |key, _| [:git, :branch].include?(key) }
48
48
  else
49
49
  gem name, options
50
50
  end
51
51
  end
52
52
 
53
- custom_gem "amq-protocol", "~> 2.2.0"
53
+ custom_gem "amq-protocol", git: "https://github.com/ruby-amqp/amq-protocol", branch: "master"
data/README.md CHANGED
@@ -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.7.2"
91
+ gem "bunny", ">= 2.8.0"
92
92
  ```
93
93
 
94
94
 
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.summary = "Popular easy to use Ruby client for RabbitMQ"
12
12
  s.description = "Easy to use, feature complete Ruby client for RabbitMQ 3.3 and later versions."
13
13
  s.license = "MIT"
14
- s.required_ruby_version = Gem::Requirement.new(">= 2.0")
14
+ s.required_ruby_version = Gem::Requirement.new(">= 2.2")
15
15
 
16
16
  # Sorted alphabetically.
17
17
  s.authors = [
@@ -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.2.0"
27
+ s.add_dependency "amq-protocol", ">= 2.2.0"
28
28
 
29
29
  # Files.
30
30
  s.has_rdoc = true
@@ -5,6 +5,8 @@ services:
5
5
  container_name: bunny_rabbitmq
6
6
  environment:
7
7
  RABBITMQ_NODENAME: bunny
8
+ # see CONTRIBUTING.md
9
+ BUNNY_RABBITMQ_HOSTNAME: mercurio
8
10
  # link to spec specific configuration
9
11
  RABBITMQ_CONFIG_FILE: /spec/config/rabbitmq
10
12
  RABBITMQ_ENABLED_PLUGINS_FILE: /spec/config/enabled_plugins
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
  server=rabbitmq-server
3
3
  ctl=rabbitmqctl
4
- delay=3
4
+ delay=5
5
5
 
6
6
  echo "[Configuration] $(eval cat $RABBITMQ_CONFIG_FILE.config)"
7
7
 
@@ -464,7 +464,7 @@ module Bunny
464
464
  # @param [String] uri amqp or amqps URI to parse
465
465
  # @return [Hash] Parsed URI as a hash
466
466
  def self.parse_uri(uri)
467
- AMQ::Settings.parse_amqp_url(uri)
467
+ AMQ::Settings.configure(uri)
468
468
  end
469
469
 
470
470
  # Checks if a queue with given name exists.
@@ -742,7 +742,7 @@ module Bunny
742
742
  rescue HostListDepleted
743
743
  reset_address_index
744
744
  retry
745
- rescue TCPConnectionFailedForAllHosts, TCPConnectionFailed, AMQ::Protocol::EmptyResponseError, SystemCallError => e
745
+ rescue TCPConnectionFailedForAllHosts, TCPConnectionFailed, AMQ::Protocol::EmptyResponseError, SystemCallError, Timeout::Error => e
746
746
  @logger.warn "TCP connection failed, reconnecting in #{@network_recovery_interval} seconds"
747
747
  if should_retry_recovery?
748
748
  decrement_recovery_attemp_counter!
@@ -26,7 +26,7 @@ module Bunny
26
26
  DEFAULT_WRITE_TIMEOUT = 30.0
27
27
 
28
28
  attr_reader :session, :host, :port, :socket, :connect_timeout, :read_timeout, :write_timeout, :disconnect_timeout
29
- attr_reader :tls_context
29
+ attr_reader :tls_context, :verify_peer, :tls_ca_certificates, :tls_certificate_path, :tls_key_path
30
30
 
31
31
  attr_writer :read_timeout
32
32
 
@@ -298,17 +298,21 @@ module Bunny
298
298
  protected
299
299
 
300
300
  def tls_enabled?(opts)
301
- return opts[:tls] unless opts[:tls].nil?
302
- return opts[:ssl] unless opts[:ssl].nil?
301
+ return !!opts[:tls] unless opts[:tls].nil?
302
+ return !!opts[:ssl] unless opts[:ssl].nil?
303
303
  (opts[:port] == AMQ::Protocol::TLS_PORT) || false
304
304
  end
305
305
 
306
+ def tls_ca_certificates_paths_from(opts)
307
+ Array(opts[:cacertfile] || opts[:tls_ca_certificates] || opts[:ssl_ca_certificates])
308
+ end
309
+
306
310
  def tls_certificate_path_from(opts)
307
- opts[:tls_cert] || opts[:ssl_cert] || opts[:tls_cert_path] || opts[:ssl_cert_path] || opts[:tls_certificate_path] || opts[:ssl_certificate_path]
311
+ opts[:certfile] || opts[:tls_cert] || opts[:ssl_cert] || opts[:tls_cert_path] || opts[:ssl_cert_path] || opts[:tls_certificate_path] || opts[:ssl_certificate_path]
308
312
  end
309
313
 
310
314
  def tls_key_path_from(opts)
311
- opts[:tls_key] || opts[:ssl_key] || opts[:tls_key_path] || opts[:ssl_key_path]
315
+ opts[:keyfile] || opts[:tls_key] || opts[:ssl_key] || opts[:tls_key_path] || opts[:ssl_key_path]
312
316
  end
313
317
 
314
318
  def tls_certificate_from(opts)
@@ -337,7 +341,7 @@ module Bunny
337
341
  end
338
342
 
339
343
  def prepare_tls_context(opts)
340
- if (opts[:verify_ssl] || opts[:verify_peer]).nil?
344
+ if (opts[:verify_ssl] || opts[:verify_peer] || opts[:verify]).nil?
341
345
  opts[:verify_peer] = true
342
346
  end
343
347
 
@@ -349,12 +353,23 @@ module Bunny
349
353
  @tls_key = tls_key_from(opts)
350
354
  @tls_certificate_store = opts[:tls_certificate_store]
351
355
 
352
- @tls_ca_certificates = opts.fetch(:tls_ca_certificates, default_tls_certificates)
353
- @verify_peer = (opts[:verify_ssl] || opts[:verify_peer])
356
+ @tls_ca_certificates = tls_ca_certificates_paths_from(opts) || default_tls_certificates
357
+ @verify_peer = as_boolean(opts[:verify_ssl] || opts[:verify_peer] || opts[:verify])
354
358
 
355
359
  @tls_context = initialize_tls_context(OpenSSL::SSL::SSLContext.new, opts)
356
360
  end
357
361
 
362
+ def as_boolean(val)
363
+ case val
364
+ when true then true
365
+ when false then false
366
+ when "true" then true
367
+ when "false" then false
368
+ else
369
+ !!val
370
+ end
371
+ end
372
+
358
373
  def wrap_in_tls_socket(socket)
359
374
  raise ArgumentError, "cannot wrap nil into TLS socket, @tls_context is nil. This is a Bunny bug." unless socket
360
375
  raise "cannot wrap a socket into TLS socket, @tls_context is nil. This is a Bunny bug." unless @tls_context
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bunny
4
4
  # @return [String] Version of the library
5
- VERSION = "2.8.1"
5
+ VERSION = "2.9.0"
6
6
  end
@@ -1,5 +1,9 @@
1
1
  require "spec_helper"
2
2
 
3
+ def local_hostname
4
+ ENV.fetch("BUNNY_RABBITMQ_HOSTNAME", "127.0.0.1")
5
+ end
6
+
3
7
  describe Bunny::Session do
4
8
  let(:port) { AMQ::Protocol::DEFAULT_PORT }
5
9
  let(:username) { "guest" }
@@ -319,9 +323,9 @@ describe Bunny::Session do
319
323
  password: "bunny_password",
320
324
  vhost: "bunny_testbed",
321
325
  ssl: true,
322
- ssl_cert: "spec/tls/client_cert.pem",
326
+ ssl_cert: "spec/tls/client_certificate.pem",
323
327
  ssl_key: "spec/tls/client_key.pem",
324
- ssl_ca_certificates: ["./spec/tls/cacert.pem"])
328
+ ssl_ca_certificates: ["./spec/tls/ca_certificate.pem"])
325
329
  end
326
330
 
327
331
  it "uses TLS port" do
@@ -2,7 +2,7 @@
2
2
  require "spec_helper"
3
3
 
4
4
  unless ENV["CI"]
5
- CERTIFICATE_DIR=ENV.fetch("BUNNY_CERTIFICATE_DIR", "./spec/tls")
5
+ CERTIFICATE_DIR = ENV.fetch("BUNNY_CERTIFICATE_DIR", "./spec/tls")
6
6
  puts "Will use certificates from #{CERTIFICATE_DIR}"
7
7
 
8
8
  shared_examples_for "successful TLS connection" do
@@ -40,14 +40,16 @@ unless ENV["CI"]
40
40
 
41
41
  context "initialized with :tls => true" do
42
42
  let(:subject) do
43
- Bunny.new(:user => "bunny_gem",
44
- :password => "bunny_password",
45
- :vhost => "bunny_testbed",
46
- :tls => true,
47
- :verify_peer => verify_peer,
48
- :tls_cert => "#{CERTIFICATE_DIR}/client_certificate.pem",
49
- :tls_key => "#{CERTIFICATE_DIR}/client_key.pem",
50
- :tls_ca_certificates => ["#{CERTIFICATE_DIR}/ca_certificate.pem"])
43
+ Bunny.new(
44
+ hostname: local_hostname(),
45
+ user: "bunny_gem",
46
+ password: "bunny_password",
47
+ vhost: "bunny_testbed",
48
+ tls: true,
49
+ verify_peer: verify_peer,
50
+ tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
51
+ tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
52
+ tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"])
51
53
  end
52
54
 
53
55
  context "peer verification is off" do
@@ -79,7 +81,9 @@ unless ENV["CI"]
79
81
 
80
82
  describe "TLS connection to RabbitMQ with client certificates" do
81
83
  let(:subject) do
82
- c = Bunny.new(username: "bunny_gem",
84
+ c = Bunny.new(
85
+ hostname: local_hostname(),
86
+ username: "bunny_gem",
83
87
  password: "bunny_password",
84
88
  vhost: "bunny_testbed",
85
89
  tls: true,
@@ -101,7 +105,9 @@ unless ENV["CI"]
101
105
 
102
106
  describe "TLS connection to RabbitMQ without client certificates" do
103
107
  let(:subject) do
104
- c = Bunny.new(username: "bunny_gem",
108
+ c = Bunny.new(
109
+ hostname: local_hostname(),
110
+ username: "bunny_gem",
105
111
  password: "bunny_password",
106
112
  vhost: "bunny_testbed",
107
113
  tls: true,
@@ -121,7 +127,7 @@ unless ENV["CI"]
121
127
 
122
128
  describe "TLS connection to RabbitMQ with a connection string" do
123
129
  let(:subject) do
124
- c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname}/bunny_testbed",
130
+ c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
125
131
  tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
126
132
  tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
127
133
  tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
@@ -135,12 +141,28 @@ unless ENV["CI"]
135
141
  end
136
142
 
137
143
  include_examples "successful TLS connection"
144
+
145
+ context "when URI contains query parameters" do
146
+ subject(:session) do
147
+ Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed?heartbeat=10&connection_timeout=100&channel_max=1000&verify=false&cacertfile=#{CERTIFICATE_DIR}/ca_certificate.pem&certfile=#{CERTIFICATE_DIR}/client_certificate.pem&keyfile=#{CERTIFICATE_DIR}/client_key.pem")
148
+ end
149
+
150
+ it "parses extra connection parameters" do
151
+ session.start
152
+
153
+ expect(session.uses_tls?).to eq(true)
154
+ expect(session.transport.verify_peer).to eq(false)
155
+ expect(session.transport.tls_ca_certificates).to eq(["#{CERTIFICATE_DIR}/ca_certificate.pem"])
156
+ expect(session.transport.tls_certificate_path).to eq("#{CERTIFICATE_DIR}/client_certificate.pem")
157
+ expect(session.transport.tls_key_path).to eq("#{CERTIFICATE_DIR}/client_key.pem")
158
+ end
159
+ end
138
160
  end
139
161
 
140
162
 
141
163
  describe "TLS connection to RabbitMQ with a connection string and w/o client certificate and key" do
142
164
  let(:subject) do
143
- c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname}/bunny_testbed",
165
+ c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
144
166
  tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
145
167
  verify_peer: verify_peer)
146
168
  c.start
@@ -177,7 +199,9 @@ unless ENV["CI"]
177
199
 
178
200
  describe "TLS connection to RabbitMQ with client certificates provided inline" do
179
201
  let(:subject) do
180
- c = Bunny.new(username: "bunny_gem",
202
+ c = Bunny.new(
203
+ hostname: local_hostname(),
204
+ username: "bunny_gem",
181
205
  password: "bunny_password",
182
206
  vhost: "bunny_testbed",
183
207
  tls: true,
@@ -198,7 +222,9 @@ unless ENV["CI"]
198
222
 
199
223
  describe "TLS connection to RabbitMQ with tls_version TLSv1.1 specified" do
200
224
  let(:subject) do
201
- c = Bunny.new(username: "bunny_gem",
225
+ c = Bunny.new(
226
+ hostname: local_hostname(),
227
+ username: "bunny_gem",
202
228
  password: "bunny_password",
203
229
  vhost: "bunny_testbed",
204
230
  tls: true,
@@ -3,15 +3,10 @@
3
3
  $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
4
 
5
5
  require 'bundler'
6
- Bundler.setup(:default, :test)
6
+ Bundler.require(:default, :test)
7
7
 
8
-
9
- require "effin_utf8"
10
8
  require "bunny"
11
- require "rabbitmq/http/client"
12
-
13
9
 
14
- require "amq/protocol/version"
15
10
  puts "Using Ruby #{RUBY_VERSION}, amq-protocol #{AMQ::Protocol::VERSION}"
16
11
 
17
12
  module RabbitMQ
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.8.1
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Duncan
@@ -12,20 +12,20 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-01-09 00:00:00.000000000 Z
15
+ date: 2018-01-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: amq-protocol
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - "~>"
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: 2.2.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
30
  version: 2.2.0
31
31
  description: Easy to use, feature complete Ruby client for RabbitMQ 3.3 and later
@@ -224,7 +224,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
224
  requirements:
225
225
  - - ">="
226
226
  - !ruby/object:Gem::Version
227
- version: '2.0'
227
+ version: '2.2'
228
228
  required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  requirements:
230
230
  - - ">="