diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rubygems/rubygems_plugin.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem_installer.rb | 27 | ||||
-rw-r--r-- | test/rubygems/test_gem_source_fetch_problem.rb | 8 | ||||
-rw-r--r-- | test/rubygems/test_remote_fetch_error.rb | 21 |
4 files changed, 56 insertions, 4 deletions
diff --git a/test/rubygems/rubygems_plugin.rb b/test/rubygems/rubygems_plugin.rb index 0195a2139a..30a67789c6 100644 --- a/test/rubygems/rubygems_plugin.rb +++ b/test/rubygems/rubygems_plugin.rb @@ -6,6 +6,10 @@ require 'rubygems/command_manager' # # DO NOT include code like this in your rubygems_plugin.rb +module Gem::Commands + remove_const(:InterruptCommand) if defined?(InterruptCommand) +end + class Gem::Commands::InterruptCommand < Gem::Command def initialize diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index f9149650f0..dedb4c99ca 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -2,6 +2,20 @@ require 'rubygems/installer_test_case' class TestGemInstaller < Gem::InstallerTestCase + @@symlink_supported = nil + + def symlink_supported? + if @@symlink_supported.nil? + begin + File.symlink("", "") + rescue Errno::ENOENT, Errno::EEXIST + @@symlink_supported = true + rescue NotImplementedError, SystemCallError + @@symlink_supported = false + end + end + @@symlink_supported + end def setup super @@ -552,7 +566,7 @@ gem 'other', version end def test_generate_bin_symlink_update_older - return if win_platform? #Windows FS do not support symlinks + return if !symlink_supported? @installer.wrappers = false util_make_exec @@ -588,7 +602,7 @@ gem 'other', version end def test_generate_bin_symlink_update_remove_wrapper - return if win_platform? #Windows FS do not support symlinks + return if !symlink_supported? @installer.wrappers = true util_make_exec @@ -639,7 +653,12 @@ gem 'other', version installed_exec = File.join(util_inst_bindir, 'executable') assert_path_exists installed_exec - assert_match(/Unable to use symlinks on Windows, installing wrapper/i, + if symlink_supported? + assert_send([File, :symlink?, installed_exec]) + return + end + + assert_match(/Unable to use symlinks, installing wrapper/i, @ui.error) wrapper = File.read installed_exec @@ -651,7 +670,7 @@ gem 'other', version end def test_generate_bin_uses_default_shebang - return if win_platform? #Windows FS do not support symlinks + return if !symlink_supported? @installer.wrappers = true util_make_exec diff --git a/test/rubygems/test_gem_source_fetch_problem.rb b/test/rubygems/test_gem_source_fetch_problem.rb index 7392a1ef0a..4a245f25df 100644 --- a/test/rubygems/test_gem_source_fetch_problem.rb +++ b/test/rubygems/test_gem_source_fetch_problem.rb @@ -16,5 +16,13 @@ class TestGemSourceFetchProblem < Gem::TestCase assert_equal 'test', e.message end + def test_password_redacted + source = Gem::Source.new 'https://username:secret@gemsource.com' + error = RuntimeError.new 'test' + + sf = Gem::SourceFetchProblem.new source, error + + refute_match sf.wordy, 'secret' + end end diff --git a/test/rubygems/test_remote_fetch_error.rb b/test/rubygems/test_remote_fetch_error.rb new file mode 100644 index 0000000000..6b0f5477d6 --- /dev/null +++ b/test/rubygems/test_remote_fetch_error.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true +require 'rubygems/test_case' + +class TestRemoteFetchError < Gem::TestCase + + def test_password_redacted + error = Gem::RemoteFetcher::FetchError.new('There was an error fetching', 'https://user:secret@gemsource.org') + refute_match error.to_s, 'secret' + end + + def test_invalid_url + error = Gem::RemoteFetcher::FetchError.new('There was an error fetching', 'https://::gemsource.org') + assert_equal error.to_s, 'There was an error fetching (https://::gemsource.org)' + end + + def test_to_s + error = Gem::RemoteFetcher::FetchError.new('There was an error fetching', 'https://gemsource.org') + assert_equal error.to_s, 'There was an error fetching (https://gemsource.org)' + end +end + |