flexirest 1.12.0 → 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: 530331988751770dc906ba6b17ffafa88cc5213f8c99a67fb8e6335af2152082
4
- data.tar.gz: a55ce84b1ac4e3b1e17df27abefd3e2d9c7250a22e4368c5806a318a29ac72cd
3
+ metadata.gz: b36abe5b5b35c85e8705681e6ec68792c20b1ec33e44cd94420e7a49a103fb50
4
+ data.tar.gz: fa2cf4caa5736b75f53b3bcf7ae61909e448ba75d58c41dfe826a92e616e42ec
5
5
  SHA512:
6
- metadata.gz: ef1ac1a698388648711b665eccbb43f0f52d751a75abe156221081f84198cdd3c426d6643db563f9bd57af9813c3ede8049114f1859603572105bec20357bfff
7
- data.tar.gz: 7f0ef624a7a958b33fcecd69f0d397e480ab98ffef1cbe3029cf87d2c290d02cb8be4b9f4c97903b6b495564dcb94607b64991ac530ec68851b13e7c474158b6
6
+ metadata.gz: 6a7b314f07d529deef241d32d750770e51fe2c4fdf32390f3cbbed814d3854d2f1229f6bc138d6b1a6688f7d152ccb330a778dd05298242bae20b9790da09e46
7
+ data.tar.gz: 3831f016b5b437374f2ba1a7fd9a9568077ffb71c9e1456359244055990dddb0aaf2a0fae0aa506d03bc8a8c5469ef1ae7809e3f6786e4d9b3a93d09937319a5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 1.12.0
4
10
 
5
11
  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
 
@@ -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.12.0"
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.12.0
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-10-08 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