summaryrefslogtreecommitdiff
path: root/test/rubygems
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems')
-rw-r--r--test/rubygems/helper.rb12
-rw-r--r--test/rubygems/specifications/rubyforge-0.0.1.gemspec21
-rw-r--r--test/rubygems/test_bundled_ca.rb2
-rw-r--r--test/rubygems/test_gem.rb6
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_environment_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_owner_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_rebuild_command.rb145
-rw-r--r--test/rubygems/test_gem_commands_signin_command.rb75
-rw-r--r--test/rubygems/test_gem_commands_yank_command.rb2
-rw-r--r--test/rubygems/test_gem_config_file.rb20
-rw-r--r--test/rubygems/test_gem_dependency.rb10
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb8
-rw-r--r--test/rubygems/test_gem_ext_builder.rb16
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder.rb4
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock12
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock12
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml2
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb2
-rw-r--r--test/rubygems/test_gem_local_remote_options.rb12
-rw-r--r--test/rubygems/test_gem_package_task.rb4
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb29
-rw-r--r--test/rubygems/test_gem_request.rb32
-rw-r--r--test/rubygems/test_gem_request_connection_pools.rb16
-rw-r--r--test/rubygems/test_gem_requirement.rb8
-rw-r--r--test/rubygems/test_gem_resolver.rb2
-rw-r--r--test/rubygems/test_gem_resolver_api_set.rb18
-rw-r--r--test/rubygems/test_gem_resolver_api_specification.rb4
-rw-r--r--test/rubygems/test_gem_resolver_best_set.rb6
-rw-r--r--test/rubygems/test_gem_safe_marshal.rb19
-rw-r--r--test/rubygems/test_gem_safe_yaml.rb24
-rw-r--r--test/rubygems/test_gem_source.rb12
-rw-r--r--test/rubygems/test_gem_source_git.rb2
-rw-r--r--test/rubygems/test_gem_source_list.rb4
-rw-r--r--test/rubygems/test_gem_source_lock.rb2
-rw-r--r--test/rubygems/test_gem_source_subpath_problem.rb2
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb2
-rw-r--r--test/rubygems/test_gem_specification.rb67
-rw-r--r--test/rubygems/test_gem_stream_ui.rb2
-rw-r--r--test/rubygems/test_kernel.rb16
-rw-r--r--test/rubygems/test_rubygems.rb2
-rw-r--r--test/rubygems/test_webauthn_listener.rb20
-rw-r--r--test/rubygems/utilities.rb12
45 files changed, 502 insertions, 178 deletions
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index e6774ded38..af298ec5e0 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -17,7 +17,7 @@ require "pp"
require "rubygems/package"
require "shellwords"
require "tmpdir"
-require "uri"
+require "rubygems/vendor/uri/lib/uri"
require "zlib"
require "benchmark" # stdlib
require_relative "mock_gem_ui"
@@ -349,6 +349,10 @@ class Gem::TestCase < Test::Unit::TestCase
Dir.chdir @tempdir
ENV["HOME"] = @userhome
+ # Remove "RUBY_CODESIGN", which is used by mkmf-generated Makefile to
+ # sign extension bundles on macOS, to avoid trying to find the specified key
+ # from the fake $HOME/Library/Keychains directory.
+ ENV.delete "RUBY_CODESIGN"
Gem.instance_variable_set :@config_file, nil
Gem.instance_variable_set :@user_home, nil
Gem.instance_variable_set :@config_home, nil
@@ -395,7 +399,7 @@ class Gem::TestCase < Test::Unit::TestCase
Gem::RemoteFetcher.fetcher = Gem::FakeFetcher.new
@gem_repo = "http://gems.example.com/"
- @uri = URI.parse @gem_repo
+ @uri = Gem::URI.parse @gem_repo
Gem.sources.replace [@gem_repo]
Gem.searcher = nil
@@ -1353,12 +1357,12 @@ Also, a list:
#
# Yields the +specification+ to the block, if given
- def vendor_gem(name = "a", version = 1)
+ def vendor_gem(name = "a", version = 1, &block)
directory = File.join "vendor", name
FileUtils.mkdir_p directory
- save_gemspec name, version, directory
+ save_gemspec name, version, directory, &block
end
##
diff --git a/test/rubygems/specifications/rubyforge-0.0.1.gemspec b/test/rubygems/specifications/rubyforge-0.0.1.gemspec
index 49619bf569..0421b675a0 100644
--- a/test/rubygems/specifications/rubyforge-0.0.1.gemspec
+++ b/test/rubygems/specifications/rubyforge-0.0.1.gemspec
@@ -1,14 +1,15 @@
# frozen_string_literal: true
Gem::Specification.new do |s|
- s.name = "rubyforge"
- s.version = "0.0.1"
- s.platform = "ruby"
- s.require_paths = ["lib"]
- s.summary = "A very bar gem"
- s.authors = ["unknown"]
- s.license = "MIT"
- s.homepage = "http://example.com"
- s.files = ["README.md"]
- s.rubyforge_project = "abc"
+ s.name = "rubyforge"
+ s.version = "0.0.1"
+ s.platform = "ruby"
+ s.require_paths = ["lib"]
+ s.summary = "A very bar gem"
+ s.authors = ["unknown"]
+ s.license = "MIT"
+ s.homepage = "http://example.com"
+ s.files = ["README.md"]
+ s.rubyforge_project = "abc"
+ s.required_ruby_version = ">= 1.9.3"
end
diff --git a/test/rubygems/test_bundled_ca.rb b/test/rubygems/test_bundled_ca.rb
index 616b18ee83..50e621f22b 100644
--- a/test/rubygems/test_bundled_ca.rb
+++ b/test/rubygems/test_bundled_ca.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require_relative "helper"
-require "rubygems/net/http"
+require "rubygems/vendored_net_http"
require "rubygems/openssl"
unless Gem::HAVE_OPENSSL
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index d4c307978e..244b7749a5 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -133,7 +133,7 @@ class TestGem < Gem::TestCase
def test_self_install_permissions_umask_077
umask = File.umask(0o077)
- assert_self_install_permissions
+ assert_self_install_permissions(data_mode: 0o600)
ensure
File.umask(umask)
end
@@ -151,12 +151,12 @@ class TestGem < Gem::TestCase
Gem::Installer.exec_format = nil
end
- def assert_self_install_permissions(format_executable: false)
+ def assert_self_install_permissions(format_executable: false, data_mode: 0o640)
mask = Gem.win_platform? ? 0o700 : 0o777
options = {
dir_mode: 0o500,
prog_mode: Gem.win_platform? ? 0o410 : 0o510,
- data_mode: 0o640,
+ data_mode: data_mode,
wrappers: true,
format_executable: format_executable,
}
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
index 983cf7b472..d44126d204 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -28,6 +28,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
@gem = util_spec "some_gem" do |s|
s.license = "AGPL-3.0-only"
s.files = ["README.md"]
+ s.required_ruby_version = "2.3.0"
end
@cmd = Gem::Commands::BuildCommand.new
@@ -178,6 +179,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
def test_execute_strict_with_warnings
bad_gem = util_spec "some_bad_gem" do |s|
s.files = ["README.md"]
+ s.required_ruby_version = ">= 1.9.3"
end
gemspec_file = File.join(@tempdir, bad_gem.spec_name)
diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb
index f527574c07..48252d84d4 100644
--- a/test/rubygems/test_gem_commands_environment_command.rb
+++ b/test/rubygems/test_gem_commands_environment_command.rb
@@ -30,7 +30,7 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
assert_match(/USER INSTALLATION DIRECTORY: #{Regexp.escape Gem.user_dir}/,
@ui.output)
assert_match(/RUBYGEMS PREFIX: /, @ui.output)
- assert_match(/RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}/,
+ assert_match(/RUBY EXECUTABLE:.*#{RbConfig::CONFIG["ruby_install_name"]}/,
@ui.output)
assert_match(/GIT EXECUTABLE: #{@cmd.send(:git_path)}/, @ui.output)
assert_match(/SYSTEM CONFIGURATION DIRECTORY:/, @ui.output)
diff --git a/test/rubygems/test_gem_commands_owner_command.rb b/test/rubygems/test_gem_commands_owner_command.rb
index 18558819f4..eddd8afaf5 100644
--- a/test/rubygems/test_gem_commands_owner_command.rb
+++ b/test/rubygems/test_gem_commands_owner_command.rb
@@ -471,7 +471,7 @@ EOF
access_notice = "The existing key doesn't have access of remove_owner on RubyGems.org. Please sign in to update access."
assert_match access_notice, @stub_ui.output
- assert_match "Email:", @stub_ui.output
+ assert_match "Username/email:", @stub_ui.output
assert_match "Password:", @stub_ui.output
assert_match "Added remove_owner scope to the existing API key", @stub_ui.output
assert_match response_success, @stub_ui.output
@@ -495,7 +495,7 @@ EOF
access_notice = "The existing key doesn't have access of add_owner on RubyGems.org. Please sign in to update access."
assert_match access_notice, @stub_ui.output
- assert_match "Email:", @stub_ui.output
+ assert_match "Username/email:", @stub_ui.output
assert_match "Password:", @stub_ui.output
assert_match "Added add_owner scope to the existing API key", @stub_ui.output
assert_match response_success, @stub_ui.output
diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb
index 66cc2303de..a7a18ff4ab 100644
--- a/test/rubygems/test_gem_commands_push_command.rb
+++ b/test/rubygems/test_gem_commands_push_command.rb
@@ -547,7 +547,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
access_notice = "The existing key doesn't have access of push_rubygem on https://rubygems.example. Please sign in to update access."
assert_match mfa_notice, @ui.output
assert_match access_notice, @ui.output
- assert_match "Email:", @ui.output
+ assert_match "Username/email:", @ui.output
assert_match "Password:", @ui.output
assert_match "Added push_rubygem scope to the existing API key", @ui.output
assert_match response_success, @ui.output
@@ -588,7 +588,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
mfa_notice = "You have enabled multi-factor authentication. Please enter OTP code."
assert_match mfa_notice, @ui.output
assert_match "Enter your https://rubygems.example credentials.", @ui.output
- assert_match "Email:", @ui.output
+ assert_match "Username/email:", @ui.output
assert_match "Password:", @ui.output
assert_match "Signed in with API key:", @ui.output
assert_match response_success, @ui.output
diff --git a/test/rubygems/test_gem_commands_rebuild_command.rb b/test/rubygems/test_gem_commands_rebuild_command.rb
new file mode 100644
index 0000000000..5e8c797e2d
--- /dev/null
+++ b/test/rubygems/test_gem_commands_rebuild_command.rb
@@ -0,0 +1,145 @@
+# frozen_string_literal: true
+
+require_relative "helper"
+require "rubygems/commands/build_command"
+require "rubygems/commands/rebuild_command"
+require "rubygems/package"
+
+class TestGemCommandsRebuildCommand < Gem::TestCase
+ def setup
+ super
+
+ readme_file = File.join(@tempdir, "README.md")
+
+ begin
+ umask_orig = File.umask(2)
+ File.open readme_file, "w" do |f|
+ f.write "My awesome gem"
+ end
+ ensure
+ File.umask(umask_orig)
+ end
+
+ @gem_name = "rebuild_test_gem"
+ @gem_version = "1.0.0"
+ @gem = util_spec @gem_name do |s|
+ s.version = @gem_version
+ s.license = "AGPL-3.0"
+ s.files = ["README.md"]
+ end
+ end
+
+ def util_test_build_gem(gem, args)
+ @ui = Gem::MockGemUi.new
+
+ cmd = Gem::Commands::BuildCommand.new
+
+ cmd.options[:args] = args
+ cmd.options[:build_path] = @tempdir
+ use_ui @ui do
+ cmd.execute
+ end
+ gem_file = "#{@gem_name}-#{@gem_version}.gem"
+ output = @ui.output.split "\n"
+ assert_equal " Successfully built RubyGem", output.shift
+ assert_equal " Name: #{@gem_name}", output.shift
+ assert_equal " Version: #{@gem_version}", output.shift
+ assert_equal " File: #{gem_file}", output.shift
+ assert_equal [], output
+
+ gem_file = File.join(@tempdir, gem_file)
+ assert File.exist?(gem_file)
+
+ spec = Gem::Package.new(gem_file).spec
+
+ assert_equal @gem_name, spec.name
+ assert_equal "this is a summary", spec.summary
+ gem_file
+ end
+
+ def util_test_rebuild_gem(gem, args, original_gem_file, gemspec_file, timestamp)
+ @ui = Gem::MockGemUi.new
+
+ cmd = Gem::Commands::RebuildCommand.new
+
+ cmd.options[:args] = args
+ cmd.options[:original_gem_file] = original_gem_file
+ cmd.options[:build_path] = @tempdir
+ cmd.options[:gemspec_file] = gemspec_file
+ use_ui @ui do
+ cmd.execute
+ end
+ gem_file = "#{@gem_name}-#{@gem_version}.gem"
+ output = @ui.output.split "\n"
+
+ assert_equal " Successfully built RubyGem", output.shift
+ assert_equal " Name: #{@gem_name}", output.shift
+ assert_equal " Version: #{@gem_version}", output.shift
+ assert_equal " File: #{gem_file}", output.shift
+ assert_empty output.shift
+ assert_match(/^Built at: .+ \(#{timestamp}\)/, output.shift)
+ original_line = output.shift
+ original = original_line.split(" ")[-1]
+ assert_match(/^Original build saved to: /, original_line)
+ reproduced_line = output.shift
+ reproduced = reproduced_line.split(" ")[-1]
+ assert_match(/^Reproduced build saved to: /, reproduced_line)
+ assert_equal "Working directory: #{@tempdir}", output.shift
+ assert_equal "", output.shift
+ assert_equal "Hash comparison:", output.shift
+ output.shift # " #{old_hash}\t#{old_file}"
+ output.shift # " #{new_hash}\t#{new_file}"
+ assert_empty output.shift
+ assert_equal "SUCCESS - original and rebuild hashes matched", output.shift
+ assert_equal [], output
+
+ assert File.exist?(original)
+ assert File.exist?(reproduced)
+
+ old_spec = Gem::Package.new(original).spec
+ new_spec = Gem::Package.new(reproduced).spec
+
+ assert_equal @gem_name, old_spec.name
+ assert_equal "this is a summary", old_spec.summary
+
+ assert_equal old_spec.name, new_spec.name
+ assert_equal old_spec.summary, new_spec.summary
+
+ reproduced
+ end
+
+ def test_build_is_reproducible
+ # Back up SOURCE_DATE_EPOCH to restore later.
+ epoch = ENV["SOURCE_DATE_EPOCH"]
+
+ gemspec_file = File.join(@tempdir, @gem.spec_name)
+
+ # Initial Build
+
+ # Set SOURCE_DATE_EPOCH to 2001-02-03 04:05:06 -0500.
+ ENV["SOURCE_DATE_EPOCH"] = timestamp = Time.new(2001, 2, 3, 4, 5, 6).to_i.to_s
+ File.write(gemspec_file, @gem.to_ruby)
+ gem_file = util_test_build_gem @gem, [gemspec_file]
+
+ build_contents = File.read(gem_file)
+
+ gem_file_dir = File.dirname(gem_file)
+ gem_file_name = File.basename(gem_file)
+ original_gem_file = File.join(gem_file_dir, "original-" + gem_file_name)
+ File.rename(gem_file, original_gem_file)
+
+ # Rebuild
+
+ # Set SOURCE_DATE_EPOCH to a different value, meaning we are
+ # also testing that `gem rebuild` overrides the value.
+ ENV["SOURCE_DATE_EPOCH"] = Time.new(2007, 8, 9, 10, 11, 12).to_s
+
+ rebuild_gem_file = util_test_rebuild_gem(@gem, [@gem_name, @gem_version], original_gem_file, gemspec_file, timestamp)
+
+ rebuild_contents = File.read(rebuild_gem_file)
+
+ assert_equal build_contents, rebuild_contents
+ ensure
+ ENV["SOURCE_DATE_EPOCH"] = epoch
+ end
+end
diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb
index fd4ffb414a..29e5edceb7 100644
--- a/test/rubygems/test_gem_commands_signin_command.rb
+++ b/test/rubygems/test_gem_commands_signin_command.rb
@@ -85,7 +85,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
headers: { "location" => redirected_uri }
)
Gem::RemoteFetcher.fetcher = fetcher
- ui = Gem::MockGemUi.new("[email protected]\nsecret\n\n\n\n\n\n\n\n\n")
+ ui = Gem::MockGemUi.new("[email protected]\nsecret\n\n\n")
assert_raise Gem::MockGemUi::TermError do
use_ui ui do
@@ -106,51 +106,98 @@ class TestGemCommandsSigninCommand < Gem::TestCase
assert_equal api_key, credentials[:rubygems_api_key]
end
- def test_execute_with_key_name_and_scope
+ def test_execute_with_key_name_default_scope
password = "secret"
api_key = "1234abcd"
fetcher = Gem::RemoteFetcher.fetcher
- key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\ny\n\n\n\n\n\n"
+ key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\n"
util_capture(key_name_ui, nil, api_key, fetcher) { @cmd.execute }
user = ENV["USER"] || ENV["USERNAME"]
assert_match "API Key name [#{Socket.gethostname}-#{user}", key_name_ui.output
+ assert_match "The default access scope is:", key_name_ui.output
+ assert_match "index_rubygems: y", key_name_ui.output
+ assert_match "Do you want to customise scopes? [yN]", key_name_ui.output
+ assert_equal "name=test-key&index_rubygems=true", fetcher.last_request.body
+
+ credentials = load_yaml_file Gem.configuration.credentials_path
+ assert_equal api_key, credentials[:rubygems_api_key]
+ end
+
+ def test_execute_with_key_name_and_custom_scope
+ email = "[email protected]"
+ password = "secret"
+ api_key = "1234abcd"
+ fetcher = Gem::RemoteFetcher.fetcher
+
+ key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\ny\n\n\ny\n\n\n\n\n\n\n"
+ util_capture(key_name_ui, nil, api_key, fetcher) { @cmd.execute }
+
+ user = ENV["USER"] || ENV["USERNAME"]
+
+ assert_match "API Key name [#{Socket.gethostname}-#{user}", key_name_ui.output
+ assert_match "The default access scope is:", key_name_ui.output
+ assert_match "Do you want to customise scopes? [yN]", key_name_ui.output
+ assert_match "show_dashboard (exclusive scope, answering yes will not prompt for other scopes) [yN]", key_name_ui.output
assert_match "index_rubygems [yN]", key_name_ui.output
assert_match "push_rubygem [yN]", key_name_ui.output
assert_match "yank_rubygem [yN]", key_name_ui.output
assert_match "add_owner [yN]", key_name_ui.output
assert_match "remove_owner [yN]", key_name_ui.output
assert_match "access_webhooks [yN]", key_name_ui.output
- assert_match "show_dashboard [yN]", key_name_ui.output
assert_equal "name=test-key&push_rubygem=true", fetcher.last_request.body
credentials = load_yaml_file Gem.configuration.credentials_path
assert_equal api_key, credentials[:rubygems_api_key]
end
- def test_execute_with_key_name_scope_and_mfa_level_of_ui_only
+ def test_execute_with_key_name_and_exclusive_scope
+ email = "[email protected]"
+ password = "secret"
+ api_key = "1234abcd"
+ fetcher = Gem::RemoteFetcher.fetcher
+
+ key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\ny\ny\n"
+ util_capture(key_name_ui, nil, api_key, fetcher) { @cmd.execute }
+
+ user = ENV["USER"] || ENV["USERNAME"]
+
+ assert_match "API Key name [#{Socket.gethostname}-#{user}", key_name_ui.output
+ assert_match "The default access scope is:", key_name_ui.output
+ assert_match "index_rubygems: y", key_name_ui.output
+ assert_match "Do you want to customise scopes? [yN]", key_name_ui.output
+ assert_match "show_dashboard (exclusive scope, answering yes will not prompt for other scopes) [yN]", key_name_ui.output
+ assert_equal "name=test-key&show_dashboard=true", fetcher.last_request.body
+
+ credentials = load_yaml_file Gem.configuration.credentials_path
+ assert_equal api_key, credentials[:rubygems_api_key]
+ end
+
+ def test_execute_with_key_name_custom_scope_and_mfa_level_of_ui_only
password = "secret"
api_key = "1234abcd"
fetcher = Gem::RemoteFetcher.fetcher
mfa_level = "ui_only"
- key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\ny\n\n\n\n\n\ny"
+ key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\ny\n\n\ny\n\n\n\n\n\n\ny"
util_capture(key_name_ui, nil, api_key, fetcher, mfa_level) { @cmd.execute }
user = ENV["USER"] || ENV["USERNAME"]
assert_match "API Key name [#{Socket.gethostname}-#{user}", key_name_ui.output
+ assert_match "The default access scope is:", key_name_ui.output
+ assert_match "Do you want to customise scopes? [yN]", key_name_ui.output
+ assert_match "show_dashboard (exclusive scope, answering yes will not prompt for other scopes) [yN]", key_name_ui.output
assert_match "index_rubygems [yN]", key_name_ui.output
assert_match "push_rubygem [yN]", key_name_ui.output
assert_match "yank_rubygem [yN]", key_name_ui.output
assert_match "add_owner [yN]", key_name_ui.output
assert_match "remove_owner [yN]", key_name_ui.output
assert_match "access_webhooks [yN]", key_name_ui.output
- assert_match "show_dashboard [yN]", key_name_ui.output
assert_match "Would you like to enable MFA for this key? (strongly recommended) [yn]", key_name_ui.output
assert_equal "name=test-key&push_rubygem=true&mfa=true", fetcher.last_request.body
@@ -158,26 +205,28 @@ class TestGemCommandsSigninCommand < Gem::TestCase
assert_equal api_key, credentials[:rubygems_api_key]
end
- def test_execute_with_key_name_scope_and_mfa_level_of_gem_signin
+ def test_execute_with_key_name_custom_scope_and_mfa_level_of_gem_signin
password = "secret"
api_key = "1234abcd"
fetcher = Gem::RemoteFetcher.fetcher
mfa_level = "ui_and_gem_signin"
- key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\ny\n\n\n\n\n\ny"
+ key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\ny\n\n\ny\n\n\n\n\n\n\ny"
util_capture(key_name_ui, nil, api_key, fetcher, mfa_level) { @cmd.execute }
user = ENV["USER"] || ENV["USERNAME"]
assert_match "API Key name [#{Socket.gethostname}-#{user}", key_name_ui.output
+ assert_match "The default access scope is:", key_name_ui.output
+ assert_match "Do you want to customise scopes? [yN]", key_name_ui.output
+ assert_match "show_dashboard (exclusive scope, answering yes will not prompt for other scopes) [yN]", key_name_ui.output
assert_match "index_rubygems [yN]", key_name_ui.output
assert_match "push_rubygem [yN]", key_name_ui.output
assert_match "yank_rubygem [yN]", key_name_ui.output
assert_match "add_owner [yN]", key_name_ui.output
assert_match "remove_owner [yN]", key_name_ui.output
assert_match "access_webhooks [yN]", key_name_ui.output
- assert_match "show_dashboard [yN]", key_name_ui.output
assert_match "Would you like to enable MFA for this key? (strongly recommended) [yn]", key_name_ui.output
assert_equal "name=test-key&push_rubygem=true&mfa=true", fetcher.last_request.body
@@ -207,7 +256,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
api_key = "1234abcd"
fetcher = Gem::RemoteFetcher.fetcher
- key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\ny\n\n\n\n\n\ny"
+ key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\ny\n\n\ny\n\n\n\n\n\n\ny"
# Set the expected response for the Web-API supplied
ENV["RUBYGEMS_HOST"] = host
@@ -221,13 +270,13 @@ class TestGemCommandsSigninCommand < Gem::TestCase
user = ENV["USER"] || ENV["USERNAME"]
assert_match "API Key name [#{Socket.gethostname}-#{user}", key_name_ui.output
+ assert_match "show_dashboard (exclusive scope, answering yes will not prompt for other scopes) [yN]", key_name_ui.output
assert_match "index_rubygems [yN]", key_name_ui.output
assert_match "push_rubygem [yN]", key_name_ui.output
assert_match "yank_rubygem [yN]", key_name_ui.output
assert_match "add_owner [yN]", key_name_ui.output
assert_match "remove_owner [yN]", key_name_ui.output
assert_match "access_webhooks [yN]", key_name_ui.output
- assert_match "show_dashboard [yN]", key_name_ui.output
assert_equal "name=test-key&push_rubygem=true", fetcher.last_request.body
end
@@ -248,7 +297,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
fetcher.data[profile] = profile_response
Gem::RemoteFetcher.fetcher = fetcher
- sign_in_ui = ui_stub || Gem::MockGemUi.new("#{email}\n#{password}\n\n\n\n\n\n\n\n\n")
+ sign_in_ui = ui_stub || Gem::MockGemUi.new("#{email}\n#{password}\n\n\n")
use_ui sign_in_ui do
yield
diff --git a/test/rubygems/test_gem_commands_yank_command.rb b/test/rubygems/test_gem_commands_yank_command.rb
index bfa0d6421f..eb78e3a542 100644
--- a/test/rubygems/test_gem_commands_yank_command.rb
+++ b/test/rubygems/test_gem_commands_yank_command.rb
@@ -291,7 +291,7 @@ class TestGemCommandsYankCommand < Gem::TestCase
access_notice = "The existing key doesn't have access of yank_rubygem on http://example. Please sign in to update access."
assert_match access_notice, @ui.output
- assert_match "Email:", @ui.output
+ assert_match "Username/email:", @ui.output
assert_match "Password:", @ui.output
assert_match "Added yank_rubygem scope to the existing API key", @ui.output
assert_match response_success, @ui.output
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
index ad120d2aaa..c56fa1a3cc 100644
--- a/test/rubygems/test_gem_config_file.rb
+++ b/test/rubygems/test_gem_config_file.rb
@@ -485,6 +485,16 @@ if you believe they were disclosed to a third party.
end
end
+ def test_accept_string_key
+ File.open @temp_conf, "w" do |fp|
+ fp.puts "verbose: false"
+ end
+
+ util_config_file
+
+ assert_equal false, @cfg.verbose
+ end
+
def test_load_ssl_verify_mode_from_config
File.open @temp_conf, "w" do |fp|
fp.puts ":ssl_verify_mode: 1"
@@ -548,4 +558,14 @@ if you believe they were disclosed to a third party.
assert_equal("---\n:foo: \"bar\"\n", actual)
end
+
+ def test_handle_comment
+ yaml = <<~YAML
+ ---
+ :foo: bar # buzz
+ YAML
+
+ actual = Gem::ConfigFile.load_with_rubygems_config_hash(yaml)
+ assert_equal("bar", actual[:foo])
+ end
end
diff --git a/test/rubygems/test_gem_dependency.rb b/test/rubygems/test_gem_dependency.rb
index 6ac03fc0e2..2a989a5551 100644
--- a/test/rubygems/test_gem_dependency.rb
+++ b/test/rubygems/test_gem_dependency.rb
@@ -394,6 +394,16 @@ class TestGemDependency < Gem::TestCase
assert_match "Could not find 'b' (= 2.0) among 1 total gem(s)", e.message
end
+ def test_to_spec_with_only_prereleases
+ a_2_a_1 = util_spec "a", "2.a1"
+ a_2_a_2 = util_spec "a", "2.a2"
+ install_specs a_2_a_1, a_2_a_2
+
+ a_dep = dep "a", ">= 1"
+
+ assert_equal a_2_a_2, a_dep.to_spec
+ end
+
def test_identity
assert_equal dep("a", "= 1").identity, :released
assert_equal dep("a", "= 1.a").identity, :complete
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index ac84a589e5..8999723ba1 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -198,7 +198,7 @@ class TestGemDependencyInstaller < Gem::TestCase
Gem::Specification.reset
FileUtils.mv @a1_gem, @tempdir
- FileUtils.mv a2_gem, @tempdir # not in index
+ FileUtils.mv a2_gem, @tempdir # not in index
FileUtils.mv @b1_gem, @tempdir
inst = nil
@@ -237,7 +237,7 @@ class TestGemDependencyInstaller < Gem::TestCase
Gem::Specification.reset
FileUtils.mv @a1_gem, @tempdir
- FileUtils.mv a2_gem, @tempdir # not in index
+ FileUtils.mv a2_gem, @tempdir # not in index
FileUtils.mv @b1_gem, @tempdir
FileUtils.mv a3_gem, @tempdir
@@ -489,7 +489,7 @@ class TestGemDependencyInstaller < Gem::TestCase
# compact index is available
compact_index_response = Gem::Net::HTTPResponse.new "1.1", 200, "OK"
- compact_index_response.uri = URI("http://gems.example.com")
+ compact_index_response.uri = Gem::URI("http://gems.example.com")
@fetcher.data["http://gems.example.com/"] = compact_index_response
# but private local gem not present there
@@ -621,7 +621,7 @@ class TestGemDependencyInstaller < Gem::TestCase
env = "/\\S+/env" unless Gem.win_platform?
- assert_match(/\A#!#{env} #{RbConfig::CONFIG['ruby_install_name']}\n/,
+ assert_match(/\A#!#{env} #{RbConfig::CONFIG["ruby_install_name"]}\n/,
File.read(File.join(@gemhome, "bin", "a_bin")))
end
diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb
index 927e2f45e4..baf6140468 100644
--- a/test/rubygems/test_gem_ext_builder.rb
+++ b/test/rubygems/test_gem_ext_builder.rb
@@ -48,11 +48,11 @@ install:
results = results.join("\n").b
- assert_match(/DESTDIR\\=#{ENV['DESTDIR']} clean$/, results)
- assert_match(/DESTDIR\\=#{ENV['DESTDIR']}$/, results)
- assert_match(/DESTDIR\\=#{ENV['DESTDIR']} install$/, results)
+ assert_match(/DESTDIR\\=#{ENV["DESTDIR"]} clean$/, results)
+ assert_match(/DESTDIR\\=#{ENV["DESTDIR"]}$/, results)
+ assert_match(/DESTDIR\\=#{ENV["DESTDIR"]} install$/, results)
- unless /nmake/.match?(results)
+ unless results.include?("nmake")
assert_match(/^clean: destination$/, results)
assert_match(/^all: destination$/, results)
assert_match(/^install: destination$/, results)
@@ -77,12 +77,14 @@ install:
results = results.join("\n").b
- assert_match(/DESTDIR\\=#{ENV['DESTDIR']} clean$/, results)
- assert_match(/DESTDIR\\=#{ENV['DESTDIR']}$/, results)
- assert_match(/DESTDIR\\=#{ENV['DESTDIR']} install$/, results)
+ assert_match(/DESTDIR\\=#{ENV["DESTDIR"]} clean$/, results)
+ assert_match(/DESTDIR\\=#{ENV["DESTDIR"]}$/, results)
+ assert_match(/DESTDIR\\=#{ENV["DESTDIR"]} install$/, results)
end
def test_custom_make_with_options
+ pend "native windows platform only provides nmake" if vc_windows?
+
ENV["make"] = "make V=1"
results = []
File.open File.join(@ext, "Makefile"), "w" do |io|
diff --git a/test/rubygems/test_gem_ext_cargo_builder.rb b/test/rubygems/test_gem_ext_cargo_builder.rb
index 0d893f5424..5faf3e2480 100644
--- a/test/rubygems/test_gem_ext_cargo_builder.rb
+++ b/test/rubygems/test_gem_ext_cargo_builder.rb
@@ -152,12 +152,16 @@ class TestGemExtCargoBuilder < Gem::TestCase
require "fiddle"
dylib_handle = Fiddle.dlopen bundle
assert_nothing_raised { dylib_handle[name] }
+ ensure
+ dylib_handle&.close
end
def refute_ffi_handle(bundle, name)
require "fiddle"
dylib_handle = Fiddle.dlopen bundle
assert_raise { dylib_handle[name] }
+ ensure
+ dylib_handle&.close
end
def replace_in_rust_file(name, from, to)
diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock b/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock
index aa9587b231..34db31f61c 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock
+++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock
@@ -152,18 +152,18 @@ dependencies = [
[[package]]
name = "rb-sys"
-version = "0.9.86"
+version = "0.9.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7285f2a7b92f58ab198e3fd59a71d2861478f9c4642f41e83582385818941697"
+checksum = "eb81203e271055178603e243fee397f5f4aac125bcd20036279683fb1445a899"
dependencies = [
"rb-sys-build",
]
[[package]]
name = "rb-sys-build"
-version = "0.9.86"
+version = "0.9.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "71583945f94dabb6c0dfa63f1b71e929c1901e1e288ef3739ab8bed3b7069550"
+checksum = "9de9403a6aac834e7c9534575cb14188b6b5b99bafe475d18d838d44fbc27d31"
dependencies = [
"bindgen",
"lazy_static",
@@ -205,9 +205,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]]
name = "shlex"
-version = "1.1.0"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "syn"
diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml b/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml
index 56a4188f15..00a48df5d5 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml
+++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2021"
crate-type = ["cdylib"]
[dependencies]
-rb-sys = "0.9.86"
+rb-sys = "0.9.91"
diff --git a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
index 8c394aec20..f96b144293 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
+++ b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
@@ -145,18 +145,18 @@ dependencies = [
[[package]]
name = "rb-sys"
-version = "0.9.86"
+version = "0.9.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7285f2a7b92f58ab198e3fd59a71d2861478f9c4642f41e83582385818941697"
+checksum = "eb81203e271055178603e243fee397f5f4aac125bcd20036279683fb1445a899"
dependencies = [
"rb-sys-build",
]
[[package]]
name = "rb-sys-build"
-version = "0.9.86"
+version = "0.9.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "71583945f94dabb6c0dfa63f1b71e929c1901e1e288ef3739ab8bed3b7069550"
+checksum = "9de9403a6aac834e7c9534575cb14188b6b5b99bafe475d18d838d44fbc27d31"
dependencies = [
"bindgen",
"lazy_static",
@@ -205,9 +205,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]]
name = "shlex"
-version = "1.1.0"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "syn"
diff --git a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml
index 39b2ae3919..dca8146394 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml
+++ b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2021"
crate-type = ["cdylib"]
[dependencies]
-rb-sys = "0.9.86"
+rb-sys = "0.9.91"
diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb
index 31933c9419..a3236e6276 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -306,7 +306,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
ENV["RUBYGEMS_HOST"] = @fetcher.host
Gem::RemoteFetcher.fetcher = @fetcher
- @sign_in_ui = Gem::MockGemUi.new("#{email}\n#{password}\n\n\n\n\n\n\n\n\n" + extra_input)
+ @sign_in_ui = Gem::MockGemUi.new("#{email}\n#{password}\n\n\n" + extra_input)
use_ui @sign_in_ui do
if args.length > 0
diff --git a/test/rubygems/test_gem_local_remote_options.rb b/test/rubygems/test_gem_local_remote_options.rb
index b84e70e8b8..cea9cde82b 100644
--- a/test/rubygems/test_gem_local_remote_options.rb
+++ b/test/rubygems/test_gem_local_remote_options.rb
@@ -34,7 +34,7 @@ class TestGemLocalRemoteOptions < Gem::TestCase
def test_clear_sources_option
@cmd.add_local_remote_options
- s = URI.parse "http://only-gems.example.com/"
+ s = Gem::URI.parse "http://only-gems.example.com/"
@cmd.handle_options %W[--clear-sources --source #{s}]
assert_equal [s.to_s], Gem.sources
@@ -76,10 +76,10 @@ class TestGemLocalRemoteOptions < Gem::TestCase
def test_source_option
@cmd.add_source_option
- s1 = URI.parse "http://more-gems.example.com/"
- s2 = URI.parse "http://even-more-gems.example.com/"
- s3 = URI.parse "http://other-gems.example.com/some_subdir"
- s4 = URI.parse "http://more-gems.example.com/" # Intentional duplicate
+ s1 = Gem::URI.parse "http://more-gems.example.com/"
+ s2 = Gem::URI.parse "http://even-more-gems.example.com/"
+ s3 = Gem::URI.parse "http://other-gems.example.com/some_subdir"
+ s4 = Gem::URI.parse "http://more-gems.example.com/" # Intentional duplicate
original_sources = Gem.sources.dup
@@ -97,7 +97,7 @@ class TestGemLocalRemoteOptions < Gem::TestCase
original_sources = Gem.sources.dup
- source = URI.parse "http://more-gems.example.com/"
+ source = Gem::URI.parse "http://more-gems.example.com/"
@cmd.handle_options %W[-s #{source}]
original_sources << source
diff --git a/test/rubygems/test_gem_package_task.rb b/test/rubygems/test_gem_package_task.rb
index f0aaa3f082..6f322ad61e 100644
--- a/test/rubygems/test_gem_package_task.rb
+++ b/test/rubygems/test_gem_package_task.rb
@@ -9,10 +9,6 @@ rescue LoadError => e
raise unless e.path == "rake/packagetask"
end
-unless defined?(Rake::PackageTask)
- warn "Skipping Gem::PackageTask tests. rake not found."
-end
-
class TestGemPackageTask < Gem::TestCase
def test_gem_package
original_rake_fileutils_verbosity = RakeFileUtils.verbose_flag
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index 42565b0b16..e71b2f5ff6 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -162,7 +162,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_cache_update_path
- uri = URI "http://example/file"
+ uri = Gem::URI "http://example/file"
path = File.join @tempdir, "file"
fetcher = util_fuck_with_fetcher "hello"
@@ -176,7 +176,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_cache_update_path_with_utf8_internal_encoding
with_internal_encoding("UTF-8") do
- uri = URI "http://example/file"
+ uri = Gem::URI "http://example/file"
path = File.join @tempdir, "file"
data = String.new("\xC8").force_encoding(Encoding::BINARY)
@@ -190,7 +190,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_cache_update_path_no_update
- uri = URI "http://example/file"
+ uri = Gem::URI "http://example/file"
path = File.join @tempdir, "file"
fetcher = util_fuck_with_fetcher "hello"
@@ -613,7 +613,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
nil
end
- assert_nil fetcher.fetch_path(URI.parse(@gem_repo), Time.at(0))
+ assert_nil fetcher.fetch_path(Gem::URI.parse(@gem_repo), Time.at(0))
end
def test_implicit_no_proxy
@@ -671,7 +671,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
res
end
- data = fetcher.fetch_http URI.parse(url)
+ data = fetcher.fetch_http Gem::URI.parse(url)
assert_equal "real_path", data
end
@@ -689,7 +689,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
e = assert_raise Gem::RemoteFetcher::FetchError do
- fetcher.fetch_http URI.parse(url)
+ fetcher.fetch_http Gem::URI.parse(url)
end
assert_equal "too many redirects (#{url})", e.message
@@ -706,7 +706,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
e = assert_raise Gem::RemoteFetcher::FetchError do
- fetcher.fetch_http URI.parse(url)
+ fetcher.fetch_http Gem::URI.parse(url)
end
assert_equal "redirecting but no redirect location was given (#{url})", e.message
@@ -714,7 +714,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_http_with_additional_headers
ENV["http_proxy"] = @proxy_uri
- ENV["no_proxy"] = URI.parse(@server_uri).host
+ ENV["no_proxy"] = Gem::URI.parse(@server_uri).host
fetcher = Gem::RemoteFetcher.new nil, nil, { "X-Captain" => "murphy" }
@fetcher = fetcher
assert_equal "murphy", fetcher.fetch_path(@server_uri)
@@ -747,7 +747,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
s3_uri_signer
end
- data = fetcher.fetch_s3 URI.parse(url)
+ data = fetcher.fetch_s3 Gem::URI.parse(url)
assert_equal "https://my-bucket.s3.#{region}.amazonaws.com/gems/specs.4.8.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=testuser%2F20190624%2F#{region}%2Fs3%2Faws4_request&X-Amz-Date=20190624T050641Z&X-Amz-Expires=86400#{token ? "&X-Amz-Security-Token=" + token : ""}&X-Amz-SignedHeaders=host&X-Amz-Signature=#{signature}", $fetched_uri.to_s
assert_equal "success", data
@@ -893,7 +893,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
@fetcher = fetcher
e = assert_raise Gem::RemoteFetcher::FetchError do
- fetcher.fetch_s3 URI.parse(url)
+ fetcher.fetch_s3 Gem::URI.parse(url)
end
assert_match expected_message, e.message
@@ -936,7 +936,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_observe_no_proxy_env_single_host
use_ui @stub_ui do
ENV["http_proxy"] = @proxy_uri
- ENV["no_proxy"] = URI.parse(@server_uri).host
+ ENV["no_proxy"] = Gem::URI.parse(@server_uri).host
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
assert_data_from_server fetcher.fetch_path(@server_uri)
@@ -946,7 +946,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_observe_no_proxy_env_list
use_ui @stub_ui do
ENV["http_proxy"] = @proxy_uri
- ENV["no_proxy"] = "fakeurl.com, #{URI.parse(@server_uri).host}"
+ ENV["no_proxy"] = "fakeurl.com, #{Gem::URI.parse(@server_uri).host}"
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
assert_data_from_server fetcher.fetch_path(@server_uri)
@@ -958,7 +958,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
@fetcher = fetcher
assert_throws :block_called do
- fetcher.request URI("http://example"), Gem::Net::HTTP::Get do |req|
+ fetcher.request Gem::URI("http://example"), Gem::Net::HTTP::Get do |req|
assert_kind_of Gem::Net::HTTPGenericRequest, req
throw :block_called
end
@@ -1129,8 +1129,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
@ssl_server_thread.kill.join
@ssl_server_thread = nil
end
- utils = WEBrick::Utils # TimeoutHandler is since 1.9
- utils::TimeoutHandler.terminate if defined?(utils::TimeoutHandler.terminate)
+ WEBrick::Utils::TimeoutHandler.terminate
end
def normal_server_port
diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb
index d5eb245352..5e9b264dac 100644
--- a/test/rubygems/test_gem_request.rb
+++ b/test/rubygems/test_gem_request.rb
@@ -34,7 +34,7 @@ class TestGemRequest < Gem::TestCase
super
@proxy_uri = "http://localhost:1234"
- @uri = URI("http://example")
+ @uri = Gem::URI("http://example")
@request = make_request @uri, nil, nil, nil
end
@@ -56,7 +56,7 @@ class TestGemRequest < Gem::TestCase
def test_initialize_proxy_URI
proxy_uri = "http://proxy.example.com"
- request = make_request @uri, nil, nil, URI(proxy_uri)
+ request = make_request @uri, nil, nil, Gem::URI(proxy_uri)
assert_equal proxy_uri, request.proxy_uri.to_s
end
@@ -77,18 +77,18 @@ class TestGemRequest < Gem::TestCase
def test_initialize_proxy_ENV_https
ENV["https_proxy"] = @proxy_uri
- request = make_request URI("https://example"), nil, nil, nil
+ request = make_request Gem::URI("https://example"), nil, nil, nil
proxy = request.proxy_uri
- assert_equal URI(@proxy_uri), proxy
+ assert_equal Gem::URI(@proxy_uri), proxy
end
def test_proxy_ENV
ENV["http_proxy"] = "http://proxy"
ENV["https_proxy"] = ""
- request = make_request URI("https://example"), nil, nil, nil
+ request = make_request Gem::URI("https://example"), nil, nil, nil
proxy = request.proxy_uri
@@ -102,7 +102,7 @@ class TestGemRequest < Gem::TestCase
def self.get_cert_files
[TestGemRequest::PUBLIC_CERT_FILE]
end
- end.create_with_proxy URI("https://example"), nil, nil, nil
+ end.create_with_proxy Gem::URI("https://example"), nil, nil, nil
Gem::Request.configure_connection_for_https connection, request.cert_files
@@ -121,7 +121,7 @@ class TestGemRequest < Gem::TestCase
def self.get_cert_files
[TestGemRequest::PUBLIC_CERT_FILE]
end
- end.create_with_proxy URI("https://example"), nil, nil, nil
+ end.create_with_proxy Gem::URI("https://example"), nil, nil, nil
Gem::Request.configure_connection_for_https connection, request.cert_files
@@ -138,17 +138,17 @@ class TestGemRequest < Gem::TestCase
request = make_request @uri, nil, nil, nil
proxy = request.proxy_uri
- assert_equal URI(@proxy_uri), proxy
+ assert_equal Gem::URI(@proxy_uri), proxy
end
def test_get_proxy_from_env_https
ENV["https_proxy"] = @proxy_uri
- uri = URI("https://example")
+ uri = Gem::URI("https://example")
request = make_request uri, nil, nil, nil
proxy = request.proxy_uri
- assert_equal URI(@proxy_uri), proxy
+ assert_equal Gem::URI(@proxy_uri), proxy
end
def test_get_proxy_from_env_domain
@@ -191,7 +191,7 @@ class TestGemRequest < Gem::TestCase
end
def test_fetch
- uri = Gem::Uri.new(URI.parse("#{@gem_repo}/specs.#{Gem.marshal_version}"))
+ uri = Gem::Uri.new(Gem::URI.parse("#{@gem_repo}/specs.#{Gem.marshal_version}"))
response = util_stub_net_http(body: :junk, code: 200) do
@request = make_request(uri, Gem::Net::HTTP::Get, nil, nil)
@@ -204,7 +204,7 @@ class TestGemRequest < Gem::TestCase
def test_fetch_basic_auth
Gem.configuration.verbose = :really
- uri = Gem::Uri.new(URI.parse("https://user:[email protected]/specs.#{Gem.marshal_version}"))
+ uri = Gem::Uri.new(Gem::URI.parse("https://user:[email protected]/specs.#{Gem.marshal_version}"))
conn = util_stub_net_http(body: :junk, code: 200) do |c|
use_ui @ui do
@request = make_request(uri, Gem::Net::HTTP::Get, nil, nil)
@@ -220,7 +220,7 @@ class TestGemRequest < Gem::TestCase
def test_fetch_basic_auth_encoded
Gem.configuration.verbose = :really
- uri = Gem::Uri.new(URI.parse("https://user:%7BDEScede%[email protected]/specs.#{Gem.marshal_version}"))
+ uri = Gem::Uri.new(Gem::URI.parse("https://user:%7BDEScede%[email protected]/specs.#{Gem.marshal_version}"))
conn = util_stub_net_http(body: :junk, code: 200) do |c|
use_ui @ui do
@@ -237,7 +237,7 @@ class TestGemRequest < Gem::TestCase
def test_fetch_basic_oauth_encoded
Gem.configuration.verbose = :really
- uri = Gem::Uri.new(URI.parse("https://%7BDEScede%7Dpass:[email protected]/specs.#{Gem.marshal_version}"))
+ uri = Gem::Uri.new(Gem::URI.parse("https://%7BDEScede%7Dpass:[email protected]/specs.#{Gem.marshal_version}"))
conn = util_stub_net_http(body: :junk, code: 200) do |c|
use_ui @ui do
@@ -253,7 +253,7 @@ class TestGemRequest < Gem::TestCase
end
def test_fetch_head
- uri = Gem::Uri.new(URI.parse("#{@gem_repo}/specs.#{Gem.marshal_version}"))
+ uri = Gem::Uri.new(Gem::URI.parse("#{@gem_repo}/specs.#{Gem.marshal_version}"))
response = util_stub_net_http(body: "", code: 200) do |_conn|
@request = make_request(uri, Gem::Net::HTTP::Get, nil, nil)
@request.fetch
@@ -264,7 +264,7 @@ class TestGemRequest < Gem::TestCase
end
def test_fetch_unmodified
- uri = Gem::Uri.new(URI.parse("#{@gem_repo}/specs.#{Gem.marshal_version}"))
+ uri = Gem::Uri.new(Gem::URI.parse("#{@gem_repo}/specs.#{Gem.marshal_version}"))
t = Time.utc(2013, 1, 2, 3, 4, 5)
conn, response = util_stub_net_http(body: "", code: 304) do |c|
@request = make_request(uri, Gem::Net::HTTP::Get, t, nil)
diff --git a/test/rubygems/test_gem_request_connection_pools.rb b/test/rubygems/test_gem_request_connection_pools.rb
index 4e1e7de07b..966447bff6 100644
--- a/test/rubygems/test_gem_request_connection_pools.rb
+++ b/test/rubygems/test_gem_request_connection_pools.rb
@@ -2,7 +2,7 @@
require_relative "helper"
require "rubygems/request"
-require "rubygems/timeout"
+require "rubygems/vendored_timeout"
class TestGemRequestConnectionPool < Gem::TestCase
class FakeHttp
@@ -18,7 +18,7 @@ class TestGemRequestConnectionPool < Gem::TestCase
@old_client = Gem::Request::ConnectionPools.client
Gem::Request::ConnectionPools.client = FakeHttp
- @proxy = URI "http://proxy.example"
+ @proxy = Gem::URI "http://proxy.example"
end
def teardown
@@ -49,7 +49,7 @@ class TestGemRequestConnectionPool < Gem::TestCase
end
def test_checkout_same_connection
- uri = URI.parse("http://example/some_endpoint")
+ uri = Gem::URI.parse("http://example/some_endpoint")
pools = Gem::Request::ConnectionPools.new nil, []
pool = pools.pool_for uri
@@ -99,7 +99,7 @@ class TestGemRequestConnectionPool < Gem::TestCase
def test_net_http_args
pools = Gem::Request::ConnectionPools.new nil, []
- net_http_args = pools.send :net_http_args, URI("http://example"), nil
+ net_http_args = pools.send :net_http_args, Gem::URI("http://example"), nil
assert_equal ["example", 80], net_http_args
end
@@ -107,7 +107,7 @@ class TestGemRequestConnectionPool < Gem::TestCase
def test_net_http_args_ipv6
pools = Gem::Request::ConnectionPools.new nil, []
- net_http_args = pools.send :net_http_args, URI("http://[::1]"), nil
+ net_http_args = pools.send :net_http_args, Gem::URI("http://[::1]"), nil
assert_equal ["::1", 80], net_http_args
end
@@ -115,7 +115,7 @@ class TestGemRequestConnectionPool < Gem::TestCase
def test_net_http_args_proxy
pools = Gem::Request::ConnectionPools.new nil, []
- net_http_args = pools.send :net_http_args, URI("http://example"), @proxy
+ net_http_args = pools.send :net_http_args, Gem::URI("http://example"), @proxy
assert_equal ["example", 80, "proxy.example", 80, nil, nil], net_http_args
end
@@ -126,7 +126,7 @@ class TestGemRequestConnectionPool < Gem::TestCase
pools = Gem::Request::ConnectionPools.new nil, []
- net_http_args = pools.send :net_http_args, URI("http://example"), @proxy
+ net_http_args = pools.send :net_http_args, Gem::URI("http://example"), @proxy
assert_equal ["example", 80, nil, nil], net_http_args
ensure
@@ -134,7 +134,7 @@ class TestGemRequestConnectionPool < Gem::TestCase
end
def test_thread_waits_for_connection
- uri = URI.parse("http://example/some_endpoint")
+ uri = Gem::URI.parse("http://example/some_endpoint")
pools = Gem::Request::ConnectionPools.new nil, []
pool = pools.pool_for uri
diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb
index 57d143180f..de0d11ec00 100644
--- a/test/rubygems/test_gem_requirement.rb
+++ b/test/rubygems/test_gem_requirement.rb
@@ -12,6 +12,14 @@ class TestGemRequirement < Gem::TestCase
assert_equal [[">=", v(1)], ["<", v(2)]], r.requirements
end
+ def test_initialize_copy
+ r = req("= 1.2")
+ r2 = r.dup
+
+ assert_equal r.requirements, r2.requirements
+ refute_same r.requirements, r2.requirements
+ end
+
def test_equals2
r = req "= 1.2"
assert_equal r, r.dup
diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb
index c2bdc5332c..b7dadda708 100644
--- a/test/rubygems/test_gem_resolver.rb
+++ b/test/rubygems/test_gem_resolver.rb
@@ -8,7 +8,7 @@ class TestGemResolver < Gem::TestCase
end
def set(*specs)
- source = Gem::Source.new URI @gem_repo
+ source = Gem::Source.new Gem::URI @gem_repo
specs = specs.map do |spec|
Gem::Resolver::SpecSpecification.new nil, spec, source
diff --git a/test/rubygems/test_gem_resolver_api_set.rb b/test/rubygems/test_gem_resolver_api_set.rb
index c0c6d82f19..5781cf37d2 100644
--- a/test/rubygems/test_gem_resolver_api_set.rb
+++ b/test/rubygems/test_gem_resolver_api_set.rb
@@ -6,30 +6,30 @@ class TestGemResolverAPISet < Gem::TestCase
def setup
super
- @dep_uri = URI "#{@gem_repo}info/"
+ @dep_uri = Gem::URI "#{@gem_repo}info/"
end
def test_initialize
set = Gem::Resolver::APISet.new
- assert_equal URI("https://index.rubygems.org/info/"), set.dep_uri
- assert_equal URI("https://index.rubygems.org/"), set.uri
- assert_equal Gem::Source.new(URI("https://index.rubygems.org")), set.source
+ assert_equal Gem::URI("https://index.rubygems.org/info/"), set.dep_uri
+ assert_equal Gem::URI("https://index.rubygems.org/"), set.uri
+ assert_equal Gem::Source.new(Gem::URI("https://index.rubygems.org")), set.source
end
def test_initialize_deeper_uri
set = Gem::Resolver::APISet.new "https://rubygemsserver.com/mygems/info"
- assert_equal URI("https://rubygemsserver.com/mygems/info"), set.dep_uri
- assert_equal URI("https://rubygemsserver.com/"), set.uri
- assert_equal Gem::Source.new(URI("https://rubygemsserver.com/")), set.source
+ assert_equal Gem::URI("https://rubygemsserver.com/mygems/info"), set.dep_uri
+ assert_equal Gem::URI("https://rubygemsserver.com/"), set.uri
+ assert_equal Gem::Source.new(Gem::URI("https://rubygemsserver.com/")), set.source
end
def test_initialize_uri
set = Gem::Resolver::APISet.new @dep_uri
- assert_equal URI("#{@gem_repo}info/"), set.dep_uri
- assert_equal URI(@gem_repo.to_s), set.uri
+ assert_equal Gem::URI("#{@gem_repo}info/"), set.dep_uri
+ assert_equal Gem::URI(@gem_repo.to_s), set.uri
end
def test_find_all
diff --git a/test/rubygems/test_gem_resolver_api_specification.rb b/test/rubygems/test_gem_resolver_api_specification.rb
index 49f3cc81d0..2119d73478 100644
--- a/test/rubygems/test_gem_resolver_api_specification.rb
+++ b/test/rubygems/test_gem_resolver_api_specification.rb
@@ -124,7 +124,7 @@ class TestGemResolverAPISpecification < Gem::TestCase
fetcher.spec "a", 1
end
- dep_uri = URI(@gem_repo) + "info"
+ dep_uri = Gem::URI(@gem_repo) + "info"
set = Gem::Resolver::APISet.new dep_uri
data = {
name: "a",
@@ -148,7 +148,7 @@ class TestGemResolverAPISpecification < Gem::TestCase
end
end
- dep_uri = URI(@gem_repo) + "info"
+ dep_uri = Gem::URI(@gem_repo) + "info"
set = Gem::Resolver::APISet.new dep_uri
data = {
name: "j",
diff --git a/test/rubygems/test_gem_resolver_best_set.rb b/test/rubygems/test_gem_resolver_best_set.rb
index 80aa883364..8a750cdf8f 100644
--- a/test/rubygems/test_gem_resolver_best_set.rb
+++ b/test/rubygems/test_gem_resolver_best_set.rb
@@ -34,7 +34,7 @@ class TestGemResolverBestSet < Gem::TestCase
set = Gem::Resolver::BestSet.new
- api_uri = URI(@gem_repo)
+ api_uri = Gem::URI(@gem_repo)
set.sets << Gem::Resolver::APISet.new(api_uri)
@@ -94,7 +94,7 @@ class TestGemResolverBestSet < Gem::TestCase
def test_replace_failed_api_set
set = Gem::Resolver::BestSet.new
- api_uri = URI(@gem_repo) + "./info/"
+ api_uri = Gem::URI(@gem_repo) + "./info/"
api_set = Gem::Resolver::APISet.new api_uri
set.sets << api_set
@@ -131,7 +131,7 @@ class TestGemResolverBestSet < Gem::TestCase
def test_replace_failed_api_set_uri_with_credentials
set = Gem::Resolver::BestSet.new
- api_uri = URI(@gem_repo) + "./info/"
+ api_uri = Gem::URI(@gem_repo) + "./info/"
api_uri.user = "user"
api_uri.password = "pass"
api_set = Gem::Resolver::APISet.new api_uri
diff --git a/test/rubygems/test_gem_safe_marshal.rb b/test/rubygems/test_gem_safe_marshal.rb
index 7f56d8d290..ebb000a9ef 100644
--- a/test/rubygems/test_gem_safe_marshal.rb
+++ b/test/rubygems/test_gem_safe_marshal.rb
@@ -120,7 +120,7 @@ class TestGemSafeMarshal < Gem::TestCase
define_method("test_safe_load_marshal Time 2001-01-01 07:59:59 UTC") { assert_safe_load_marshal "\x04\bIu:\tTime\r'@\x19\xC0\x00\x00\xB0\xEF\x06:\tzoneI\"\bUTC\x06:\x06EF", additional_methods: [:ctime, :to_f, :to_r, :to_i, :zone, :subsec, :instance_variables, :dst?, :to_a] }
define_method("test_safe_load_marshal Time 2001-01-01 11:59:59 +0400") { assert_safe_load_marshal "\x04\bIu:\tTime\r'@\x19\x80\x00\x00\xB0\xEF\a:\voffseti\x02@8:\tzone0", additional_methods: [:ctime, :to_f, :to_r, :to_i, :zone, :subsec, :instance_variables, :dst?, :to_a] }
define_method("test_safe_load_marshal Time 2023-08-24 10:10:39.09565 -0700") { assert_safe_load_marshal "\x04\bIu:\tTime\r\x11\xDF\x1E\x80\xA2uq*\a:\voffseti\xFE\x90\x9D:\tzoneI\"\bPDT\x06:\x06EF" }
- define_method("test_safe_load_marshal Time 2023-08-24 10:10:39.098453 -0700") { assert_safe_load_marshal "\x04\bIu:\tTime\r\x11\xDF\x1E\x80\x95\x80q*\b:\n@typeI\"\fruntime\x06:\x06ET:\voffseti\xFE\x90\x9D:\tzoneI\"\bPDT\x06;\aF", permitted_ivars: { "Time" => %w[@type offset zone], "String" => %w[E @debug_created_info] }, marshal_dump_equality: (RUBY_ENGINE != "truffleruby" || RUBY_ENGINE_VERSION >= "23") }
+ define_method("test_safe_load_marshal Time 2023-08-24 10:10:39.098453 -0700") { assert_safe_load_marshal "\x04\bIu:\tTime\r\x11\xDF\x1E\x80\x95\x80q*\b:\n@typeI\"\fruntime\x06:\x06ET:\voffseti\xFE\x90\x9D:\tzoneI\"\bPDT\x06;\aF", permitted_ivars: { "Time" => %w[@type offset zone], "String" => %w[E @debug_created_info] }, marshal_dump_equality: true }
def test_repeated_symbol
assert_safe_load_as [:development, :development]
@@ -188,7 +188,7 @@ class TestGemSafeMarshal < Gem::TestCase
pend "Marshal.load of Time with ivars is broken on jruby, see https://github.com/jruby/jruby/issues/7902" if RUBY_ENGINE == "jruby"
with_const(Gem::SafeMarshal, :PERMITTED_IVARS, { "Time" => %w[@type offset zone nano_num nano_den submicro], "String" => %w[E @debug_created_info] }) do
- assert_safe_load_as Time.new.tap {|t| t.instance_variable_set :@type, "runtime" }, marshal_dump_equality: (RUBY_ENGINE != "truffleruby" || RUBY_ENGINE_VERSION >= "23")
+ assert_safe_load_as Time.new.tap {|t| t.instance_variable_set :@type, "runtime" }, marshal_dump_equality: true
end
end
@@ -211,17 +211,10 @@ class TestGemSafeMarshal < Gem::TestCase
Time.at(secs, 1.001, :nanosecond),
Time.at(secs, 1.00001, :nanosecond),
Time.at(secs, 1.00001, :nanosecond),
- ].tap do |times|
- unless RUBY_ENGINE == "truffleruby" && RUBY_ENGINE_VERSION < "23"
- times.concat [
- Time.at(secs, in: "UTC"),
- Time.at(secs, in: "Z"),
- ]
- end
- end.each_with_index do |t, i|
+ Time.at(secs, in: "UTC"),
+ Time.at(secs, in: "Z"),
+ ].each_with_index do |t, i|
define_method("test_time_#{i} #{t.inspect}") do
- pend "Marshal.load of Time with custom zone is broken before Truffleruby 23" if t.zone.nil? && RUBY_ENGINE == "truffleruby" && RUBY_ENGINE_VERSION < "23"
-
additional_methods = [:ctime, :to_f, :to_r, :to_i, :zone, :subsec, :instance_variables, :dst?, :to_a]
assert_safe_load_as t, additional_methods: additional_methods
end
@@ -293,8 +286,6 @@ class TestGemSafeMarshal < Gem::TestCase
end
def test_rational
- pend "truffleruby dumps rationals with ivars set on array, see https://github.com/oracle/truffleruby/issues/3228" if RUBY_ENGINE == "truffleruby"
-
assert_safe_load_as Rational(1, 3)
end
diff --git a/test/rubygems/test_gem_safe_yaml.rb b/test/rubygems/test_gem_safe_yaml.rb
new file mode 100644
index 0000000000..02df9f97da
--- /dev/null
+++ b/test/rubygems/test_gem_safe_yaml.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+require_relative "helper"
+
+Gem.load_yaml
+
+class TestGemSafeYAML < Gem::TestCase
+ def test_aliases_enabled_by_default
+ assert_predicate Gem::SafeYAML, :aliases_enabled?
+ assert_equal({ "a" => "a", "b" => "a" }, Gem::SafeYAML.safe_load("a: &a a\nb: *a\n"))
+ end
+
+ def test_aliases_disabled
+ aliases_enabled = Gem::SafeYAML.aliases_enabled?
+ Gem::SafeYAML.aliases_enabled = false
+ refute_predicate Gem::SafeYAML, :aliases_enabled?
+ expected_error = defined?(Psych::AliasesNotEnabled) ? Psych::AliasesNotEnabled : Psych::BadAlias
+ assert_raise expected_error do
+ Gem::SafeYAML.safe_load("a: &a\nb: *a\n")
+ end
+ ensure
+ Gem::SafeYAML.aliases_enabled = aliases_enabled
+ end
+end
diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb
index 096ac36a66..4d445f3437 100644
--- a/test/rubygems/test_gem_source.rb
+++ b/test/rubygems/test_gem_source.rb
@@ -22,7 +22,7 @@ class TestGemSource < Gem::TestCase
end
def test_initialize_invalid_uri
- assert_raise URI::InvalidURIError do
+ assert_raise Gem::URI::InvalidURIError do
Gem::Source.new "git@example:a.git"
end
end
@@ -36,15 +36,15 @@ class TestGemSource < Gem::TestCase
end
def test_cache_dir_escapes_windows_paths
- uri = URI.parse("file:///C:/WINDOWS/Temp/gem_repo")
+ uri = Gem::URI.parse("file:///C:/WINDOWS/Temp/gem_repo")
root = Gem.spec_cache_dir
cache_dir = @source.cache_dir(uri).gsub(root, "")
- assert cache_dir !~ /:/, "#{cache_dir} should not contain a :"
+ assert !cache_dir.include?(":"), "#{cache_dir} should not contain a :"
end
def test_dependency_resolver_set_bundler_api
response = Gem::Net::HTTPResponse.new "1.1", 200, "OK"
- response.uri = URI("http://example")
+ response.uri = Gem::URI("http://example")
@fetcher.data[@gem_repo] = response
@@ -78,7 +78,7 @@ class TestGemSource < Gem::TestCase
spec = @source.fetch_spec tuple("a", Gem::Version.new(1), "ruby")
assert_equal a1.full_name, spec.full_name
- cache_dir = @source.cache_dir URI.parse(spec_uri)
+ cache_dir = @source.cache_dir Gem::URI.parse(spec_uri)
cache_file = File.join cache_dir, a1.spec_name
@@ -91,7 +91,7 @@ class TestGemSource < Gem::TestCase
spec_uri = "#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{a1.spec_name}"
@fetcher.data["#{spec_uri}.rz"] = nil
- cache_dir = @source.cache_dir URI.parse(spec_uri)
+ cache_dir = @source.cache_dir Gem::URI.parse(spec_uri)
FileUtils.mkdir_p cache_dir
cache_file = File.join cache_dir, a1.spec_name
diff --git a/test/rubygems/test_gem_source_git.rb b/test/rubygems/test_gem_source_git.rb
index 18265bd814..20e750a0d4 100644
--- a/test/rubygems/test_gem_source_git.rb
+++ b/test/rubygems/test_gem_source_git.rb
@@ -289,7 +289,7 @@ class TestGemSourceGit < Gem::TestCase
end
def test_uri
- assert_equal URI(@repository), @source.uri
+ assert_equal Gem::URI(@repository), @source.uri
end
def test_uri_hash
diff --git a/test/rubygems/test_gem_source_list.rb b/test/rubygems/test_gem_source_list.rb
index fc084830ba..64353f8f90 100644
--- a/test/rubygems/test_gem_source_list.rb
+++ b/test/rubygems/test_gem_source_list.rb
@@ -37,7 +37,7 @@ class TestGemSourceList < Gem::TestCase
assert_kind_of Gem::Source, source
- assert_kind_of URI, source.uri
+ assert_kind_of Gem::URI, source.uri
assert_equal source.uri.to_s, @uri
assert_equal [source], sl.sources
@@ -99,7 +99,7 @@ class TestGemSourceList < Gem::TestCase
def test_include_eh
assert @sl.include?(@uri), "string comparison not working"
- assert @sl.include?(URI.parse(@uri)), "uri comparison not working"
+ assert @sl.include?(Gem::URI.parse(@uri)), "uri comparison not working"
end
def test_include_matches_a_source
diff --git a/test/rubygems/test_gem_source_lock.rb b/test/rubygems/test_gem_source_lock.rb
index ece55581ec..91ffee68f2 100644
--- a/test/rubygems/test_gem_source_lock.rb
+++ b/test/rubygems/test_gem_source_lock.rb
@@ -110,6 +110,6 @@ class TestGemSourceLock < Gem::TestCase
remote = Gem::Source.new @gem_repo
lock = Gem::Source::Lock.new remote
- assert_equal URI(@gem_repo), lock.uri
+ assert_equal Gem::URI(@gem_repo), lock.uri
end
end
diff --git a/test/rubygems/test_gem_source_subpath_problem.rb b/test/rubygems/test_gem_source_subpath_problem.rb
index 1ca9b67159..a451a81a25 100644
--- a/test/rubygems/test_gem_source_subpath_problem.rb
+++ b/test/rubygems/test_gem_source_subpath_problem.rb
@@ -22,7 +22,7 @@ class TestGemSourceSubpathProblem < Gem::TestCase
def test_dependency_resolver_set
response = Gem::Net::HTTPResponse.new "1.1", 200, "OK"
- response.uri = URI("http://example")
+ response.uri = Gem::URI("http://example")
@fetcher.data["#{@gem_repo}/"] = response
diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb
index 0fca9f0c48..cb4a4f7204 100644
--- a/test/rubygems/test_gem_spec_fetcher.rb
+++ b/test/rubygems/test_gem_spec_fetcher.rb
@@ -11,7 +11,7 @@ class TestGemSpecFetcher < Gem::TestCase
def setup
super
- @uri = URI.parse @gem_repo
+ @uri = Gem::URI.parse @gem_repo
@source = Gem::Source.new(@uri)
@sf = Gem::SpecFetcher.new
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 5f0546b93d..f28015c7b5 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -90,6 +90,7 @@ end
Gem.instance_variable_set(:'@default_source_date_epoch', nil)
@a1 = util_spec "a", "1" do |s|
+ s.required_ruby_version = ">= 2.3.0"
s.executable = "exec"
s.test_file = "test/suite.rb"
s.requirements << "A working computer"
@@ -1194,10 +1195,13 @@ dependencies: []
assert_same spec.bindir, dup_spec.bindir
assert_equal ">= 0", spec.required_ruby_version.to_s
- assert_same spec.required_ruby_version, dup_spec.required_ruby_version
+ assert_equal spec.required_ruby_version, dup_spec.required_ruby_version
+ refute_same spec.required_ruby_version, dup_spec.required_ruby_version
assert_equal ">= 0", spec.required_rubygems_version.to_s
- assert_same spec.required_rubygems_version,
+ assert_equal spec.required_rubygems_version,
+ dup_spec.required_rubygems_version
+ refute_same spec.required_rubygems_version,
dup_spec.required_rubygems_version
end
@@ -2684,6 +2688,53 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
end
end
+ def test_validate_no_required_ruby_versions
+ util_setup_validate
+
+ Dir.chdir @tempdir do
+ use_ui @ui do
+ @a1.required_ruby_version = nil # reset
+ @a1.validate
+ end
+
+ assert_equal <<-EXPECTED, @ui.error
+#{w}: make sure you specify the oldest ruby version constraint (like \">= 3.0\") that you want your gem to support by setting the `required_ruby_version` gemspec attribute
+#{w}: See https://guides.rubygems.org/specification-reference/ for help
+ EXPECTED
+ end
+ end
+
+ def test_validate_open_required_ruby_versions
+ util_setup_validate
+
+ Dir.chdir @tempdir do
+ @a1.required_ruby_version = ">= 0"
+
+ use_ui @ui do
+ @a1.validate
+ end
+
+ assert_equal <<-EXPECTED, @ui.error
+#{w}: make sure you specify the oldest ruby version constraint (like \">= 3.0\") that you want your gem to support by setting the `required_ruby_version` gemspec attribute
+#{w}: See https://guides.rubygems.org/specification-reference/ for help
+ EXPECTED
+ end
+ end
+
+ def test_validate_valid_required_ruby_versions
+ util_setup_validate
+
+ Dir.chdir @tempdir do
+ @a1.required_ruby_version = ">= 2.3.0"
+
+ use_ui @ui do
+ @a1.validate
+ end
+
+ assert_equal "", @ui.error, "warning"
+ end
+ end
+
def test_validate_prerelease_dependencies_with_prerelease_version
util_setup_validate
@@ -2727,7 +2778,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
@a1.validate
end
- assert_match(/add rake as a dependency/, @ui.error)
+ assert_match(/add rake as a runtime dependency/, @ui.error)
end
end
@@ -2743,7 +2794,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
@a1.validate
end
- refute_match(/add rake as a dependency/, @ui.error)
+ refute_match(/add rake as a runtime dependency/, @ui.error)
end
end
@@ -3660,6 +3711,7 @@ Did you mean 'Ruby'?
Dir.chdir @tempdir do
@m2 = quick_gem "m", "2" do |s|
+ s.required_ruby_version = ">= 2.3.0"
s.files = %w[lib/code.rb]
s.licenses = "BSD-2-Clause"
s.metadata = {
@@ -3798,6 +3850,13 @@ end
assert Gem::Specification.find_by_name "q"
end
+ def test_find_by_name_with_only_prereleases_with_requirements
+ q = util_spec "q", "2.a"
+ install_specs q
+
+ assert Gem::Specification.find_by_name "q", ">= 1"
+ end
+
def test_find_by_name_prerelease
b = util_spec "b", "2.a"
diff --git a/test/rubygems/test_gem_stream_ui.rb b/test/rubygems/test_gem_stream_ui.rb
index e34110fe84..b1fcb3bc26 100644
--- a/test/rubygems/test_gem_stream_ui.rb
+++ b/test/rubygems/test_gem_stream_ui.rb
@@ -2,7 +2,7 @@
require_relative "helper"
require "rubygems/user_interaction"
-require "rubygems/timeout/lib/timeout"
+require "rubygems/vendored_timeout"
class TestGemStreamUI < Gem::TestCase
# increase timeout with RJIT for --jit-wait testing
diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb
index 4c3d2d20c6..d862b26fe9 100644
--- a/test/rubygems/test_kernel.rb
+++ b/test/rubygems/test_kernel.rb
@@ -52,10 +52,20 @@ class TestGemKernel < Gem::TestCase
assert_equal 1, $:.count {|p| p.include?("a-1/lib") }
end
- def test_gem_prerelease
+ def test_gem_prerelease_is_the_only_available
quick_gem "d", "1.1.a"
- refute gem("d", ">= 1"), "release requirement must not load prerelease"
- assert gem("d", ">= 1.a"), "prerelease requirement may load prerelease"
+
+ assert gem("d", ">= 1"), "release requirement may load prerelease when sole option"
+ assert $:.one? {|p| p.include?("/d-1.1.a/lib") }
+ end
+
+ def test_release_favored_over_prerelease
+ quick_gem "d", "1.1.a"
+ quick_gem "d", "1.2"
+ gem("d", ">= 1")
+
+ refute $:.any? {|p| p.include?("/d-1.1.a/lib") }
+ assert $:.one? {|p| p.include?("/d-1.2/lib") }
end
def test_gem_env_req
diff --git a/test/rubygems/test_rubygems.rb b/test/rubygems/test_rubygems.rb
index 25211cb0e9..ec195b65cd 100644
--- a/test/rubygems/test_rubygems.rb
+++ b/test/rubygems/test_rubygems.rb
@@ -17,7 +17,7 @@ class GemTest < Gem::TestCase
output = Gem::Util.popen(*ruby_with_rubygems_and_fake_operating_system_in_load_path(path), "-e", "'require \"rubygems\"'", { err: [:child, :out] }).strip
assert !$?.success?
- assert_includes output, "undefined local variable or method `intentionally_not_implemented_method'"
+ assert_match(/undefined local variable or method [`']intentionally_not_implemented_method'/, output)
assert_includes output, "Loading the #{operating_system_rb_at(path)} file caused an error. " \
"This file is owned by your OS, not by rubygems upstream. " \
"Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \
diff --git a/test/rubygems/test_webauthn_listener.rb b/test/rubygems/test_webauthn_listener.rb
index e3f7c8c395..08edabceb2 100644
--- a/test/rubygems/test_webauthn_listener.rb
+++ b/test/rubygems/test_webauthn_listener.rb
@@ -19,7 +19,7 @@ class WebauthnListenerTest < Gem::TestCase
def test_listener_thread_retreives_otp_code
thread = Gem::GemcutterUtilities::WebauthnListener.listener_thread(Gem.host, @server)
- Gem::MockBrowser.get URI("http://localhost:#{@port}?code=xyz")
+ Gem::MockBrowser.get Gem::URI("http://localhost:#{@port}?code=xyz")
thread.join
assert_equal "xyz", thread[:otp]
@@ -27,7 +27,7 @@ class WebauthnListenerTest < Gem::TestCase
def test_listener_thread_sets_error
thread = Gem::GemcutterUtilities::WebauthnListener.listener_thread(Gem.host, @server)
- Gem::MockBrowser.post URI("http://localhost:#{@port}?code=xyz")
+ Gem::MockBrowser.post Gem::URI("http://localhost:#{@port}?code=xyz")
thread.join
assert_equal "Security device verification failed: Invalid HTTP method POST received.", thread[:error].message
@@ -35,13 +35,13 @@ class WebauthnListenerTest < Gem::TestCase
def test_wait_for_otp_code_get_follows_options
wait_for_otp_code
- assert Gem::MockBrowser.options(URI("http://localhost:#{@port}?code=xyz")).is_a? Gem::Net::HTTPNoContent
- assert Gem::MockBrowser.get(URI("http://localhost:#{@port}?code=xyz")).is_a? Gem::Net::HTTPOK
+ assert Gem::MockBrowser.options(Gem::URI("http://localhost:#{@port}?code=xyz")).is_a? Gem::Net::HTTPNoContent
+ assert Gem::MockBrowser.get(Gem::URI("http://localhost:#{@port}?code=xyz")).is_a? Gem::Net::HTTPOK
end
def test_wait_for_otp_code_options_request
wait_for_otp_code
- response = Gem::MockBrowser.options URI("http://localhost:#{@port}?code=xyz")
+ response = Gem::MockBrowser.options Gem::URI("http://localhost:#{@port}?code=xyz")
assert response.is_a? Gem::Net::HTTPNoContent
assert_equal Gem.host, response["access-control-allow-origin"]
@@ -52,7 +52,7 @@ class WebauthnListenerTest < Gem::TestCase
def test_wait_for_otp_code_get_request
wait_for_otp_code
- response = Gem::MockBrowser.get URI("http://localhost:#{@port}?code=xyz")
+ response = Gem::MockBrowser.get Gem::URI("http://localhost:#{@port}?code=xyz")
assert response.is_a? Gem::Net::HTTPOK
assert_equal "text/plain; charset=utf-8", response["Content-Type"]
@@ -69,7 +69,7 @@ class WebauthnListenerTest < Gem::TestCase
def test_wait_for_otp_code_invalid_post_req_method
wait_for_otp_code_expect_error_with_message("Security device verification failed: Invalid HTTP method POST received.")
- response = Gem::MockBrowser.post URI("http://localhost:#{@port}?code=xyz")
+ response = Gem::MockBrowser.post Gem::URI("http://localhost:#{@port}?code=xyz")
assert response
assert response.is_a? Gem::Net::HTTPMethodNotAllowed
@@ -82,7 +82,7 @@ class WebauthnListenerTest < Gem::TestCase
def test_wait_for_otp_code_incorrect_path
wait_for_otp_code_expect_error_with_message("Security device verification failed: Page at /path not found.")
- response = Gem::MockBrowser.post URI("http://localhost:#{@port}/path?code=xyz")
+ response = Gem::MockBrowser.post Gem::URI("http://localhost:#{@port}/path?code=xyz")
assert response.is_a? Gem::Net::HTTPNotFound
assert_equal "close", response["Connection"]
@@ -93,7 +93,7 @@ class WebauthnListenerTest < Gem::TestCase
def test_wait_for_otp_code_no_params_response
wait_for_otp_code_expect_error_with_message("Security device verification failed: Did not receive OTP from https://rubygems.org.")
- response = Gem::MockBrowser.get URI("http://localhost:#{@port}")
+ response = Gem::MockBrowser.get Gem::URI("http://localhost:#{@port}")
assert response.is_a? Gem::Net::HTTPBadRequest
assert_equal "text/plain; charset=utf-8", response["Content-Type"]
@@ -107,7 +107,7 @@ class WebauthnListenerTest < Gem::TestCase
def test_wait_for_otp_code_incorrect_params
wait_for_otp_code_expect_error_with_message("Security device verification failed: Did not receive OTP from https://rubygems.org.")
- response = Gem::MockBrowser.get URI("http://localhost:#{@port}?param=xyz")
+ response = Gem::MockBrowser.get Gem::URI("http://localhost:#{@port}?param=xyz")
assert response.is_a? Gem::Net::HTTPBadRequest
assert_equal "text/plain; charset=utf-8", response["Content-Type"]
diff --git a/test/rubygems/utilities.rb b/test/rubygems/utilities.rb
index 996b1f3440..357379f88d 100644
--- a/test/rubygems/utilities.rb
+++ b/test/rubygems/utilities.rb
@@ -40,16 +40,16 @@ class Gem::FakeFetcher
end
def find_data(path)
- return Gem.read_binary path.path if URI === path && path.scheme == "file"
+ return Gem.read_binary path.path if Gem::URI === path && path.scheme == "file"
- if URI === path && "URI::#{path.scheme.upcase}" != path.class.name
+ if Gem::URI === path && "Gem::URI::#{path.scheme.upcase}" != path.class.name
raise ArgumentError,
"mismatch for scheme #{path.scheme} and class #{path.class}"
end
path = path.to_s
@paths << path
- raise ArgumentError, "need full URI" unless path.start_with?("https://", "https://")
+ raise ArgumentError, "need full Gem::URI" unless path.start_with?("https://", "https://")
unless @data.key? path
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
@@ -194,7 +194,7 @@ end
# Example:
#
# # Sends a get request to http://localhost:5678
-# Gem::MockBrowser.get URI("http://localhost:5678")
+# Gem::MockBrowser.get Gem::URI("http://localhost:5678")
#
# See RubyGems' tests for more examples of MockBrowser.
#
@@ -368,12 +368,12 @@ class Gem::TestCase::SpecFetcherSetup
begin
gem_repo = @test.gem_repo
@test.gem_repo = @repository
- @test.uri = URI @repository
+ @test.uri = Gem::URI @repository
@test.util_setup_spec_fetcher(*@downloaded)
ensure
@test.gem_repo = gem_repo
- @test.uri = URI gem_repo
+ @test.uri = Gem::URI gem_repo
end
@gems.each do |spec, gem|