bunny 2.14.4 → 2.19.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.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +30 -12
  3. data/lib/bunny/channel.rb +2 -2
  4. data/lib/bunny/queue.rb +0 -3
  5. data/lib/bunny/reader_loop.rb +11 -11
  6. data/lib/bunny/session.rb +42 -9
  7. data/lib/bunny/transport.rb +12 -11
  8. data/lib/bunny/version.rb +1 -1
  9. data/spec/higher_level_api/integration/basic_cancel_spec.rb +4 -4
  10. data/spec/higher_level_api/integration/basic_consume_spec.rb +17 -9
  11. data/spec/higher_level_api/integration/connection_spec.rb +26 -0
  12. data/spec/higher_level_api/integration/tls_connection_spec.rb +194 -189
  13. data/spec/issues/issue202_spec.rb +1 -1
  14. data/spec/issues/issue609_spec.rb +84 -0
  15. data/spec/issues/issue78_spec.rb +2 -2
  16. data/spec/lower_level_api/integration/basic_cancel_spec.rb +1 -1
  17. data/spec/lower_level_api/integration/basic_consume_spec.rb +8 -8
  18. data/spec/unit/exchange_recovery_spec.rb +2 -2
  19. metadata +37 -95
  20. data/.github/ISSUE_TEMPLATE.md +0 -18
  21. data/.gitignore +0 -28
  22. data/.rspec +0 -1
  23. data/.travis.yml +0 -32
  24. data/.yardopts +0 -8
  25. data/CONTRIBUTING.md +0 -132
  26. data/ChangeLog.md +0 -2103
  27. data/Gemfile +0 -55
  28. data/LICENSE +0 -21
  29. data/Rakefile +0 -54
  30. data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
  31. data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
  32. data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
  33. data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
  34. data/benchmarks/channel_open.rb +0 -28
  35. data/benchmarks/mutex_and_monitor.rb +0 -42
  36. data/benchmarks/queue_declare.rb +0 -29
  37. data/benchmarks/queue_declare_and_bind.rb +0 -29
  38. data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
  39. data/benchmarks/synchronized_sorted_set.rb +0 -53
  40. data/benchmarks/write_vs_write_nonblock.rb +0 -49
  41. data/bunny.gemspec +0 -34
  42. data/docker-compose.yml +0 -28
  43. data/docker/Dockerfile +0 -24
  44. data/docker/apt/preferences.d/erlang +0 -3
  45. data/docker/apt/sources.list.d/bintray.rabbitmq.list +0 -2
  46. data/docker/docker-entrypoint.sh +0 -26
  47. data/docker/rabbitmq.conf +0 -29
  48. data/examples/connection/authentication_failure.rb +0 -16
  49. data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
  50. data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
  51. data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
  52. data/examples/connection/automatic_recovery_with_republishing.rb +0 -109
  53. data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
  54. data/examples/connection/channel_level_exception.rb +0 -27
  55. data/examples/connection/disabled_automatic_recovery.rb +0 -34
  56. data/examples/connection/heartbeat.rb +0 -17
  57. data/examples/connection/manually_reconnecting_consumer.rb +0 -23
  58. data/examples/connection/manually_reconnecting_publisher.rb +0 -28
  59. data/examples/connection/unknown_host.rb +0 -16
  60. data/examples/consumers/high_and_low_priority.rb +0 -50
  61. data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
  62. data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
  63. data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
  64. data/examples/guides/exchanges/mandatory_messages.rb +0 -30
  65. data/examples/guides/extensions/alternate_exchange.rb +0 -30
  66. data/examples/guides/extensions/basic_nack.rb +0 -33
  67. data/examples/guides/extensions/connection_blocked.rb +0 -35
  68. data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
  69. data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
  70. data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
  71. data/examples/guides/extensions/per_message_ttl.rb +0 -36
  72. data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
  73. data/examples/guides/extensions/publisher_confirms.rb +0 -28
  74. data/examples/guides/extensions/queue_lease.rb +0 -26
  75. data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
  76. data/examples/guides/getting_started/blabbr.rb +0 -27
  77. data/examples/guides/getting_started/hello_world.rb +0 -22
  78. data/examples/guides/getting_started/weathr.rb +0 -49
  79. data/examples/guides/queues/one_off_consumer.rb +0 -25
  80. data/examples/guides/queues/redeliveries.rb +0 -81
  81. data/profiling/basic_publish/with_4K_messages.rb +0 -33
  82. data/repl +0 -3
  83. data/spec/tls/generate-server-cert.sh +0 -8
  84. data/spec/tls/server-openssl.cnf +0 -10
  85. 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.0
