rabbitmq_http_api_client 1.9.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 689fb5a05c6fead2a4cb21bec129cb4be0a13041
4
- data.tar.gz: a31f9a028e196524eff2670de85fdffd3740260f
3
+ metadata.gz: 3a4aaf38eb884212e4479dacfac1a76c51c572ef
4
+ data.tar.gz: 494214b32974d9daacb4428b0a0392a9b3dad3be
5
5
  SHA512:
6
- metadata.gz: 02ea6b0b437ca540616eb474b558c09572d750ffc67fc2fa57ed4bb64f843e56dd250dca154c428318670493028c8c2d9923794a967e5273c05ba813f7e94c41
7
- data.tar.gz: 7d5e0de0708c2d07baa06c74c246a994e9651044fd22604af3860535dedc7230bf5308074275e3029c5ed61a5952535ce10efcf2952fb674fddf757205e737cc
6
+ metadata.gz: 8b5f54d4e59747460bacef94d8b9aee186a52265a183b3977f10df7f1d900119ba3ad1530db7d0309db1b92fc8d7623bdd327a8914272ec582fd3115a9a3ac4e
7
+ data.tar.gz: a7db77b3296d3ac2490baa512669874eb968829477f5c0f14e170fe4b1633c045c1960dc0a7a559893494b9212532df4a3360a2ab677ea09e1864631ab22a1fe
@@ -1,4 +1,4 @@
1
- ## Changes Between 1.8.0 and 1.9.0 (unreleased)
1
+ ## Changes Between 1.9.0 and 1.10.0 (unreleased)
2
2
 
3
3
  No changes yet.
4
4
 
