bunny 2.14.4 → 2.19.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 +30 -12
- data/lib/bunny/channel.rb +2 -2
- data/lib/bunny/queue.rb +0 -3
- data/lib/bunny/reader_loop.rb +11 -11
- data/lib/bunny/session.rb +42 -9
- data/lib/bunny/transport.rb +12 -11
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +4 -4
- data/spec/higher_level_api/integration/basic_consume_spec.rb +17 -9
- data/spec/higher_level_api/integration/connection_spec.rb +26 -0
- data/spec/higher_level_api/integration/tls_connection_spec.rb +194 -189
- data/spec/issues/issue202_spec.rb +1 -1
- data/spec/issues/issue609_spec.rb +84 -0
- data/spec/issues/issue78_spec.rb +2 -2
- data/spec/lower_level_api/integration/basic_cancel_spec.rb +1 -1
- data/spec/lower_level_api/integration/basic_consume_spec.rb +8 -8
- data/spec/unit/exchange_recovery_spec.rb +2 -2
- metadata +37 -95
- data/.github/ISSUE_TEMPLATE.md +0 -18
- data/.gitignore +0 -28
- data/.rspec +0 -1
- data/.travis.yml +0 -32
- data/.yardopts +0 -8
- data/CONTRIBUTING.md +0 -132
- data/ChangeLog.md +0 -2103
- 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
@@ -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
|
|
@@ -189,17 +193,17 @@ describe Bunny::Queue, "#subscribe" do
|
|
189
193
|
ch = connection.create_channel
|
190
194
|
q = ch.queue(queue_name)
|
191
195
|
|
192
|
-
c1 = q.subscribe(exclusive: false, manual_ack: false
|
196
|
+
c1 = q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
193
197
|
end
|
194
198
|
c1.cancel
|
195
199
|
|
196
|
-
c2 = q.subscribe(exclusive: false, manual_ack: false
|
200
|
+
c2 = q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
197
201
|
delivered_keys << delivery_info.routing_key
|
198
202
|
delivered_data << payload
|
199
203
|
end
|
200
204
|
c2.cancel
|
201
205
|
|
202
|
-
q.subscribe(exclusive: false, manual_ack: false
|
206
|
+
q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
203
207
|
delivered_keys << delivery_info.routing_key
|
204
208
|
delivered_data << payload
|
205
209
|
end
|
@@ -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
|
|
@@ -560,4 +560,30 @@ describe Bunny::Session do
|
|
560
560
|
described_class.new(logger: logger)
|
561
561
|
end
|
562
562
|
end
|
563
|
+
|
564
|
+
context "initialized with a custom connection name" do
|
565
|
+
it "uses provided connection name with default connection string" do
|
566
|
+
conn = Bunny.new(connection_name: 'test_name')
|
567
|
+
|
568
|
+
expect(conn.connection_name).to eq 'test_name'
|
569
|
+
end
|
570
|
+
|
571
|
+
it "uses provided connection name from client property hash" do
|
572
|
+
conn = Bunny.new(client_properties: {connection_name: 'cp/test_name'})
|
573
|
+
|
574
|
+
expect(conn.connection_name).to eq 'cp/test_name'
|
575
|
+
end
|
576
|
+
|
577
|
+
it "uses provided connection name with custom connection string" do
|
578
|
+
conn = Bunny.new('amqp://guest:guest@rabbitmq:5672', connection_name: 'test_name3')
|
579
|
+
|
580
|
+
expect(conn.connection_name).to eq 'test_name3'
|
581
|
+
end
|
582
|
+
|
583
|
+
it "uses provided connection name with hash options" do
|
584
|
+
conn = Bunny.new(user: 'user', password: 'p455w0rd', connection_name: 'test_name4')
|
585
|
+
|
586
|
+
expect(conn.connection_name).to eq 'test_name4'
|
587
|
+
end
|
588
|
+
end
|
563
589
|
end
|
@@ -3,248 +3,253 @@ require "spec_helper"
|
|
3
3
|
|
4
4
|
require "socket"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
puts "Will use certificates from #{CERTIFICATE_DIR}"
|
9
|
-
|
10
|
-
shared_examples_for "successful TLS connection" do
|
11
|
-
it "succeeds" do
|
12
|
-
expect(subject).to be_tls
|
13
|
-
ch = subject.create_channel
|
14
|
-
ch.confirm_select
|
15
|
-
|
16
|
-
q = ch.queue("", exclusive: true)
|
17
|
-
x = ch.default_exchange
|
18
|
-
|
19
|
-
x.publish("xyzzy", routing_key: q.name).
|
20
|
-
publish("xyzzy", routing_key: q.name).
|
21
|
-
publish("xyzzy", routing_key: q.name).
|
22
|
-
publish("xyzzy", routing_key: q.name)
|
23
|
-
|
24
|
-
x.wait_for_confirms
|
25
|
-
expect(q.message_count).to eq 4
|
26
|
-
|
27
|
-
i = 0
|
28
|
-
q.subscribe do |delivery_info, _, payload|
|
29
|
-
i += 1
|
30
|
-
end
|
31
|
-
sleep 1.0
|
32
|
-
expect(i).to eq 4
|
33
|
-
expect(q.message_count).to eq 0
|
34
|
-
|
35
|
-
ch.close
|
36
|
-
end
|
37
|
-
end
|
6
|
+
CERTIFICATE_DIR = ENV.fetch("BUNNY_CERTIFICATE_DIR", "./spec/tls")
|
7
|
+
puts "Will use certificates from #{CERTIFICATE_DIR}"
|
38
8
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
let(:subject) do
|
45
|
-
Bunny.new(
|
46
|
-
hostname: local_hostname(),
|
47
|
-
user: "bunny_gem",
|
48
|
-
password: "bunny_password",
|
49
|
-
vhost: "bunny_testbed",
|
50
|
-
tls: true,
|
51
|
-
verify_peer: verify_peer,
|
52
|
-
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
53
|
-
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
54
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"])
|
55
|
-
end
|
9
|
+
shared_examples_for "successful TLS connection" do
|
10
|
+
it "succeeds", skip: ENV["CI"] do
|
11
|
+
expect(subject).to be_tls
|
12
|
+
ch = subject.create_channel
|
13
|
+
ch.confirm_select
|
56
14
|
|
57
|
-
|
58
|
-
|
15
|
+
q = ch.queue("", exclusive: true)
|
16
|
+
x = ch.default_exchange
|
59
17
|
|
60
|
-
|
61
|
-
|
62
|
-
|
18
|
+
x.publish("xyzzy", routing_key: q.name).
|
19
|
+
publish("xyzzy", routing_key: q.name).
|
20
|
+
publish("xyzzy", routing_key: q.name).
|
21
|
+
publish("xyzzy", routing_key: q.name)
|
63
22
|
|
64
|
-
|
65
|
-
|
66
|
-
subject.start
|
67
|
-
expect(subject.transport.socket.hostname).to_not be_empty
|
68
|
-
end
|
23
|
+
x.wait_for_confirms
|
24
|
+
expect(q.message_count).to eq 4
|
69
25
|
|
70
|
-
|
71
|
-
|
72
|
-
|
26
|
+
i = 0
|
27
|
+
q.subscribe do |delivery_info, _, payload|
|
28
|
+
i += 1
|
73
29
|
end
|
30
|
+
sleep 1.0
|
31
|
+
expect(i).to eq 4
|
32
|
+
expect(q.message_count).to eq 0
|
74
33
|
|
75
|
-
|
76
|
-
|
34
|
+
ch.close
|
35
|
+
end
|
36
|
+
end
|
77
37
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
38
|
+
def local_hostname
|
39
|
+
ENV.fetch("BUNNY_RABBITMQ_HOSTNAME", "localhost")
|
40
|
+
end
|
41
|
+
|
42
|
+
context "initialized with tls: true", skip: ENV["CI"] do
|
43
|
+
let(:subject) do
|
44
|
+
Bunny.new(
|
45
|
+
hostname: local_hostname(),
|
46
|
+
user: "bunny_gem",
|
47
|
+
password: "bunny_password",
|
48
|
+
vhost: "bunny_testbed",
|
49
|
+
tls: true,
|
50
|
+
verify_peer: verify_peer,
|
51
|
+
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
52
|
+
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
53
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"])
|
82
54
|
end
|
83
55
|
|
84
|
-
|
85
|
-
let(:
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
verify_peer: false)
|
96
|
-
c.start
|
97
|
-
c
|
56
|
+
context "peer verification is off" do
|
57
|
+
let(:verify_peer) { false }
|
58
|
+
|
59
|
+
it "uses TLS port" do
|
60
|
+
expect(subject.port).to eq AMQ::Protocol::TLS_PORT
|
61
|
+
end
|
62
|
+
|
63
|
+
it "sends the SNI details" do
|
64
|
+
# https://github.com/ruby-amqp/bunny/issues/440
|
65
|
+
subject.start
|
66
|
+
expect(subject.transport.socket.hostname).to_not be_empty
|
98
67
|
end
|
99
68
|
|
100
69
|
after :each do
|
101
70
|
subject.close
|
102
71
|
end
|
103
|
-
|
104
|
-
include_examples "successful TLS connection"
|
105
72
|
end
|
106
73
|
|
74
|
+
context "peer verification is on" do
|
75
|
+
let(:verify_peer) { true }
|
107
76
|
|
108
|
-
|
109
|
-
|
110
|
-
c = Bunny.new(
|
111
|
-
hostname: local_hostname(),
|
112
|
-
username: "bunny_gem",
|
113
|
-
password: "bunny_password",
|
114
|
-
vhost: "bunny_testbed",
|
115
|
-
tls: true,
|
116
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
117
|
-
verify_peer: false)
|
118
|
-
c.start
|
119
|
-
c
|
77
|
+
it "uses TLS port" do
|
78
|
+
expect(subject.port).to eq AMQ::Protocol::TLS_PORT
|
120
79
|
end
|
80
|
+
end
|
81
|
+
end
|
121
82
|
|
122
|
-
|
123
|
-
|
124
|
-
|
83
|
+
describe "TLS connection to RabbitMQ with client certificates", skip: ENV["CI"] do
|
84
|
+
let(:subject) do
|
85
|
+
c = Bunny.new(
|
86
|
+
hostname: local_hostname(),
|
87
|
+
username: "bunny_gem",
|
88
|
+
password: "bunny_password",
|
89
|
+
vhost: "bunny_testbed",
|
90
|
+
tls: true,
|
91
|
+
tls_protocol: :TLSv1_2,
|
92
|
+
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
93
|
+
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
94
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
95
|
+
verify_peer: false)
|
96
|
+
c.start
|
97
|
+
c
|
98
|
+
end
|
125
99
|
|
126
|
-
|
100
|
+
after :each do
|
101
|
+
subject.close
|
127
102
|
end
|
128
103
|
|
104
|
+
include_examples "successful TLS connection"
|
105
|
+
end
|
129
106
|
|
130
|
-
describe "TLS connection to RabbitMQ with a connection string" do
|
131
|
-
let(:subject) do
|
132
|
-
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
133
|
-
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
134
|
-
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
135
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
136
|
-
verify_peer: false)
|
137
|
-
c.start
|
138
|
-
c
|
139
|
-
end
|
140
107
|
|
141
|
-
|
142
|
-
|
143
|
-
|
108
|
+
describe "TLS connection to RabbitMQ without client certificates", skip: ENV["CI"] do
|
109
|
+
let(:subject) do
|
110
|
+
c = Bunny.new(
|
111
|
+
hostname: local_hostname(),
|
112
|
+
username: "bunny_gem",
|
113
|
+
password: "bunny_password",
|
114
|
+
vhost: "bunny_testbed",
|
115
|
+
tls: true,
|
116
|
+
tls_protocol: :TLSv1_2,
|
117
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
118
|
+
verify_peer: false)
|
119
|
+
c.start
|
120
|
+
c
|
121
|
+
end
|
144
122
|
|
145
|
-
|
123
|
+
after :each do
|
124
|
+
subject.close
|
125
|
+
end
|
146
126
|
|
147
|
-
|
148
|
-
|
149
|
-
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")
|
150
|
-
end
|
127
|
+
include_examples "successful TLS connection"
|
128
|
+
end
|
151
129
|
|
152
|
-
it "parses extra connection parameters" do
|
153
|
-
session.start
|
154
130
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
131
|
+
describe "TLS connection to RabbitMQ with a connection string", skip: ENV["CI"] do
|
132
|
+
let(:subject) do
|
133
|
+
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
134
|
+
tls_protocol: :TLSv1_2,
|
135
|
+
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
136
|
+
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
137
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
138
|
+
verify_peer: false)
|
139
|
+
c.start
|
140
|
+
c
|
141
|
+
end
|
142
|
+
|
143
|
+
after :each do
|
144
|
+
subject.close
|
162
145
|
end
|
163
146
|
|
147
|
+
include_examples "successful TLS connection"
|
164
148
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
169
|
-
verify_peer: verify_peer)
|
170
|
-
c.start
|
171
|
-
c
|
149
|
+
context "when URI contains query parameters" do
|
150
|
+
subject(:session) do
|
151
|
+
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")
|
172
152
|
end
|
173
153
|
|
174
|
-
|
175
|
-
|
154
|
+
it "parses extra connection parameters" do
|
155
|
+
session.start
|
156
|
+
|
157
|
+
expect(session.uses_tls?).to eq(true)
|
158
|
+
expect(session.transport.verify_peer).to eq(false)
|
159
|
+
expect(session.transport.tls_ca_certificates).to eq(["#{CERTIFICATE_DIR}/ca_certificate.pem"])
|
160
|
+
expect(session.transport.tls_certificate_path).to eq("#{CERTIFICATE_DIR}/client_certificate.pem")
|
161
|
+
expect(session.transport.tls_key_path).to eq("#{CERTIFICATE_DIR}/client_key.pem")
|
176
162
|
end
|
163
|
+
end
|
164
|
+
end
|
177
165
|
|
178
|
-
context "peer verification is off" do
|
179
|
-
let(:verify_peer) { false }
|
180
166
|
|
181
|
-
|
167
|
+
describe "TLS connection to RabbitMQ with a connection string and w/o client certificate and key", skip: ENV["CI"] do
|
168
|
+
let(:subject) do
|
169
|
+
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
170
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
171
|
+
tls_protocol: :TLSv1_2,
|
172
|
+
verify_peer: verify_peer)
|
173
|
+
c.start
|
174
|
+
c
|
175
|
+
end
|
182
176
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
end
|
187
|
-
end
|
177
|
+
after :each do
|
178
|
+
subject.close
|
179
|
+
end
|
188
180
|
|
189
|
-
|
190
|
-
|
181
|
+
context "peer verification is off" do
|
182
|
+
let(:verify_peer) { false }
|
191
183
|
|
192
|
-
|
184
|
+
include_examples "successful TLS connection"
|
193
185
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
end
|
186
|
+
it "sends the SNI details" do
|
187
|
+
# https://github.com/ruby-amqp/bunny/issues/440
|
188
|
+
expect(subject.transport.socket.hostname).to_not be_empty
|
198
189
|
end
|
199
190
|
end
|
200
191
|
|
192
|
+
context "peer verification is on" do
|
193
|
+
let(:verify_peer) { true }
|
201
194
|
|
202
|
-
|
203
|
-
let(:subject) do
|
204
|
-
c = Bunny.new(
|
205
|
-
hostname: local_hostname(),
|
206
|
-
username: "bunny_gem",
|
207
|
-
password: "bunny_password",
|
208
|
-
vhost: "bunny_testbed",
|
209
|
-
tls: true,
|
210
|
-
tls_cert: File.read("#{CERTIFICATE_DIR}/client_certificate.pem"),
|
211
|
-
tls_key: File.read("#{CERTIFICATE_DIR}/client_key.pem"),
|
212
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
213
|
-
verify_peer: false)
|
214
|
-
c.start
|
215
|
-
c
|
216
|
-
end
|
195
|
+
include_examples "successful TLS connection"
|
217
196
|
|
218
|
-
|
219
|
-
|
197
|
+
it "sends the SNI details" do
|
198
|
+
# https://github.com/ruby-amqp/bunny/issues/440
|
199
|
+
expect(subject.transport.socket.hostname).to_not be_empty
|
220
200
|
end
|
201
|
+
end
|
202
|
+
end
|
221
203
|
|
222
|
-
|
204
|
+
describe "TLS connection to RabbitMQ w/o client certificate", skip: ENV["CI"] do
|
205
|
+
let(:subject) do
|
206
|
+
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
207
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
208
|
+
tls_protocol: :TLSv1_2,
|
209
|
+
verify_peer: false,
|
210
|
+
tls_silence_warnings: should_silence_warnings)
|
211
|
+
c.start
|
212
|
+
c
|
223
213
|
end
|
224
214
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
hostname: local_hostname(),
|
229
|
-
username: "bunny_gem",
|
230
|
-
password: "bunny_password",
|
231
|
-
vhost: "bunny_testbed",
|
232
|
-
tls: true,
|
233
|
-
tls_protocol: :TLSv1_1,
|
234
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
235
|
-
verify_peer: false)
|
236
|
-
c.start
|
237
|
-
c
|
238
|
-
end
|
215
|
+
after :each do
|
216
|
+
subject.close
|
217
|
+
end
|
239
218
|
|
240
|
-
|
241
|
-
|
242
|
-
end
|
219
|
+
context "TLS-related warnings are enabled" do
|
220
|
+
let(:should_silence_warnings) { false }
|
243
221
|
|
244
222
|
include_examples "successful TLS connection"
|
223
|
+
end
|
245
224
|
|
246
|
-
|
247
|
-
|
248
|
-
|
225
|
+
context "TLS-related warnings are silenced" do
|
226
|
+
let(:should_silence_warnings) { true }
|
227
|
+
|
228
|
+
include_examples "successful TLS connection"
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
describe "TLS connection to RabbitMQ with client certificates provided inline", skip: ENV["CI"] do
|
234
|
+
let(:subject) do
|
235
|
+
c = Bunny.new(
|
236
|
+
hostname: local_hostname(),
|
237
|
+
username: "bunny_gem",
|
238
|
+
password: "bunny_password",
|
239
|
+
vhost: "bunny_testbed",
|
240
|
+
tls: true,
|
241
|
+
tls_cert: File.read("#{CERTIFICATE_DIR}/client_certificate.pem"),
|
242
|
+
tls_key: File.read("#{CERTIFICATE_DIR}/client_key.pem"),
|
243
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
244
|
+
tls_protocol: :TLSv1_2,
|
245
|
+
verify_peer: false)
|
246
|
+
c.start
|
247
|
+
c
|
248
|
+
end
|
249
|
+
|
250
|
+
after :each do
|
251
|
+
subject.close
|
249
252
|
end
|
253
|
+
|
254
|
+
include_examples "successful TLS connection"
|
250
255
|
end
|