66
- expect(delivery_tags).to eq SortedSet.new(Range.new(1, 100).to_a)
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
- expect(delivery_tags).to eq SortedSet.new(Range.new(1, 100).to_a)
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, block: false) do |delivery_info, properties, payload|
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, block: false) do |delivery_info, properties, payload|
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, block: true) do |delivery_info, properties, payload|
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.0
309
- expect(delivery_tags).to eq SortedSet.new(Range.new(1, 100).to_a)
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
- expect(delivery_tags).to eq SortedSet.new(Range.new(1, 100).to_a)
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
- unless ENV["CI"]
7
- CERTIFICATE_DIR = ENV.fetch("BUNNY_CERTIFICATE_DIR", "./spec/tls")
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
- def local_hostname
40
- ENV.fetch("BUNNY_RABBITMQ_HOSTNAME", "localhost")
41
- end
42
-
43
- context "initialized with :tls => true" do
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
- context "peer verification is off" do
58
- let(:verify_peer) { false }
15
+ q = ch.queue("", exclusive: true)
16
+ x = ch.default_exchange
59
17
 
60
- it "uses TLS port" do
61
- expect(subject.port).to eq AMQ::Protocol::TLS_PORT
62
- end
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
- it "sends the SNI details" do
65
- # https://github.com/ruby-amqp/bunny/issues/440
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
- after :each do
71
- subject.close
72
- end
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
- context "peer verification is on" do
76
- let(:verify_peer) { true }
34
+ ch.close
35
+ end
36
+ end
77
37
 
78
- it "uses TLS port" do
79
- expect(subject.port).to eq AMQ::Protocol::TLS_PORT
80
- end
81
- end
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
- describe "TLS connection to RabbitMQ with client certificates" do
85
- let(:subject) do
86
- c = Bunny.new(
87
- hostname: local_hostname(),
88
- username: "bunny_gem",
89
- password: "bunny_password",
90
- vhost: "bunny_testbed",
91
- tls: true,
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
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
- describe "TLS connection to RabbitMQ without client certificates" 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_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
- after :each do
123
- subject.close
124
- end
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
- include_examples "successful TLS connection"
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
- after :each do
142
- subject.close
143
- end
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
- include_examples "successful TLS connection"
123
+ after :each do
124
+ subject.close
125
+ end
146
126
 
147
- context "when URI contains query parameters" do
148
- subject(:session) do
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
- expect(session.uses_tls?).to eq(true)
156
- expect(session.transport.verify_peer).to eq(false)
157
- expect(session.transport.tls_ca_certificates).to eq(["#{CERTIFICATE_DIR}/ca_certificate.pem"])
158
- expect(session.transport.tls_certificate_path).to eq("#{CERTIFICATE_DIR}/client_certificate.pem")
159
- expect(session.transport.tls_key_path).to eq("#{CERTIFICATE_DIR}/client_key.pem")
160
- end
161
- end
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
- describe "TLS connection to RabbitMQ with a connection string and w/o client certificate and key" do
166
- let(:subject) do
167
- c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
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
- after :each do
175
- subject.close
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
- include_examples "successful TLS connection"
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
- it "sends the SNI details" do
184
- # https://github.com/ruby-amqp/bunny/issues/440
185
- expect(subject.transport.socket.hostname).to_not be_empty
186
- end
187
- end
177
+ after :each do
178
+ subject.close
179
+ end
188
180
 
189
- context "peer verification is on" do
190
- let(:verify_peer) { true }
181
+ context "peer verification is off" do
182
+ let(:verify_peer) { false }
191
183
 
192
- include_examples "successful TLS connection"
184
+ include_examples "successful TLS connection"
193
185
 
194
- it "sends the SNI details" do
195
- # https://github.com/ruby-amqp/bunny/issues/440
196
- expect(subject.transport.socket.hostname).to_not be_empty
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
- describe "TLS connection to RabbitMQ with client certificates provided inline" do
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
- after :each do
219
- subject.close
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
- include_examples "successful TLS connection"
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
- describe "TLS connection to RabbitMQ with tls_version TLSv1.1 specified" do
226
- let(:subject) do
227
- c = Bunny.new(
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
- after :each do
241
- subject.close
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
- it "connects using TLSv1.1" do
247
- expect(subject.transport.socket.ssl_version).to eq "TLSv1.1"
248
- end
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