flexirest 1.11.3 → 1.12.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
  SHA256:
3
- metadata.gz: abc3590ed1c31e53df7d8be038fad0a01f66d4d50dd3effbb17f0ed41256e6fa
4
- data.tar.gz: 6049f2be6ecb5c921b4c0d10c1e4e3533dc50adaf98d153bae690e1d01413ecb
3
+ metadata.gz: b36abe5b5b35c85e8705681e6ec68792c20b1ec33e44cd94420e7a49a103fb50
4
+ data.tar.gz: fa2cf4caa5736b75f53b3bcf7ae61909e448ba75d58c41dfe826a92e616e42ec
5
5
  SHA512:
6
- metadata.gz: 469d6426f9de8945cc94af7c26e06a88e6b7b570e3c0b72487dd4d940518d54eba224ed522efe8abc12f822d80350b89658ac0cc4d7b7fcdc64c581075f44644
7
- data.tar.gz: d6d241da12c0049113e692693a4d98b7cbaa45f7ad06f5733a21eb7c516507e6ae9d513620feca19372f8039a2a9c3019bfb98005b8670a1920a860a363a181d
6
+ metadata.gz: 6a7b314f07d529deef241d32d750770e51fe2c4fdf32390f3cbbed814d3854d2f1229f6bc138d6b1a6688f7d152ccb330a778dd05298242bae20b9790da09e46
7
+ data.tar.gz: 3831f016b5b437374f2ba1a7fd9a9568077ffb71c9e1456359244055990dddb0aaf2a0fae0aa506d03bc8a8c5469ef1ae7809e3f6786e4d9b3a93d09937319a5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.12.1
4
+
5
+ Bugfix:
6
+
7
+ - Usernames and passwords for simple authentication should be URL-encoded unless they're actually going in the URL (thanks to Scott Duke for the bug report)
8
+
9
+ ## 1.12.0
10
+
11
+ Bugfix:
12
+
13
+ - Add compatibility with Ruby on Rails 7.1 (requires a method on the logger)
14
+
3
15
  ## 1.11.3
4
16
 
5
17
  Bugfix:
@@ -92,7 +92,6 @@ module Flexirest
92
92
  if value.respond_to?(:call)
93
93
  @username = value
94
94
  else
95
- value = CGI::escape(value) if value.present? && !value.include?("%")
96
95
  @username = value
97
96
  end
98
97
  end
@@ -100,7 +99,6 @@ module Flexirest
100
99
 
101
100
  def username=(value)
102
101
  Flexirest::Logger.info "\033[1;4;32m#{name}\033[0m Username set to be #{value}"
103
- value = CGI::escape(value) if value.present? && !value.include?("%")
104
102
  @@username = value
105
103
  end
106
104
 
@@ -123,7 +121,6 @@ module Flexirest
123
121
  if value.respond_to?(:call)
124
122
  @password = value
125
123
  else
126
- value = CGI::escape(value) if value.present? && !value.include?("%")
127
124
  @password = value
128
125
  end
129
126
  end
@@ -131,7 +128,6 @@ module Flexirest
131
128
 
132
129
  def password=(value)
133
130
  Flexirest::Logger.info "\033[1;4;32m#{name}\033[0m Password set..."
134
- value = CGI::escape(value) if value.present? && !value.include?("%")
135
131
  @@password = value
136
132
  end
137
133
 
@@ -16,6 +16,14 @@ module Flexirest
16
16
  @messages = []
17
17
  end
18
18
 
19
+ def self.level
20
+ if defined?(Rails) && Rails.logger.present?
21
+ Rails.logger.level
22
+ else
23
+ 0
24
+ end
25
+ end
26
+
19
27
  def self.debug(message)
20
28
  if defined?(Rails) && Rails.logger.present?
21
29
  Rails.logger.debug(message)
@@ -129,7 +129,11 @@ module Flexirest
129
129
  end
130
130
 
131
131
  def inject_basic_auth_in_url(url)
