amq-protocol 2.5.0 → 2.5.1
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 +4 -4
- data/ChangeLog.md +5 -2
- data/lib/amq/protocol/version.rb +1 -1
- metadata +3 -55
- data/.github/ISSUE_TEMPLATE.md +0 -18
- data/.github/workflows/ci.yml +0 -31
- data/.gitignore +0 -18
- data/.gitmodules +0 -3
- data/.rspec +0 -1
- data/.travis.yml +0 -17
- data/AGENTS.md +0 -23
- data/CLAUDE.md +0 -1
- data/GEMINI.md +0 -1
- data/Gemfile +0 -27
- data/Rakefile +0 -55
- data/amq-protocol.gemspec +0 -27
- data/benchmarks/frame_encoding.rb +0 -75
- data/benchmarks/int_allocator.rb +0 -34
- data/benchmarks/method_encoding.rb +0 -198
- data/benchmarks/pack_unpack.rb +0 -158
- data/benchmarks/pure/body_framing_with_256k_payload.rb +0 -28
- data/benchmarks/pure/body_framing_with_2k_payload.rb +0 -28
- data/benchmarks/run_all.rb +0 -64
- data/benchmarks/table_encoding.rb +0 -110
- data/codegen/__init__.py +0 -0
- data/codegen/amqp_0.9.1_changes.json +0 -1
- data/codegen/codegen.py +0 -151
- data/codegen/codegen_helpers.py +0 -162
- data/codegen/protocol.rb.pytemplate +0 -320
- data/generate.rb +0 -24
- data/profiling/README.md +0 -9
- data/profiling/stackprof/body_framing_with_2k_payload.rb +0 -33
- data/spec/amq/bit_set_spec.rb +0 -249
- data/spec/amq/endianness_spec.rb +0 -23
- data/spec/amq/int_allocator_spec.rb +0 -136
- data/spec/amq/pack_spec.rb +0 -58
- data/spec/amq/protocol/basic_spec.rb +0 -325
- data/spec/amq/protocol/blank_body_encoding_spec.rb +0 -9
- data/spec/amq/protocol/channel_spec.rb +0 -127
- data/spec/amq/protocol/confirm_spec.rb +0 -41
- data/spec/amq/protocol/connection_spec.rb +0 -146
- data/spec/amq/protocol/constants_spec.rb +0 -10
- data/spec/amq/protocol/exceptions_spec.rb +0 -70
- data/spec/amq/protocol/exchange_spec.rb +0 -106
- data/spec/amq/protocol/float_32bit_spec.rb +0 -27
- data/spec/amq/protocol/frame_spec.rb +0 -156
- data/spec/amq/protocol/method_spec.rb +0 -43
- data/spec/amq/protocol/queue_spec.rb +0 -126
- data/spec/amq/protocol/table_spec.rb +0 -291
- data/spec/amq/protocol/tx_spec.rb +0 -55
- data/spec/amq/protocol/value_decoder_spec.rb +0 -183
- data/spec/amq/protocol/value_encoder_spec.rb +0 -161
- data/spec/amq/protocol_spec.rb +0 -812
- data/spec/amq/settings_spec.rb +0 -58
- data/spec/amq/uri_parsing_spec.rb +0 -287
- data/spec/spec_helper.rb +0 -29
data/spec/amq/settings_spec.rb
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
require "amq/settings"
|
|
2
|
-
|
|
3
|
-
RSpec.describe AMQ::Settings do
|
|
4
|
-
describe ".default" do
|
|
5
|
-
it "should provide some default values" do
|
|
6
|
-
expect(AMQ::Settings.default).to_not be_nil
|
|
7
|
-
expect(AMQ::Settings.default[:host]).to_not be_nil
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "includes default port" do
|
|
11
|
-
expect(AMQ::Settings.default[:port]).to eq(5672)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "includes default credentials" do
|
|
15
|
-
expect(AMQ::Settings.default[:user]).to eq("guest")
|
|
16
|
-
expect(AMQ::Settings.default[:pass]).to eq("guest")
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe ".configure" do
|
|
21
|
-
it "should merge custom settings with default settings" do
|
|
22
|
-
settings = AMQ::Settings.configure(:host => "tagadab")
|
|
23
|
-
expect(settings[:host]).to eql("tagadab")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should merge custom settings from AMQP URL with default settings" do
|
|
27
|
-
settings = AMQ::Settings.configure("amqp://tagadab")
|
|
28
|
-
expect(settings[:host]).to eql("tagadab")
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "returns default when passed nil" do
|
|
32
|
-
settings = AMQ::Settings.configure(nil)
|
|
33
|
-
expect(settings).to eq(AMQ::Settings.default)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "normalizes username to user" do
|
|
37
|
-
settings = AMQ::Settings.configure(:username => "admin")
|
|
38
|
-
expect(settings[:user]).to eq("admin")
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "normalizes password to pass" do
|
|
42
|
-
settings = AMQ::Settings.configure(:password => "secret")
|
|
43
|
-
expect(settings[:pass]).to eq("secret")
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "prefers user over username when both provided" do
|
|
47
|
-
settings = AMQ::Settings.configure(:user => "admin", :username => "other")
|
|
48
|
-
expect(settings[:user]).to eq("admin")
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
describe ".parse_amqp_url" do
|
|
53
|
-
it "delegates to AMQ::URI.parse" do
|
|
54
|
-
result = AMQ::Settings.parse_amqp_url("amqp://localhost")
|
|
55
|
-
expect(result[:host]).to eq("localhost")
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
require "amq/uri"
|
|
2
|
-
|
|
3
|
-
# https://www.rabbitmq.com/uri-spec.html
|
|
4
|
-
# http://www.ietf.org/rfc/rfc3986.txt
|
|
5
|
-
# https://tools.ietf.org/rfc/rfc5246.txt
|
|
6
|
-
|
|
7
|
-
RSpec.describe AMQ::URI do
|
|
8
|
-
describe ".parse" do
|
|
9
|
-
subject { described_class.parse(uri) }
|
|
10
|
-
|
|
11
|
-
context "schema is not amqp or amqps" do
|
|
12
|
-
let(:uri) { "http://rabbitmq" }
|
|
13
|
-
|
|
14
|
-
it "raises ArgumentError" do
|
|
15
|
-
expect { subject }.to raise_error(ArgumentError, /amqp or amqps schema/)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe "host" do
|
|
20
|
-
context "present" do
|
|
21
|
-
let(:uri) { "amqp://rabbitmq" }
|
|
22
|
-
|
|
23
|
-
it "parses host" do
|
|
24
|
-
expect(subject[:host]).to eq("rabbitmq")
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
if RUBY_VERSION >= "2.2"
|
|
29
|
-
context "absent" do
|
|
30
|
-
let(:uri) { "amqp://" }
|
|
31
|
-
|
|
32
|
-
# Note that according to the ABNF, the host component may not be absent, but it may be zero-length.
|
|
33
|
-
it "falls back to a blank value" do
|
|
34
|
-
expect(subject[:host]).to be_nil
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
if RUBY_VERSION < "2.2"
|
|
40
|
-
context "absent" do
|
|
41
|
-
let(:uri) { "amqp://" }
|
|
42
|
-
|
|
43
|
-
# Note that according to the ABNF, the host component may not be absent, but it may be zero-length.
|
|
44
|
-
it "raises InvalidURIError" do
|
|
45
|
-
expect { subject[:host] }.to raise_error(URI::InvalidURIError, /bad URI\(absolute but no path\)/)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
describe "port" do
|
|
52
|
-
context "present" do
|
|
53
|
-
let(:uri) { "amqp://rabbitmq:5672" }
|
|
54
|
-
|
|
55
|
-
it "parses port" do
|
|
56
|
-
expect(subject[:port]).to eq(5672)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
context "absent" do
|
|
61
|
-
context "schema amqp" do
|
|
62
|
-
let(:uri) { "amqp://rabbitmq" }
|
|
63
|
-
|
|
64
|
-
it "falls back to 5672 port" do
|
|
65
|
-
expect(subject[:port]).to eq(5672)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context "schema amqps" do
|
|
70
|
-
let(:uri) { "amqps://rabbitmq" }
|
|
71
|
-
|
|
72
|
-
it "falls back to 5671 port" do
|
|
73
|
-
expect(subject[:port]).to eq(5671)
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
describe "username and passowrd" do
|
|
80
|
-
context "both present" do
|
|
81
|
-
let(:uri) { "amqp://alpha:beta@rabbitmq" }
|
|
82
|
-
|
|
83
|
-
it "parses user and pass" do
|
|
84
|
-
expect(subject[:user]).to eq("alpha")
|
|
85
|
-
expect(subject[:pass]).to eq("beta")
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
context "only username present" do
|
|
90
|
-
let(:uri) { "amqp://alpha@rabbitmq" }
|
|
91
|
-
|
|
92
|
-
it "parses user and falls back to nil pass" do
|
|
93
|
-
expect(subject[:user]).to eq("alpha")
|
|
94
|
-
expect(subject[:pass]).to be_nil
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
context "with ':'" do
|
|
98
|
-
let(:uri) { "amqp://alpha:@rabbitmq" }
|
|
99
|
-
|
|
100
|
-
it "parses user and falls back to "" (empty) pass" do
|
|
101
|
-
expect(subject[:user]).to eq("alpha")
|
|
102
|
-
expect(subject[:pass]).to eq("")
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
context "only password present" do
|
|
108
|
-
let(:uri) { "amqp://:beta@rabbitmq" }
|
|
109
|
-
|
|
110
|
-
it "parses pass and falls back to "" (empty) user" do
|
|
111
|
-
expect(subject[:user]).to eq("")
|
|
112
|
-
expect(subject[:pass]).to eq("beta")
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
context "both absent" do
|
|
117
|
-
let(:uri) { "amqp://rabbitmq" }
|
|
118
|
-
|
|
119
|
-
it "falls back to nil user and pass" do
|
|
120
|
-
expect(subject[:user]).to be_nil
|
|
121
|
-
expect(subject[:pass]).to be_nil
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
context "with ':'" do
|
|
125
|
-
let(:uri) { "amqp://:@rabbitmq" }
|
|
126
|
-
|
|
127
|
-
it "falls back to "" (empty) user and "" (empty) pass" do
|
|
128
|
-
expect(subject[:user]).to eq("")
|
|
129
|
-
expect(subject[:pass]).to eq("")
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
context "%-encoded" do
|
|
135
|
-
let(:uri) { "amqp://%61lpha:bet%61@rabbitmq" }
|
|
136
|
-
|
|
137
|
-
it "parses user and pass" do
|
|
138
|
-
expect(subject[:user]).to eq("alpha")
|
|
139
|
-
expect(subject[:pass]).to eq("beta")
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
describe "path" do
|
|
145
|
-
context "present" do
|
|
146
|
-
let(:uri) { "amqp://rabbitmq/staging" }
|
|
147
|
-
|
|
148
|
-
it "parses vhost" do
|
|
149
|
-
expect(subject[:vhost]).to eq("staging")
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
context "with dots" do
|
|
153
|
-
let(:uri) { "amqp://rabbitmq/staging.critical.subsystem-a" }
|
|
154
|
-
|
|
155
|
-
it "parses vhost" do
|
|
156
|
-
expect(subject[:vhost]).to eq("staging.critical.subsystem-a")
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
context "with slashes" do
|
|
161
|
-
let(:uri) { "amqp://rabbitmq/staging/critical/subsystem-a" }
|
|
162
|
-
|
|
163
|
-
it "raises ArgumentError" do
|
|
164
|
-
expect { subject[:vhost] }.to raise_error(ArgumentError)
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
context "with trailing slash" do
|
|
169
|
-
let(:uri) { "amqp://rabbitmq/" }
|
|
170
|
-
|
|
171
|
-
it "parses vhost as an empty string" do
|
|
172
|
-
expect(subject[:vhost]).to eq("")
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
context "with trailing %-encoded slashes" do
|
|
177
|
-
let(:uri) { "amqp://rabbitmq/%2Fstaging" }
|
|
178
|
-
|
|
179
|
-
it "parses vhost as string with leading slash" do
|
|
180
|
-
expect(subject[:vhost]).to eq("/staging")
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
context "%-encoded" do
|
|
185
|
-
let(:uri) { "amqp://rabbitmq/%2Fstaging%2Fcritical%2Fsubsystem-a" }
|
|
186
|
-
|
|
187
|
-
it "parses vhost as string with leading slash" do
|
|
188
|
-
expect(subject[:vhost]).to eq("/staging/critical/subsystem-a")
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
context "absent" do
|
|
194
|
-
let(:uri) { "amqp://rabbitmq" }
|
|
195
|
-
|
|
196
|
-
it "falls back to default nil vhost" do
|
|
197
|
-
expect(subject[:vhost]).to be_nil
|
|
198
|
-
end
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
describe "query parameters" do
|
|
203
|
-
context "present" do
|
|
204
|
-
let(:uri) { "amqp://rabbitmq?heartbeat=10&connection_timeout=100&channel_max=1000&auth_mechanism=plain&auth_mechanism=amqplain" }
|
|
205
|
-
|
|
206
|
-
it "parses client connection parameters" do
|
|
207
|
-
expect(subject[:heartbeat]).to eq(10)
|
|
208
|
-
expect(subject[:connection_timeout]).to eq(100)
|
|
209
|
-
expect(subject[:channel_max]).to eq(1000)
|
|
210
|
-
expect(subject[:auth_mechanism]).to eq(["plain", "amqplain"])
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
context "absent" do
|
|
215
|
-
let(:uri) { "amqp://rabbitmq" }
|
|
216
|
-
|
|
217
|
-
it "falls back to default client connection parameters" do
|
|
218
|
-
expect(subject[:heartbeat]).to be_nil
|
|
219
|
-
expect(subject[:connection_timeout]).to be_nil
|
|
220
|
-
expect(subject[:channel_max]).to be_nil
|
|
221
|
-
expect(subject[:auth_mechanism]).to be_empty
|
|
222
|
-
end
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
context "schema amqp" do
|
|
226
|
-
context "tls parameters" do
|
|
227
|
-
%w(verify fail_if_no_peer_cert cacertfile certfile keyfile).each do |tls_param|
|
|
228
|
-
describe "#{tls_param}" do
|
|
229
|
-
let(:uri) { "amqp://rabbitmq?#{tls_param}=value" }
|
|
230
|
-
|
|
231
|
-
it "raises ArgumentError" do
|
|
232
|
-
expect { subject }.to raise_error(ArgumentError, /The option '#{tls_param}' can only be used in URIs that use amqps schema/)
|
|
233
|
-
end
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
context "amqpa schema" do
|
|
240
|
-
context "TLS parameters in query string" do
|
|
241
|
-
context "case 1" do
|
|
242
|
-
let(:uri) { "amqps://rabbitmq?verify=true&fail_if_no_peer_cert=true&cacertfile=/examples/tls/cacert.pem&certfile=/examples/tls/client_cert.pem&keyfile=/examples/tls/client_key.pem" }
|
|
243
|
-
|
|
244
|
-
it "parses tls options" do
|
|
245
|
-
expect(subject[:verify]).to be_truthy
|
|
246
|
-
expect(subject[:fail_if_no_peer_cert]).to be_truthy
|
|
247
|
-
expect(subject[:cacertfile]).to eq("/examples/tls/cacert.pem")
|
|
248
|
-
expect(subject[:certfile]).to eq("/examples/tls/client_cert.pem")
|
|
249
|
-
expect(subject[:keyfile]).to eq("/examples/tls/client_key.pem")
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
context "case 2" do
|
|
254
|
-
let(:uri) { "amqps://bunny_gem:bunny_password@/bunny_testbed?heartbeat=10&connection_timeout=100&channel_max=1000&verify=false&cacertfile=spec/tls/ca_certificate.pem&certfile=spec/tls/client_certificate.pem&keyfile=spec/tls/client_key.pem" }
|
|
255
|
-
|
|
256
|
-
it "parses tls options" do
|
|
257
|
-
expect(subject[:verify]).to be_falsey
|
|
258
|
-
expect(subject[:fail_if_no_peer_cert]).to be_falsey
|
|
259
|
-
expect(subject[:cacertfile]).to eq("spec/tls/ca_certificate.pem")
|
|
260
|
-
expect(subject[:certfile]).to eq("spec/tls/client_certificate.pem")
|
|
261
|
-
expect(subject[:keyfile]).to eq("spec/tls/client_key.pem")
|
|
262
|
-
end
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
context "absent" do
|
|
266
|
-
let(:uri) { "amqps://rabbitmq" }
|
|
267
|
-
|
|
268
|
-
it "falls back to default tls options" do
|
|
269
|
-
expect(subject[:verify]).to be_falsey
|
|
270
|
-
expect(subject[:fail_if_no_peer_cert]).to be_falsey
|
|
271
|
-
expect(subject[:cacertfile]).to be_nil
|
|
272
|
-
expect(subject[:certfile]).to be_nil
|
|
273
|
-
expect(subject[:keyfile]).to be_nil
|
|
274
|
-
end
|
|
275
|
-
end
|
|
276
|
-
end
|
|
277
|
-
end
|
|
278
|
-
end
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
describe ".parse_amqp_url" do
|
|
282
|
-
it "is an alias for .parse" do
|
|
283
|
-
result = described_class.parse_amqp_url("amqp://localhost")
|
|
284
|
-
expect(result[:host]).to eq("localhost")
|
|
285
|
-
end
|
|
286
|
-
end
|
|
287
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# encoding: binary
|
|
2
|
-
|
|
3
|
-
require 'bundler/setup'
|
|
4
|
-
Bundler.require(:test)
|
|
5
|
-
|
|
6
|
-
begin
|
|
7
|
-
require 'simplecov'
|
|
8
|
-
|
|
9
|
-
SimpleCov.start do
|
|
10
|
-
add_filter '/spec/'
|
|
11
|
-
end
|
|
12
|
-
rescue LoadError
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
$: << File.expand_path('../../lib', __FILE__)
|
|
16
|
-
|
|
17
|
-
require "amq/protocol"
|
|
18
|
-
|
|
19
|
-
puts "Running on #{RUBY_VERSION}"
|
|
20
|
-
|
|
21
|
-
RSpec.configure do |config|
|
|
22
|
-
config.include AMQ::Protocol
|
|
23
|
-
|
|
24
|
-
config.filter_run_when_matching :focus
|
|
25
|
-
|
|
26
|
-
config.disable_monkey_patching!
|
|
27
|
-
|
|
28
|
-
config.warnings = true
|
|
29
|
-
end
|