webmock 3.6.0 → 3.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/CHANGELOG.md +20 -0
- data/README.md +12 -0
- data/lib/webmock/http_lib_adapters/manticore_adapter.rb +9 -6
- data/lib/webmock/http_lib_adapters/net_http.rb +3 -2
- data/lib/webmock/http_lib_adapters/patron_adapter.rb +1 -1
- data/lib/webmock/request_pattern.rb +1 -2
- data/lib/webmock/util/uri.rb +3 -4
- data/lib/webmock/version.rb +1 -1
- data/spec/support/webmock_server.rb +1 -0
- data/spec/unit/request_pattern_spec.rb +5 -0
- data/spec/unit/util/uri_spec.rb +64 -2
- data/webmock.gemspec +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d54455d6752d60f630b108721f21ad51f4d2e648cf1fe492f72cce5d0e3bd66
|
4
|
+
data.tar.gz: 937d29ecd33fe244fe5f9749140d94c4ea68134b8afdcdd44a4ec41d5562df10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46ffed006b40f5d04d66ca5c3997f5874801e55d50a6580c1f3686a1c06a2fd4f69b4ab23c07f4828bdf01ace8749a0a7874a92db04780e621333a731bf89baf
|
7
|
+
data.tar.gz: 3d265897b59b5adcf8cf1954c5656160eb8bfeeb583d3abdcf9883b61b88b1b09ed050da8f45f582a190a86beb8d1bb809d55b39d89ac9ab4ed1681bc05ebeaa
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.6.2
|
4
|
+
|
5
|
+
* Fixed Patron adapter to handle HTTP/2 status line.
|
6
|
+
|
7
|
+
Thanks to [Fábio D. Batista](https://github.com/fabiob)
|
8
|
+
|
9
|
+
## 3.6.1
|
10
|
+
|
11
|
+
* Fixed issue with matching Addressable::Template without a period in the domain
|
12
|
+
|
13
|
+
Thanks to [Eike Send](https://github.com/eikes)
|
14
|
+
|
15
|
+
* Support for `write_timeout` in Net::HTTP
|
16
|
+
|
17
|
+
Thanks to [Claudio Poli](https://github.com/masterkain)
|
18
|
+
|
19
|
+
* Fixed issue with handling urls with ":80" or ":443" in the path.
|
20
|
+
|
21
|
+
Thanks to [Csaba Apagyi](https://github.com/thisismydesign) for reporting and to [Frederick Cheung](https://github.com/fcheung) for fixing the issue.
|
22
|
+
|
3
23
|
## 3.6.0
|
4
24
|
|
5
25
|
* Compatibility with the latest version of hashdiff gem, with constant changed from HashDiff to Hashdiff
|
data/README.md
CHANGED
@@ -878,6 +878,10 @@ end
|
|
878
878
|
|
879
879
|
Please submit them here [http://github.com/bblimke/webmock/issues](http://github.com/bblimke/webmock/issues)
|
880
880
|
|
881
|
+
## Issue triage [![Open Source Helpers](https://www.codetriage.com/bblimke/webmock/badges/users.svg)](https://www.codetriage.com/bblimke/webmock)
|
882
|
+
|
883
|
+
You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to webmock on CodeTriage](https://www.codetriage.com/bblimke/webmock).
|
884
|
+
|
881
885
|
## Suggestions
|
882
886
|
|
883
887
|
If you have any suggestions on how to improve WebMock please send an email to the mailing list [groups.google.com/group/webmock-users](http://groups.google.com/group/webmock-users)
|
@@ -1096,6 +1100,14 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
1096
1100
|
* Pavel Valena
|
1097
1101
|
* Adam Sokolnicki
|
1098
1102
|
* Jeff Felchner
|
1103
|
+
* Eike Send
|
1104
|
+
* Claudio Poli
|
1105
|
+
* Csaba Apagyi
|
1106
|
+
* Frederick Cheung
|
1107
|
+
* Fábio D. Batista
|
1108
|
+
|
1109
|
+
|
1110
|
+
|
1099
1111
|
|
1100
1112
|
For a full list of contributors you can visit the
|
1101
1113
|
[contributors](https://github.com/bblimke/webmock/contributors) page.
|
@@ -50,19 +50,22 @@ if defined?(Manticore)
|
|
50
50
|
|
51
51
|
if webmock_response = registered_response_for(request_signature)
|
52
52
|
webmock_response.raise_error_if_any
|
53
|
-
manticore_response = generate_manticore_response(webmock_response)
|
54
|
-
|
53
|
+
manticore_response = generate_manticore_response(webmock_response)
|
54
|
+
manticore_response.on_success do
|
55
|
+
WebMock::CallbackRegistry.invoke_callbacks({lib: :manticore, real_request: false}, request_signature, webmock_response)
|
56
|
+
end
|
55
57
|
|
56
58
|
elsif real_request_allowed?(request_signature.uri)
|
57
|
-
manticore_response = Manticore::Response.new(self, request, context, &block)
|
58
|
-
|
59
|
-
|
59
|
+
manticore_response = Manticore::Response.new(self, request, context, &block)
|
60
|
+
manticore_response.on_complete do |completed_response|
|
61
|
+
webmock_response = generate_webmock_response(completed_response)
|
62
|
+
WebMock::CallbackRegistry.invoke_callbacks({lib: :manticore, real_request: true}, request_signature, webmock_response)
|
63
|
+
end
|
60
64
|
|
61
65
|
else
|
62
66
|
raise WebMock::NetConnectNotAllowedError.new(request_signature)
|
63
67
|
end
|
64
68
|
|
65
|
-
WebMock::CallbackRegistry.invoke_callbacks({lib: :manticore, real_request: real_request}, request_signature, webmock_response)
|
66
69
|
manticore_response
|
67
70
|
end
|
68
71
|
|
@@ -229,14 +229,15 @@ class PatchedStringIO < StringIO #:nodoc:
|
|
229
229
|
alias_method :orig_read_nonblock, :read_nonblock
|
230
230
|
|
231
231
|
def read_nonblock(size, *args)
|
232
|
-
|
232
|
+
args.reject! {|arg| !arg.is_a?(Hash)}
|
233
|
+
orig_read_nonblock(size, *args)
|
233
234
|
end
|
234
235
|
|
235
236
|
end
|
236
237
|
|
237
238
|
class StubSocket #:nodoc:
|
238
239
|
|
239
|
-
attr_accessor :read_timeout, :continue_timeout
|
240
|
+
attr_accessor :read_timeout, :continue_timeout, :write_timeout
|
240
241
|
|
241
242
|
def initialize(*args)
|
242
243
|
end
|
@@ -118,7 +118,7 @@ if defined?(::Patron)
|
|
118
118
|
def self.build_webmock_response(patron_response)
|
119
119
|
webmock_response = WebMock::Response.new
|
120
120
|
reason = patron_response.status_line.
|
121
|
-
scan(%r(\AHTTP/(\d
|
121
|
+
scan(%r(\AHTTP/(\d+(?:\.\d+)?)\s+(\d\d\d)\s*([^\r\n]+)?))[0][2]
|
122
122
|
webmock_response.status = [patron_response.status, reason]
|
123
123
|
webmock_response.body = patron_response.body
|
124
124
|
webmock_response.headers = patron_response.headers
|
@@ -183,8 +183,7 @@ module WebMock
|
|
183
183
|
def matches_with_variations?(uri)
|
184
184
|
normalized_template = Addressable::Template.new(WebMock::Util::URI.heuristic_parse(@pattern.pattern))
|
185
185
|
|
186
|
-
WebMock::Util::URI.variations_of_uri_as_strings(uri
|
187
|
-
.any? { |u| normalized_template.match(u) }
|
186
|
+
WebMock::Util::URI.variations_of_uri_as_strings(uri).any? { |u| normalized_template.match(u) }
|
188
187
|
end
|
189
188
|
end
|
190
189
|
|
data/lib/webmock/util/uri.rb
CHANGED
@@ -41,12 +41,12 @@ module WebMock
|
|
41
41
|
uris = uris_with_trailing_slash_and_without(uris)
|
42
42
|
end
|
43
43
|
|
44
|
-
uris = uris_encoded_and_unencoded(uris)
|
45
|
-
|
46
44
|
if normalized_uri.port == Addressable::URI.port_mapping[normalized_uri.scheme]
|
47
45
|
uris = uris_with_inferred_port_and_without(uris)
|
48
46
|
end
|
49
47
|
|
48
|
+
uris = uris_encoded_and_unencoded(uris)
|
49
|
+
|
50
50
|
if normalized_uri.scheme == "http" && !only_with_scheme
|
51
51
|
uris = uris_with_scheme_and_without(uris)
|
52
52
|
end
|
@@ -80,8 +80,7 @@ module WebMock
|
|
80
80
|
|
81
81
|
def self.uris_with_inferred_port_and_without(uris)
|
82
82
|
uris.map { |uri|
|
83
|
-
|
84
|
-
[ uri, uri.gsub(%r{(:80)|(:443)}, "").freeze ]
|
83
|
+
[ uri, uri.omit(:port)]
|
85
84
|
}.flatten
|
86
85
|
end
|
87
86
|
|
data/lib/webmock/version.rb
CHANGED
@@ -121,6 +121,11 @@ describe WebMock::RequestPattern do
|
|
121
121
|
to match(WebMock::RequestSignature.new(:get, "www.example.com"))
|
122
122
|
end
|
123
123
|
|
124
|
+
it "should match if uri Addressable::Template pattern matches request uri without TLD" do
|
125
|
+
expect(WebMock::RequestPattern.new(:get, Addressable::Template.new("localhost"))).
|
126
|
+
to match(WebMock::RequestSignature.new(:get, "localhost"))
|
127
|
+
end
|
128
|
+
|
124
129
|
it "should match if Addressable::Template pattern that has ip address host matches request uri" do
|
125
130
|
signature = WebMock::RequestSignature.new(:get, "127.0.0.1:3000/1234")
|
126
131
|
uri = Addressable::Template.new("127.0.0.1:3000/{id}")
|
data/spec/unit/util/uri_spec.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
3
|
URIS_WITHOUT_PATH_OR_PARAMS =
|
5
4
|
[
|
6
5
|
"www.example.com",
|
@@ -65,7 +64,6 @@ URIS_WITH_DIFFERENT_PORT =
|
|
65
64
|
"http://www.example.com:88/"
|
66
65
|
].sort
|
67
66
|
|
68
|
-
|
69
67
|
URIS_FOR_HTTPS =
|
70
68
|
[
|
71
69
|
"https://www.example.com",
|
@@ -74,6 +72,49 @@ URIS_FOR_HTTPS =
|
|
74
72
|
"https://www.example.com:443/"
|
75
73
|
].sort
|
76
74
|
|
75
|
+
URIS_FOR_LOCALHOST =
|
76
|
+
[
|
77
|
+
"localhost",
|
78
|
+
"localhost/",
|
79
|
+
"localhost:80",
|
80
|
+
"localhost:80/",
|
81
|
+
"http://localhost",
|
82
|
+
"http://localhost/",
|
83
|
+
"http://localhost:80",
|
84
|
+
"http://localhost:80/"
|
85
|
+
].sort
|
86
|
+
|
87
|
+
URIS_WITH_SCHEME =
|
88
|
+
[
|
89
|
+
"http://www.example.com",
|
90
|
+
"http://www.example.com/",
|
91
|
+
"http://www.example.com:80",
|
92
|
+
"http://www.example.com:80/"
|
93
|
+
].sort
|
94
|
+
|
95
|
+
URIS_WITH_COLON_IN_PATH =
|
96
|
+
[
|
97
|
+
[
|
98
|
+
"https://example.com/a/b:80",
|
99
|
+
"https://example.com:443/a/b:80",
|
100
|
+
].sort,
|
101
|
+
[
|
102
|
+
"https://example.com:443/a/b:443",
|
103
|
+
"https://example.com/a/b:443",
|
104
|
+
].sort,
|
105
|
+
[
|
106
|
+
"http://example.com/a/b:443",
|
107
|
+
"example.com/a/b:443",
|
108
|
+
"http://example.com:80/a/b:443",
|
109
|
+
"example.com:80/a/b:443",
|
110
|
+
].sort,
|
111
|
+
[
|
112
|
+
"http://example.com/a/b:80",
|
113
|
+
"example.com/a/b:80",
|
114
|
+
"http://example.com:80/a/b:80",
|
115
|
+
"example.com:80/a/b:80",
|
116
|
+
].sort
|
117
|
+
]
|
77
118
|
|
78
119
|
describe WebMock::Util::URI do
|
79
120
|
|
@@ -115,6 +156,27 @@ describe WebMock::Util::URI do
|
|
115
156
|
end
|
116
157
|
end
|
117
158
|
|
159
|
+
it "should find all variations of the same uri for all variations of host names uris without a period" do
|
160
|
+
URIS_FOR_LOCALHOST.each do |uri|
|
161
|
+
expect(WebMock::Util::URI.variations_of_uri_as_strings(uri).sort).to eq(URIS_FOR_LOCALHOST)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should find all variations of the same uri with scheme for all variations when only_with_scheme is true" do
|
166
|
+
URIS_WITHOUT_PATH_OR_PARAMS.each do |uri|
|
167
|
+
variations_of_uri_with_scheme = WebMock::Util::URI.variations_of_uri_as_strings(uri, only_with_scheme: true)
|
168
|
+
expect(variations_of_uri_with_scheme.sort).to eq(URIS_WITH_SCHEME)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should not replace :80 or :443 in path" do
|
173
|
+
URIS_WITH_COLON_IN_PATH.each do |uris|
|
174
|
+
uris.each do |uri|
|
175
|
+
expect(WebMock::Util::URI.variations_of_uri_as_strings(uri).sort).to eq(uris)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
118
180
|
end
|
119
181
|
|
120
182
|
describe "normalized uri equality" do
|
data/webmock.gemspec
CHANGED
@@ -13,8 +13,6 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = %q{WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.}
|
14
14
|
s.license = "MIT"
|
15
15
|
|
16
|
-
s.rubyforge_project = 'webmock'
|
17
|
-
|
18
16
|
s.required_ruby_version = '>= 2.0'
|
19
17
|
|
20
18
|
s.add_dependency 'addressable', '>= 2.3.6'
|
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: 3.6.
|
4
|
+
version: 3.6.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: 2019-
|
11
|
+
date: 2019-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|