132
- url.gsub!(%r{//(.)}, "//#{username}:#{password}@\\1") if !url[%r{//[^/]*:[^/]*@}]
132
+ u = username
133
+ u = CGI::escape(u) if u.present? && !u.include?("%")
134
+ p = password
135
+ p = CGI::escape(p) if p.present? && !p.include?("%")
136
+ url.gsub!(%r{//(.)}, "//#{u}:#{p}@\\1") if !url[%r{//[^/]*:[^/]*@}]
133
137
  end
134
138
 
135
139
  def using_basic_auth?
@@ -1,3 +1,3 @@
1
1
  module Flexirest
2
- VERSION = "1.11.3"
2
+ VERSION = "1.12.1"
3
3
  end
@@ -78,15 +78,15 @@ describe Flexirest::Request do
78
78
 
79
79
  class AuthenticatedExampleClient < Flexirest::Base
80
80
  base_url "http://www.example.com"
81
- username "john"
82
- password "smith"
81
+ username "john@example.com"
82
+ password "smith?$"
83
83
  get :all, "/"
84
84
  end
85
85
 
86
86
  class AuthenticatedBasicHeaderExampleClient < Flexirest::Base
87
87
  base_url "http://www.example.com"
88
- username "john"
89
- password "smith"
88
+ username "john@example.com"
89
+ password "smith?$"
90
90
  basic_auth_method :header
91
91
  get :all, "/"
92
92
  end
@@ -97,8 +97,8 @@ describe Flexirest::Request do
97
97
 
98
98
  class AuthenticatedBasicUrlExampleClient < Flexirest::Base
99
99
  base_url "http://www.example.com"
100
- username "john"
101
- password "smith"
100
+ username "john@example.com"
101
+ password "smith?$"
102
102
  basic_auth_method :url
103
103
  get :all, "/"
104
104
  end
@@ -357,14 +357,14 @@ describe Flexirest::Request do
357
357
  mocked_response = ::FaradayResponseMock.new(OpenStruct.new(body:'{"result":true}', response_headers:{}))
358
358
 
359
359
  connection = double(Flexirest::Connection).as_null_object
360
- expect(Flexirest::ConnectionManager).to receive(:get_connection).with("http://john:smith@www.example.com").and_return(connection)
360
+ expect(Flexirest::ConnectionManager).to receive(:get_connection).with("http://john%40example.com:smith%3F%24@www.example.com").and_return(connection)
361
361
  expect(connection).to receive(:get).with("/", an_instance_of(Hash)).and_return(mocked_response)
362
362
  AuthenticatedExampleClient.all
363
363
  end
364
364
 
365
365
  it "should use the headers method for Basic auth when basic_auth_method is set to :header" do
366
366
  mocked_response = ::FaradayResponseMock.new(OpenStruct.new(body:'{"result":true}', response_headers:{}))
367
- headers_including_auth = hash_including({ "Authorization" => "Basic am9objpzbWl0aA==" })
367
+ headers_including_auth = hash_including({ "Authorization" => "Basic am9obkBleGFtcGxlLmNvbTpzbWl0aD8k" })
368
368
 
369
369
  connection = double(Flexirest::Connection).as_null_object
370
370
  expect(Flexirest::ConnectionManager).to receive(:get_connection).with("http://www.example.com").and_return(connection)
@@ -382,7 +382,7 @@ describe Flexirest::Request do
382
382
 
383
383
  it "should use the setting set on the parent class" do
384
384
  mocked_response = ::FaradayResponseMock.new(OpenStruct.new(body:'{"result":true}', response_headers:{}))
385
- headers_including_auth = hash_including({ "Authorization" => "Basic am9objpzbWl0aA==" })
385
+ headers_including_auth = hash_including({ "Authorization" => "Basic am9obkBleGFtcGxlLmNvbTpzbWl0aD8k" })
386
386
 
387
387
  connection = double(Flexirest::Connection).as_null_object
388
388
  expect(Flexirest::ConnectionManager).to receive(:get_connection).with("http://www.example.com").and_return(connection)
@@ -394,7 +394,7 @@ describe Flexirest::Request do
394
394
  mocked_response = ::FaradayResponseMock.new(OpenStruct.new(body:'{"result":true}', response_headers:{}))
395
395
 
396
396
  connection = double(Flexirest::Connection).as_null_object
397
- expect(Flexirest::ConnectionManager).to receive(:get_connection).with("http://john:smith@www.example.com").and_return(connection)
397
+ expect(Flexirest::ConnectionManager).to receive(:get_connection).with("http://john%40example.com:smith%3F%24@www.example.com").and_return(connection)
398
398
  expect(connection).to receive(:get) do |path, options|
399
399
  expect(path).to eq("/")
400
400
  expect(options[:headers]).to eq({"Accept"=>"application/hal+json, application/json;q=0.5", "Content-Type"=>"application/x-www-form-urlencoded; charset=utf-8"})
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.11.3
4
+ version: 1.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-14 00:00:00.000000000 Z
11
+ date: 2024-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -407,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
407
407
  - !ruby/object:Gem::Version
408
408
  version: '0'
409
409
  requirements: []
410
- rubygems_version: 3.4.6
410
+ rubygems_version: 3.4.10
411
411
  signing_key:
412
412
  specification_version: 4
413
413
  summary: This gem is for accessing REST services in a flexible way. ActiveResource