diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-05 03:32:58 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-05 03:32:58 +0000 |
commit | 08f8cfe14e0f8937e3bcf8a22becdc5ce60b920e (patch) | |
tree | 30977064b5f93f9ac5b01b2a676f6d6ffdcec652 /lib/rubygems/test_utilities.rb | |
parent | 593505ac6f802d2b5bff469425b7c76b65cc9b10 (diff) |
Merge RubyGems upstream: 56c0bbb69e4506bda7ef7f447dfec5db820df20b
It fixed the multiple vulnerabilities.
https://blog.rubygems.org/2019/03/05/security-advisories-2019-03.html
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/test_utilities.rb')
-rw-r--r-- | lib/rubygems/test_utilities.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb index 069ecccabe..5d02b04897 100644 --- a/lib/rubygems/test_utilities.rb +++ b/lib/rubygems/test_utilities.rb @@ -13,6 +13,13 @@ require 'rubygems/remote_fetcher' # @fetcher.data['http://gems.example.com/yaml'] = source_index.to_yaml # Gem::RemoteFetcher.fetcher = @fetcher # +# use nested array if multiple response is needed +# +# @fetcher.data['http://gems.example.com/sequence'] = [['Success', 200, 'OK'], ['Failed', 401, 'Unauthorized']] +# +# @fetcher.fetch_path('http://gems.example.com/sequence') # => ['Success', 200, 'OK'] +# @fetcher.fetch_path('http://gems.example.com/sequence') # => ['Failed', 401, 'Unauthorized'] +# # # invoke RubyGems code # # paths = @fetcher.paths @@ -32,7 +39,7 @@ class Gem::FakeFetcher @paths = [] end - def find_data(path) + def find_data(path, nargs = 3) return File.read path.path if URI === path and 'file' == path.scheme if URI === path and "URI::#{path.scheme.upcase}" != path.class.name @@ -48,7 +55,10 @@ class Gem::FakeFetcher raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path) end - @data[path] + data = @data[path] + + data.flatten! and return data.shift(nargs) if data.respond_to?(:flatten!) + data end def fetch_path(path, mtime = nil, head = false) @@ -60,7 +70,6 @@ class Gem::FakeFetcher if path.to_s =~ /gz$/ and not data.nil? and not data.empty? data = Gem::Util.gunzip data end - data end end |