From 97b7bbc402043d6bc6ac0c8c76203de980bf7d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 26 Nov 2019 11:47:43 +0100 Subject: [PATCH] Use vendorized version of uri library --- lib/bundler/cli.rb | 2 +- lib/bundler/fetcher.rb | 4 ++-- lib/bundler/fetcher/downloader.rb | 2 +- lib/bundler/fetcher/index.rb | 2 +- lib/bundler/mirror.rb | 6 ++--- lib/bundler/plugin/api/source.rb | 4 ++-- lib/bundler/settings.rb | 8 +++---- lib/bundler/source/git.rb | 2 +- lib/bundler/source/git/git_proxy.rb | 2 +- lib/bundler/source/rubygems.rb | 6 ++--- lib/bundler/source/rubygems/remote.rb | 2 +- lib/bundler/uri_credentials_filter.rb | 6 ++--- spec/bundler/fetcher/base_spec.rb | 6 ++--- spec/bundler/fetcher/compact_index_spec.rb | 2 +- spec/bundler/fetcher/dependency_spec.rb | 4 ++-- spec/bundler/fetcher/downloader_spec.rb | 26 ++++++++++----------- spec/bundler/fetcher/index_spec.rb | 2 +- spec/bundler/fetcher_spec.rb | 4 ++-- spec/bundler/mirror_spec.rb | 16 ++++++------- spec/bundler/rubygems_integration_spec.rb | 4 ++-- spec/bundler/settings_spec.rb | 10 ++++---- spec/bundler/source/rubygems/remote_spec.rb | 20 ++++++++-------- spec/bundler/source_list_spec.rb | 4 ++-- spec/bundler/uri_credentials_filter_spec.rb | 10 ++++---- spec/bundler/vendored_persistent_spec.rb | 4 ++-- spec/realworld/edgecases_spec.rb | 2 +- spec/spec_helper.rb | 2 +- 27 files changed, 81 insertions(+), 81 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 86c9da6b992..8afa649874b 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -784,7 +784,7 @@ def warn_on_outdated_bundler return unless SharedHelpers.md5_available? latest = Fetcher::CompactIndex. - new(nil, Source::Rubygems::Remote.new(URI("https://rubygems.org")), nil). + new(nil, Source::Rubygems::Remote.new(Bundler::URI("https://rubygems.org")), nil). send(:compact_index_client). instance_variable_get(:@cache). dependencies("bundler"). diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 7bda26770b3..caf33bcfc91 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -97,7 +97,7 @@ def fetch_spec(spec) spec -= [nil, "ruby", ""] spec_file_name = "#{spec.join "-"}.gemspec" - uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz") + uri = Bundler::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz") if uri.scheme == "file" path = Bundler.rubygems.correct_for_windows_path(uri.path) Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path)) @@ -244,7 +244,7 @@ def connection con = PersistentHTTP.new :name => "bundler", :proxy => :ENV if gem_proxy = Bundler.rubygems.configuration[:http_proxy] - con.proxy = URI.parse(gem_proxy) if gem_proxy != :no_proxy + con.proxy = Bundler::URI.parse(gem_proxy) if gem_proxy != :no_proxy end if remote_uri.scheme == "https" diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb index 73f125af91c..498852c1749 100644 --- a/lib/bundler/fetcher/downloader.rb +++ b/lib/bundler/fetcher/downloader.rb @@ -21,7 +21,7 @@ def fetch(uri, headers = {}, counter = 0) when Net::HTTPSuccess, Net::HTTPNotModified response when Net::HTTPRedirection - new_uri = URI.parse(response["location"]) + new_uri = Bundler::URI.parse(response["location"]) if new_uri.host == uri.host new_uri.user = uri.user new_uri.password = uri.password diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb index d2ad657fe6b..034a225198c 100644 --- a/lib/bundler/fetcher/index.rb +++ b/lib/bundler/fetcher/index.rb @@ -28,7 +28,7 @@ def fetch_spec(spec) spec -= [nil, "ruby", ""] spec_file_name = "#{spec.join "-"}.gemspec" - uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz") + uri = Bundler::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz") if uri.scheme == "file" path = Bundler.rubygems.correct_for_windows_path(uri.path) Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path)) diff --git a/lib/bundler/mirror.rb b/lib/bundler/mirror.rb index b15190e7e57..0e554bcc3f0 100644 --- a/lib/bundler/mirror.rb +++ b/lib/bundler/mirror.rb @@ -47,7 +47,7 @@ def parse(key, value) def fetch_valid_mirror_for(uri) downcased = uri.to_s.downcase - mirror = @mirrors[downcased] || @mirrors[URI(downcased).host] || Mirror.new(uri) + mirror = @mirrors[downcased] || @mirrors[Bundler::URI(downcased).host] || Mirror.new(uri) mirror.validate!(@prober) mirror = Mirror.new(uri) unless mirror.valid? mirror @@ -74,7 +74,7 @@ def uri=(uri) @uri = if uri.nil? nil else - URI(uri.to_s) + Bundler::URI(uri.to_s) end @valid = nil end @@ -126,7 +126,7 @@ def initialize(config_line, value) if uri == "all" @all = true else - @uri = URI(uri).absolute? ? Settings.normalize_uri(uri) : uri + @uri = Bundler::URI(uri).absolute? ? Settings.normalize_uri(uri) : uri end @value = value end diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb index 4d437184248..56e97f4aa41 100644 --- a/lib/bundler/plugin/api/source.rb +++ b/lib/bundler/plugin/api/source.rb @@ -106,7 +106,7 @@ def post_install(spec, disable_exts = false) def install_path @install_path ||= begin - base_name = File.basename(URI.parse(uri).normalize.path) + base_name = File.basename(Bundler::URI.parse(uri).normalize.path) gem_install_dir.join("#{base_name}-#{uri_hash[0..11]}") end @@ -168,7 +168,7 @@ def unlock! # # This is used by `app_cache_path` def app_cache_dirname - base_name = File.basename(URI.parse(uri).normalize.path) + base_name = File.basename(Bundler::URI.parse(uri).normalize.path) "#{base_name}-#{uri_hash}" end diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index b9bbd7b952e..afbb02397c7 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -151,8 +151,8 @@ def local_overrides def mirror_for(uri) if uri.is_a?(String) - require "uri" - uri = URI(uri) + require_relative "vendored_uri" + uri = Bundler::URI(uri) end gem_mirrors.for(uri.to_s).uri @@ -423,8 +423,8 @@ def self.normalize_uri(uri) suffix = $3 end uri = "#{uri}/" unless uri.end_with?("/") - require "uri" - uri = URI(uri) + require_relative "vendored_uri" + uri = Bundler::URI(uri) unless uri.absolute? raise ArgumentError, format("Gem sources must be absolute. You provided '%s'.", uri) end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 54d3c20a69a..0b4d76939b4 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -284,7 +284,7 @@ def uri_hash if uri =~ %r{^\w+://(\w+@)?} # Downcase the domain component of the URI # and strip off a trailing slash, if one is present - input = URI.parse(uri).normalize.to_s.sub(%r{/$}, "") + input = Bundler::URI.parse(uri).normalize.to_s.sub(%r{/$}, "") else # If there is no URI scheme, assume it is an ssh/git URI input = uri diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index 671610e7c1b..7612eb16c65 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -217,7 +217,7 @@ def uri_escaped_with_configured_credentials # Adds credentials to the URI as Fetcher#configured_uri_for does def configured_uri_for(uri) if /https?:/ =~ uri - remote = URI(uri) + remote = Bundler::URI(uri) config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host] remote.userinfo ||= config_auth remote.to_s diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index a6a0652d6de..6c0de204e75 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -327,10 +327,10 @@ def cached_path(spec) def normalize_uri(uri) uri = uri.to_s uri = "#{uri}/" unless uri =~ %r{/$} - require "uri" - uri = URI(uri) + require_relative "../vendored_uri" + uri = Bundler::URI(uri) raise ArgumentError, "The source must be an absolute URI. For example:\n" \ - "source 'https://rubygems.org'" if !uri.absolute? || (uri.is_a?(URI::HTTP) && uri.host.nil?) + "source 'https://rubygems.org'" if !uri.absolute? || (uri.is_a?(Bundler::URI::HTTP) && uri.host.nil?) uri end diff --git a/lib/bundler/source/rubygems/remote.rb b/lib/bundler/source/rubygems/remote.rb index 7558b2cc3fa..45ea61acb2f 100644 --- a/lib/bundler/source/rubygems/remote.rb +++ b/lib/bundler/source/rubygems/remote.rb @@ -48,7 +48,7 @@ def apply_auth(uri, auth) end uri - rescue URI::InvalidComponentError + rescue Bundler::URI::InvalidComponentError error_message = "Please CGI escape your usernames and passwords before " \ "setting them for authentication." raise HTTPError.new(error_message) diff --git a/lib/bundler/uri_credentials_filter.rb b/lib/bundler/uri_credentials_filter.rb index 455b4503ea0..9b9e9c2799f 100644 --- a/lib/bundler/uri_credentials_filter.rb +++ b/lib/bundler/uri_credentials_filter.rb @@ -8,8 +8,8 @@ def credential_filtered_uri(uri_to_anonymize) return uri_to_anonymize if uri_to_anonymize.nil? uri = uri_to_anonymize.dup if uri.is_a?(String) - require "uri" - uri = URI(uri) + require_relative "vendored_uri" + uri = Bundler::URI(uri) end if uri.userinfo @@ -23,7 +23,7 @@ def credential_filtered_uri(uri_to_anonymize) end return uri.to_s if uri_to_anonymize.is_a?(String) uri - rescue URI::InvalidURIError # uri is not canonical uri scheme + rescue Bundler::URI::InvalidURIError # uri is not canonical uri scheme uri end diff --git a/spec/bundler/fetcher/base_spec.rb b/spec/bundler/fetcher/base_spec.rb index df1245d44d0..02506591f37 100644 --- a/spec/bundler/fetcher/base_spec.rb +++ b/spec/bundler/fetcher/base_spec.rb @@ -36,7 +36,7 @@ class TestClass < described_class; end end describe "#fetch_uri" do - let(:remote_uri_obj) { URI("http://rubygems.org") } + let(:remote_uri_obj) { Bundler::URI("http://rubygems.org") } before { allow(subject).to receive(:remote_uri).and_return(remote_uri_obj) } @@ -49,10 +49,10 @@ class TestClass < described_class; end end context "when the remote uri's host is not rubygems.org" do - let(:remote_uri_obj) { URI("http://otherhost.org") } + let(:remote_uri_obj) { Bundler::URI("http://otherhost.org") } it "should return the remote uri" do - expect(subject.fetch_uri).to eq(URI("http://otherhost.org")) + expect(subject.fetch_uri).to eq(Bundler::URI("http://otherhost.org")) end end diff --git a/spec/bundler/fetcher/compact_index_spec.rb b/spec/bundler/fetcher/compact_index_spec.rb index f5ae6f4d776..c9419d3eb16 100644 --- a/spec/bundler/fetcher/compact_index_spec.rb +++ b/spec/bundler/fetcher/compact_index_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Bundler::Fetcher::CompactIndex do let(:downloader) { double(:downloader) } - let(:display_uri) { URI("http://sampleuri.com") } + let(:display_uri) { Bundler::URI("http://sampleuri.com") } let(:remote) { double(:remote, :cache_slug => "lsjdf", :uri => display_uri) } let(:compact_index) { described_class.new(downloader, remote, display_uri) } diff --git a/spec/bundler/fetcher/dependency_spec.rb b/spec/bundler/fetcher/dependency_spec.rb index 081fdff34de..53249116cdb 100644 --- a/spec/bundler/fetcher/dependency_spec.rb +++ b/spec/bundler/fetcher/dependency_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Bundler::Fetcher::Dependency do let(:downloader) { double(:downloader) } - let(:remote) { double(:remote, :uri => URI("http://localhost:5000")) } + let(:remote) { double(:remote, :uri => Bundler::URI("http://localhost:5000")) } let(:display_uri) { "http://sample_uri.com" } subject { described_class.new(downloader, remote, display_uri) } @@ -258,7 +258,7 @@ end describe "#dependency_api_uri" do - let(:uri) { URI("http://gem-api.com") } + let(:uri) { Bundler::URI("http://gem-api.com") } context "with gem names" do let(:gem_names) { %w[foo bar bundler rubocop] } diff --git a/spec/bundler/fetcher/downloader_spec.rb b/spec/bundler/fetcher/downloader_spec.rb index f985b889820..ba8451d9fa6 100644 --- a/spec/bundler/fetcher/downloader_spec.rb +++ b/spec/bundler/fetcher/downloader_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Bundler::Fetcher::Downloader do let(:connection) { double(:connection) } let(:redirect_limit) { 5 } - let(:uri) { URI("http://www.uri-to-fetch.com/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://www.uri-to-fetch.com/api/v2/endpoint") } let(:options) { double(:options) } subject { described_class.new(connection, redirect_limit) } @@ -41,19 +41,19 @@ before { http_response["location"] = "http://www.redirect-uri.com/api/v2/endpoint" } it "should try to fetch the redirect uri and iterate the # requests counter" do - expect(subject).to receive(:fetch).with(URI("http://www.uri-to-fetch.com/api/v2/endpoint"), options, 0).and_call_original - expect(subject).to receive(:fetch).with(URI("http://www.redirect-uri.com/api/v2/endpoint"), options, 1) + expect(subject).to receive(:fetch).with(Bundler::URI("http://www.uri-to-fetch.com/api/v2/endpoint"), options, 0).and_call_original + expect(subject).to receive(:fetch).with(Bundler::URI("http://www.redirect-uri.com/api/v2/endpoint"), options, 1) subject.fetch(uri, options, counter) end context "when the redirect uri and original uri are the same" do - let(:uri) { URI("ssh://username:password@www.uri-to-fetch.com/api/v2/endpoint") } + let(:uri) { Bundler::URI("ssh://username:password@www.uri-to-fetch.com/api/v2/endpoint") } before { http_response["location"] = "ssh://www.uri-to-fetch.com/api/v1/endpoint" } it "should set the same user and password for the redirect uri" do - expect(subject).to receive(:fetch).with(URI("ssh://username:password@www.uri-to-fetch.com/api/v2/endpoint"), options, 0).and_call_original - expect(subject).to receive(:fetch).with(URI("ssh://username:password@www.uri-to-fetch.com/api/v1/endpoint"), options, 1) + expect(subject).to receive(:fetch).with(Bundler::URI("ssh://username:password@www.uri-to-fetch.com/api/v2/endpoint"), options, 0).and_call_original + expect(subject).to receive(:fetch).with(Bundler::URI("ssh://username:password@www.uri-to-fetch.com/api/v1/endpoint"), options, 1) subject.fetch(uri, options, counter) end end @@ -84,7 +84,7 @@ end context "when the there are credentials provided in the request" do - let(:uri) { URI("http://user:password@www.uri-to-fetch.com") } + let(:uri) { Bundler::URI("http://user:password@www.uri-to-fetch.com") } it "should raise a Bundler::Fetcher::BadAuthenticationError that doesn't contain the password" do expect { subject.fetch(uri, options, counter) }. @@ -102,7 +102,7 @@ end context "when the there are credentials provided in the request" do - let(:uri) { URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") } it "should raise a Bundler::Fetcher::FallbackError that doesn't contain the password" do expect { subject.fetch(uri, options, counter) }. @@ -137,7 +137,7 @@ context "when there is a user provided in the request" do context "and there is also a password provided" do context "that contains cgi escaped characters" do - let(:uri) { URI("http://username:password%24@www.uri-to-fetch.com/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username:password%24@www.uri-to-fetch.com/api/v2/endpoint") } it "should request basic authentication with the username and password" do expect(net_http_get).to receive(:basic_auth).with("username", "password$") @@ -146,7 +146,7 @@ end context "that is all unescaped characters" do - let(:uri) { URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") } it "should request basic authentication with the username and proper cgi compliant password" do expect(net_http_get).to receive(:basic_auth).with("username", "password") subject.request(uri, options) @@ -155,7 +155,7 @@ end context "and there is no password provided" do - let(:uri) { URI("http://username@www.uri-to-fetch.com/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username@www.uri-to-fetch.com/api/v2/endpoint") } it "should request basic authentication with just the user" do expect(net_http_get).to receive(:basic_auth).with("username", nil) @@ -164,7 +164,7 @@ end context "that contains cgi escaped characters" do - let(:uri) { URI("http://username%24@www.uri-to-fetch.com/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username%24@www.uri-to-fetch.com/api/v2/endpoint") } it "should request basic authentication with the proper cgi compliant password user" do expect(net_http_get).to receive(:basic_auth).with("username$", nil) @@ -244,7 +244,7 @@ end context "when the there are credentials provided in the request" do - let(:uri) { URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") } before do allow(net_http_get).to receive(:basic_auth).with("username", "password") end diff --git a/spec/bundler/fetcher/index_spec.rb b/spec/bundler/fetcher/index_spec.rb index d5ededae3ea..5ecd7d9e059 100644 --- a/spec/bundler/fetcher/index_spec.rb +++ b/spec/bundler/fetcher/index_spec.rb @@ -18,7 +18,7 @@ context "error handling" do shared_examples_for "the error is properly handled" do - let(:remote_uri) { URI("http://remote-uri.org") } + let(:remote_uri) { Bundler::URI("http://remote-uri.org") } before do allow(subject).to receive(:remote_uri).and_return(remote_uri) end diff --git a/spec/bundler/fetcher_spec.rb b/spec/bundler/fetcher_spec.rb index 9176eb32f0d..539179db43a 100644 --- a/spec/bundler/fetcher_spec.rb +++ b/spec/bundler/fetcher_spec.rb @@ -3,7 +3,7 @@ require "bundler/fetcher" RSpec.describe Bundler::Fetcher do - let(:uri) { URI("https://example.com") } + let(:uri) { Bundler::URI("https://example.com") } let(:remote) { double("remote", :uri => uri, :original_uri => nil) } subject(:fetcher) { Bundler::Fetcher.new(remote) } @@ -45,7 +45,7 @@ end context "when a rubygems source mirror is set" do - let(:orig_uri) { URI("http://zombo.com") } + let(:orig_uri) { Bundler::URI("http://zombo.com") } let(:remote_with_mirror) do double("remote", :uri => uri, :original_uri => orig_uri, :anonymized_uri => uri) end diff --git a/spec/bundler/mirror_spec.rb b/spec/bundler/mirror_spec.rb index 76b697c4d29..4a8a0c7c484 100644 --- a/spec/bundler/mirror_spec.rb +++ b/spec/bundler/mirror_spec.rb @@ -36,12 +36,12 @@ it "takes a string for the uri but returns an uri object" do mirror.uri = "http://localhost:9292" - expect(mirror.uri).to eq(URI("http://localhost:9292")) + expect(mirror.uri).to eq(Bundler::URI("http://localhost:9292")) end it "takes an uri object for the uri" do - mirror.uri = URI("http://localhost:9293") - expect(mirror.uri).to eq(URI("http://localhost:9293")) + mirror.uri = Bundler::URI("http://localhost:9293") + expect(mirror.uri).to eq(Bundler::URI("http://localhost:9293")) end context "without a uri" do @@ -145,7 +145,7 @@ end RSpec.describe Bundler::Settings::Mirrors do - let(:localhost_uri) { URI("http://localhost:9292") } + let(:localhost_uri) { Bundler::URI("http://localhost:9292") } context "with a just created mirror" do let(:mirrors) do @@ -260,7 +260,7 @@ before { mirrors.parse("mirror.all.fallback_timeout", "true") } it "returns the source uri, not localhost" do - expect(mirrors.for("http://whatever.com").uri).to eq(URI("http://whatever.com/")) + expect(mirrors.for("http://whatever.com").uri).to eq(Bundler::URI("http://whatever.com/")) end end end @@ -270,7 +270,7 @@ context "without a fallback timeout" do it "returns the uri that is not mirrored" do - expect(mirrors.for("http://whatever.com").uri).to eq(URI("http://whatever.com/")) + expect(mirrors.for("http://whatever.com").uri).to eq(Bundler::URI("http://whatever.com/")) end it "returns localhost for rubygems.org" do @@ -282,11 +282,11 @@ before { mirrors.parse("mirror.http://rubygems.org/.fallback_timeout", "true") } it "returns the uri that is not mirrored" do - expect(mirrors.for("http://whatever.com").uri).to eq(URI("http://whatever.com/")) + expect(mirrors.for("http://whatever.com").uri).to eq(Bundler::URI("http://whatever.com/")) end it "returns rubygems.org for rubygems.org" do - expect(mirrors.for("http://rubygems.org/").uri).to eq(URI("http://rubygems.org/")) + expect(mirrors.for("http://rubygems.org/").uri).to eq(Bundler::URI("http://rubygems.org/")) end end end diff --git a/spec/bundler/rubygems_integration_spec.rb b/spec/bundler/rubygems_integration_spec.rb index ce2b1000884..11fa2f4e0d7 100644 --- a/spec/bundler/rubygems_integration_spec.rb +++ b/spec/bundler/rubygems_integration_spec.rb @@ -44,7 +44,7 @@ describe "#download_gem" do let(:bundler_retry) { double(Bundler::Retry) } let(:retry) { double("Bundler::Retry") } - let(:uri) { URI.parse("https://foo.bar") } + let(:uri) { Bundler::URI.parse("https://foo.bar") } let(:path) { Gem.path.first } let(:spec) do spec = Bundler::RemoteSpecification.new("Foo", Gem::Version.new("2.5.2"), @@ -73,7 +73,7 @@ let(:prerelease_specs_response) { Marshal.dump(["prerelease_specs"]) } context "when a rubygems source mirror is set" do - let(:orig_uri) { URI("http://zombo.com") } + let(:orig_uri) { Bundler::URI("http://zombo.com") } let(:remote_with_mirror) { double("remote", :uri => uri, :original_uri => orig_uri) } it "sets the 'X-Gemfile-Source' header containing the original source" do diff --git a/spec/bundler/settings_spec.rb b/spec/bundler/settings_spec.rb index 2a285fdcf37..b83d768477a 100644 --- a/spec/bundler/settings_spec.rb +++ b/spec/bundler/settings_spec.rb @@ -180,7 +180,7 @@ end describe "#mirror_for" do - let(:uri) { URI("https://rubygems.org/") } + let(:uri) { Bundler::URI("https://rubygems.org/") } context "with no configured mirror" do it "returns the original URI" do @@ -193,7 +193,7 @@ end context "with a configured mirror" do - let(:mirror_uri) { URI("https://rubygems-mirror.org/") } + let(:mirror_uri) { Bundler::URI("https://rubygems-mirror.org/") } before { settings.set_local "mirror.https://rubygems.org/", mirror_uri.to_s } @@ -214,7 +214,7 @@ end context "with a file URI" do - let(:mirror_uri) { URI("file:/foo/BAR/baz/qUx/") } + let(:mirror_uri) { Bundler::URI("file:/foo/BAR/baz/qUx/") } it "returns the mirror URI" do expect(settings.mirror_for(uri)).to eq(mirror_uri) @@ -232,7 +232,7 @@ end describe "#credentials_for" do - let(:uri) { URI("https://gemserver.example.org/") } + let(:uri) { Bundler::URI("https://gemserver.example.org/") } let(:credentials) { "username:password" } context "with no configured credentials" do @@ -292,7 +292,7 @@ it "reads older keys without trailing slashes" do settings.set_local "mirror.https://rubygems.org", "http://rubygems-mirror.org" expect(settings.mirror_for("https://rubygems.org/")).to eq( - URI("http://rubygems-mirror.org/") + Bundler::URI("http://rubygems-mirror.org/") ) end diff --git a/spec/bundler/source/rubygems/remote_spec.rb b/spec/bundler/source/rubygems/remote_spec.rb index 52fb4e7f1c1..07ce4f968e9 100644 --- a/spec/bundler/source/rubygems/remote_spec.rb +++ b/spec/bundler/source/rubygems/remote_spec.rb @@ -11,8 +11,8 @@ def remote(uri) allow(Digest(:MD5)).to receive(:hexdigest).with(duck_type(:to_s)) {|string| "MD5HEX(#{string})" } end - let(:uri_no_auth) { URI("https://gems.example.com") } - let(:uri_with_auth) { URI("https://#{credentials}@gems.example.com") } + let(:uri_no_auth) { Bundler::URI("https://gems.example.com") } + let(:uri_with_auth) { Bundler::URI("https://#{credentials}@gems.example.com") } let(:credentials) { "username:password" } context "when the original URI has no credentials" do @@ -89,11 +89,11 @@ def remote(uri) end context "when the original URI has only a username" do - let(:uri) { URI("https://SeCrEt-ToKeN@gem.fury.io/me/") } + let(:uri) { Bundler::URI("https://SeCrEt-ToKeN@gem.fury.io/me/") } describe "#anonymized_uri" do it "returns the URI without username and password" do - expect(remote(uri).anonymized_uri).to eq(URI("https://gem.fury.io/me/")) + expect(remote(uri).anonymized_uri).to eq(Bundler::URI("https://gem.fury.io/me/")) end end @@ -105,9 +105,9 @@ def remote(uri) end context "when a mirror with inline credentials is configured for the URI" do - let(:uri) { URI("https://rubygems.org/") } - let(:mirror_uri_with_auth) { URI("https://username:password@rubygems-mirror.org/") } - let(:mirror_uri_no_auth) { URI("https://rubygems-mirror.org/") } + let(:uri) { Bundler::URI("https://rubygems.org/") } + let(:mirror_uri_with_auth) { Bundler::URI("https://username:password@rubygems-mirror.org/") } + let(:mirror_uri_no_auth) { Bundler::URI("https://rubygems-mirror.org/") } before { Bundler.settings.temporary("mirror.https://rubygems.org/" => mirror_uri_with_auth.to_s) } @@ -131,9 +131,9 @@ def remote(uri) end context "when a mirror with configured credentials is configured for the URI" do - let(:uri) { URI("https://rubygems.org/") } - let(:mirror_uri_with_auth) { URI("https://#{credentials}@rubygems-mirror.org/") } - let(:mirror_uri_no_auth) { URI("https://rubygems-mirror.org/") } + let(:uri) { Bundler::URI("https://rubygems.org/") } + let(:mirror_uri_with_auth) { Bundler::URI("https://#{credentials}@rubygems-mirror.org/") } + let(:mirror_uri_no_auth) { Bundler::URI("https://rubygems-mirror.org/") } before do Bundler.settings.temporary("mirror.https://rubygems.org/" => mirror_uri_no_auth.to_s) diff --git a/spec/bundler/source_list_spec.rb b/spec/bundler/source_list_spec.rb index a78b80ec3ba..93159998c6f 100644 --- a/spec/bundler/source_list_spec.rb +++ b/spec/bundler/source_list_spec.rb @@ -125,8 +125,8 @@ it "adds the provided remote to the beginning of the aggregate source" do source_list.add_rubygems_remote("https://othersource.org") expect(returned_source.remotes).to eq [ - URI("https://othersource.org/"), - URI("https://rubygems.org/"), + Bundler::URI("https://othersource.org/"), + Bundler::URI("https://rubygems.org/"), ] end end diff --git a/spec/bundler/uri_credentials_filter_spec.rb b/spec/bundler/uri_credentials_filter_spec.rb index fe52d16306c..466c1b8594b 100644 --- a/spec/bundler/uri_credentials_filter_spec.rb +++ b/spec/bundler/uri_credentials_filter_spec.rb @@ -16,7 +16,7 @@ let(:credentials) { "oauth_token:x-oauth-basic@" } it "returns the uri without the oauth token" do - expect(subject.credential_filtered_uri(uri).to_s).to eq(URI("https://x-oauth-basic@github.com/company/private-repo").to_s) + expect(subject.credential_filtered_uri(uri).to_s).to eq(Bundler::URI("https://x-oauth-basic@github.com/company/private-repo").to_s) end it_behaves_like "original type of uri is maintained" @@ -26,7 +26,7 @@ let(:credentials) { "oauth_token:x@" } it "returns the uri without the oauth token" do - expect(subject.credential_filtered_uri(uri).to_s).to eq(URI("https://x@github.com/company/private-repo").to_s) + expect(subject.credential_filtered_uri(uri).to_s).to eq(Bundler::URI("https://x@github.com/company/private-repo").to_s) end it_behaves_like "original type of uri is maintained" @@ -37,7 +37,7 @@ let(:credentials) { "username1:hunter3@" } it "returns the uri without the password" do - expect(subject.credential_filtered_uri(uri).to_s).to eq(URI("https://username1@github.com/company/private-repo").to_s) + expect(subject.credential_filtered_uri(uri).to_s).to eq(Bundler::URI("https://username1@github.com/company/private-repo").to_s) end it_behaves_like "original type of uri is maintained" @@ -55,7 +55,7 @@ end context "uri is a uri object" do - let(:uri) { URI("https://#{credentials}github.com/company/private-repo") } + let(:uri) { Bundler::URI("https://#{credentials}github.com/company/private-repo") } it_behaves_like "sensitive credentials in uri are filtered out" end @@ -90,7 +90,7 @@ describe "#credential_filtered_string" do let(:str_to_filter) { "This is a git message containing a uri #{uri}!" } let(:credentials) { "" } - let(:uri) { URI("https://#{credentials}github.com/company/private-repo") } + let(:uri) { Bundler::URI("https://#{credentials}github.com/company/private-repo") } context "with a uri that contains credentials" do let(:credentials) { "oauth_token:x-oauth-basic@" } diff --git a/spec/bundler/vendored_persistent_spec.rb b/spec/bundler/vendored_persistent_spec.rb index b4d68c2ea0e..3ed899dbcfd 100644 --- a/spec/bundler/vendored_persistent_spec.rb +++ b/spec/bundler/vendored_persistent_spec.rb @@ -23,14 +23,14 @@ shared_examples_for "does not warn" do it "does not warn" do allow(Bundler.ui).to receive(:warn).never - subject.warn_old_tls_version_rubygems_connection(URI(uri), connection) + subject.warn_old_tls_version_rubygems_connection(Bundler::URI(uri), connection) end end shared_examples_for "does warn" do |*expected| it "warns" do expect(Bundler.ui).to receive(:warn).with(*expected) - subject.warn_old_tls_version_rubygems_connection(URI(uri), connection) + subject.warn_old_tls_version_rubygems_connection(Bundler::URI(uri), connection) end end diff --git a/spec/realworld/edgecases_spec.rb b/spec/realworld/edgecases_spec.rb index 53d9f9a0261..a91e6a359e4 100644 --- a/spec/realworld/edgecases_spec.rb +++ b/spec/realworld/edgecases_spec.rb @@ -8,7 +8,7 @@ def rubygems_version(name, requirement) require "#{lib_dir}/bundler/source/rubygems/remote" require "#{lib_dir}/bundler/fetcher" rubygem = Bundler.ui.silence do - source = Bundler::Source::Rubygems::Remote.new(URI("https://rubygems.org")) + source = Bundler::Source::Rubygems::Remote.new(Bundler::URI("https://rubygems.org")) fetcher = Bundler::Fetcher.new(source) index = fetcher.specs([#{name.dump}], nil) index.search(Gem::Dependency.new(#{name.dump}, #{requirement.dump})).last diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ba21d22fbda..0a49b46aaaf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,7 +7,7 @@ require "bundler/psyched_yaml" require "bundler/vendored_fileutils" -require "uri" +require "bundler/vendored_uri" require "digest" if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])}