data/README.md CHANGED
@@ -32,7 +32,7 @@ All versions require [RabbitMQ Management UI plugin](http://www.rabbitmq.com/man
32
32
  Add this line to your application's Gemfile:
33
33
 
34
34
  ``` ruby
35
- gem 'rabbitmq_http_api_client', '>= 1.8.0'
35
+ gem 'rabbitmq_http_api_client', '>= 1.9.0'
36
36
  ```
37
37
 
38
38
  And then execute:
@@ -1,7 +1,7 @@
1
1
  module RabbitMQ
2
2
  module HTTP
3
3
  class Client
4
- VERSION = "1.9.0"
4
+ VERSION = "1.9.1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbitmq_http_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klishin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-30 00:00:00.000000000 Z
11
+ date: 2017-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '3.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '3.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.9'
33
+ version: '1.12'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.9'
40
+ version: '1.12'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.9.0
47
+ version: 0.13.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.9.0
54
+ version: 0.13.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: faraday_middleware
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.9.0
61
+ version: 0.12.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.9.0
68
+ version: 0.12.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: effin_utf8
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -82,27 +82,16 @@ dependencies:
82
82
  version: 1.0.0
83
83
  description: RabbitMQ HTTP API client for Ruby
84
84
  email:
85
- - michael@defprotocol.org
86
- executables:
87
- - before_build.sh
85
+ - michael@clojurewerkz.org
86
+ executables: []
88
87
  extensions: []
89
88
  extra_rdoc_files: []
90
89
  files:
91
- - ".gitignore"
92
- - ".rspec"
93
- - ".travis.yml"
94
90
  - ChangeLog.md
95
- - Gemfile
96
91
  - LICENSE.txt
97
92
  - README.md
98
- - Rakefile
99
- - bin/before_build.sh
100
93
  - lib/rabbitmq/http/client.rb
101
94
  - lib/rabbitmq/http/client/version.rb
102
- - rabbitmq_http_api_client.gemspec
103
- - repl
104
- - spec/integration/client_spec.rb
105
- - spec/spec_helper.rb
106
95
  homepage: http://github.com/ruby-amqp/rabbitmq_http_api_client
107
96
  licenses:
108
97
  - MIT
@@ -128,6 +117,4 @@ rubygems_version: 2.6.11
128
117
  signing_key:
129
118
  specification_version: 4
130
119
  summary: RabbitMQ HTTP API client for Ruby
131
- test_files:
132
- - spec/integration/client_spec.rb
133
- - spec/spec_helper.rb
120
+ test_files: []
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- bin/autospec
19
- bin/bundler
20
- bin/rspec
21
- bin/ldiff
22
- bin/htmldiff
data/.rspec DELETED
@@ -1 +0,0 @@
1
- -cfd
@@ -1,14 +0,0 @@
1
- bundler_args: --without development
2
- before_script: ./bin/before_build.sh
3
- script: "bundle exec rspec"
4
- rvm:
5
- - "2.4.0"
6
- - "2.3.3"
7
- - "2.2"
8
- notifications:
9
- email: michael@rabbitmq.com
10
- services:
11
- - rabbitmq
12
- branches:
13
- only:
14
- - master
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- group :development, :test do
4
- gem "rspec", ">= 3.5.0"
5
- gem "json", :platform => :ruby_18
6
- gem "bunny", ">= 2.6.4"
7
-
8
- gem "rantly"
9
- end
10
-
11
- # Specify your gem's dependencies in superintendent.gemspec
12
- gemspec
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,13 +0,0 @@
1
- #!/bin/sh
2
-
3
- ${RUBY_RABBITMQ_HTTP_API_CLIENT_RABBITMQCTL:="sudo rabbitmqctl"}
4
-
5
- # guest:guest has full access to /
6
-
7
- $RUBY_RABBITMQ_HTTP_API_CLIENT_RABBITMQCTL add_vhost /
8
- $RUBY_RABBITMQ_HTTP_API_CLIENT_RABBITMQCTL add_user guest guest
9
- $RUBY_RABBITMQ_HTTP_API_CLIENT_RABBITMQCTL set_permissions -p / guest ".*" ".*" ".*"
10
-
11
- # Reduce retention policy for faster publishing of stats
12
- $RUBY_RABBITMQ_HTTP_API_CLIENT_RABBITMQCTL eval 'supervisor2:terminate_child(rabbit_mgmt_sup_sup, rabbit_mgmt_sup), application:set_env(rabbitmq_management, sample_retention_policies, [{global, [{605, 1}]}, {basic, [{605, 1}]}, {detailed, [{10, 1}]}]), rabbit_mgmt_sup_sup:start_child().' | true
13
- $RUBY_RABBITMQ_HTTP_API_CLIENT_RABBITMQCTL eval 'supervisor2:terminate_child(rabbit_mgmt_agent_sup_sup, rabbit_mgmt_agent_sup), application:set_env(rabbitmq_management_agent, sample_retention_policies, [{global, [{605, 1}]}, {basic, [{605, 1}]}, {detailed, [{10, 1}]}]), rabbit_mgmt_agent_sup_sup:start_child().' | true
@@ -1,26 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rabbitmq/http/client/version'
5
-
6
- Gem::Specification.new do |gem|
7
- gem.name = "rabbitmq_http_api_client"
8
- gem.version = RabbitMQ::HTTP::Client::VERSION
9
- gem.authors = ["Michael Klishin"]
10
- gem.email = ["michael@defprotocol.org"]
11
- gem.description = %q{RabbitMQ HTTP API client for Ruby}
12
- gem.summary = %q{RabbitMQ HTTP API client for Ruby}
13
- gem.homepage = "http://github.com/ruby-amqp/rabbitmq_http_api_client"
14
- gem.licenses = ["MIT", "Mozilla Public License"]
15
-
16
- gem.files = `git ls-files`.split($/)
17
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
- gem.require_paths = ["lib"]
20
-
21
- gem.add_dependency "hashie", "~> 3.2"
22
- gem.add_dependency "multi_json", "~> 1.9"
23
- gem.add_dependency "faraday", "~> 0.9.0"
24
- gem.add_dependency "faraday_middleware", "~> 0.9.0"
25
- gem.add_dependency "effin_utf8", "~> 1.0.0"
26
- end
data/repl DELETED
@@ -1,3 +0,0 @@
1
- #!/bin/sh
2
-
3
- bundle exec irb -Ilib -r'json' -r'rabbitmq/http/client'
@@ -1,1079 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require "spec_helper"
3
-
4
- describe RabbitMQ::HTTP::Client do
5
- let(:endpoint) { "http://127.0.0.1:15672" }
6
-
7
- subject do
8
- described_class.connect(endpoint, :username => "guest", :password => "guest")
9
- end
10
-
11
- before :each do
12
- @conn = Bunny.new
13
- @conn.start
14
- end
15
-
16
- after :each do
17
- @conn.close
18
- end
19
-
20
- #
21
- # Helpers
22
- #
23
-
24
- # Statistics tables in the server are updated asynchronously,
25
- # in particular starting with rabbitmq/rabbitmq-management#236,
26
- # so in some cases we need to wait before GET'ing e.g. a newly opened connection.
27
- def await_event_propagation
28
- # same number as used in rabbit-hole test suite. Works OK.
29
- sleep 1
30
- end
31
-
32
- #
33
- # Default endpoint path
34
- #
35
- describe "default endpoint path" do
36
- it "does NOT append '/api' if the endpoint provides a path" do
37
- c = described_class.connect("http://guest:guest@127.0.0.1:15672/api")
38
-
39
- r = c.overview
40
- expect(r.rabbitmq_version).to_not be_nil
41
- expect(r.erlang_version).to_not be_nil
42
- end
43
- end
44
-
45
-
46
- #
47
- # URI-only access
48
- #
49
-
50
- describe "URI-only access" do
51
- it "authenticates successfully" do
52
- c = described_class.connect("http://guest:guest@127.0.0.1:15672")
53
-
54
- r = c.overview
55
- expect(r.rabbitmq_version).to_not be_nil
56
- expect(r.erlang_version).to_not be_nil
57
- end
58
- end
59
-
60
-
61
- #
62
- # Overview
63
- #
64
-
65
- describe "GET /api/overview" do
66
- it "returns an overview" do
67
- r = subject.overview
68
-
69
- ts = r.exchange_types.map { |h| h.name }.
70
- sort
71
- ["direct", "fanout", "headers", "topic"].each do |t|
72
- expect(ts).to include(t)
73
- end
74
-
75
- expect(r.rabbitmq_version).to_not be_nil
76
- expect(r.erlang_version).to_not be_nil
77
- end
78
- end
79
-
80
- describe "#enabled_protocols" do
81
- it "returns a list of enabled protocols" do
82
- xs = subject.enabled_protocols
83
-
84
- expect(xs).to include("amqp")
85
- end
86
- end
87
-
88
- describe "#enabled_protocols" do
89
- it "returns a list of enabled protocols" do
90
- xs = subject.protocol_ports
91
-
92
- # hash of protocol => port
93
- expect(xs["amqp"]).to eq(5672)
94
- end
95
- end
96
-
97
- #
98
- # Nodes
99
- #
100
-
101
- describe "GET /api/nodes" do
102
- it "lists cluster nodes with detailed status information for each one of them" do
103
- await_event_propagation
104
- nodes = subject.list_nodes
105
- n = nodes.first
106
-
107
- expect(n.name).to match(/^rabbit/)
108
- end
109
- end
110
-
111
- describe "GET /api/node/:name" do
112
- it "returns status information for a single cluster node" do
113
- await_event_propagation
114
- ns = subject.list_nodes
115
- n = subject.node_info(ns.first.name)
116
-
117
- expect(n.name).to match(/^rabbit/)
118
- end
119
- end
120
-
121
- #
122
- # Extensions
123
- #
124
-
125
- describe "GET /api/extensions" do
126
- it "returns a list of enabled management plugin extensions" do
127
- await_event_propagation
128
- xs = subject.list_extensions
129
-
130
- expect(xs).to be_kind_of(Array)
131
- end
132
- end
133
-
134
- #
135
- # Definitions
136
- #
137
-
138
- describe "GET /api/definitions" do
139
- it "returns a list of all resources/definitions (vhosts, users, permissions, queues, exchanges, bindings, etc)" do
140
- await_event_propagation
141
- xs = subject.list_definitions
142
-
143
- expect(xs.bindings).not_to be_nil
144
- expect(xs.queues).not_to be_nil
145
- expect(xs.exchanges).not_to be_nil
146
- expect(xs.users).not_to be_nil
147
- expect(xs.vhosts).not_to be_nil
148
- end
149
- end
150
-
151
- describe "POST /api/definitions" do
152
- let(:queue_name) { 'my-definition-queue' }
153
-
154
- let(:definition) do
155
- {
156
- :queues => [{
157
- :name => queue_name,
158
- :vhost => '/',
159
- durable: true,
160
- :auto_delete => false,
161
- :arguments => {
162
- "x-dead-letter-exchange" => 'dead'
163
- }
164
- }]
165
- }.to_json
166
- end
167
-
168
- it "returns true when successful" do
169
- r = subject.upload_definitions(definition)
170
- expect(r).to eq(true)
171
-
172
- subject.delete_queue("/", queue_name)
173
- end
174
-
175
- it "stores the uploaded definitions" do
176
- subject.upload_definitions(definition)
177
- xs = subject.list_definitions
178
- uploaded_queue = xs.queues.detect { |q| q.name == queue_name }
179
- expect(uploaded_queue).not_to eq(nil)
180
-
181
- subject.delete_queue("/", queue_name)
182
- end
183
- end
184
-
185
- #
186
- # Connections
187
- #
188
-
189
- describe "GET /api/connections" do
190
- before :each do
191
- @conn = Bunny.new
192
- @conn.start
193
- end
194
-
195
- it "returns a list of all active connections" do
196
- await_event_propagation
197
- xs = subject.list_connections
198
- f = xs.first
199
-
200
- expect(f.name).to match(/127.0.0.1/)
201
- expect(f.client_properties.product).to eq("Bunny")
202
- end
203
- end
204
-
205
- describe "GET /api/connections/:name" do
206
- it "returns information about the connection" do
207
- await_event_propagation
208
- xs = subject.list_connections
209
- c = subject.connection_info(xs.first.name)
210
-
211
- expect(c.name).to match(/127.0.0.1/)
212
- expect(c.client_properties.product).to eq("Bunny")
213
- end
214
- end
215
-
216
-
217
- #
218
- # Channels
219
- #
220
-
221
- describe "GET /api/channels" do
222
- it "returns a list of all active channels" do
223
- conn = Bunny.new; conn.start
224
- ch = conn.create_channel
225
- await_event_propagation
226
- xs = subject.list_channels
227
- f = xs.first
228
-
229
- expect(f.number).to be >= 1
230
- expect(f.prefetch_count).to be >= 0
231
-
232
- ch.close
233
- conn.close
234
- end
235
- end
236
-
237
- describe "GET /api/channels/:name" do
238
- it "returns information about the channel" do
239
- conn = Bunny.new; conn.start
240
- ch = conn.create_channel
241
-
242
- await_event_propagation
243
- xs = subject.list_channels
244
- c = subject.channel_info(xs.first.name)
245
-
246
- expect(c.number).to be >= 1
247
- expect(c.prefetch_count).to be >= 0
248
-
249
- ch.close
250
- conn.close
251
- end
252
- end
253
-
254
- #
255
- # Exchanges
256
- #
257
-
258
- describe "GET /api/exchanges" do
259
- it "returns a list of all exchanges in the cluster" do
260
- xs = subject.list_exchanges
261
- f = xs.first
262
-
263
- expect(f.type).to_not be_nil
264
- expect(f.name).to_not be_nil
265
- expect(f.vhost).to_not be_nil
266
- expect(f.durable).to_not be_nil
267
- expect(f.auto_delete).to_not be_nil
268
- end
269
- end
270
-
271
- describe "GET /api/exchanges/:vhost" do
272
- it "returns a list of all exchanges in a vhost" do
273
- xs = subject.list_exchanges("/")
274
- f = xs.first
275
-
276
- expect(f.vhost).to eq("/")
277
- end
278
- end
279
-
280
- describe "GET /api/exchanges/:vhost/:name" do
281
- it "returns information about the exchange" do
282
- e = subject.exchange_info("/", "amq.fanout")
283
-
284
- expect(e.type).to eq("fanout")
285
- expect(e.name).to eq("amq.fanout")
286
- expect(e.durable).to eq(true)
287
- expect(e.vhost).to eq("/")
288
- end
289
- end
290
-
291
- describe "PUT /api/exchanges/:vhost/:name" do
292
- before :each do
293
- @channel = @conn.create_channel
294
- end
295
-
296
- after :each do
297
- @channel.close
298
- end
299
-
300
- let(:exchange_name) { "httpdeclared" }
301
-
302
- it "declares an exchange" do
303
- subject.declare_exchange("/", exchange_name, durable: false, type: "fanout")
304
-
305
- x = @channel.fanout(exchange_name, durable: false, auto_delete: false)
306
- x.delete
307
- end
308
- end
309
-
310
- describe "DELETE /api/exchanges/:vhost/:name" do
311
- before :each do
312
- @channel = @conn.create_channel
313
- end
314
-
315
- after :each do
316
- @channel.close
317
- end
318
-
319
- let(:exchange_name) { "httpdeclared" }
320
-
321
- it "deletes an exchange" do
322
- x = @channel.fanout(exchange_name, durable: false)
323
- subject.delete_exchange("/", exchange_name)
324
- end
325
- end
326
-
327
-
328
- describe "GET /api/exchanges/:vhost/:name/bindings/source" do
329
- before :each do
330
- @channel = @conn.create_channel
331
- end
332
- after :each do
333
- @channel.close
334
- end
335
-
336
- it "returns a list of all bindings in which the given exchange is the source" do
337
- e = @channel.fanout("http.api.tests.fanout", durable: true)
338
- q = @channel.queue("http.api.tests.queue1", durable: true)
339
- q.bind(e)
340
-
341
- xs = subject.list_bindings_by_source("/", "http.api.tests.fanout")
342
- f = xs.first
343
-
344
- expect(f.destination).to eq(q.name)
345
- expect(f.destination_type).to eq("queue")
346
- expect(f.routing_key).to eq("")
347
- expect(f.source).to eq(e.name)
348
- expect(f.vhost).to eq("/")
349
-
350
- e.delete
351
- q.delete
352
- end
353
- end
354
-
355
-
356
- describe "GET /api/exchanges/:vhost/:name/bindings/destination" do
357
- before :each do
358
- @channel = @conn.create_channel
359
- end
360
- after :each do
361
- @channel.close
362
- end
363
-
364
- it "returns a list of all bindings in which the given exchange is the destination" do
365
- e1 = @channel.fanout("http.api.tests.fanout1", durable: true)
366
- e2 = @channel.fanout("http.api.tests.fanout2", durable: true)
367
- e1.bind(e2)
368
-
369
- xs = subject.list_bindings_by_destination("/", "http.api.tests.fanout1")
370
- f = xs.first
371
-
372
- expect(f.destination).to eq(e1.name)
373
- expect(f.destination_type).to eq("exchange")
374
- expect(f.routing_key).to eq("")
375
- expect(f.source).to eq(e2.name)
376
- expect(f.vhost).to eq("/")
377
-
378
- e1.delete
379
- e2.delete
380
- end
381
- end
382
-
383
-
384
-
385
- describe "POST /api/exchanges/:vhost/:name/publish" do
386
- it "publishes a messages to the exchange"
387
- end
388
-
389
-
390
- #
391
- # Queues
392
- #
393
-
394
- describe "GET /api/queues" do
395
- before :each do
396
- @channel = @conn.create_channel
397
- end
398
- after :each do
399
- @channel.close
400
- end
401
-
402
- it "returns a list of all queues" do
403
- q = @channel.queue("", durable: false)
404
-
405
- xs = subject.list_queues
406
- expect(xs.detect { |x| x.name == q.name }).to_not be_empty
407
-
408
- subject.delete_queue("/", q.name)
409
- end
410
- end
411
-
412
- describe "GET /api/queues/:vhost" do
413
- before :each do
414
- @channel = @conn.create_channel
415
- end
416
- after :each do
417
- @channel.close
418
- end
419
-
420
- it "returns a list of all queues" do
421
- q = @channel.queue("", durable: false)
422
-
423
- xs = subject.list_queues("/")
424
- expect(xs.detect { |x| x.name == q.name }).to_not be_empty
425
-
426
- subject.delete_queue("/", q.name)
427
- end
428
- end
429
-
430
- describe "GET /api/queues/:vhost/:name" do
431
- context "when queue exists" do
432
- before :each do
433
- @channel = @conn.create_channel
434
- end
435
- after :each do
436
- @channel.close
437
- end
438
-
439
- it "returns information about a queue" do
440
- q = @channel.queue("", durable: false)
441
- await_event_propagation
442
- i = subject.queue_info("/", q.name)
443
-
444
- expect(i.durable).to eq(false)
445
- expect(i.durable).to eq(q.durable?)
446
-
447
- expect(i.name).to eq(q.name)
448
- expect(i.auto_delete).to eq(q.auto_delete?)
449
- expect(i.active_consumers).to be_nil
450
- expect(i.backing_queue_status.avg_ack_egress_rate).to eq(0.0)
451
-
452
- subject.delete_queue("/", q.name)
453
- end
454
- end
455
-
456
- context "when queue DOES NOT exist" do
457
- it "raises NotFound" do
458
- expect do
459
- subject.queue_info("/", Time.now.to_i.to_s)
460
- end.to raise_error(Faraday::Error::ResourceNotFound)
461
- end
462
- end
463
- end
464
-
465
- describe "PUT /api/queues/:vhost/:name" do
466
- before :each do
467
- @channel = @conn.create_channel
468
- end
469
-
470
- let(:queue_name) { "httpdeclared" }
471
-
472
- it "declares a queue" do
473
- subject.declare_queue("/", queue_name, durable: false, auto_delete: true)
474
-
475
- q = @channel.queue(queue_name, durable: false, auto_delete: true)
476
- q.delete
477
- end
478
- end
479
-
480
- describe "DELETE /api/queues/:vhost/:name" do
481
- before :each do
482
- @channel = @conn.create_channel
483
- end
484
-
485
- let(:queue_name) { "httpdeclared" }
486
-
487
- it "deletes a queue" do
488
- q = @channel.queue(queue_name, durable: false)
489
- subject.delete_queue("/", queue_name)
490
- end
491
- end
492
-
493
- describe "GET /api/queues/:vhost/:name/bindings" do
494
- before :each do
495
- @channel = @conn.create_channel
496
- end
497
-
498
- it "returns a list of bindings for a queue" do
499
- q = @channel.queue("")
500
- q.bind("amq.fanout")
501
-
502
- xs = subject.list_queue_bindings("/", q.name)
503
- x = xs.first
504
-
505
- expect(x.destination).to eq(q.name)
506
- expect(x.destination_type).to eq("queue")
507
-
508
- q.delete
509
- end
510
- end
511
-
512
- describe "DELETE /api/queues/:vhost/:name/contents" do
513
- before :each do
514
- @channel = @conn.create_channel
515
- end
516
- after :each do
517
- @channel.close
518
- end
519
-
520
- it "purges a queue" do
521
- q = @channel.queue("")
522
- x = @channel.fanout("amq.fanout", durable: true, auto_delete: false)
523
- q.bind(x)
524
-
525
- 10.times do
526
- x.publish("", :routing_key => q.name)
527
- end
528
- sleep 0.7
529
-
530
- expect(q.message_count).to eq(10)
531
- subject.purge_queue("/", q.name)
532
- sleep 0.5
533
- expect(q.message_count).to eq(0)
534
- q.delete
535
- end
536
- end
537
-
538
- # yes, POST, because it potentially modifies the state (ordering) of the queue
539
- describe "POST /api/queues/:vhost/:name/get" do
540
- before :each do
541
- @channel = @conn.create_channel
542
- end
543
- after :each do
544
- @channel.close
545
- end
546
-
547
- it "fetches a message from a queue, a la basic.get" do
548
- q = @channel.queue("")
549
- x = @channel.fanout("amq.fanout", durable: true, auto_delete: false)
550
- q.bind(x)
551
-
552
- 10.times do |i|
553
- x.publish("msg #{i}", :routing_key => q.name, :content_type => "application/xyz")
554
- end
555
- sleep 0.7
556
-
557
- expect(q.message_count).to eq(10)
558
- # the requeueing arguments differ between RabbitMQ 3.7.0 and earlier versions,
559
- # so pass both
560
- xs = subject.get_messages("/", q.name, count: 10,
561
- requeue: false, ackmode: "ack_requeue_false", encoding: "auto")
562
- m = xs.first
563
-
564
- expect(m.properties.content_type).to eq("application/xyz")
565
- expect(m.payload).to eq("msg 0")
566
- expect(m.payload_encoding).to eq("string")
567
-
568
- q.delete
569
- end
570
- end
571
-
572
- describe "GET /api/bindings" do
573
- before :each do
574
- @channel = @conn.create_channel
575
- end
576
- after :each do
577
- @channel.close
578
- end
579
-
580
- it "returns a list of all bindings" do
581
- q = @channel.queue("")
582
- x = @channel.fanout("amq.fanout", durable: true, auto_delete: false)
583
- q.bind(x)
584
- await_event_propagation
585
- xs = subject.list_bindings
586
- b = xs.first
587
-
588
- expect(b.destination).to_not be_nil
589
- expect(b.destination_type).to_not be_nil
590
- expect(b.source).to_not be_nil
591
- expect(b.routing_key).to_not be_nil
592
- expect(b.vhost).to_not be_nil
593
-
594
- q.delete
595
- end
596
- end
597
-
598
- describe "GET /api/bindings/:vhost" do
599
- before :each do
600
- @channel = @conn.create_channel
601
- end
602
- after :each do
603
- @channel.close
604
- end
605
-
606
- it "returns a list of all bindings in a vhost" do
607
- q = @channel.queue("")
608
- x = @channel.fanout("amq.fanout", durable: true, auto_delete: false)
609
- q.bind(x)
610
- await_event_propagation
611
- xs = subject.list_bindings("/")
612
- b = xs.first
613
-
614
- expect(b.destination).to_not be_nil
615
- expect(b.destination_type).to_not be_nil
616
- expect(b.source).to_not be_nil
617
- expect(b.routing_key).to_not be_nil
618
- expect(b.vhost).to_not be_nil
619
-
620
- q.delete
621
- end
622
- end
623
-
624
- describe "GET /api/bindings/:vhost/e/:exchange/q/:queue" do
625
- before :each do
626
- @channel = @conn.create_channel
627
- end
628
- after :each do
629
- @channel.close
630
- end
631
-
632
- it "returns a list of all bindings between an exchange and a queue" do
633
- q = @channel.queue("")
634
- x = @channel.fanout("http.client.fanout")
635
- q.bind(x)
636
-
637
- await_event_propagation
638
-
639
- xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
640
- b = xs.first
641
- expect(b.destination).to eq(q.name)
642
- expect(b.destination_type).to eq("queue")
643
- expect(b.source).to eq(x.name)
644
- expect(b.routing_key).to_not be_nil
645
- expect(b.properties_key).to_not be_nil
646
- expect(b.vhost).to eq("/")
647
-
648
- q.delete
649
- x.delete
650
- end
651
- end
652
-
653
- describe "POST /api/bindings/:vhost/e/:exchange/q/:queue" do
654
- before :each do
655
- @channel = @conn.create_channel
656
- end
657
- after :each do
658
- @channel.close
659
- end
660
-
661
- it "creates a binding between an exchange and a queue" do
662
- routing_key = 'test.key'
663
- q = @channel.queue("")
664
- x = @channel.fanout("http.client.fanout")
665
- q.bind(x)
666
-
667
- b = subject.bind_queue("/", q.name, x.name, routing_key)
668
-
669
- expect(b).to eq(q.name + "/" + routing_key)
670
-
671
- q.delete
672
- x.delete
673
- end
674
- end
675
-
676
- describe "GET /api/bindings/:vhost/e/:exchange/q/:queue/props" do
677
- before :each do
678
- @channel = @conn.create_channel
679
- end
680
- after :each do
681
- @channel.close
682
- end
683
-
684
- it "returns an individual binding between an exchange and a queue" do
685
- routing_key = 'test.key'
686
- q = @channel.queue("")
687
- x = @channel.fanout("http.client.fanout")
688
- q.bind(x)
689
-
690
- xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
691
- b1 = xs.first
692
-
693
- b2 = subject.queue_binding_info("/", q.name, x.name, b1.properties_key)
694
-
695
- expect(b1).to eq(b2)
696
- q.delete
697
- end
698
- end
699
-
700
- describe "DELETE /api/bindings/:vhost/e/:exchange/q/:queue/props" do
701
- before :each do
702
- @channel = @conn.create_channel
703
- end
704
- after :each do
705
- @channel.close
706
- end
707
-
708
- it "deletes an individual binding between an exchange and a queue" do
709
- routing_key = 'test.key'
710
- q = @channel.queue("")
711
- x = @channel.fanout("http.client.fanout")
712
- q.bind(x)
713
-
714
- xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
715
- b = xs.first
716
-
717
- expect(subject.delete_queue_binding("/", q.name, x.name, b.properties_key)).to eq(true)
718
-
719
- xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
720
-
721
- expect(xs.size).to eq(0)
722
-
723
- q.delete
724
- x.delete
725
- end
726
- end
727
-
728
- describe "POST /api/bindings/:vhost/e/:source_exchange/e/:destination_exchange" do
729
- before :each do
730
- @channel = @conn.create_channel
731
- end
732
- after :each do
733
- @channel.close
734
- end
735
-
736
- it "creates a binding between two exchanges" do
737
- routing_key = 'test.key'
738
- sx = @channel.fanout("http.client.fanout_source")
739
- dx = @channel.fanout("http.client.fanout_destination")
740
-
741
- xs = subject.list_bindings_between_exchanges("/", dx.name, sx.name)
742
- expect(xs).to be_empty
743
-
744
- dx.bind(sx)
745
-
746
- b = subject.bind_exchange("/", dx.name, sx.name, routing_key)
747
- xs = subject.list_bindings_between_exchanges("/", dx.name, sx.name)
748
- expect(xs).to_not be_empty
749
-
750
- dx.delete
751
- sx.delete
752
- end
753
- end
754
-
755
- describe "GET /api/bindings/:vhost/e/:exchange/q/:queue/props" do
756
- before :each do
757
- @channel = @conn.create_channel
758
- end
759
- after :each do
760
- @channel.close
761
- end
762
-
763
- it "returns an individual binding between two exchanges" do
764
- routing_key = 'test.key'
765
- sx = @channel.fanout("http.client.fanout_source")
766
- dx = @channel.fanout("http.client.fanout_destination")
767
- dx.bind(sx)
768
-
769
- xs = subject.list_bindings_between_exchanges("/", dx.name, sx.name)
770
- b1 = xs.first
771
-
772
- b2 = subject.exchange_binding_info("/", dx.name, sx.name, b1.properties_key)
773
-
774
- expect(b1).to eq(b2)
775
-
776
- end
777
- end
778
-
779
- describe "DELETE /api/bindings/:vhost/e/:exchange/q/:queue/props" do
780
- before :each do
781
- @channel = @conn.create_channel
782
- end
783
- after :each do
784
- @channel.close
785
- end
786
-
787
- it "deletes an individual binding between two exchanges" do
788
- routing_key = 'test.key'
789
- sx = @channel.fanout("http.client.fanout_source")
790
- dx = @channel.fanout("http.client.fanout_destination")
791
- dx.bind(sx)
792
-
793
- xs = subject.list_bindings_between_exchanges("/", dx.name, sx.name)
794
- b = xs.first
795
-
796
- expect(subject.delete_exchange_binding("/", dx.name, sx.name, b.properties_key)).to eq(true)
797
-
798
- xs = subject.list_bindings_between_exchanges("/", dx.name, sx.name)
799
-
800
- expect(xs.size).to eq(0)
801
-
802
- dx.delete
803
- sx.delete
804
- end
805
- end
806
-
807
- describe "GET /api/vhosts" do
808
- it "returns a list of vhosts" do
809
- xs = subject.list_vhosts
810
- v = xs.first
811
-
812
- expect(v.name).to_not be_nil
813
- expect(v.tracing).to eq(false)
814
- end
815
- end
816
-
817
- describe "GET /api/vhosts/:name" do
818
- context "when vhost exists" do
819
- it "returns infomation about a vhost" do
820
- v = subject.vhost_info("/")
821
-
822
- expect(v.name).to_not be_nil
823
- expect(v.tracing).to eq(false)
824
- end
825
- end
826
-
827
- context "when vhost DOES NOT exist" do
828
- it "raises NotFound" do
829
- expect do
830
- subject.vhost_info(Time.now.to_i.to_s)
831
- end.to raise_error(Faraday::Error::ResourceNotFound)
832
- end
833
- end
834
-
835
- end
836
-
837
- describe "PUT /api/vhosts/:name" do
838
- gen = Rantly.new
839
-
840
- [
841
- "http-created",
842
- "http_created",
843
- "http created",
844
- "создан по хатэтэпэ",
845
- "creado a través de HTTP",
846
- "通过http",
847
- "HTTP를 통해 생성",
848
- "HTTPを介して作成",
849
- "created over http?",
850
- "created @ http API",
851
- "erstellt über http",
852
- "http पर बनाया",
853
- "ถูกสร้างขึ้นผ่าน HTTP",
854
- "±!@^&#*"
855
- ].each do |vhost|
856
- context "when vhost name is #{vhost}" do
857
- it "creates a vhost" do
858
- subject.create_vhost(vhost)
859
- subject.create_vhost(vhost)
860
-
861
- v = subject.vhost_info(vhost)
862
- expect(v.name).to eq(vhost)
863
-
864
- subject.delete_vhost(v.name)
865
- end
866
- end
867
- end
868
-
869
- 200.times do
870
- vhost = gen.string
871
-
872
- context "when vhost name is #{vhost}" do
873
- it "creates a vhost" do
874
- subject.create_vhost(vhost)
875
- subject.create_vhost(vhost)
876
-
877
- v = subject.vhost_info(vhost)
878
- expect(v.name).to eq(vhost)
879
-
880
- subject.delete_vhost(v.name)
881
- end
882
- end
883
- end
884
- end
885
-
886
- describe "DELETE /api/vhosts/:name" do
887
- let(:vhost) { "http-created2" }
888
-
889
- it "deletes a vhost" do
890
- subject.create_vhost(vhost)
891
- subject.delete_vhost(vhost)
892
- end
893
-
894
- gen = Rantly.new
895
- 200.times do
896
- vhost = gen.string
897
-
898
- context "when vhost #{vhost} is deleted immediately after being created" do
899
- it "creates a vhost" do
900
- subject.create_vhost(vhost)
901
- subject.create_vhost(vhost)
902
-
903
- v = subject.vhost_info(vhost)
904
- expect(v.name).to eq(vhost)
905
-
906
- subject.delete_vhost(v.name)
907
- end
908
- end
909
- end
910
- end
911
-
912
- describe "GET /api/vhosts/:name/permissions" do
913
- it "returns a list of permissions in a vhost" do
914
- xs = subject.list_permissions("/")
915
- p = xs.detect { |x| x.user == "guest" }
916
-
917
- expect(p.read).to eq(".*")
918
- end
919
- end
920
-
921
- describe "GET /api/users" do
922
- it "returns a list of all users" do
923
- xs = subject.list_users
924
- u = xs.first
925
-
926
- expect(u.name).to_not be_nil
927
- expect(u.password_hash).to_not be_nil
928
- expect(u.tags).to_not be_nil
929
- end
930
- end
931
-
932
- describe "GET /api/users/:name" do
933
- it "returns information about a user" do
934
- u = subject.user_info("guest")
935
- expect(u.name).to eq("guest")
936
- expect(u.tags).to eq("administrator")
937
- end
938
- end
939
-
940
- describe "PUT /api/users/:name" do
941
- context "with tags provided explicitly" do
942
- it "updates information about a user" do
943
- subject.update_user("alt-user", tags: "http, policymaker, management", password: "alt-user")
944
-
945
- u = subject.user_info("alt-user")
946
- expect(u.tags).to eq("http,policymaker,management")
947
- end
948
- end
949
-
950
- context "without tags provided" do
951
- it "uses blank tag list" do
952
- subject.update_user("alt-user", password: "alt-user")
953
-
954
- u = subject.user_info("alt-user")
955
- expect(u.tags).to eq("")
956
- end
957
- end
958
- end
959
-
960
- describe "DELETE /api/users/:name" do
961
- it "deletes a user" do
962
- subject.update_user("alt2-user", tags: "http", password: "alt2-user")
963
- subject.delete_user("alt2-user")
964
- end
965
- end
966
-
967
- describe "GET /api/users/:name/permissions" do
968
- it "returns a list of permissions for a user" do
969
- xs = subject.user_permissions("guest")
970
- p = xs.first
971
-
972
- expect(p.read).to eq(".*")
973
- end
974
- end
975
-
976
- describe "GET /api/whoami" do
977
- it "returns information about the current user" do
978
- u = subject.whoami
979
- expect(u.name).to eq("guest")
980
- end
981
- end
982
-
983
- describe "GET /api/permissions" do
984
- it "lists all permissions" do
985
- xs = subject.list_permissions
986
- expect(xs.first.read).to_not be_nil
987
- end
988
- end
989
-
990
- describe "GET /api/permissions/:vhost/:user" do
991
- it "returns a list of permissions of a user in a vhost" do
992
- p = subject.list_permissions_of("/", "guest")
993
-
994
- expect(p.read).to eq(".*")
995
- expect(p.write).to eq(".*")
996
- expect(p.configure).to eq(".*")
997
- end
998
- end
999
-
1000
- describe "PUT /api/permissions/:vhost/:user" do
1001
- it "updates permissions of a user in a vhost" do
1002
- subject.update_permissions_of("/", "guest", {write: ".*", read: ".*", configure: ".*"})
1003
-
1004
- p = subject.list_permissions_of("/", "guest")
1005
-
1006
- expect(p.read).to eq(".*")
1007
- expect(p.write).to eq(".*")
1008
- expect(p.configure).to eq(".*")
1009
- end
1010
- end
1011
-
1012
- describe "DELETE /api/permissions/:vhost/:user" do
1013
- it "clears permissions of a user in a vhost" do
1014
- subject.create_user("alt3", {password: "s3cRE7"})
1015
- subject.update_permissions_of("/", "alt3", {write: ".*", read: ".*", configure: ".*"}).inspect
1016
- subject.clear_permissions_of("/", "alt3")
1017
-
1018
- expect do
1019
- subject.list_permissions_of("/", "alt3")
1020
- end.to raise_error(Faraday::Error::ResourceNotFound)
1021
- end
1022
- end
1023
-
1024
- #
1025
- # Parameters
1026
- #
1027
-
1028
- describe "GET /api/parameters" do
1029
- it "returns a list of all parameters" do
1030
- xs = subject.list_parameters
1031
- expect(xs).to be_kind_of(Array)
1032
- end
1033
- end
1034
-
1035
-
1036
- #
1037
- # Policies
1038
- #
1039
-
1040
- describe "GET /api/policies" do
1041
- it "returns a list of all policies" do
1042
- xs = subject.list_policies
1043
- expect(xs).to be_kind_of(Array)
1044
- end
1045
- end
1046
-
1047
- describe "GET /api/policies/:vhost" do
1048
- it "returns a list of all policies in a vhost" do
1049
- xs = subject.list_policies("/")
1050
- expect(xs).to be_kind_of(Array)
1051
- end
1052
- end
1053
-
1054
-
1055
- #
1056
- # Aliveness Test
1057
- #
1058
-
1059
- describe "GET /api/aliveness-test/:vhost" do
1060
- it "performs aliveness check" do
1061
- r = subject.aliveness_test("/")
1062
-
1063
- expect(r).to eq(true)
1064
- end
1065
- end
1066
-
1067
- #
1068
- # Accept Faraday adapter options
1069
- #
1070
- describe "connection accepts different faraday adapters" do
1071
- it "accepts explicit adapter" do
1072
- c = described_class.connect("http://guest:guest@127.0.0.1:15672/api",
1073
- adapter: :net_http)
1074
- r = c.overview
1075
- expect(r.rabbitmq_version).to_not be_nil
1076
- expect(r.erlang_version).to_not be_nil
1077
- end
1078
- end
1079
- end
@@ -1,14 +0,0 @@
1
- # -*- encoding: utf-8; mode: ruby -*-
2
-
3
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
-
5
- require 'bundler'
6
- Bundler.setup(:default, :test)
7
-
8
-
9
- require "effin_utf8"
10
- require "rspec"
11
- require "json"
12
- require "rabbitmq/http/client"
13
- require "bunny"
14
- require "rantly"