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 +4 -4
- data/CHANGELOG.md +15 -1
- data/README.md +3 -1
- data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +1 -1
- data/lib/webmock/util/headers.rb +1 -1
- data/lib/webmock/version.rb +1 -1
- data/lib/webmock/webmock.rb +2 -2
- data/spec/acceptance/shared/stubbing_requests.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 050c61fa8c7558b2c5fc52862600577199f286c7
|
4
|
+
data.tar.gz: 9745a14b5c7b2428dcd8720efc132c0b1573b43c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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
|
|
data/lib/webmock/util/headers.rb
CHANGED
data/lib/webmock/version.rb
CHANGED
data/lib/webmock/webmock.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2016-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|