rabbitmq_http_api_client 0.6.0 → 0.7.0

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: 366f97e6e4043f1e77d62b5f09b6e8e357a8d99d
4
- data.tar.gz: 9bdcde9439b49077c30290ec7f2b6b3ff210cc2b
3
+ metadata.gz: 1da7410d9c30f5c606fa7c3625603cd6f7452062
4
+ data.tar.gz: ce4cab4b22d59edb563d2d99c6c9d4237263e5d1
5
5
  SHA512:
6
- metadata.gz: 5befe88a6a443db70b828e3fc1f01407cb1f8767ad90aada1ab241404d3f33b28fa4c2b1194762c3793b1a06edc57c3ce1ce6026d19495c2229243ac8153344e
7
- data.tar.gz: a9e0034159d5c9baeacf7a96c2922a98d9f9cadd2cf04a5b9dee6077de8c46123018af934a790a1b959cce4225bfa9421c54c2f91a341f208fdfe909db798a9c
6
+ metadata.gz: 1fe4dd68dacda7a8bdf1d90c47af6f889b0031da6d62fdaff6d97f35f28bb67eb4eace7e8b487df1d912b0bc67b4941dd60166151df52060b66edccf460f9eee
7
+ data.tar.gz: a78ecfd9ae9a8507f71d71ba8da24a1da0e42115f5a11f0607fdf054f4a1235e829bef1fcc61a7a0866f4dacf8af3bd79226d7d14f48af49c71dc65686d63258
data/ChangeLog.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## Changes Between 0.6.0 and 0.7.0
2
+
3
+ ### Support for Basic HTTP Auth Credentials in URI
4
+
5
+ It is now possible to pass credentials in the endpoint URI:
6
+
7
+ ``` ruby
8
+ c = RabbitMQ::HTTP::Client.new("https://guest:guest@127.0.0.1:15672/")
9
+ ```
10
+
11
+
1
12
  ## Changes Between 0.5.0 and 0.6.0
2
13
 
3
14
  ### Support for Advanced Connection Options
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  group :development, :test do
4
4
  gem "rspec"
5
- gem "json"
5
+ gem "json", :platform => :ruby_18
6
6
  gem "bunny", ">= 0.10.2"
7
7
  end
8
8
 
data/README.md CHANGED
@@ -75,6 +75,29 @@ puts r[:rabbitmq_version]
75
75
  puts r.erlang_version
76
76
  ```
77
77
 
78
+ ### Accessing Management API with HTTPS
79
+
80
+ All additional options other than `:username` and `:password` are passed
81
+ to [Faraday::Connection](https://github.com/lostisland/faraday). So, it is possible to use HTTPS
82
+ like so:
83
+
84
+ ``` ruby
85
+ c = RabbitMQ::HTTP::Client.new("https://127.0.0.1:15672/", username: "guest", password: "guest", ssl: {
86
+ client_cer: ...,
87
+ client_key: ...,
88
+ ca_file: ...,
89
+ ca_path: ...,
90
+ cert_store: ...
91
+ })
92
+ ```
93
+
94
+ Or, if you have good reasons to do so, disable peer verification:
95
+
96
+ ``` ruby
97
+ c = RabbitMQ::HTTP::Client.new("https://127.0.0.1:15672/", username: "guest", password: "guest", ssl: {
98
+ verify: false
99
+ })
100
+ ```
78
101
 
79
102
 
80
103
  ### Node and Cluster Status
@@ -1,7 +1,7 @@
1
1
  module RabbitMQ
2
2
  module HTTP
3
3
  class Client
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@ require "hashie"
2
2
  require "faraday"
3
3
  require "faraday_middleware"
4
4
  require "multi_json"
5
+ require "uri"
5
6
 
6
7
  # for URI encoding
7
8
  require "cgi"
@@ -308,8 +309,13 @@ module RabbitMQ
308
309
  protected
309
310
 
310
311
  def initialize_connection(endpoint, options = {})
312
+ uri = URI.parse(endpoint)
313
+
314
+ user = uri.user || options[:username] || "guest"
315
+ password = uri.password || options[:password] || "guest"
316
+
311
317
  @connection = Faraday.new(options.merge(:url => endpoint)) do |conn|
312
- conn.basic_auth options.fetch(:username, "guest"), options.fetch(:password, "guest")
318
+ conn.basic_auth user, password
313
319
  conn.use FaradayMiddleware::FollowRedirects, :limit => 3
314
320
  conn.use Faraday::Response::RaiseError
315
321
  conn.response :json, :content_type => /\bjson$/
@@ -17,6 +17,21 @@ describe RabbitMQ::HTTP::Client do
17
17
  end
18
18
 
19
19
 
20
+ #
21
+ # URI-only access
22
+ #
23
+
24
+ describe "URI-only access" do
25
+ it "authenticates successfully" do
26
+ c = described_class.connect("http://guest:guest@127.0.0.1:15672")
27
+
28
+ r = c.overview
29
+ r.rabbitmq_version.should_not be_nil
30
+ r.erlang_version.should_not be_nil
31
+ end
32
+ end
33
+
34
+
20
35
  #
21
36
  # Overview
22
37
  #
data/spec/spec_helper.rb CHANGED
@@ -8,5 +8,6 @@ Bundler.setup(:default, :test)
8
8
 
9
9
  require "effin_utf8"
10
10
  require "rspec"
11
+ require "json"
11
12
  require "rabbitmq/http/client"
12
13
  require "bunny"
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: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klishin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-07 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.0.6
123
+ rubygems_version: 2.1.6
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: RabbitMQ HTTP API client for Ruby