bunny 2.17.0 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/bunny/session.rb +22 -4
- data/lib/bunny/transport.rb +7 -6
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/basic_consume_spec.rb +14 -6
- data/spec/higher_level_api/integration/tls_connection_spec.rb +25 -32
- data/spec/issues/issue609_spec.rb +84 -0
- data/spec/lower_level_api/integration/basic_cancel_spec.rb +1 -1
- data/spec/lower_level_api/integration/basic_consume_spec.rb +8 -8
- metadata +28 -87
- data/.github/ISSUE_TEMPLATE.md +0 -18
- data/.gitignore +0 -28
- data/.rspec +0 -1
- data/.travis.yml +0 -33
- data/.yardopts +0 -8
- data/CONTRIBUTING.md +0 -132
- data/ChangeLog.md +0 -2129
- data/Gemfile +0 -55
- data/LICENSE +0 -21
- data/Rakefile +0 -54
- data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
- data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
- data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
- data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
- data/benchmarks/channel_open.rb +0 -28
- data/benchmarks/mutex_and_monitor.rb +0 -42
- data/benchmarks/queue_declare.rb +0 -29
- data/benchmarks/queue_declare_and_bind.rb +0 -29
- data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
- data/benchmarks/synchronized_sorted_set.rb +0 -53
- data/benchmarks/write_vs_write_nonblock.rb +0 -49
- data/bunny.gemspec +0 -34
- data/docker-compose.yml +0 -28
- data/docker/Dockerfile +0 -24
- data/docker/apt/preferences.d/erlang +0 -3
- data/docker/apt/sources.list.d/bintray.rabbitmq.list +0 -2
- data/docker/docker-entrypoint.sh +0 -26
- data/docker/rabbitmq.conf +0 -29
- data/examples/connection/authentication_failure.rb +0 -16
- data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
- data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
- data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
- data/examples/connection/automatic_recovery_with_republishing.rb +0 -109
- data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
- data/examples/connection/channel_level_exception.rb +0 -27
- data/examples/connection/disabled_automatic_recovery.rb +0 -34
- data/examples/connection/heartbeat.rb +0 -17
- data/examples/connection/manually_reconnecting_consumer.rb +0 -23
- data/examples/connection/manually_reconnecting_publisher.rb +0 -28
- data/examples/connection/unknown_host.rb +0 -16
- data/examples/consumers/high_and_low_priority.rb +0 -50
- data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
- data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
- data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
- data/examples/guides/exchanges/mandatory_messages.rb +0 -30
- data/examples/guides/extensions/alternate_exchange.rb +0 -30
- data/examples/guides/extensions/basic_nack.rb +0 -33
- data/examples/guides/extensions/connection_blocked.rb +0 -35
- data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
- data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
- data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
- data/examples/guides/extensions/per_message_ttl.rb +0 -36
- data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
- data/examples/guides/extensions/publisher_confirms.rb +0 -28
- data/examples/guides/extensions/queue_lease.rb +0 -26
- data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
- data/examples/guides/getting_started/blabbr.rb +0 -27
- data/examples/guides/getting_started/hello_world.rb +0 -22
- data/examples/guides/getting_started/weathr.rb +0 -49
- data/examples/guides/queues/one_off_consumer.rb +0 -25
- data/examples/guides/queues/redeliveries.rb +0 -81
- data/profiling/basic_publish/with_4K_messages.rb +0 -33
- data/repl +0 -3
- data/spec/tls/generate-server-cert.sh +0 -8
- data/spec/tls/server-openssl.cnf +0 -10
- data/spec/tls/server.csr +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12c06caafbcd9f9246ab4bd8431fd4eaea5dbbd312ff0d44a771eba7ed6a9a45
|
4
|
+
data.tar.gz: 73aa41037c3c38ff236ddec494cbb9b7678804265e1ec90c8fca0a6bafcdff8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8abbfee40480a6421fb1b17004796970cfec645ec133d9330ae7338b0877ee8f8ef8a2eda8ccce00106fccef0c73d009da1179345261509d6f30de300df38db3
|
7
|
+
data.tar.gz: 62748d088e8b346041f502f02ef08837b78ecf0acc5e2599c5e7640c6f6af7fcba4dfa261b7cc1e458bf672fe69ecc423660905c7f220bfb1b933937ea2537ea
|
data/README.md
CHANGED
@@ -70,10 +70,10 @@ a stable public API.
|
|
70
70
|
Change logs per release series:
|
71
71
|
|
72
72
|
* [master](https://github.com/ruby-amqp/bunny/blob/master/ChangeLog.md)
|
73
|
+
* [2.17.x](https://github.com/ruby-amqp/bunny/blob/2.17.x-stable/ChangeLog.md)
|
73
74
|
* [2.16.x](https://github.com/ruby-amqp/bunny/blob/2.16.x-stable/ChangeLog.md)
|
74
75
|
* [2.15.x](https://github.com/ruby-amqp/bunny/blob/2.15.x-stable/ChangeLog.md)
|
75
76
|
* [2.14.x](https://github.com/ruby-amqp/bunny/blob/2.14.x-stable/ChangeLog.md)
|
76
|
-
* [2.13.x](https://github.com/ruby-amqp/bunny/blob/2.13.x-stable/ChangeLog.md)
|
77
77
|
|
78
78
|
|
79
79
|
|
@@ -96,7 +96,7 @@ gem install bunny
|
|
96
96
|
To use Bunny in a project managed with Bundler:
|
97
97
|
|
98
98
|
``` ruby
|
99
|
-
gem "bunny", ">= 2.
|
99
|
+
gem "bunny", ">= 2.17.0"
|
100
100
|
```
|
101
101
|
|
102
102
|
|
data/lib/bunny/session.rb
CHANGED
@@ -124,6 +124,8 @@ module Bunny
|
|
124
124
|
# @option connection_string_or_opts [Boolean] :automatically_recover (true) Should automatically recover from network failures?
|
125
125
|
# @option connection_string_or_opts [Integer] :recovery_attempts (nil) Max number of recovery attempts, nil means forever
|
126
126
|
# @option connection_string_or_opts [Integer] :reset_recovery_attempts_after_reconnection (true) Should recovery attempt counter be reset after successful reconnection? When set to false, the attempt counter will last through the entire lifetime of the connection object.
|
127
|
+
# @option connection_string_or_opts [Proc] :recovery_attempt_started (nil) Will be called before every connection recovery attempt
|
128
|
+
# @option connection_string_or_opts [Proc] :recovery_completed (nil) Will be called after successful connection recovery
|
127
129
|
# @option connection_string_or_opts [Boolean] :recover_from_connection_close (true) Should this connection recover after receiving a server-sent connection.close (e.g. connection was force closed)?
|
128
130
|
# @option connection_string_or_opts [Object] :session_error_handler (Thread.current) Object which responds to #raise that will act as a session error handler. Defaults to Thread.current, which will raise asynchronous exceptions in the thread that created the session.
|
129
131
|
#
|
@@ -172,7 +174,7 @@ module Bunny
|
|
172
174
|
@automatically_recover = if opts[:automatically_recover].nil? && opts[:automatic_recovery].nil?
|
173
175
|
true
|
174
176
|
else
|
175
|
-
opts[:automatically_recover]
|
177
|
+
opts[:automatically_recover] | opts[:automatic_recovery]
|
176
178
|
end
|
177
179
|
@recovering_from_network_failure = false
|
178
180
|
@max_recovery_attempts = opts[:recovery_attempts]
|
@@ -218,7 +220,9 @@ module Bunny
|
|
218
220
|
@address_index_mutex = @mutex_impl.new
|
219
221
|
|
220
222
|
@channels = Hash.new
|
221
|
-
|
223
|
+
|
224
|
+
@recovery_attempt_started = opts[:recovery_attempt_started]
|
225
|
+
@recovery_completed = opts[:recovery_completed]
|
222
226
|
|
223
227
|
@session_error_handler = opts.fetch(:session_error_handler, Thread.current)
|
224
228
|
|
@@ -533,6 +537,18 @@ module Bunny
|
|
533
537
|
end
|
534
538
|
end
|
535
539
|
|
540
|
+
# Defines a callable (e.g. a block) that will be called
|
541
|
+
# before every connection recovery attempt.
|
542
|
+
def before_recovery_attempt_starts(&block)
|
543
|
+
@recovery_attempt_started = block
|
544
|
+
end
|
545
|
+
|
546
|
+
# Defines a callable (e.g. a block) that will be called
|
547
|
+
# after successful connection recovery.
|
548
|
+
def after_recovery_completed(&block)
|
549
|
+
@recovery_completed = block
|
550
|
+
end
|
551
|
+
|
536
552
|
|
537
553
|
#
|
538
554
|
# Implementation
|
@@ -750,6 +766,7 @@ module Bunny
|
|
750
766
|
def recover_from_network_failure
|
751
767
|
sleep @network_recovery_interval
|
752
768
|
@logger.debug "Will attempt connection recovery..."
|
769
|
+
notify_of_recovery_attempt_start
|
753
770
|
|
754
771
|
self.initialize_transport
|
755
772
|
|
@@ -823,8 +840,9 @@ module Bunny
|
|
823
840
|
end
|
824
841
|
end
|
825
842
|
|
826
|
-
|
827
|
-
|
843
|
+
# @private
|
844
|
+
def notify_of_recovery_attempt_start
|
845
|
+
@recovery_attempt_started.call if @recovery_attempt_started
|
828
846
|
end
|
829
847
|
|
830
848
|
# @private
|
data/lib/bunny/transport.rb
CHANGED
@@ -453,9 +453,9 @@ module Bunny
|
|
453
453
|
end
|
454
454
|
end
|
455
455
|
|
456
|
-
def initialize_tls_context(ctx, opts={})
|
456
|
+
def initialize_tls_context(ctx, opts = {})
|
457
457
|
ctx.cert = OpenSSL::X509::Certificate.new(@tls_certificate) if @tls_certificate
|
458
|
-
ctx.key = OpenSSL::PKey
|
458
|
+
ctx.key = OpenSSL::PKey.read(@tls_key) if @tls_key
|
459
459
|
ctx.cert_store = if @tls_certificate_store
|
460
460
|
@tls_certificate_store
|
461
461
|
else
|
@@ -463,8 +463,9 @@ module Bunny
|
|
463
463
|
@tls_ca_certificates = tls_ca_certificates_paths_from(opts)
|
464
464
|
initialize_tls_certificate_store(@tls_ca_certificates)
|
465
465
|
end
|
466
|
+
should_silence_warnings = opts.fetch(:tls_silence_warnings, false)
|
466
467
|
|
467
|
-
if !@tls_certificate
|
468
|
+
if !@tls_certificate && !should_silence_warnings
|
468
469
|
@logger.warn <<-MSG
|
469
470
|
Using TLS but no client certificate is provided. If RabbitMQ is configured to require & verify peer
|
470
471
|
certificate, connection will be rejected. Learn more at https://www.rabbitmq.com/ssl.html
|
@@ -482,14 +483,14 @@ certificate, connection will be rejected. Learn more at https://www.rabbitmq.com
|
|
482
483
|
@logger.debug { "Will use peer verification mode #{verify_mode}" }
|
483
484
|
ctx.verify_mode = verify_mode
|
484
485
|
|
485
|
-
if !@verify_peer
|
486
|
+
if !@verify_peer && !should_silence_warnings
|
486
487
|
@logger.warn <<-MSG
|
487
488
|
Using TLS but peer hostname verification is disabled. This is convenient for local development
|
488
489
|
but prone to man-in-the-middle attacks. Please set verify_peer: true in production. Learn more at https://www.rabbitmq.com/ssl.html
|
489
490
|
MSG
|
490
491
|
end
|
491
492
|
|
492
|
-
ssl_version = opts[:tls_protocol] || opts[:ssl_version]
|
493
|
+
ssl_version = opts[:tls_protocol] || opts[:ssl_version] || :TLSv1_2
|
493
494
|
ctx.ssl_version = ssl_version if ssl_version
|
494
495
|
|
495
496
|
ctx
|
@@ -501,7 +502,7 @@ but prone to man-in-the-middle attacks. Please set verify_peer: true in producti
|
|
501
502
|
certs.each do |cert|
|
502
503
|
# if it starts with / or C:/ then it's a file path that may or may not
|
503
504
|
# exist (e.g. a default OpenSSL path). MK.
|
504
|
-
if File.readable?(cert) || cert =~
|
505
|
+
if File.readable?(cert) || cert =~ /\A([a-z]:?)?\//i
|
505
506
|
cert_files.push(cert)
|
506
507
|
else
|
507
508
|
cert_inlines.push(cert)
|
data/lib/bunny/version.rb
CHANGED
@@ -62,8 +62,10 @@ describe Bunny::Queue, "#subscribe" do
|
|
62
62
|
x.publish("hello", routing_key: queue_name)
|
63
63
|
end
|
64
64
|
|
65
|
-
sleep 1.
|
66
|
-
|
65
|
+
sleep 1.5
|
66
|
+
100.times do |i|
|
67
|
+
expect(delivery_tags).to include(i + 1)
|
68
|
+
end
|
67
69
|
|
68
70
|
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
69
71
|
|
@@ -95,7 +97,9 @@ describe Bunny::Queue, "#subscribe" do
|
|
95
97
|
end
|
96
98
|
|
97
99
|
sleep 1.5
|
98
|
-
|
100
|
+
100.times do |i|
|
101
|
+
expect(delivery_tags).to include(i + 1)
|
102
|
+
end
|
99
103
|
|
100
104
|
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
101
105
|
|
@@ -305,8 +309,10 @@ describe Bunny::Queue, "#subscribe" do
|
|
305
309
|
x.publish("hello", routing_key: queue_name)
|
306
310
|
end
|
307
311
|
|
308
|
-
sleep 1.
|
309
|
-
|
312
|
+
sleep 1.5
|
313
|
+
100.times do |i|
|
314
|
+
expect(delivery_tags).to include(i + 1)
|
315
|
+
end
|
310
316
|
|
311
317
|
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
312
318
|
|
@@ -338,7 +344,9 @@ describe Bunny::Queue, "#subscribe" do
|
|
338
344
|
end
|
339
345
|
|
340
346
|
sleep 1.5
|
341
|
-
|
347
|
+
100.times do |i|
|
348
|
+
expect(delivery_tags).to include(i + 1)
|
349
|
+
end
|
342
350
|
|
343
351
|
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
344
352
|
|
@@ -39,20 +39,6 @@ def local_hostname
|
|
39
39
|
ENV.fetch("BUNNY_RABBITMQ_HOSTNAME", "localhost")
|
40
40
|
end
|
41
41
|
|
42
|
-
def no_tls12_supported?
|
43
|
-
not tls12_supported?
|
44
|
-
end
|
45
|
-
|
46
|
-
def tls12_supported?
|
47
|
-
begin
|
48
|
-
ctx = OpenSSL::SSL::SSLContext.new
|
49
|
-
ctx.min_version = ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
|
50
|
-
true
|
51
|
-
rescue
|
52
|
-
false
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
42
|
context "initialized with tls: true", skip: ENV["CI"] do
|
57
43
|
let(:subject) do
|
58
44
|
Bunny.new(
|
@@ -102,6 +88,7 @@ describe "TLS connection to RabbitMQ with client certificates", skip: ENV["CI"]
|
|
102
88
|
password: "bunny_password",
|
103
89
|
vhost: "bunny_testbed",
|
104
90
|
tls: true,
|
91
|
+
tls_protocol: :TLSv1_2,
|
105
92
|
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
106
93
|
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
107
94
|
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
@@ -126,6 +113,7 @@ describe "TLS connection to RabbitMQ without client certificates", skip: ENV["CI
|
|
126
113
|
password: "bunny_password",
|
127
114
|
vhost: "bunny_testbed",
|
128
115
|
tls: true,
|
116
|
+
tls_protocol: :TLSv1_2,
|
129
117
|
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
130
118
|
verify_peer: false)
|
131
119
|
c.start
|
@@ -143,6 +131,7 @@ end
|
|
143
131
|
describe "TLS connection to RabbitMQ with a connection string", skip: ENV["CI"] do
|
144
132
|
let(:subject) do
|
145
133
|
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
134
|
+
tls_protocol: :TLSv1_2,
|
146
135
|
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
147
136
|
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
148
137
|
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
@@ -179,6 +168,7 @@ describe "TLS connection to RabbitMQ with a connection string and w/o client cer
|
|
179
168
|
let(:subject) do
|
180
169
|
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
181
170
|
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
171
|
+
tls_protocol: :TLSv1_2,
|
182
172
|
verify_peer: verify_peer)
|
183
173
|
c.start
|
184
174
|
c
|
@@ -211,19 +201,13 @@ describe "TLS connection to RabbitMQ with a connection string and w/o client cer
|
|
211
201
|
end
|
212
202
|
end
|
213
203
|
|
214
|
-
|
215
|
-
describe "TLS connection to RabbitMQ with client certificates provided inline", skip: ENV["CI"] do
|
204
|
+
describe "TLS connection to RabbitMQ w/o client certificate", skip: ENV["CI"] do
|
216
205
|
let(:subject) do
|
217
|
-
c = Bunny.new(
|
218
|
-
hostname: local_hostname(),
|
219
|
-
username: "bunny_gem",
|
220
|
-
password: "bunny_password",
|
221
|
-
vhost: "bunny_testbed",
|
222
|
-
tls: true,
|
223
|
-
tls_cert: File.read("#{CERTIFICATE_DIR}/client_certificate.pem"),
|
224
|
-
tls_key: File.read("#{CERTIFICATE_DIR}/client_key.pem"),
|
206
|
+
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
225
207
|
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
226
|
-
|
208
|
+
tls_protocol: :TLSv1_2,
|
209
|
+
verify_peer: false,
|
210
|
+
tls_silence_warnings: should_silence_warnings)
|
227
211
|
c.start
|
228
212
|
c
|
229
213
|
end
|
@@ -232,10 +216,21 @@ describe "TLS connection to RabbitMQ with client certificates provided inline",
|
|
232
216
|
subject.close
|
233
217
|
end
|
234
218
|
|
235
|
-
|
219
|
+
context "TLS-related warnings are enabled" do
|
220
|
+
let(:should_silence_warnings) { false }
|
221
|
+
|
222
|
+
include_examples "successful TLS connection"
|
223
|
+
end
|
224
|
+
|
225
|
+
context "TLS-related warnings are silenced" do
|
226
|
+
let(:should_silence_warnings) { true }
|
227
|
+
|
228
|
+
include_examples "successful TLS connection"
|
229
|
+
end
|
236
230
|
end
|
237
231
|
|
238
|
-
|
232
|
+
|
233
|
+
describe "TLS connection to RabbitMQ with client certificates provided inline", skip: ENV["CI"] do
|
239
234
|
let(:subject) do
|
240
235
|
c = Bunny.new(
|
241
236
|
hostname: local_hostname(),
|
@@ -243,8 +238,10 @@ describe "TLS connection to RabbitMQ with tls_version TLSv1.2 specified", skip:
|
|
243
238
|
password: "bunny_password",
|
244
239
|
vhost: "bunny_testbed",
|
245
240
|
tls: true,
|
246
|
-
|
241
|
+
tls_cert: File.read("#{CERTIFICATE_DIR}/client_certificate.pem"),
|
242
|
+
tls_key: File.read("#{CERTIFICATE_DIR}/client_key.pem"),
|
247
243
|
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
244
|
+
tls_protocol: :TLSv1_2,
|
248
245
|
verify_peer: false)
|
249
246
|
c.start
|
250
247
|
c
|
@@ -255,8 +252,4 @@ describe "TLS connection to RabbitMQ with tls_version TLSv1.2 specified", skip:
|
|
255
252
|
end
|
256
253
|
|
257
254
|
include_examples "successful TLS connection"
|
258
|
-
|
259
|
-
it "connects using TLSv1.2", skip: no_tls12_supported? do
|
260
|
-
expect(subject.transport.socket.ssl_version).to eq "TLSv1.2"
|
261
|
-
end
|
262
255
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Bunny::Session, 'TLS certificate store' do
|
6
|
+
subject { described_class.new tls: true, tls_ca_certificates: [certificate], logger: logger }
|
7
|
+
|
8
|
+
let(:logger) { Logger.new(io).tap { |l| l.level = :debug } }
|
9
|
+
let(:io) { StringIO.new }
|
10
|
+
|
11
|
+
context 'when a Windows path given' do
|
12
|
+
let(:certificate) { 'C:/some/path/cacert.pem' }
|
13
|
+
|
14
|
+
# skipping actual work with file by Windows path as this spec runs in Linux
|
15
|
+
before do
|
16
|
+
allow(File).to receive(:readable?).with(certificate).and_return(true)
|
17
|
+
allow_any_instance_of(OpenSSL::X509::Store).to receive(:add_file)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'uses the certificate by path' do
|
21
|
+
subject
|
22
|
+
|
23
|
+
expect(log_content).to include('Using CA certificates at C:/some/path/cacert.pem')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when a POSIX path given' do
|
28
|
+
let(:certificate) { './spec/tls/ca_certificate.pem' }
|
29
|
+
|
30
|
+
it 'uses the certificate by path' do
|
31
|
+
subject
|
32
|
+
|
33
|
+
expect(log_content).to include('Using CA certificates at ./spec/tls/ca_certificate.pem')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when an inline certificate given' do
|
38
|
+
let(:certificate) do
|
39
|
+
<<~CERT
|
40
|
+
-----BEGIN CERTIFICATE-----
|
41
|
+
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
|
69
|
+
eYEXqywYlmGZite4N3qb3qQnyGw=
|
70
|
+
-----END CERTIFICATE-----
|
71
|
+
CERT
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'uses the inline certificate' do
|
75
|
+
subject
|
76
|
+
|
77
|
+
expect(log_content).to include('Using 1 inline CA certificates')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def log_content
|
82
|
+
io.tap(&:rewind).read
|
83
|
+
end
|
84
|
+
end
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Bunny::Channel, "#basic_cancel" do
|
4
4
|
before(:all) do
|
5
|
-
@connection = Bunny.new(:user => "bunny_gem", :
|
5
|
+
@connection = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
|
6
6
|
@connection.start
|
7
7
|
end
|
8
8
|
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Bunny::Channel, "#basic_consume" do
|
4
4
|
before(:all) do
|
5
|
-
@connection = Bunny.new(:user => "bunny_gem", :
|
5
|
+
@connection = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
|
6
6
|
@connection.start
|
7
7
|
end
|
8
8
|
|
@@ -12,7 +12,7 @@ describe Bunny::Channel, "#basic_consume" do
|
|
12
12
|
|
13
13
|
it "returns basic.consume-ok when it is received" do
|
14
14
|
ch = @connection.create_channel
|
15
|
-
q = ch.queue("", :
|
15
|
+
q = ch.queue("", exclusive: true)
|
16
16
|
|
17
17
|
consume_ok = ch.basic_consume(q)
|
18
18
|
expect(consume_ok).to be_instance_of AMQ::Protocol::Basic::ConsumeOk
|
@@ -23,7 +23,7 @@ describe Bunny::Channel, "#basic_consume" do
|
|
23
23
|
|
24
24
|
it "carries server-generated consumer tag with basic.consume-ok" do
|
25
25
|
ch = @connection.create_channel
|
26
|
-
q = ch.queue("", :
|
26
|
+
q = ch.queue("", exclusive: true)
|
27
27
|
|
28
28
|
consume_ok = ch.basic_consume(q, "")
|
29
29
|
expect(consume_ok.consumer_tag).to match /amq\.ctag.*/
|
@@ -51,13 +51,13 @@ describe Bunny::Channel, "#basic_consume" do
|
|
51
51
|
|
52
52
|
ch = @connection.create_channel
|
53
53
|
x = ch.default_exchange
|
54
|
-
x.publish("hello", :
|
54
|
+
x.publish("hello", routing_key: queue_name)
|
55
55
|
|
56
56
|
sleep 0.7
|
57
57
|
expect(delivered_keys).to include queue_name
|
58
58
|
expect(delivered_data).to include "hello"
|
59
59
|
|
60
|
-
expect(ch.queue(queue_name, :
|
60
|
+
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
61
61
|
|
62
62
|
ch.close
|
63
63
|
end
|
@@ -72,7 +72,7 @@ describe Bunny::Channel, "#basic_consume" do
|
|
72
72
|
|
73
73
|
t = Thread.new do
|
74
74
|
ch = @connection.create_channel
|
75
|
-
q = ch.queue(queue_name, :
|
75
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
76
76
|
ch.basic_consume(q, "", false, false) do |delivery_info, properties, payload|
|
77
77
|
delivered_keys << delivery_info.routing_key
|
78
78
|
delivered_data << payload
|
@@ -85,13 +85,13 @@ describe Bunny::Channel, "#basic_consume" do
|
|
85
85
|
|
86
86
|
ch = @connection.create_channel
|
87
87
|
x = ch.default_exchange
|
88
|
-
x.publish("hello", :
|
88
|
+
x.publish("hello", routing_key: queue_name)
|
89
89
|
|
90
90
|
sleep 0.7
|
91
91
|
expect(delivered_keys).to include queue_name
|
92
92
|
expect(delivered_data).to include "hello"
|
93
93
|
|
94
|
-
expect(ch.queue(queue_name, :
|
94
|
+
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
95
95
|
|
96
96
|
ch.close
|
97
97
|
end
|