webmock 2.0.1 → 2.0.2

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: c62cee53bf447bb19145917ce3ce566167e2c73c
4
- data.tar.gz: a88c14886f10f7951ce3683bdd92c7420cad1d5a
3
+ metadata.gz: 050c61fa8c7558b2c5fc52862600577199f286c7
4
+ data.tar.gz: 9745a14b5c7b2428dcd8720efc132c0b1573b43c
5
5
  SHA512:
6
- metadata.gz: e23e4392312fbfbac76d8f29e44eb6711753a8c3a6010d5553587f583ec9fd6da45f06f37f58cdfbd1e48d7adb63034a0a68de52cfe4c1c77bff718a46966b38
7
- data.tar.gz: 850b7aa2808bfb7ebccb8875cfc9f05a35d110bcf754a519c37ae59c0675a390f4294f6b97b17c49555271df8b8f1c67287bd7319cf01f84ac32114c72da63d1
6
+ metadata.gz: b698fda2494837e51abd90df2eaef0a651d87b6968a3c541af5630f951b60e2b7dd09d50a12f1a8fb0f3adc5583d079d0805067ecfdce6168cd56d0e6119c833
7
+ data.tar.gz: 33d11e2e5d09870aaf44ef1522c4381b83c37d4dd0e9b88d75be9b3c7321a82e7f008d3c8da831ee0957a61c8a6226f9adbe211f88e5de5e4fa36888d115c4af
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.2
4
+
5
+ * Using `Base64.strict_encode64` instead of `Base64.encode64` to handle long user:pass basic auth credentials
6
+
7
+ Thanks to [Jonathan Schatz](https://github.com/modosc)
8
+
9
+ * Fixed handling of Authorisation header provided as string instead of array when using em-http-request.
10
+
11
+ Thanks to [Michael Richardson](https://github.com/TTransmit) for reporing the issue.
12
+
13
+ * Ensured `WebMock.net_connect_explicit_allowed?` always returns boolean.
14
+
15
+ Thanks tp [Jose Luis Honorato](https://github.com/jlhonora)
16
+
3
17
  ## 2.0.1
4
18
 
5
19
  * Added code responsible for loading em-http-request if available, which has been removed by mistake.
@@ -40,7 +54,7 @@
40
54
  or
41
55
 
42
56
  stub_request(:get, "www.example.com").
43
- with(headers: 'Authorization' => "Basic #{ Base64.encode64('user:pass').chomp}")
57
+ with(headers: 'Authorization' => "Basic #{ Base64.strict_encode64('user:pass').chomp}")
44
58
 
45
59
  In order to stub a request with basic authentication credentials provided in the url, please use the following code:
46
60
 
data/README.md CHANGED
@@ -209,7 +209,7 @@ RestClient.post('www.example.com', 'abc') # ===> Success
209
209
  stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
210
210
  # or
211
211
  # stub_request(:get, "www.example.com").
212
- # with(headers: 'Authorization' => "Basic #{ Base64.encode64('user:pass').chomp}")
212
+ # with(headers: {'Authorization' => "Basic #{ Base64.strict_encode64('user:pass').chomp}"})
213
213
 
214
214
  Net::HTTP.start('www.example.com') do |http|
215
215
  req = Net::HTTP::Get.new('/')
@@ -1017,6 +1017,8 @@ People who submitted patches and new features or suggested improvements. Many th
1017
1017
  * Gabriel Chaney
1018
1018
  * Chris Griego
1019
1019
  * Taiki Ono
1020
+ * Jonathan Schatz
1021
+ * Jose Luis Honorato
1020
1022
 
1021
1023
  For a full list of contributors you can visit the
1022
1024
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -180,7 +180,7 @@ if defined?(EventMachine::HttpClient)
180
180
 
181
181
  headers = @req.headers
182
182
 
183
- if headers['authorization']
183
+ if headers['authorization'] && headers['authorization'].is_a?(Array)
184
184
  headers['Authorization'] = WebMock::Util::Headers.basic_auth_header(headers.delete('authorization'))
185
185
  end
186
186
 
@@ -39,7 +39,7 @@ module WebMock
39
39
  end
40
40
 
41
41
  def self.basic_auth_header(*credentials)
42
- "Basic #{Base64.encode64(credentials.join(':')).chomp}"
42
+ "Basic #{Base64.strict_encode64(credentials.join(':')).chomp}"
43
43
  end
44
44
 
45
45
  end
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '2.0.1' unless defined?(::WebMock::VERSION)
2
+ VERSION = '2.0.2' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -68,8 +68,8 @@ module WebMock
68
68
  when Array
69
69
  allowed.any? { |allowed_item| net_connect_explicit_allowed?(allowed_item, uri) }
70
70
  when Regexp
71
- uri.to_s =~ allowed ||
72
- uri.omit(:port).to_s =~ allowed && uri.port == uri.default_port
71
+ (uri.to_s =~ allowed) != nil ||
72
+ (uri.omit(:port).to_s =~ allowed) != nil && uri.port == uri.default_port
73
73
  when String
74
74
  allowed == uri.to_s ||
75
75
  allowed == uri.host ||
@@ -403,6 +403,11 @@ shared_examples_for "stubbing requests" do |*adapter_info|
403
403
  expect(http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pass']).status).to eq("200")
404
404
  end
405
405
 
406
+ it "should match if credentials are the same and encode to more than one line" do
407
+ stub_request(:get, "www.example.com").with(basic_auth: ['user' * 5, 'pass' * 5])
408
+ expect(http_request(:get, "http://www.example.com/", basic_auth: ['user' * 5, 'pass' * 5]).status).to eq("200")
409
+ end
410
+
406
411
  it "should match if credentials are the same and were provided directly as authentication headers in request" do
407
412
  stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
408
413
  expect(http_request(:get, "http://www.example.com/", headers: {'Authorization'=>'Basic dXNlcjpwYXNz'}).status).to eq("200")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Blimke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-02 00:00:00.000000000 Z
11
+ date: 2016-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable