aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-05 03:32:58 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-05 03:32:58 +0000
commit08f8cfe14e0f8937e3bcf8a22becdc5ce60b920e (patch)
tree30977064b5f93f9ac5b01b2a676f6d6ffdcec652 /test/rubygems/test_gem.rb
parent593505ac6f802d2b5bff469425b7c76b65cc9b10 (diff)
downloadruby-08f8cfe14e0f8937e3bcf8a22becdc5ce60b920e.tar.gz
Merge RubyGems upstream: 56c0bbb69e4506bda7ef7f447dfec5db820df20b
It fixed the multiple vulnerabilities. https://blog.rubygems.org/2019/03/05/security-advisories-2019-03.html git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem.rb')
-rw-r--r--test/rubygems/test_gem.rb44
1 files changed, 26 insertions, 18 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index b2f718bf1a..ad802e0f95 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -155,8 +155,10 @@ class TestGem < Gem::TestCase
def test_self_install_permissions_with_format_executable_and_non_standard_ruby_install_name
Gem::Installer.exec_format = nil
- ruby_install_name 'ruby27' do
- assert_self_install_permissions(format_executable: true)
+ with_clean_path_to_ruby do
+ ruby_install_name 'ruby27' do
+ assert_self_install_permissions(format_executable: true)
+ end
end
ensure
Gem::Installer.exec_format = nil
@@ -553,7 +555,7 @@ class TestGem < Gem::TestCase
Gem.ensure_gem_subdirectories @gemhome, 0750
- assert File.directory? File.join(@gemhome, "cache")
+ assert_directory_exists File.join(@gemhome, "cache")
assert_equal 0750, File::Stat.new(@gemhome).mode & 0777
assert_equal 0750, File::Stat.new(File.join(@gemhome, "cache")).mode & 0777
@@ -582,7 +584,7 @@ class TestGem < Gem::TestCase
Gem.ensure_gem_subdirectories gemdir
- assert File.directory?(util_cache_dir)
+ assert_directory_exists util_cache_dir
end
unless win_platform? || Process.uid.zero? # only for FS that support write protection
@@ -952,40 +954,36 @@ class TestGem < Gem::TestCase
end
def test_self_ruby_escaping_spaces_in_path
- orig_ruby = Gem.ruby
orig_bindir = RbConfig::CONFIG['bindir']
- orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name']
orig_exe_ext = RbConfig::CONFIG['EXEEXT']
RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin"
- RbConfig::CONFIG['ruby_install_name'] = "ruby"
RbConfig::CONFIG['EXEEXT'] = ".exe"
- Gem.instance_variable_set("@ruby", nil)
- assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
+ ruby_install_name "ruby" do
+ with_clean_path_to_ruby do
+ assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
+ end
+ end
ensure
- Gem.instance_variable_set("@ruby", orig_ruby)
RbConfig::CONFIG['bindir'] = orig_bindir
- RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name
RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
end
def test_self_ruby_path_without_spaces
- orig_ruby = Gem.ruby
orig_bindir = RbConfig::CONFIG['bindir']
- orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name']
orig_exe_ext = RbConfig::CONFIG['EXEEXT']
RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin"
- RbConfig::CONFIG['ruby_install_name'] = "ruby"
RbConfig::CONFIG['EXEEXT'] = ".exe"
- Gem.instance_variable_set("@ruby", nil)
- assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
+ ruby_install_name "ruby" do
+ with_clean_path_to_ruby do
+ assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
+ end
+ end
ensure
- Gem.instance_variable_set("@ruby", orig_ruby)
RbConfig::CONFIG['bindir'] = orig_bindir
- RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name
RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
end
@@ -1904,6 +1902,16 @@ You may need to `gem install -g` to install missing gems
end
end
+ def with_clean_path_to_ruby
+ orig_ruby = Gem.ruby
+
+ Gem.instance_variable_set :@ruby, nil
+
+ yield
+ ensure
+ Gem.instance_variable_set("@ruby", orig_ruby)
+ end
+
def with_plugin(path)
test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}",
@@project_dir)