flexirest 1.3.16 → 1.3.17

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: a05916ea9c0a9dff55d6d260df70ab263b4cb51f
4
- data.tar.gz: b8f74642b6c7ee86a8819f6ca2077cfc153be34c
3
+ metadata.gz: d3f5b7fd58fca9e5b1af0e80cd566a98404033d4
4
+ data.tar.gz: 66f2a9a29930347f6e72452b12d2adff5ab18145
5
5
  SHA512:
6
- metadata.gz: 9e92347d9e7654e6296827a40ace68a536f39204b6fec78ece3955efba329768c5522e65715dc8ea3f7fb6bff739f639892fec26e06627a2b67a356375cf3bf9
7
- data.tar.gz: d9582c21066db41a975ffe5f4c76ffcff27c85ea11af012f38acc267d71a7791ebc83dfc6b6951c6857527f7fc2b5c9e3d2e1ec163f577225c89bdb31e10d94a
6
+ metadata.gz: c2f55e90d6c57f50cb85b90f3acdd1981d8ff0bb206591ecf26f1d002c286cf71c4bc76d1b3d671c9f5a459d92ba3b12e6627e0c0fc2692a12c8b3e6e52ece67
7
+ data.tar.gz: 989344a2cece5f68cb99df45b2a4a0bb9372839be88c3853acf20d9b8710b813cfa26a7ed976176c450e6090dd204541ba5451f16319bbd09fa33fa49ba1b948
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.17
4
+
5
+ Bugfix:
6
+
7
+ - Authentication credentials weren't being passed through proxied classes (thanks to Lukasz Modlinski for the contribution).
8
+
3
9
  ## 1.3.16
4
10
 
5
11
  Feature:
@@ -315,7 +315,7 @@ module Flexirest
315
315
  _, @base_url, @url = parts
316
316
  end
317
317
  base_url.gsub!(%r{//(.)}, "//#{username}:#{password}@\\1") if username && !base_url[%r{//[^/]*:[^/]*@}]
318
- connection = Flexirest::ConnectionManager.get_connection(@base_url)
318
+ connection = Flexirest::ConnectionManager.get_connection(base_url)
319
319
  end
320
320
  else
321
321
  parts = @url.match(%r{^(https?://[a-z\d\.:-]+?)(/.*)}).to_a
@@ -1,3 +1,3 @@
1
1
  module Flexirest
2
- VERSION = "1.3.16"
2
+ VERSION = "1.3.17"
3
3
  end
@@ -147,7 +147,7 @@ describe Flexirest::Connection do
147
147
  expect(auth_header == "APIAuth id123:TQiQIW6vVaDC5jvh99uTNkxIg6Q=" || auth_header == "APIAuth id123:PMWBThkB8vKbvUccHvoqu9G3eVk=").to be_truthy
148
148
  end
149
149
 
150
- if Gem.loaded_specs["api-auth"].version.to_s >= "2.0.0"
150
+ if Gem.loaded_specs["api-auth"].present? && Gem.loaded_specs["api-auth"].version.to_s >= "2.0.0"
151
151
  it 'should have an Authorization header with a custom digest method' do
152
152
  puts Gem.loaded_specs["api-auth"].version
153
153
  @options[:api_auth][:api_auth_options] = {
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'active_support/core_ext/hash'
3
+ require 'base64'
3
4
 
4
5
  class ProxyExample < Flexirest::ProxyBase
5
6
  get "/all" do
@@ -30,7 +31,7 @@ class ProxyExample < Flexirest::ProxyBase
30
31
  body "MY-BODY-CONTENT"
31
32
  passthrough
32
33
  end
33
-
34
+
34
35
  patch "/partial_update" do
35
36
  body "MY-BODY-CONTENT"
36
37
  passthrough
@@ -93,6 +94,8 @@ class ProxyClientExample < Flexirest::Base
93
94
  end
94
95
 
95
96
  describe Flexirest::Base do
97
+ before(:each) { ProxyClientExample.base_url 'http://www.example.com' }
98
+
96
99
  it "allows the URL to be changed" do
97
100
  expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/getAll?id=1", instance_of(Hash)).and_return(OpenStruct.new(body:"{\"result\":true}", status:200, headers:{}))
98
101
  ProxyClientExample.all(id:1)
@@ -112,7 +115,7 @@ describe Flexirest::Base do
112
115
  expect_any_instance_of(Flexirest::Connection).to receive(:post).with("/create", {age:12, first_name:"John"}.to_query, instance_of(Hash)).and_return(OpenStruct.new(body:"{\"result\":true}", status:200, headers:{}))
113
116
  ProxyClientExample.create(fname:"John", lname:"Smith")
114
117
  end
115
-
118
+
116
119
  it "has access to raw body content for PATCH requests" do
117
120
  expect_any_instance_of(Flexirest::Connection).to receive(:patch).with("/partial_update", "MY-BODY-CONTENT", instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(body:"{\"result\":true}", status:200, response_headers:{})))
118
121
  ProxyClientExample.partial_update(fname:"John", lname:"Smith")
@@ -197,4 +200,13 @@ describe Flexirest::Base do
197
200
  expect(ProxyClientExample.hal_test(id:1).test.result).to eq(true)
198
201
  end
199
202
 
203
+ it "properly passes basic HTTP auth credentials" do
204
+ host, credentials, url_path = 'www.example.com', 'user:pass', '/getAll?id=1'
205
+ ProxyClientExample.base_url "http://#{credentials}@#{host}"
206
+ stub_request(:get, "#{host}#{url_path}")
207
+ ProxyClientExample.all(id:1)
208
+ expect(a_request(:get, "#{host}#{url_path}").with(headers: {
209
+ 'Authorization'=>"Basic #{Base64.strict_encode64(credentials)}"
210
+ })).to have_been_made
211
+ end
200
212
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexirest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.16
4
+ version: 1.3.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler