From 5b0abba9317f206913cf2e599d0dac7e9dbd0baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 21 Apr 2021 13:54:29 +0200 Subject: Sync bundler & rubygems --- spec/bundler/install/gemfile/gemspec_spec.rb | 53 ++++++++++++++++++++++++ spec/bundler/install/gemfile/sources_spec.rb | 11 +++-- spec/bundler/install/gems/compact_index_spec.rb | 33 +++++++++++++++ spec/bundler/install/gems/dependency_api_spec.rb | 27 ++++++++++++ spec/bundler/install/gems/post_install_spec.rb | 2 +- spec/bundler/install/prereleases_spec.rb | 6 ++- 6 files changed, 126 insertions(+), 6 deletions(-) (limited to 'spec/bundler/install') diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb index ec6a1d4a4a..32dd7d24b8 100644 --- a/spec/bundler/install/gemfile/gemspec_spec.rb +++ b/spec/bundler/install/gemfile/gemspec_spec.rb @@ -567,4 +567,57 @@ RSpec.describe "bundle install from an existing gemspec" do expect(the_bundle).not_to include_gem "rack" end end + + context "with multiple platforms and resolving for more specific platforms" do + before do + build_lib("chef", :path => tmp.join("chef")) do |s| + s.version = "17.1.17" + s.write "chef-universal-mingw32.gemspec", build_spec("chef", "17.1.17", "universal-mingw32") {|sw| sw.runtime "win32-api", "~> 1.5.3" }.first.to_ruby + end + end + + it "does not remove the platform specific specs from the lockfile when updating" do + build_repo4 do + build_gem "win32-api", "1.5.3" do |s| + s.platform = "universal-mingw32" + end + end + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gemspec :path => "../chef" + G + + initial_lockfile = <<~L + PATH + remote: ../chef + specs: + chef (17.1.17) + chef (17.1.17-universal-mingw32) + win32-api (~> 1.5.3) + + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + win32-api (1.5.3-universal-mingw32) + + PLATFORMS + ruby + x64-mingw32 + x86-mingw32 + + DEPENDENCIES + chef! + + BUNDLED WITH + #{Bundler::VERSION} + L + + lockfile initial_lockfile + + bundle "update" + + expect(lockfile).to eq initial_lockfile + end + end end diff --git a/spec/bundler/install/gemfile/sources_spec.rb b/spec/bundler/install/gemfile/sources_spec.rb index d86bc18311..4f931a493b 100644 --- a/spec/bundler/install/gemfile/sources_spec.rb +++ b/spec/bundler/install/gemfile/sources_spec.rb @@ -90,7 +90,7 @@ RSpec.describe "bundle install with gems on multiple sources" do gem "thin" # comes first to test name sorting gem "rack" end - gem "rack-obama" # shoud come from repo3! + gem "rack-obama" # should come from repo3! G end @@ -596,7 +596,7 @@ RSpec.describe "bundle install with gems on multiple sources" do L end - it "it keeps the currrent lockfile format and upgrades the requested gem when running bundle update with an argument, and warns", :bundler => "< 3" do + it "it keeps the current lockfile format and upgrades the requested gem when running bundle update with an argument, and warns", :bundler => "< 3" do bundle "update concurrent-ruby" expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") @@ -921,7 +921,7 @@ RSpec.describe "bundle install with gems on multiple sources" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" - gem "rack" # shoud come from repo1! + gem "rack" # should come from repo1! G end @@ -974,7 +974,10 @@ RSpec.describe "bundle install with gems on multiple sources" do context "re-resolving" do context "when there is a mix of sources in the gemfile" do before do - build_repo3 + build_repo gem_repo3 do + build_gem "rack" + end + build_lib "path1" build_lib "path2" build_git "git1" diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb index 92cbd26b88..9454508e41 100644 --- a/spec/bundler/install/gems/compact_index_spec.rb +++ b/spec/bundler/install/gems/compact_index_spec.rb @@ -614,6 +614,17 @@ The checksum of /versions does not match the checksum provided by the server! So expect(the_bundle).to include_gems "rack 1.0.0" end + it "passes basic authentication details and strips out creds also in verbose mode" do + gemfile <<-G + source "#{basic_auth_source_uri}" + gem "rack" + G + + bundle :install, :verbose => true, :artifice => "compact_index_basic_authentication" + expect(out).not_to include("#{user}:#{password}") + expect(the_bundle).to include_gems "rack 1.0.0" + end + it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do gemfile <<-G source "#{basic_auth_source_uri}" @@ -815,6 +826,28 @@ The checksum of /versions does not match the checksum provided by the server! So expect(the_bundle).to include_gems "rack 1.0.0" end + it "performs full update if server endpoints serve partial content responses but don't have incremental content and provide no Etag" do + build_repo4 do + build_gem "rack", "0.9.1" + end + + install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + source "#{source_uri}" + gem 'rack', '0.9.1' + G + + update_repo4 do + build_gem "rack", "1.0.0" + end + + install_gemfile <<-G, :artifice => "compact_index_partial_update_no_etag_not_incremental", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + source "#{source_uri}" + gem 'rack', '1.0.0' + G + + expect(the_bundle).to include_gems "rack 1.0.0" + end + it "performs full update of compact index info cache if range is not satisfiable" do gemfile <<-G source "#{source_uri}" diff --git a/spec/bundler/install/gems/dependency_api_spec.rb b/spec/bundler/install/gems/dependency_api_spec.rb index c23323682d..d8d2ac1668 100644 --- a/spec/bundler/install/gems/dependency_api_spec.rb +++ b/spec/bundler/install/gems/dependency_api_spec.rb @@ -586,6 +586,17 @@ RSpec.describe "gemcutter's dependency API" do expect(the_bundle).to include_gems "rack 1.0.0" end + it "passes basic authentication details and strips out creds also in verbose mode" do + gemfile <<-G + source "#{basic_auth_source_uri}" + gem "rack" + G + + bundle :install, :verbose => true, :artifice => "endpoint_basic_authentication" + expect(out).not_to include("#{user}:#{password}") + expect(the_bundle).to include_gems "rack 1.0.0" + end + it "strips http basic authentication creds for modern index" do gemfile <<-G source "#{basic_auth_source_uri}" @@ -630,6 +641,22 @@ RSpec.describe "gemcutter's dependency API" do expect(the_bundle).to include_gems "rack 1.0.0" end + describe "with host including dashes" do + before do + gemfile <<-G + source "http://local-gemserver.test" + gem "rack" + G + end + + it "reads authentication details from a valid ENV variable" do + bundle :install, :artifice => "endpoint_strict_basic_authentication", :env => { "BUNDLE_LOCAL___GEMSERVER__TEST" => "#{user}:#{password}" } + + expect(out).to include("Fetching gem metadata from http://local-gemserver.test") + expect(the_bundle).to include_gems "rack 1.0.0" + end + end + describe "with authentication details in bundle config" do before do gemfile <<-G diff --git a/spec/bundler/install/gems/post_install_spec.rb b/spec/bundler/install/gems/post_install_spec.rb index 3f6d7ce42c..7426f54877 100644 --- a/spec/bundler/install/gems/post_install_spec.rb +++ b/spec/bundler/install/gems/post_install_spec.rb @@ -33,7 +33,7 @@ RSpec.describe "bundle install" do end end - context "when a dependecy includes a post install message" do + context "when a dependency includes a post install message" do it "should display the post install message" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" diff --git a/spec/bundler/install/prereleases_spec.rb b/spec/bundler/install/prereleases_spec.rb index c3f968ad70..629eb89dac 100644 --- a/spec/bundler/install/prereleases_spec.rb +++ b/spec/bundler/install/prereleases_spec.rb @@ -38,7 +38,11 @@ RSpec.describe "bundle install" do describe "when prerelease gems are not available" do it "still works" do - build_repo3 + build_repo gem_repo3 do + build_gem "rack" + end + FileUtils.rm_rf Dir[gem_repo3("prerelease*")] + install_gemfile <<-G source "#{file_uri_for(gem_repo3)}" gem "rack" -- cgit v1.2.3