util/rubocop -A --only Style/NumericLiteralPrefix
This commit is contained in:
parent
65e276096f
commit
d89cc317c6
@ -429,7 +429,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|||||||
|
|
||||||
def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc:
|
def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc:
|
||||||
old_umask = File.umask
|
old_umask = File.umask
|
||||||
File.umask old_umask | 002
|
File.umask old_umask | 0o002
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ class Gem::Commands::CertCommand < Gem::Command
|
|||||||
|
|
||||||
algorithm = options[:key_algorithm] || Gem::Security::DEFAULT_KEY_ALGORITHM
|
algorithm = options[:key_algorithm] || Gem::Security::DEFAULT_KEY_ALGORITHM
|
||||||
key = Gem::Security.create_key(algorithm)
|
key = Gem::Security.create_key(algorithm)
|
||||||
key_path = Gem::Security.write key, "gem-private_key.pem", 0600, passphrase
|
key_path = Gem::Security.write key, "gem-private_key.pem", 0o600, passphrase
|
||||||
|
|
||||||
[key, key_path]
|
[key, key_path]
|
||||||
end
|
end
|
||||||
@ -291,7 +291,7 @@ For further reading on signing gems see `ri Gem::Security`.
|
|||||||
cert = File.read cert_file
|
cert = File.read cert_file
|
||||||
cert = OpenSSL::X509::Certificate.new cert
|
cert = OpenSSL::X509::Certificate.new cert
|
||||||
|
|
||||||
permissions = File.stat(cert_file).mode & 0777
|
permissions = File.stat(cert_file).mode & 0o777
|
||||||
|
|
||||||
issuer_cert = options[:issuer_cert]
|
issuer_cert = options[:issuer_cert]
|
||||||
issuer_key = options[:key]
|
issuer_key = options[:key]
|
||||||
|
@ -243,7 +243,7 @@ By default, this RubyGems will install gem as:
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install_executables(bin_dir)
|
def install_executables(bin_dir)
|
||||||
prog_mode = options[:prog_mode] || 0755
|
prog_mode = options[:prog_mode] || 0o755
|
||||||
|
|
||||||
executables = { "gem" => "bin" }
|
executables = { "gem" => "bin" }
|
||||||
executables.each do |tool, path|
|
executables.each do |tool, path|
|
||||||
@ -369,7 +369,7 @@ By default, this RubyGems will install gem as:
|
|||||||
File.dirname(loaded_from)
|
File.dirname(loaded_from)
|
||||||
else
|
else
|
||||||
target_specs_dir = File.join(default_dir, "specifications", "default")
|
target_specs_dir = File.join(default_dir, "specifications", "default")
|
||||||
mkdir_p target_specs_dir, :mode => 0755
|
mkdir_p target_specs_dir, :mode => 0o755
|
||||||
target_specs_dir
|
target_specs_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ By default, this RubyGems will install gem as:
|
|||||||
end
|
end
|
||||||
|
|
||||||
bundler_bin_dir = bundler_spec.bin_dir
|
bundler_bin_dir = bundler_spec.bin_dir
|
||||||
mkdir_p bundler_bin_dir, :mode => 0755
|
mkdir_p bundler_bin_dir, :mode => 0o755
|
||||||
bundler_spec.executables.each do |e|
|
bundler_spec.executables.each do |e|
|
||||||
cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
|
cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
|
||||||
end
|
end
|
||||||
@ -430,8 +430,8 @@ By default, this RubyGems will install gem as:
|
|||||||
lib_dir, bin_dir = generate_default_dirs
|
lib_dir, bin_dir = generate_default_dirs
|
||||||
end
|
end
|
||||||
|
|
||||||
mkdir_p lib_dir, :mode => 0755
|
mkdir_p lib_dir, :mode => 0o755
|
||||||
mkdir_p bin_dir, :mode => 0755
|
mkdir_p bin_dir, :mode => 0o755
|
||||||
|
|
||||||
[lib_dir, bin_dir]
|
[lib_dir, bin_dir]
|
||||||
end
|
end
|
||||||
@ -639,10 +639,10 @@ abort "#{deprecation_message}"
|
|||||||
dest_file = File.join dest_dir, file
|
dest_file = File.join dest_dir, file
|
||||||
dest_dir = File.dirname dest_file
|
dest_dir = File.dirname dest_file
|
||||||
unless File.directory? dest_dir
|
unless File.directory? dest_dir
|
||||||
mkdir_p dest_dir, :mode => 0755
|
mkdir_p dest_dir, :mode => 0o755
|
||||||
end
|
end
|
||||||
|
|
||||||
install file, dest_file, :mode => options[:data_mode] || 0644
|
install file, dest_file, :mode => options[:data_mode] || 0o644
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_file_list(files, dir)
|
def remove_file_list(files, dir)
|
||||||
|
@ -241,9 +241,9 @@ class Gem::ConfigFile
|
|||||||
return if Gem.win_platform? # windows doesn't write 0600 as 0600
|
return if Gem.win_platform? # windows doesn't write 0600 as 0600
|
||||||
return unless File.exist? credentials_path
|
return unless File.exist? credentials_path
|
||||||
|
|
||||||
existing_permissions = File.stat(credentials_path).mode & 0777
|
existing_permissions = File.stat(credentials_path).mode & 0o777
|
||||||
|
|
||||||
return if existing_permissions == 0600
|
return if existing_permissions == 0o600
|
||||||
|
|
||||||
alert_error <<-ERROR
|
alert_error <<-ERROR
|
||||||
Your gem push credentials file located at:
|
Your gem push credentials file located at:
|
||||||
@ -326,7 +326,7 @@ if you believe they were disclosed to a third party.
|
|||||||
|
|
||||||
Gem.load_yaml
|
Gem.load_yaml
|
||||||
|
|
||||||
permissions = 0600 & (~File.umask)
|
permissions = 0o600 & (~File.umask)
|
||||||
File.open(credentials_path, "w", permissions) do |f|
|
File.open(credentials_path, "w", permissions) do |f|
|
||||||
f.write config.to_yaml
|
f.write config.to_yaml
|
||||||
end
|
end
|
||||||
|
@ -327,7 +327,7 @@ class Gem::Indexer
|
|||||||
|
|
||||||
def make_temp_directories
|
def make_temp_directories
|
||||||
FileUtils.rm_rf @directory
|
FileUtils.rm_rf @directory
|
||||||
FileUtils.mkdir_p @directory, :mode => 0700
|
FileUtils.mkdir_p @directory, :mode => 0o700
|
||||||
FileUtils.mkdir_p @quick_marshal_dir
|
FileUtils.mkdir_p @quick_marshal_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ class Gem::Installer
|
|||||||
FileUtils.rm_rf spec.extension_dir
|
FileUtils.rm_rf spec.extension_dir
|
||||||
|
|
||||||
dir_mode = options[:dir_mode]
|
dir_mode = options[:dir_mode]
|
||||||
FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0755
|
FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0o755
|
||||||
|
|
||||||
if @options[:install_as_default]
|
if @options[:install_as_default]
|
||||||
extract_bin
|
extract_bin
|
||||||
@ -495,7 +495,7 @@ class Gem::Installer
|
|||||||
next unless File.exist? bin_path
|
next unless File.exist? bin_path
|
||||||
|
|
||||||
mode = File.stat(bin_path).mode
|
mode = File.stat(bin_path).mode
|
||||||
dir_mode = options[:prog_mode] || (mode | 0111)
|
dir_mode = options[:prog_mode] || (mode | 0o111)
|
||||||
|
|
||||||
unless dir_mode == mode
|
unless dir_mode == mode
|
||||||
require "fileutils"
|
require "fileutils"
|
||||||
@ -540,9 +540,9 @@ class Gem::Installer
|
|||||||
require "fileutils"
|
require "fileutils"
|
||||||
FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
|
FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
|
||||||
|
|
||||||
File.open bin_script_path, "wb", 0755 do |file|
|
File.open bin_script_path, "wb", 0o755 do |file|
|
||||||
file.print app_script_text(filename)
|
file.print app_script_text(filename)
|
||||||
file.chmod(options[:prog_mode] || 0755)
|
file.chmod(options[:prog_mode] || 0o755)
|
||||||
end
|
end
|
||||||
|
|
||||||
verbose bin_script_path
|
verbose bin_script_path
|
||||||
@ -712,7 +712,7 @@ class Gem::Installer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def verify_gem_home # :nodoc:
|
def verify_gem_home # :nodoc:
|
||||||
FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0755
|
FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0o755
|
||||||
raise Gem::FilePermissionError, gem_home unless File.writable?(gem_home)
|
raise Gem::FilePermissionError, gem_home unless File.writable?(gem_home)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -934,7 +934,7 @@ TEXT
|
|||||||
build_info_dir = File.join gem_home, "build_info"
|
build_info_dir = File.join gem_home, "build_info"
|
||||||
|
|
||||||
dir_mode = options[:dir_mode]
|
dir_mode = options[:dir_mode]
|
||||||
FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0755
|
FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0o755
|
||||||
|
|
||||||
build_info_file = File.join build_info_dir, "#{spec.full_name}.info"
|
build_info_file = File.join build_info_dir, "#{spec.full_name}.info"
|
||||||
|
|
||||||
@ -957,7 +957,7 @@ TEXT
|
|||||||
|
|
||||||
def ensure_writable_dir(dir) # :nodoc:
|
def ensure_writable_dir(dir) # :nodoc:
|
||||||
begin
|
begin
|
||||||
Dir.mkdir dir, *[options[:dir_mode] && 0755].compact
|
Dir.mkdir dir, *[options[:dir_mode] && 0o755].compact
|
||||||
rescue SystemCallError
|
rescue SystemCallError
|
||||||
raise unless File.directory? dir
|
raise unless File.directory? dir
|
||||||
end
|
end
|
||||||
|
@ -230,7 +230,7 @@ class Gem::Package
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
tar.add_file_signed "checksums.yaml.gz", 0444, @signer do |io|
|
tar.add_file_signed "checksums.yaml.gz", 0o444, @signer do |io|
|
||||||
gzip_to io do |gz_io|
|
gzip_to io do |gz_io|
|
||||||
Psych.dump checksums_by_algorithm, gz_io
|
Psych.dump checksums_by_algorithm, gz_io
|
||||||
end
|
end
|
||||||
@ -242,7 +242,7 @@ class Gem::Package
|
|||||||
# and adds this file to the +tar+.
|
# and adds this file to the +tar+.
|
||||||
|
|
||||||
def add_contents(tar) # :nodoc:
|
def add_contents(tar) # :nodoc:
|
||||||
digests = tar.add_file_signed "data.tar.gz", 0444, @signer do |io|
|
digests = tar.add_file_signed "data.tar.gz", 0o444, @signer do |io|
|
||||||
gzip_to io do |gz_io|
|
gzip_to io do |gz_io|
|
||||||
Gem::Package::TarWriter.new gz_io do |data_tar|
|
Gem::Package::TarWriter.new gz_io do |data_tar|
|
||||||
add_files data_tar
|
add_files data_tar
|
||||||
@ -278,7 +278,7 @@ class Gem::Package
|
|||||||
# Adds the package's Gem::Specification to the +tar+ file
|
# Adds the package's Gem::Specification to the +tar+ file
|
||||||
|
|
||||||
def add_metadata(tar) # :nodoc:
|
def add_metadata(tar) # :nodoc:
|
||||||
digests = tar.add_file_signed "metadata.gz", 0444, @signer do |io|
|
digests = tar.add_file_signed "metadata.gz", 0o444, @signer do |io|
|
||||||
gzip_to io do |gz_io|
|
gzip_to io do |gz_io|
|
||||||
gz_io.write @spec.to_yaml
|
gz_io.write @spec.to_yaml
|
||||||
end
|
end
|
||||||
@ -382,7 +382,7 @@ EOM
|
|||||||
def extract_files(destination_dir, pattern = "*")
|
def extract_files(destination_dir, pattern = "*")
|
||||||
verify unless @spec
|
verify unless @spec
|
||||||
|
|
||||||
FileUtils.mkdir_p destination_dir, :mode => dir_mode && 0755
|
FileUtils.mkdir_p destination_dir, :mode => dir_mode && 0o755
|
||||||
|
|
||||||
@gem.with_read_io do |io|
|
@gem.with_read_io do |io|
|
||||||
reader = Gem::Package::TarReader.new io
|
reader = Gem::Package::TarReader.new io
|
||||||
@ -432,7 +432,7 @@ EOM
|
|||||||
FileUtils.rm_rf destination
|
FileUtils.rm_rf destination
|
||||||
|
|
||||||
mkdir_options = {}
|
mkdir_options = {}
|
||||||
mkdir_options[:mode] = dir_mode ? 0755 : (entry.header.mode if entry.directory?)
|
mkdir_options[:mode] = dir_mode ? 0o755 : (entry.header.mode if entry.directory?)
|
||||||
mkdir =
|
mkdir =
|
||||||
if entry.directory?
|
if entry.directory?
|
||||||
destination
|
destination
|
||||||
@ -468,7 +468,7 @@ EOM
|
|||||||
end
|
end
|
||||||
|
|
||||||
def file_mode(mode) # :nodoc:
|
def file_mode(mode) # :nodoc:
|
||||||
((mode & 0111).zero? ? data_mode : prog_mode) ||
|
((mode & 0o111).zero? ? data_mode : prog_mode) ||
|
||||||
# If we're not using one of the default modes, then we're going to fall
|
# If we're not using one of the default modes, then we're going to fall
|
||||||
# back to the mode from the tarball. In this case we need to mask it down
|
# back to the mode from the tarball. In this case we need to mask it down
|
||||||
# to fit into 2^16 bits (the maximum value for a mode in CRuby since it
|
# to fit into 2^16 bits (the maximum value for a mode in CRuby since it
|
||||||
|
@ -78,7 +78,7 @@ class Gem::Package::Old < Gem::Package
|
|||||||
|
|
||||||
FileUtils.rm_rf destination
|
FileUtils.rm_rf destination
|
||||||
|
|
||||||
FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0755
|
FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0o755
|
||||||
|
|
||||||
File.open destination, "wb", file_mode(entry["mode"]) do |out|
|
File.open destination, "wb", file_mode(entry["mode"]) do |out|
|
||||||
out.write file_data
|
out.write file_data
|
||||||
|
@ -192,7 +192,7 @@ class Gem::Package::TarWriter
|
|||||||
if signer.key
|
if signer.key
|
||||||
signature = signer.sign signature_digest.digest
|
signature = signer.sign signature_digest.digest
|
||||||
|
|
||||||
add_file_simple "#{name}.sig", 0444, signature.length do |io|
|
add_file_simple "#{name}.sig", 0o444, signature.length do |io|
|
||||||
io.write signature
|
io.write signature
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -589,7 +589,7 @@ module Gem::Security
|
|||||||
# +permissions+. If passed +cipher+ and +passphrase+ those arguments will be
|
# +permissions+. If passed +cipher+ and +passphrase+ those arguments will be
|
||||||
# passed to +to_pem+.
|
# passed to +to_pem+.
|
||||||
|
|
||||||
def self.write(pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER)
|
def self.write(pemmable, path, permissions = 0o600, passphrase = nil, cipher = KEY_CIPHER)
|
||||||
path = File.expand_path path
|
path = File.expand_path path
|
||||||
|
|
||||||
File.open path, "wb", permissions do |io|
|
File.open path, "wb", permissions do |io|
|
||||||
|
@ -9,8 +9,8 @@ class Gem::Security::TrustDir
|
|||||||
# Default permissions for the trust directory and its contents
|
# Default permissions for the trust directory and its contents
|
||||||
|
|
||||||
DEFAULT_PERMISSIONS = {
|
DEFAULT_PERMISSIONS = {
|
||||||
:trust_dir => 0700,
|
:trust_dir => 0o700,
|
||||||
:trusted_cert => 0600,
|
:trusted_cert => 0o600,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -91,7 +91,7 @@ class Gem::Security::TrustDir
|
|||||||
|
|
||||||
destination = cert_path certificate
|
destination = cert_path certificate
|
||||||
|
|
||||||
File.open destination, "wb", 0600 do |io|
|
File.open destination, "wb", 0o600 do |io|
|
||||||
io.write certificate.to_pem
|
io.write certificate.to_pem
|
||||||
io.chmod(@permissions[:trusted_cert])
|
io.chmod(@permissions[:trusted_cert])
|
||||||
end
|
end
|
||||||
@ -109,7 +109,7 @@ class Gem::Security::TrustDir
|
|||||||
"trust directory #{@dir} is not a directory" unless
|
"trust directory #{@dir} is not a directory" unless
|
||||||
File.directory? @dir
|
File.directory? @dir
|
||||||
|
|
||||||
FileUtils.chmod 0700, @dir
|
FileUtils.chmod 0o700, @dir
|
||||||
else
|
else
|
||||||
FileUtils.mkdir_p @dir, :mode => @permissions[:trust_dir]
|
FileUtils.mkdir_p @dir, :mode => @permissions[:trust_dir]
|
||||||
end
|
end
|
||||||
|
@ -234,7 +234,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
|||||||
|
|
||||||
@specification.files.each do |file|
|
@specification.files.each do |file|
|
||||||
next unless File.file?(file)
|
next unless File.file?(file)
|
||||||
next if File.stat(file).mode & 0444 == 0444
|
next if File.stat(file).mode & 0o444 == 0o444
|
||||||
warning "#{file} is not world-readable"
|
warning "#{file} is not world-readable"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ class Gem::TestCase < Test::Unit::TestCase
|
|||||||
@temp_cred = File.join(@userhome, ".gem", "credentials")
|
@temp_cred = File.join(@userhome, ".gem", "credentials")
|
||||||
FileUtils.mkdir_p File.dirname(@temp_cred)
|
FileUtils.mkdir_p File.dirname(@temp_cred)
|
||||||
File.write @temp_cred, ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
|
File.write @temp_cred, ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
|
||||||
File.chmod 0600, @temp_cred
|
File.chmod 0o600, @temp_cred
|
||||||
end
|
end
|
||||||
|
|
||||||
def credential_teardown
|
def credential_teardown
|
||||||
|
@ -163,11 +163,11 @@ class Gem::Package::TarTestCase < Gem::TestCase
|
|||||||
data_tgz = util_tar_gz(&block)
|
data_tgz = util_tar_gz(&block)
|
||||||
util_tar do |tar|
|
util_tar do |tar|
|
||||||
if spec
|
if spec
|
||||||
tar.add_file "metadata.gz", 0444 do |io|
|
tar.add_file "metadata.gz", 0o444 do |io|
|
||||||
io.write util_gzip(spec.to_yaml)
|
io.write util_gzip(spec.to_yaml)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
tar.add_file "data.tar.gz", 0644 do |io|
|
tar.add_file "data.tar.gz", 0o644 do |io|
|
||||||
io.write data_tgz.string
|
io.write data_tgz.string
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -132,7 +132,7 @@ class TestGem < Gem::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_self_install_permissions_umask_077
|
def test_self_install_permissions_umask_077
|
||||||
umask = File.umask(077)
|
umask = File.umask(0o077)
|
||||||
assert_self_install_permissions
|
assert_self_install_permissions
|
||||||
ensure
|
ensure
|
||||||
File.umask(umask)
|
File.umask(umask)
|
||||||
@ -152,11 +152,11 @@ class TestGem < Gem::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assert_self_install_permissions(format_executable: false)
|
def assert_self_install_permissions(format_executable: false)
|
||||||
mask = Gem.win_platform? ? 0700 : 0777
|
mask = Gem.win_platform? ? 0o700 : 0o777
|
||||||
options = {
|
options = {
|
||||||
:dir_mode => 0500,
|
:dir_mode => 0o500,
|
||||||
:prog_mode => Gem.win_platform? ? 0410 : 0510,
|
:prog_mode => Gem.win_platform? ? 0o410 : 0o510,
|
||||||
:data_mode => 0640,
|
:data_mode => 0o640,
|
||||||
:wrappers => true,
|
:wrappers => true,
|
||||||
:format_executable => format_executable,
|
:format_executable => format_executable,
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ class TestGem < Gem::TestCase
|
|||||||
Dir.mkdir "data"
|
Dir.mkdir "data"
|
||||||
|
|
||||||
File.write "bin/foo", "#!/usr/bin/env ruby\n"
|
File.write "bin/foo", "#!/usr/bin/env ruby\n"
|
||||||
File.chmod 0755, "bin/foo"
|
File.chmod 0o755, "bin/foo"
|
||||||
|
|
||||||
File.write "data/foo.txt", "blah\n"
|
File.write "data/foo.txt", "blah\n"
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ class TestGem < Gem::TestCase
|
|||||||
end
|
end
|
||||||
assert_equal(expected, result)
|
assert_equal(expected, result)
|
||||||
ensure
|
ensure
|
||||||
File.chmod(0755, *Dir.glob(@gemhome + "/gems/**/").map {|path| path.tap(&Gem::UNTAINT) })
|
File.chmod(0o755, *Dir.glob(@gemhome + "/gems/**/").map {|path| path.tap(&Gem::UNTAINT) })
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_require_missing
|
def test_require_missing
|
||||||
@ -639,12 +639,12 @@ class TestGem < Gem::TestCase
|
|||||||
FileUtils.rm_r @gemhome
|
FileUtils.rm_r @gemhome
|
||||||
Gem.use_paths @gemhome
|
Gem.use_paths @gemhome
|
||||||
|
|
||||||
Gem.ensure_gem_subdirectories @gemhome, 0750
|
Gem.ensure_gem_subdirectories @gemhome, 0o750
|
||||||
|
|
||||||
assert_directory_exists File.join(@gemhome, "cache")
|
assert_directory_exists File.join(@gemhome, "cache")
|
||||||
|
|
||||||
assert_equal 0750, File::Stat.new(@gemhome).mode & 0777
|
assert_equal 0o750, File::Stat.new(@gemhome).mode & 0o777
|
||||||
assert_equal 0750, File::Stat.new(File.join(@gemhome, "cache")).mode & 0777
|
assert_equal 0o750, File::Stat.new(File.join(@gemhome, "cache")).mode & 0o777
|
||||||
end unless Gem.win_platform?
|
end unless Gem.win_platform?
|
||||||
|
|
||||||
def test_self_ensure_gem_directories_safe_permissions
|
def test_self_ensure_gem_directories_safe_permissions
|
||||||
@ -655,8 +655,8 @@ class TestGem < Gem::TestCase
|
|||||||
File.umask 0
|
File.umask 0
|
||||||
Gem.ensure_gem_subdirectories @gemhome
|
Gem.ensure_gem_subdirectories @gemhome
|
||||||
|
|
||||||
assert_equal 0, File::Stat.new(@gemhome).mode & 002
|
assert_equal 0, File::Stat.new(@gemhome).mode & 0o002
|
||||||
assert_equal 0, File::Stat.new(File.join(@gemhome, "cache")).mode & 002
|
assert_equal 0, File::Stat.new(File.join(@gemhome, "cache")).mode & 0o002
|
||||||
ensure
|
ensure
|
||||||
File.umask old_umask
|
File.umask old_umask
|
||||||
end unless Gem.win_platform?
|
end unless Gem.win_platform?
|
||||||
@ -687,14 +687,14 @@ class TestGem < Gem::TestCase
|
|||||||
end
|
end
|
||||||
refute File.exist?(gemdir), "manually remove #{gemdir}, tests are broken"
|
refute File.exist?(gemdir), "manually remove #{gemdir}, tests are broken"
|
||||||
FileUtils.mkdir_p gemdir
|
FileUtils.mkdir_p gemdir
|
||||||
FileUtils.chmod 0400, gemdir
|
FileUtils.chmod 0o400, gemdir
|
||||||
Gem.use_paths gemdir
|
Gem.use_paths gemdir
|
||||||
|
|
||||||
Gem.ensure_gem_subdirectories gemdir
|
Gem.ensure_gem_subdirectories gemdir
|
||||||
|
|
||||||
refute File.exist?(util_cache_dir)
|
refute File.exist?(util_cache_dir)
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0600, gemdir
|
FileUtils.chmod 0o600, gemdir
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_ensure_gem_directories_write_protected_parents
|
def test_self_ensure_gem_directories_write_protected_parents
|
||||||
@ -708,14 +708,14 @@ class TestGem < Gem::TestCase
|
|||||||
end
|
end
|
||||||
refute File.exist?(parent), "manually remove #{parent}, tests are broken"
|
refute File.exist?(parent), "manually remove #{parent}, tests are broken"
|
||||||
FileUtils.mkdir_p parent
|
FileUtils.mkdir_p parent
|
||||||
FileUtils.chmod 0400, parent
|
FileUtils.chmod 0o400, parent
|
||||||
Gem.use_paths(gemdir)
|
Gem.use_paths(gemdir)
|
||||||
|
|
||||||
Gem.ensure_gem_subdirectories gemdir
|
Gem.ensure_gem_subdirectories gemdir
|
||||||
|
|
||||||
refute File.exist? File.join(gemdir, "gems")
|
refute File.exist? File.join(gemdir, "gems")
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0600, parent
|
FileUtils.chmod 0o600, parent
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_ensure_gem_directories_non_existent_paths
|
def test_self_ensure_gem_directories_non_existent_paths
|
||||||
@ -977,11 +977,11 @@ class TestGem < Gem::TestCase
|
|||||||
pend "chmod not supported" if Gem.win_platform?
|
pend "chmod not supported" if Gem.win_platform?
|
||||||
|
|
||||||
begin
|
begin
|
||||||
File.chmod 0444, "test"
|
File.chmod 0o444, "test"
|
||||||
|
|
||||||
assert_equal ["\xCF", "\x80"], Gem.read_binary("test").chars.to_a
|
assert_equal ["\xCF", "\x80"], Gem.read_binary("test").chars.to_a
|
||||||
ensure
|
ensure
|
||||||
File.chmod 0644, "test"
|
File.chmod 0o644, "test"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -476,7 +476,7 @@ Removed '/CN=alternate/DC=example'
|
|||||||
|
|
||||||
def test_execute_sign
|
def test_execute_sign
|
||||||
path = File.join @tempdir, "cert.pem"
|
path = File.join @tempdir, "cert.pem"
|
||||||
Gem::Security.write ALTERNATE_CERT, path, 0600
|
Gem::Security.write ALTERNATE_CERT, path, 0o600
|
||||||
|
|
||||||
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
||||||
|
|
||||||
@ -498,14 +498,14 @@ Removed '/CN=alternate/DC=example'
|
|||||||
|
|
||||||
assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
|
assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
|
||||||
|
|
||||||
mask = 0100600 & (~File.umask)
|
mask = 0o100600 & (~File.umask)
|
||||||
|
|
||||||
assert_equal mask, File.stat(path).mode unless Gem.win_platform?
|
assert_equal mask, File.stat(path).mode unless Gem.win_platform?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_sign_encrypted_key
|
def test_execute_sign_encrypted_key
|
||||||
path = File.join @tempdir, "cert.pem"
|
path = File.join @tempdir, "cert.pem"
|
||||||
Gem::Security.write ALTERNATE_CERT, path, 0600
|
Gem::Security.write ALTERNATE_CERT, path, 0o600
|
||||||
|
|
||||||
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ Removed '/CN=alternate/DC=example'
|
|||||||
|
|
||||||
assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
|
assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
|
||||||
|
|
||||||
mask = 0100600 & (~File.umask)
|
mask = 0o100600 & (~File.umask)
|
||||||
|
|
||||||
assert_equal mask, File.stat(path).mode unless Gem.win_platform?
|
assert_equal mask, File.stat(path).mode unless Gem.win_platform?
|
||||||
end
|
end
|
||||||
@ -542,7 +542,7 @@ Removed '/CN=alternate/DC=example'
|
|||||||
Gem::Security.write PUBLIC_CERT, public_cert_path
|
Gem::Security.write PUBLIC_CERT, public_cert_path
|
||||||
|
|
||||||
path = File.join @tempdir, "cert.pem"
|
path = File.join @tempdir, "cert.pem"
|
||||||
Gem::Security.write ALTERNATE_CERT, path, 0600
|
Gem::Security.write ALTERNATE_CERT, path, 0o600
|
||||||
|
|
||||||
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
||||||
|
|
||||||
@ -559,7 +559,7 @@ Removed '/CN=alternate/DC=example'
|
|||||||
|
|
||||||
assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
|
assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
|
||||||
|
|
||||||
mask = 0100600 & (~File.umask)
|
mask = 0o100600 & (~File.umask)
|
||||||
|
|
||||||
assert_equal mask, File.stat(path).mode unless Gem.win_platform?
|
assert_equal mask, File.stat(path).mode unless Gem.win_platform?
|
||||||
end
|
end
|
||||||
@ -568,13 +568,13 @@ Removed '/CN=alternate/DC=example'
|
|||||||
FileUtils.mkdir_p File.join(Gem.user_home, ".gem")
|
FileUtils.mkdir_p File.join(Gem.user_home, ".gem")
|
||||||
|
|
||||||
private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem"
|
private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem"
|
||||||
Gem::Security.write ENCRYPTED_PRIVATE_KEY, private_key_path, 0600, PRIVATE_KEY_PASSPHRASE
|
Gem::Security.write ENCRYPTED_PRIVATE_KEY, private_key_path, 0o600, PRIVATE_KEY_PASSPHRASE
|
||||||
|
|
||||||
public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem"
|
public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem"
|
||||||
Gem::Security.write PUBLIC_CERT, public_cert_path
|
Gem::Security.write PUBLIC_CERT, public_cert_path
|
||||||
|
|
||||||
path = File.join @tempdir, "cert.pem"
|
path = File.join @tempdir, "cert.pem"
|
||||||
Gem::Security.write ALTERNATE_CERT, path, 0600
|
Gem::Security.write ALTERNATE_CERT, path, 0o600
|
||||||
|
|
||||||
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
||||||
|
|
||||||
@ -591,7 +591,7 @@ Removed '/CN=alternate/DC=example'
|
|||||||
|
|
||||||
assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
|
assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
|
||||||
|
|
||||||
mask = 0100600 & (~File.umask)
|
mask = 0o100600 & (~File.umask)
|
||||||
|
|
||||||
assert_equal mask, File.stat(path).mode unless Gem.win_platform?
|
assert_equal mask, File.stat(path).mode unless Gem.win_platform?
|
||||||
end
|
end
|
||||||
@ -603,7 +603,7 @@ Removed '/CN=alternate/DC=example'
|
|||||||
Gem::Security.write PRIVATE_KEY, private_key_path
|
Gem::Security.write PRIVATE_KEY, private_key_path
|
||||||
|
|
||||||
path = File.join @tempdir, "cert.pem"
|
path = File.join @tempdir, "cert.pem"
|
||||||
Gem::Security.write ALTERNATE_CERT, path, 0600
|
Gem::Security.write ALTERNATE_CERT, path, 0o600
|
||||||
|
|
||||||
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
||||||
|
|
||||||
@ -631,7 +631,7 @@ ERROR: --certificate not specified and ~/.gem/gem-public_cert.pem does not exis
|
|||||||
Gem::Security.write PUBLIC_CERT, public_cert_path
|
Gem::Security.write PUBLIC_CERT, public_cert_path
|
||||||
|
|
||||||
path = File.join @tempdir, "cert.pem"
|
path = File.join @tempdir, "cert.pem"
|
||||||
Gem::Security.write ALTERNATE_CERT, path, 0600
|
Gem::Security.write ALTERNATE_CERT, path, 0o600
|
||||||
|
|
||||||
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
|
||||||
|
|
||||||
@ -657,7 +657,7 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
|
|||||||
Dir.mkdir gem_path
|
Dir.mkdir gem_path
|
||||||
|
|
||||||
path = File.join @tempdir, "cert.pem"
|
path = File.join @tempdir, "cert.pem"
|
||||||
Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600
|
Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0o600
|
||||||
|
|
||||||
assert_equal "/CN=nobody/DC=example", EXPIRED_PUBLIC_CERT.issuer.to_s
|
assert_equal "/CN=nobody/DC=example", EXPIRED_PUBLIC_CERT.issuer.to_s
|
||||||
|
|
||||||
@ -689,7 +689,7 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
|
|||||||
Dir.mkdir gem_path
|
Dir.mkdir gem_path
|
||||||
|
|
||||||
path = File.join @tempdir, "cert.pem"
|
path = File.join @tempdir, "cert.pem"
|
||||||
Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600
|
Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0o600
|
||||||
|
|
||||||
assert_equal "/CN=nobody/DC=example", EXPIRED_PUBLIC_CERT.issuer.to_s
|
assert_equal "/CN=nobody/DC=example", EXPIRED_PUBLIC_CERT.issuer.to_s
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_all_user_no_sudo
|
def test_execute_all_user_no_sudo
|
||||||
FileUtils.chmod 0555, @gemhome
|
FileUtils.chmod 0o555, @gemhome
|
||||||
|
|
||||||
@a_1_1, = util_gem "a", "1.1"
|
@a_1_1, = util_gem "a", "1.1"
|
||||||
@a_1_1 = install_gem @a_1_1, :user_install => true # pick up user install path
|
@a_1_1 = install_gem @a_1_1, :user_install => true # pick up user install path
|
||||||
@ -183,7 +183,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
|||||||
assert_path_exist @a_1.gem_dir
|
assert_path_exist @a_1.gem_dir
|
||||||
assert_path_exist @a_1_1.gem_dir
|
assert_path_exist @a_1_1.gem_dir
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0755, @gemhome
|
FileUtils.chmod 0o755, @gemhome
|
||||||
end unless Gem.win_platform? || Process.uid.zero?
|
end unless Gem.win_platform? || Process.uid.zero?
|
||||||
|
|
||||||
def test_execute_dry_run
|
def test_execute_dry_run
|
||||||
|
@ -205,8 +205,8 @@ ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in a
|
|||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
orig_dir = Dir.pwd
|
orig_dir = Dir.pwd
|
||||||
begin
|
begin
|
||||||
FileUtils.chmod 0755, @userhome
|
FileUtils.chmod 0o755, @userhome
|
||||||
FileUtils.chmod 0555, @gemhome
|
FileUtils.chmod 0o555, @gemhome
|
||||||
|
|
||||||
Dir.chdir @tempdir
|
Dir.chdir @tempdir
|
||||||
assert_raise Gem::FilePermissionError do
|
assert_raise Gem::FilePermissionError do
|
||||||
@ -214,7 +214,7 @@ ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in a
|
|||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
Dir.chdir orig_dir
|
Dir.chdir orig_dir
|
||||||
FileUtils.chmod 0755, @gemhome
|
FileUtils.chmod 0o755, @gemhome
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -54,7 +54,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_user_install
|
def test_execute_user_install
|
||||||
FileUtils.chmod 0555, @gemhome
|
FileUtils.chmod 0o555, @gemhome
|
||||||
|
|
||||||
a = util_spec "a" do |s|
|
a = util_spec "a" do |s|
|
||||||
s.executables = %w[foo]
|
s.executables = %w[foo]
|
||||||
@ -99,7 +99,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
|||||||
assert_equal "Restored #{a.full_name}", out.shift
|
assert_equal "Restored #{a.full_name}", out.shift
|
||||||
assert_empty out, out.inspect
|
assert_empty out, out.inspect
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod(0755, @gemhome)
|
FileUtils.chmod(0o755, @gemhome)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_all
|
def test_execute_all
|
||||||
|
@ -156,7 +156,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
|||||||
|
|
||||||
util_make_gems
|
util_make_gems
|
||||||
|
|
||||||
FileUtils.chmod 0555, @gemhome
|
FileUtils.chmod 0o555, @gemhome
|
||||||
|
|
||||||
@cmd.options[:args] = %w[b]
|
@cmd.options[:args] = %w[b]
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
|||||||
|
|
||||||
assert File.exist?(File.join(@tempdir, "b-2")), "b should be unpacked"
|
assert File.exist?(File.join(@tempdir, "b-2")), "b should be unpacked"
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0755, @gemhome
|
FileUtils.chmod 0o755, @gemhome
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_with_target_option
|
def test_execute_with_target_option
|
||||||
|
@ -185,7 +185,7 @@ class TestGemConfigFile < Gem::TestCase
|
|||||||
|
|
||||||
temp_cred = File.join Gem.user_home, ".gem", "credentials"
|
temp_cred = File.join Gem.user_home, ".gem", "credentials"
|
||||||
FileUtils.mkdir_p File.dirname(temp_cred)
|
FileUtils.mkdir_p File.dirname(temp_cred)
|
||||||
File.open temp_cred, "w", 0600 do |fp|
|
File.open temp_cred, "w", 0o600 do |fp|
|
||||||
fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
|
fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ class TestGemConfigFile < Gem::TestCase
|
|||||||
|
|
||||||
@cfg.rubygems_api_key = "x"
|
@cfg.rubygems_api_key = "x"
|
||||||
|
|
||||||
File.chmod 0644, @cfg.credentials_path
|
File.chmod 0o644, @cfg.credentials_path
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raise Gem::MockGemUi::TermError do
|
assert_raise Gem::MockGemUi::TermError do
|
||||||
@ -323,7 +323,7 @@ if you believe they were disclosed to a third party.
|
|||||||
def test_load_api_keys
|
def test_load_api_keys
|
||||||
temp_cred = File.join Gem.user_home, ".gem", "credentials"
|
temp_cred = File.join Gem.user_home, ".gem", "credentials"
|
||||||
FileUtils.mkdir_p File.dirname(temp_cred)
|
FileUtils.mkdir_p File.dirname(temp_cred)
|
||||||
File.open temp_cred, "w", 0600 do |fp|
|
File.open temp_cred, "w", 0o600 do |fp|
|
||||||
fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
|
fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
|
||||||
fp.puts ":other: a5fdbb6ba150cbb83aad2bb2fede64c"
|
fp.puts ":other: a5fdbb6ba150cbb83aad2bb2fede64c"
|
||||||
end
|
end
|
||||||
@ -339,7 +339,7 @@ if you believe they were disclosed to a third party.
|
|||||||
|
|
||||||
@cfg.rubygems_api_key = "x"
|
@cfg.rubygems_api_key = "x"
|
||||||
|
|
||||||
File.chmod 0644, @cfg.credentials_path
|
File.chmod 0o644, @cfg.credentials_path
|
||||||
|
|
||||||
assert_raise Gem::MockGemUi::TermError do
|
assert_raise Gem::MockGemUi::TermError do
|
||||||
@cfg.load_api_keys
|
@cfg.load_api_keys
|
||||||
@ -372,7 +372,7 @@ if you believe they were disclosed to a third party.
|
|||||||
unless Gem.win_platform?
|
unless Gem.win_platform?
|
||||||
stat = File.stat @cfg.credentials_path
|
stat = File.stat @cfg.credentials_path
|
||||||
|
|
||||||
assert_equal 0600, stat.mode & 0600
|
assert_equal 0o600, stat.mode & 0o600
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ if you believe they were disclosed to a third party.
|
|||||||
|
|
||||||
@cfg.rubygems_api_key = "x"
|
@cfg.rubygems_api_key = "x"
|
||||||
|
|
||||||
File.chmod 0644, @cfg.credentials_path
|
File.chmod 0o644, @cfg.credentials_path
|
||||||
|
|
||||||
assert_raise Gem::MockGemUi::TermError do
|
assert_raise Gem::MockGemUi::TermError do
|
||||||
@cfg.rubygems_api_key = "y"
|
@cfg.rubygems_api_key = "y"
|
||||||
@ -395,7 +395,7 @@ if you believe they were disclosed to a third party.
|
|||||||
|
|
||||||
stat = File.stat @cfg.credentials_path
|
stat = File.stat @cfg.credentials_path
|
||||||
|
|
||||||
assert_equal 0644, stat.mode & 0644
|
assert_equal 0o644, stat.mode & 0o644
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_write
|
def test_write
|
||||||
|
@ -146,8 +146,8 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
|
|||||||
|
|
||||||
refute @cmd.options[:user_install]
|
refute @cmd.options[:user_install]
|
||||||
|
|
||||||
FileUtils.chmod 0755, @userhome
|
FileUtils.chmod 0o755, @userhome
|
||||||
FileUtils.chmod 0000, @gemhome
|
FileUtils.chmod 0o000, @gemhome
|
||||||
|
|
||||||
Gem.use_paths @gemhome, @userhome
|
Gem.use_paths @gemhome, @userhome
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0755, @gemhome
|
FileUtils.chmod 0o755, @gemhome
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_vendor
|
def test_vendor
|
||||||
|
@ -469,14 +469,14 @@ gem 'other', version
|
|||||||
elsif Process.uid.zero?
|
elsif Process.uid.zero?
|
||||||
pend("test_generate_bin_script_no_perms skipped in root privilege")
|
pend("test_generate_bin_script_no_perms skipped in root privilege")
|
||||||
else
|
else
|
||||||
FileUtils.chmod 0000, util_inst_bindir
|
FileUtils.chmod 0o000, util_inst_bindir
|
||||||
|
|
||||||
assert_raise Gem::FilePermissionError do
|
assert_raise Gem::FilePermissionError do
|
||||||
installer.generate_bin
|
installer.generate_bin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0755, util_inst_bindir unless $DEBUG || Gem.win_platform?
|
FileUtils.chmod 0o755, util_inst_bindir unless $DEBUG || Gem.win_platform?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_script_no_shebang
|
def test_generate_bin_script_no_shebang
|
||||||
@ -573,14 +573,14 @@ gem 'other', version
|
|||||||
elsif Process.uid.zero?
|
elsif Process.uid.zero?
|
||||||
pend("test_user_install_disabled_read_only test skipped in root privilege")
|
pend("test_user_install_disabled_read_only test skipped in root privilege")
|
||||||
else
|
else
|
||||||
FileUtils.chmod 0000, util_inst_bindir
|
FileUtils.chmod 0o000, util_inst_bindir
|
||||||
|
|
||||||
assert_raise Gem::FilePermissionError do
|
assert_raise Gem::FilePermissionError do
|
||||||
installer.generate_bin
|
installer.generate_bin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0755, util_inst_bindir unless $DEBUG || Gem.win_platform?
|
FileUtils.chmod 0o755, util_inst_bindir unless $DEBUG || Gem.win_platform?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlink_update_newer
|
def test_generate_bin_symlink_update_newer
|
||||||
@ -818,7 +818,7 @@ gem 'other', version
|
|||||||
|
|
||||||
util_build_gem spec
|
util_build_gem spec
|
||||||
|
|
||||||
File.chmod(0555, Gem.plugindir)
|
File.chmod(0o555, Gem.plugindir)
|
||||||
system_path = File.join(Gem.plugindir, "a_plugin.rb")
|
system_path = File.join(Gem.plugindir, "a_plugin.rb")
|
||||||
user_path = File.join(Gem.plugindir(Gem.user_dir), "a_plugin.rb")
|
user_path = File.join(Gem.plugindir(Gem.user_dir), "a_plugin.rb")
|
||||||
installer = util_installer spec, Gem.dir, :user
|
installer = util_installer spec, Gem.dir, :user
|
||||||
@ -840,7 +840,7 @@ gem 'other', version
|
|||||||
|
|
||||||
util_build_gem spec
|
util_build_gem spec
|
||||||
|
|
||||||
File.chmod(0555, Gem.plugindir)
|
File.chmod(0o555, Gem.plugindir)
|
||||||
system_path = File.join(Gem.plugindir, "a_plugin.rb")
|
system_path = File.join(Gem.plugindir, "a_plugin.rb")
|
||||||
|
|
||||||
build_root = File.join(@tempdir, "build_root")
|
build_root = File.join(@tempdir, "build_root")
|
||||||
@ -986,8 +986,8 @@ gem 'other', version
|
|||||||
exe = File.join gemdir, "bin", "executable"
|
exe = File.join gemdir, "bin", "executable"
|
||||||
assert_path_exist exe
|
assert_path_exist exe
|
||||||
|
|
||||||
exe_mode = File.stat(exe).mode & 0111
|
exe_mode = File.stat(exe).mode & 0o111
|
||||||
assert_equal 0111, exe_mode, format("0%o", exe_mode) unless Gem.win_platform?
|
assert_equal 0o111, exe_mode, format("0%o", exe_mode) unless Gem.win_platform?
|
||||||
|
|
||||||
assert_path_exist File.join gemdir, "lib", "code.rb"
|
assert_path_exist File.join gemdir, "lib", "code.rb"
|
||||||
|
|
||||||
@ -2458,7 +2458,7 @@ gem 'other', version
|
|||||||
end
|
end
|
||||||
|
|
||||||
def mask
|
def mask
|
||||||
0100755
|
0o100755
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_relative(value)
|
def load_relative(value)
|
||||||
|
@ -442,11 +442,11 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
data_tgz = util_tar_gz {}
|
data_tgz = util_tar_gz {}
|
||||||
|
|
||||||
gem = util_tar do |tar|
|
gem = util_tar do |tar|
|
||||||
tar.add_file "data.tar.gz", 0644 do |io|
|
tar.add_file "data.tar.gz", 0o644 do |io|
|
||||||
io.write data_tgz.string
|
io.write data_tgz.string
|
||||||
end
|
end
|
||||||
|
|
||||||
tar.add_file "metadata.gz", 0644 do |io|
|
tar.add_file "metadata.gz", 0o644 do |io|
|
||||||
Zlib::GzipWriter.wrap io do |gzio|
|
Zlib::GzipWriter.wrap io do |gzio|
|
||||||
gzio.write @spec.to_yaml
|
gzio.write @spec.to_yaml
|
||||||
end
|
end
|
||||||
@ -479,7 +479,7 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
extracted = File.join @destination, "lib/code.rb"
|
extracted = File.join @destination, "lib/code.rb"
|
||||||
assert_path_exist extracted
|
assert_path_exist extracted
|
||||||
|
|
||||||
mask = 0100666 & (~File.umask)
|
mask = 0o100666 & (~File.umask)
|
||||||
|
|
||||||
assert_equal mask.to_s(8), File.stat(extracted).mode.to_s(8) unless
|
assert_equal mask.to_s(8), File.stat(extracted).mode.to_s(8) unless
|
||||||
Gem.win_platform?
|
Gem.win_platform?
|
||||||
@ -489,11 +489,11 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
data_tgz = util_tar_gz {}
|
data_tgz = util_tar_gz {}
|
||||||
|
|
||||||
gem = util_tar do |tar|
|
gem = util_tar do |tar|
|
||||||
tar.add_file "data.tar.gz", 0644 do |io|
|
tar.add_file "data.tar.gz", 0o644 do |io|
|
||||||
io.write data_tgz.string
|
io.write data_tgz.string
|
||||||
end
|
end
|
||||||
|
|
||||||
tar.add_file "metadata.gz", 0644 do |io|
|
tar.add_file "metadata.gz", 0o644 do |io|
|
||||||
Zlib::GzipWriter.wrap io do |gzio|
|
Zlib::GzipWriter.wrap io do |gzio|
|
||||||
gzio.write @spec.to_yaml
|
gzio.write @spec.to_yaml
|
||||||
end
|
end
|
||||||
@ -523,14 +523,14 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
filepath = File.join @destination, "README.rdoc"
|
filepath = File.join @destination, "README.rdoc"
|
||||||
assert_path_exist filepath
|
assert_path_exist filepath
|
||||||
|
|
||||||
assert_equal 0104444, File.stat(filepath).mode
|
assert_equal 0o104444, File.stat(filepath).mode
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_extract_tar_gz_absolute
|
def test_extract_tar_gz_absolute
|
||||||
package = Gem::Package.new @gem
|
package = Gem::Package.new @gem
|
||||||
|
|
||||||
tgz_io = util_tar_gz do |tar|
|
tgz_io = util_tar_gz do |tar|
|
||||||
tar.add_file "/absolute.rb", 0644 do |io|
|
tar.add_file "/absolute.rb", 0o644 do |io|
|
||||||
io.write "hi"
|
io.write "hi"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -548,12 +548,12 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
package.verify
|
package.verify
|
||||||
|
|
||||||
tgz_io = util_tar_gz do |tar|
|
tgz_io = util_tar_gz do |tar|
|
||||||
tar.add_file "relative.rb", 0644 do |io|
|
tar.add_file "relative.rb", 0o644 do |io|
|
||||||
io.write "hi"
|
io.write "hi"
|
||||||
end
|
end
|
||||||
|
|
||||||
tar.mkdir "lib", 0755
|
tar.mkdir "lib", 0o755
|
||||||
tar.add_symlink "lib/foo.rb", "../relative.rb", 0644
|
tar.add_symlink "lib/foo.rb", "../relative.rb", 0o644
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -579,8 +579,8 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
package.verify
|
package.verify
|
||||||
|
|
||||||
tgz_io = util_tar_gz do |tar|
|
tgz_io = util_tar_gz do |tar|
|
||||||
tar.mkdir "lib", 0755
|
tar.mkdir "lib", 0o755
|
||||||
tar.add_symlink "lib/foo.rb", "../broken.rb", 0644
|
tar.add_symlink "lib/foo.rb", "../broken.rb", 0o644
|
||||||
end
|
end
|
||||||
|
|
||||||
ui = Gem::MockGemUi.new
|
ui = Gem::MockGemUi.new
|
||||||
@ -599,9 +599,9 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
package = Gem::Package.new @gem
|
package = Gem::Package.new @gem
|
||||||
|
|
||||||
tgz_io = util_tar_gz do |tar|
|
tgz_io = util_tar_gz do |tar|
|
||||||
tar.mkdir "lib", 0755
|
tar.mkdir "lib", 0o755
|
||||||
tar.add_symlink "lib/link", "../..", 0644
|
tar.add_symlink "lib/link", "../..", 0o644
|
||||||
tar.add_file "lib/link/outside.txt", 0644 do |io|
|
tar.add_file "lib/link/outside.txt", 0o644 do |io|
|
||||||
io.write "hi"
|
io.write "hi"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -667,11 +667,11 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
package = Gem::Package.new @gem
|
package = Gem::Package.new @gem
|
||||||
|
|
||||||
tgz_io = util_tar_gz do |tar|
|
tgz_io = util_tar_gz do |tar|
|
||||||
tar.mkdir "lib", 0755
|
tar.mkdir "lib", 0o755
|
||||||
tar.add_file "lib/foo.rb", 0644 do |io|
|
tar.add_file "lib/foo.rb", 0o644 do |io|
|
||||||
io.write "hi"
|
io.write "hi"
|
||||||
end
|
end
|
||||||
tar.mkdir "lib/foo", 0755
|
tar.mkdir "lib/foo", 0o755
|
||||||
end
|
end
|
||||||
|
|
||||||
package.extract_tar_gz tgz_io, @destination
|
package.extract_tar_gz tgz_io, @destination
|
||||||
@ -687,7 +687,7 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
package = Gem::Package.new @gem
|
package = Gem::Package.new @gem
|
||||||
|
|
||||||
tgz_io = util_tar_gz do |tar|
|
tgz_io = util_tar_gz do |tar|
|
||||||
tar.add_file "./dot_slash.rb", 0644 do |io|
|
tar.add_file "./dot_slash.rb", 0o644 do |io|
|
||||||
io.write "hi"
|
io.write "hi"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -702,7 +702,7 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
package = Gem::Package.new @gem
|
package = Gem::Package.new @gem
|
||||||
|
|
||||||
tgz_io = util_tar_gz do |tar|
|
tgz_io = util_tar_gz do |tar|
|
||||||
tar.add_file ".dot_file.rb", 0644 do |io|
|
tar.add_file ".dot_file.rb", 0o644 do |io|
|
||||||
io.write "hi"
|
io.write "hi"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -718,7 +718,7 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
package = Gem::Package.new @gem
|
package = Gem::Package.new @gem
|
||||||
|
|
||||||
tgz_io = util_tar_gz do |tar|
|
tgz_io = util_tar_gz do |tar|
|
||||||
tar.add_file "foo/file.rb", 0644 do |io|
|
tar.add_file "foo/file.rb", 0o644 do |io|
|
||||||
io.write "hi"
|
io.write "hi"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -834,7 +834,7 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
|
|
||||||
def test_verify_checksum_bad
|
def test_verify_checksum_bad
|
||||||
data_tgz = util_tar_gz do |tar|
|
data_tgz = util_tar_gz do |tar|
|
||||||
tar.add_file "lib/code.rb", 0444 do |io|
|
tar.add_file "lib/code.rb", 0o444 do |io|
|
||||||
io.write "# lib/code.rb"
|
io.write "# lib/code.rb"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -844,11 +844,11 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
gem = util_tar do |tar|
|
gem = util_tar do |tar|
|
||||||
metadata_gz = Gem::Util.gzip @spec.to_yaml
|
metadata_gz = Gem::Util.gzip @spec.to_yaml
|
||||||
|
|
||||||
tar.add_file "metadata.gz", 0444 do |io|
|
tar.add_file "metadata.gz", 0o444 do |io|
|
||||||
io.write metadata_gz
|
io.write metadata_gz
|
||||||
end
|
end
|
||||||
|
|
||||||
tar.add_file "data.tar.gz", 0444 do |io|
|
tar.add_file "data.tar.gz", 0o444 do |io|
|
||||||
io.write data_tgz
|
io.write data_tgz
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -858,7 +858,7 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
"metadata.gz" => "bogus",
|
"metadata.gz" => "bogus",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
tar.add_file "checksums.yaml.gz", 0444 do |io|
|
tar.add_file "checksums.yaml.gz", 0o444 do |io|
|
||||||
Zlib::GzipWriter.wrap io do |gz_io|
|
Zlib::GzipWriter.wrap io do |gz_io|
|
||||||
gz_io.write Psych.dump bogus_checksums
|
gz_io.write Psych.dump bogus_checksums
|
||||||
end
|
end
|
||||||
@ -881,7 +881,7 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
|
|
||||||
def test_verify_checksum_missing
|
def test_verify_checksum_missing
|
||||||
data_tgz = util_tar_gz do |tar|
|
data_tgz = util_tar_gz do |tar|
|
||||||
tar.add_file "lib/code.rb", 0444 do |io|
|
tar.add_file "lib/code.rb", 0o444 do |io|
|
||||||
io.write "# lib/code.rb"
|
io.write "# lib/code.rb"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -891,7 +891,7 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
gem = util_tar do |tar|
|
gem = util_tar do |tar|
|
||||||
metadata_gz = Gem::Util.gzip @spec.to_yaml
|
metadata_gz = Gem::Util.gzip @spec.to_yaml
|
||||||
|
|
||||||
tar.add_file "metadata.gz", 0444 do |io|
|
tar.add_file "metadata.gz", 0o444 do |io|
|
||||||
io.write metadata_gz
|
io.write metadata_gz
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -904,13 +904,13 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
tar.add_file "checksums.yaml.gz", 0444 do |io|
|
tar.add_file "checksums.yaml.gz", 0o444 do |io|
|
||||||
Zlib::GzipWriter.wrap io do |gz_io|
|
Zlib::GzipWriter.wrap io do |gz_io|
|
||||||
gz_io.write Psych.dump checksums
|
gz_io.write Psych.dump checksums
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
tar.add_file "data.tar.gz", 0444 do |io|
|
tar.add_file "data.tar.gz", 0o444 do |io|
|
||||||
io.write data_tgz
|
io.write data_tgz
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -929,7 +929,7 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
tf = Tempfile.open "corrupt" do |io|
|
tf = Tempfile.open "corrupt" do |io|
|
||||||
data = Gem::Util.gzip "a" * 10
|
data = Gem::Util.gzip "a" * 10
|
||||||
io.write \
|
io.write \
|
||||||
tar_file_header("metadata.gz", "\000x", 0644, data.length, Time.now)
|
tar_file_header("metadata.gz", "\000x", 0o644, data.length, Time.now)
|
||||||
io.write data
|
io.write data
|
||||||
io.rewind
|
io.rewind
|
||||||
|
|
||||||
@ -981,8 +981,8 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
build.add_metadata gem
|
build.add_metadata gem
|
||||||
build.add_contents gem
|
build.add_contents gem
|
||||||
|
|
||||||
gem.add_file_simple "a.sig", 0444, 0
|
gem.add_file_simple "a.sig", 0o444, 0
|
||||||
gem.add_file_simple "a.sig", 0444, 0
|
gem.add_file_simple "a.sig", 0o444, 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1069,7 +1069,7 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||||||
"fake_sig"
|
"fake_sig"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
gem.add_file_signed "data2.tar.gz", 0444, fake_signer.new do |io|
|
gem.add_file_signed "data2.tar.gz", 0o444, fake_signer.new do |io|
|
||||||
io.write bogus_data
|
io.write bogus_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ unless Gem.java_platform? # jruby can't require the simple_gem file
|
|||||||
extracted = File.join @destination, "lib/foo.rb"
|
extracted = File.join @destination, "lib/foo.rb"
|
||||||
assert_path_exist extracted
|
assert_path_exist extracted
|
||||||
|
|
||||||
mask = 0100644 & (~File.umask)
|
mask = 0o100644 & (~File.umask)
|
||||||
|
|
||||||
assert_equal mask, File.stat(extracted).mode unless Gem.win_platform?
|
assert_equal mask, File.stat(extracted).mode unless Gem.win_platform?
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ class TestGemPackageTarHeader < Gem::Package::TarTestCase
|
|||||||
|
|
||||||
header = {
|
header = {
|
||||||
:name => "x",
|
:name => "x",
|
||||||
:mode => 0644,
|
:mode => 0o644,
|
||||||
:uid => 1000,
|
:uid => 1000,
|
||||||
:gid => 10_000,
|
:gid => 10_000,
|
||||||
:size => 100,
|
:size => 100,
|
||||||
@ -44,7 +44,7 @@ class TestGemPackageTarHeader < Gem::Package::TarTestCase
|
|||||||
assert_equal "group", @tar_header.gname, "gname"
|
assert_equal "group", @tar_header.gname, "gname"
|
||||||
assert_equal "link", @tar_header.linkname, "linkname"
|
assert_equal "link", @tar_header.linkname, "linkname"
|
||||||
assert_equal "ustar", @tar_header.magic, "magic"
|
assert_equal "ustar", @tar_header.magic, "magic"
|
||||||
assert_equal 0644, @tar_header.mode, "mode"
|
assert_equal 0o644, @tar_header.mode, "mode"
|
||||||
assert_equal 12_345, @tar_header.mtime, "mtime"
|
assert_equal 12_345, @tar_header.mtime, "mtime"
|
||||||
assert_equal "x", @tar_header.name, "name"
|
assert_equal "x", @tar_header.name, "name"
|
||||||
assert_equal "y", @tar_header.prefix, "prefix"
|
assert_equal "y", @tar_header.prefix, "prefix"
|
||||||
@ -200,7 +200,7 @@ tjmather\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
|||||||
assert_equal 1_991_400_094, tar_header.gid
|
assert_equal 1_991_400_094, tar_header.gid
|
||||||
|
|
||||||
assert_equal "GeoIP2-City_20190528/", tar_header.name
|
assert_equal "GeoIP2-City_20190528/", tar_header.name
|
||||||
assert_equal 0755, tar_header.mode
|
assert_equal 0o755, tar_header.mode
|
||||||
assert_equal 0, tar_header.size
|
assert_equal 0, tar_header.size
|
||||||
assert_equal 1_559_064_640, tar_header.mtime
|
assert_equal 1_559_064_640, tar_header.mtime
|
||||||
assert_equal 6932, tar_header.checksum
|
assert_equal 6932, tar_header.checksum
|
||||||
|
@ -29,7 +29,7 @@ class TestGemPackageTarReader < Gem::Package::TarTestCase
|
|||||||
content = ("a".."z").to_a.join(" ")
|
content = ("a".."z").to_a.join(" ")
|
||||||
|
|
||||||
str =
|
str =
|
||||||
tar_file_header("lib/foo", "", 010644, content.size, Time.now) +
|
tar_file_header("lib/foo", "", 0o10644, content.size, Time.now) +
|
||||||
content + "\0" * (512 - content.size)
|
content + "\0" * (512 - content.size)
|
||||||
str << "\0" * 1024
|
str << "\0" * 1024
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class TestGemPackageTarReader < Gem::Package::TarTestCase
|
|||||||
|
|
||||||
def test_read_in_gem_data
|
def test_read_in_gem_data
|
||||||
gem_tar = util_gem_data_tar do |tar|
|
gem_tar = util_gem_data_tar do |tar|
|
||||||
tar.add_file "lib/code.rb", 0444 do |io|
|
tar.add_file "lib/code.rb", 0o444 do |io|
|
||||||
io.write "# lib/code.rb"
|
io.write "# lib/code.rb"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -112,10 +112,10 @@ class TestGemPackageTarReader < Gem::Package::TarTestCase
|
|||||||
|
|
||||||
def test_seek_in_gem_data
|
def test_seek_in_gem_data
|
||||||
gem_tar = util_gem_data_tar do |tar|
|
gem_tar = util_gem_data_tar do |tar|
|
||||||
tar.add_file "lib/code.rb", 0444 do |io|
|
tar.add_file "lib/code.rb", 0o444 do |io|
|
||||||
io.write "# lib/code.rb"
|
io.write "# lib/code.rb"
|
||||||
end
|
end
|
||||||
tar.add_file "lib/foo.rb", 0444 do |io|
|
tar.add_file "lib/foo.rb", 0o444 do |io|
|
||||||
io.write "# lib/foo.rb"
|
io.write "# lib/foo.rb"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -29,11 +29,11 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
|
|
||||||
def test_add_file
|
def test_add_file
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
@tar_writer.add_file "x", 0644 do |f|
|
@tar_writer.add_file "x", 0o644 do |f|
|
||||||
f.write "a" * 10
|
f.write "a" * 10
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now),
|
assert_headers_equal(tar_file_header("x", "", 0o644, 10, Time.now),
|
||||||
@io.string[0, 512])
|
@io.string[0, 512])
|
||||||
end
|
end
|
||||||
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
||||||
@ -43,18 +43,18 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
def test_add_file_source_date_epoch
|
def test_add_file_source_date_epoch
|
||||||
ENV["SOURCE_DATE_EPOCH"] = "123456789"
|
ENV["SOURCE_DATE_EPOCH"] = "123456789"
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
@tar_writer.mkdir "foo", 0644
|
@tar_writer.mkdir "foo", 0o644
|
||||||
|
|
||||||
assert_headers_equal tar_dir_header("foo", "", 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc),
|
assert_headers_equal tar_dir_header("foo", "", 0o644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc),
|
||||||
@io.string[0, 512]
|
@io.string[0, 512]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_symlink
|
def test_add_symlink
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
@tar_writer.add_symlink "x", "y", 0644
|
@tar_writer.add_symlink "x", "y", 0o644
|
||||||
|
|
||||||
assert_headers_equal(tar_symlink_header("x", "", 0644, Time.now, "y"),
|
assert_headers_equal(tar_symlink_header("x", "", 0o644, Time.now, "y"),
|
||||||
@io.string[0, 512])
|
@io.string[0, 512])
|
||||||
end
|
end
|
||||||
assert_equal 512, @io.pos
|
assert_equal 512, @io.pos
|
||||||
@ -63,9 +63,9 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
def test_add_symlink_source_date_epoch
|
def test_add_symlink_source_date_epoch
|
||||||
ENV["SOURCE_DATE_EPOCH"] = "123456789"
|
ENV["SOURCE_DATE_EPOCH"] = "123456789"
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
@tar_writer.add_symlink "x", "y", 0644
|
@tar_writer.add_symlink "x", "y", 0o644
|
||||||
|
|
||||||
assert_headers_equal(tar_symlink_header("x", "", 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc, "y"),
|
assert_headers_equal(tar_symlink_header("x", "", 0o644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc, "y"),
|
||||||
@io.string[0, 512])
|
@io.string[0, 512])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -74,7 +74,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
digest_algorithms = OpenSSL::Digest::SHA1.new, OpenSSL::Digest::SHA512.new
|
digest_algorithms = OpenSSL::Digest::SHA1.new, OpenSSL::Digest::SHA512.new
|
||||||
|
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
digests = @tar_writer.add_file_digest "x", 0644, digest_algorithms do |io|
|
digests = @tar_writer.add_file_digest "x", 0o644, digest_algorithms do |io|
|
||||||
io.write "a" * 10
|
io.write "a" * 10
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
"e1cf14b0",
|
"e1cf14b0",
|
||||||
digests["SHA512"].hexdigest
|
digests["SHA512"].hexdigest
|
||||||
|
|
||||||
assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now),
|
assert_headers_equal(tar_file_header("x", "", 0o644, 10, Time.now),
|
||||||
@io.string[0, 512])
|
@io.string[0, 512])
|
||||||
end
|
end
|
||||||
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
||||||
@ -97,7 +97,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
digest_algorithms = [OpenSSL::Digest::SHA1.new, OpenSSL::Digest::SHA512.new]
|
digest_algorithms = [OpenSSL::Digest::SHA1.new, OpenSSL::Digest::SHA512.new]
|
||||||
|
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
digests = @tar_writer.add_file_digest "x", 0644, digest_algorithms do |io|
|
digests = @tar_writer.add_file_digest "x", 0o644, digest_algorithms do |io|
|
||||||
io.write "a" * 10
|
io.write "a" * 10
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
"e1cf14b0",
|
"e1cf14b0",
|
||||||
digests["SHA512"].hexdigest
|
digests["SHA512"].hexdigest
|
||||||
|
|
||||||
assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now),
|
assert_headers_equal(tar_file_header("x", "", 0o644, 10, Time.now),
|
||||||
@io.string[0, 512])
|
@io.string[0, 512])
|
||||||
end
|
end
|
||||||
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
||||||
@ -122,11 +122,11 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
signer = Gem::Security::Signer.new PRIVATE_KEY, [PUBLIC_CERT]
|
signer = Gem::Security::Signer.new PRIVATE_KEY, [PUBLIC_CERT]
|
||||||
|
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
@tar_writer.add_file_signed "x", 0644, signer do |io|
|
@tar_writer.add_file_signed "x", 0o644, signer do |io|
|
||||||
io.write "a" * 10
|
io.write "a" * 10
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now),
|
assert_headers_equal(tar_file_header("x", "", 0o644, 10, Time.now),
|
||||||
@io.string[0, 512])
|
@io.string[0, 512])
|
||||||
|
|
||||||
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
||||||
@ -136,7 +136,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
|
|
||||||
signature = signer.sign digest.digest
|
signature = signer.sign digest.digest
|
||||||
|
|
||||||
assert_headers_equal(tar_file_header("x.sig", "", 0444, signature.length,
|
assert_headers_equal(tar_file_header("x.sig", "", 0o444, signature.length,
|
||||||
Time.now),
|
Time.now),
|
||||||
@io.string[1024, 512])
|
@io.string[1024, 512])
|
||||||
assert_equal "#{signature}#{"\0" * (512 - signature.length)}",
|
assert_equal "#{signature}#{"\0" * (512 - signature.length)}",
|
||||||
@ -150,11 +150,11 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
signer = Gem::Security::Signer.new nil, nil
|
signer = Gem::Security::Signer.new nil, nil
|
||||||
|
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
@tar_writer.add_file_signed "x", 0644, signer do |io|
|
@tar_writer.add_file_signed "x", 0o644, signer do |io|
|
||||||
io.write "a" * 10
|
io.write "a" * 10
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now),
|
assert_headers_equal(tar_file_header("x", "", 0o644, 10, Time.now),
|
||||||
@io.string[0, 512])
|
@io.string[0, 512])
|
||||||
end
|
end
|
||||||
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
||||||
@ -164,11 +164,11 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
|
|
||||||
def test_add_file_simple
|
def test_add_file_simple
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
@tar_writer.add_file_simple "x", 0644, 10 do |io|
|
@tar_writer.add_file_simple "x", 0o644, 10 do |io|
|
||||||
io.write "a" * 10
|
io.write "a" * 10
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now),
|
assert_headers_equal(tar_file_header("x", "", 0o644, 10, Time.now),
|
||||||
@io.string[0, 512])
|
@io.string[0, 512])
|
||||||
|
|
||||||
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
|
||||||
@ -179,11 +179,11 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
def test_add_file_simple_source_date_epoch
|
def test_add_file_simple_source_date_epoch
|
||||||
ENV["SOURCE_DATE_EPOCH"] = "123456789"
|
ENV["SOURCE_DATE_EPOCH"] = "123456789"
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
@tar_writer.add_file_simple "x", 0644, 10 do |io|
|
@tar_writer.add_file_simple "x", 0o644, 10 do |io|
|
||||||
io.write "a" * 10
|
io.write "a" * 10
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc),
|
assert_headers_equal(tar_file_header("x", "", 0o644, 10, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc),
|
||||||
@io.string[0, 512])
|
@io.string[0, 512])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -248,9 +248,9 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
|
|
||||||
def test_mkdir
|
def test_mkdir
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
@tar_writer.mkdir "foo", 0644
|
@tar_writer.mkdir "foo", 0o644
|
||||||
|
|
||||||
assert_headers_equal tar_dir_header("foo", "", 0644, Time.now),
|
assert_headers_equal tar_dir_header("foo", "", 0o644, Time.now),
|
||||||
@io.string[0, 512]
|
@io.string[0, 512]
|
||||||
|
|
||||||
assert_equal 512, @io.pos
|
assert_equal 512, @io.pos
|
||||||
@ -260,9 +260,9 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
|
|||||||
def test_mkdir_source_date_epoch
|
def test_mkdir_source_date_epoch
|
||||||
ENV["SOURCE_DATE_EPOCH"] = "123456789"
|
ENV["SOURCE_DATE_EPOCH"] = "123456789"
|
||||||
Time.stub :now, Time.at(1_458_518_157) do
|
Time.stub :now, Time.at(1_458_518_157) do
|
||||||
@tar_writer.mkdir "foo", 0644
|
@tar_writer.mkdir "foo", 0o644
|
||||||
|
|
||||||
assert_headers_equal tar_dir_header("foo", "", 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc),
|
assert_headers_equal tar_dir_header("foo", "", 0o644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc),
|
||||||
@io.string[0, 512]
|
@io.string[0, 512]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -100,7 +100,7 @@ class TestGemRDoc < Gem::TestCase
|
|||||||
|
|
||||||
assert_equal @a.base_dir, e.directory
|
assert_equal @a.base_dir, e.directory
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod(0755, @a.base_dir) if File.directory?(@a.base_dir)
|
FileUtils.chmod(0o755, @a.base_dir) if File.directory?(@a.base_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ri_installed?
|
def test_ri_installed?
|
||||||
@ -130,7 +130,7 @@ class TestGemRDoc < Gem::TestCase
|
|||||||
assert_equal @a.doc_dir, e.directory
|
assert_equal @a.doc_dir, e.directory
|
||||||
ensure
|
ensure
|
||||||
if File.exist? @a.doc_dir
|
if File.exist? @a.doc_dir
|
||||||
FileUtils.chmod 0755, @a.doc_dir
|
FileUtils.chmod 0o755, @a.doc_dir
|
||||||
FileUtils.rm_r @a.doc_dir
|
FileUtils.rm_r @a.doc_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -359,13 +359,13 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|||||||
FileUtils.mv @a1_gem, @tempdir
|
FileUtils.mv @a1_gem, @tempdir
|
||||||
local_path = File.join @tempdir, @a1.file_name
|
local_path = File.join @tempdir, @a1.file_name
|
||||||
inst = nil
|
inst = nil
|
||||||
FileUtils.chmod 0555, @a1.cache_dir
|
FileUtils.chmod 0o555, @a1.cache_dir
|
||||||
begin
|
begin
|
||||||
FileUtils.mkdir_p File.join(Gem.user_dir, "cache")
|
FileUtils.mkdir_p File.join(Gem.user_dir, "cache")
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
FileUtils.chmod 0555, File.join(Gem.user_dir, "cache")
|
FileUtils.chmod 0o555, File.join(Gem.user_dir, "cache")
|
||||||
|
|
||||||
Dir.chdir @tempdir do
|
Dir.chdir @tempdir do
|
||||||
inst = Gem::RemoteFetcher.fetcher
|
inst = Gem::RemoteFetcher.fetcher
|
||||||
@ -374,21 +374,21 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|||||||
assert_equal(File.join(@tempdir, @a1.file_name),
|
assert_equal(File.join(@tempdir, @a1.file_name),
|
||||||
inst.download(@a1, local_path))
|
inst.download(@a1, local_path))
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0755, File.join(Gem.user_dir, "cache")
|
FileUtils.chmod 0o755, File.join(Gem.user_dir, "cache")
|
||||||
FileUtils.chmod 0755, @a1.cache_dir
|
FileUtils.chmod 0o755, @a1.cache_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_download_read_only
|
def test_download_read_only
|
||||||
FileUtils.chmod 0555, @a1.cache_dir
|
FileUtils.chmod 0o555, @a1.cache_dir
|
||||||
FileUtils.chmod 0555, @gemhome
|
FileUtils.chmod 0o555, @gemhome
|
||||||
|
|
||||||
fetcher = util_fuck_with_fetcher File.read(@a1_gem)
|
fetcher = util_fuck_with_fetcher File.read(@a1_gem)
|
||||||
fetcher.download(@a1, "http://gems.example.com")
|
fetcher.download(@a1, "http://gems.example.com")
|
||||||
a1_cache_gem = File.join Gem.user_dir, "cache", @a1.file_name
|
a1_cache_gem = File.join Gem.user_dir, "cache", @a1.file_name
|
||||||
assert File.exist? a1_cache_gem
|
assert File.exist? a1_cache_gem
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0755, @gemhome
|
FileUtils.chmod 0o755, @gemhome
|
||||||
FileUtils.chmod 0755, @a1.cache_dir
|
FileUtils.chmod 0o755, @a1.cache_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ class TestGemSecurity < Gem::TestCase
|
|||||||
|
|
||||||
passphrase = "It should be long."
|
passphrase = "It should be long."
|
||||||
|
|
||||||
@SEC.write key, path, 0600, passphrase
|
@SEC.write key, path, 0o600, passphrase
|
||||||
|
|
||||||
assert_path_exist path
|
assert_path_exist path
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ class TestGemSecurity < Gem::TestCase
|
|||||||
|
|
||||||
cipher = OpenSSL::Cipher.new "AES-192-CBC"
|
cipher = OpenSSL::Cipher.new "AES-192-CBC"
|
||||||
|
|
||||||
@SEC.write key, path, 0600, passphrase, cipher
|
@SEC.write key, path, 0o600, passphrase, cipher
|
||||||
|
|
||||||
assert_path_exist path
|
assert_path_exist path
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ B8khkB8hDKC6moCzebmUxCBmTmXD0Wjzon+bf4MOriVE3a0ySGRvpr1mKR2+
|
|||||||
|
|
||||||
def test_sign_expired_auto_update
|
def test_sign_expired_auto_update
|
||||||
pend if Gem.java_platform?
|
pend if Gem.java_platform?
|
||||||
FileUtils.mkdir_p File.join(Gem.user_home, ".gem"), :mode => 0700
|
FileUtils.mkdir_p File.join(Gem.user_home, ".gem"), :mode => 0o700
|
||||||
|
|
||||||
private_key_path = File.join(Gem.user_home, ".gem", "gem-private_key.pem")
|
private_key_path = File.join(Gem.user_home, ".gem", "gem-private_key.pem")
|
||||||
Gem::Security.write PRIVATE_KEY, private_key_path
|
Gem::Security.write PRIVATE_KEY, private_key_path
|
||||||
@ -171,7 +171,7 @@ B8khkB8hDKC6moCzebmUxCBmTmXD0Wjzon+bf4MOriVE3a0ySGRvpr1mKR2+
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_sign_expired_auto_update_exists
|
def test_sign_expired_auto_update_exists
|
||||||
FileUtils.mkdir_p File.join(Gem.user_home, ".gem"), :mode => 0700
|
FileUtils.mkdir_p File.join(Gem.user_home, ".gem"), :mode => 0o700
|
||||||
|
|
||||||
expiry = EXPIRED_CERT.not_after.strftime "%Y%m%d%H%M%S"
|
expiry = EXPIRED_CERT.not_after.strftime "%Y%m%d%H%M%S"
|
||||||
expired_path =
|
expired_path =
|
||||||
|
@ -56,7 +56,7 @@ class TestGemSecurityTrustDir < Gem::TestCase
|
|||||||
|
|
||||||
assert_path_exist trusted
|
assert_path_exist trusted
|
||||||
|
|
||||||
mask = 0100600 & (~File.umask)
|
mask = 0o100600 & (~File.umask)
|
||||||
|
|
||||||
assert_equal mask, File.stat(trusted).mode unless Gem.win_platform?
|
assert_equal mask, File.stat(trusted).mode unless Gem.win_platform?
|
||||||
|
|
||||||
@ -70,8 +70,8 @@ class TestGemSecurityTrustDir < Gem::TestCase
|
|||||||
|
|
||||||
assert_path_exist @dest_dir
|
assert_path_exist @dest_dir
|
||||||
|
|
||||||
mask = 040700 & (~File.umask)
|
mask = 0o040700 & (~File.umask)
|
||||||
mask |= 0200000 if RUBY_PLATFORM.include?("aix")
|
mask |= 0o200000 if RUBY_PLATFORM.include?("aix")
|
||||||
|
|
||||||
assert_equal mask, File.stat(@dest_dir).mode unless Gem.win_platform?
|
assert_equal mask, File.stat(@dest_dir).mode unless Gem.win_platform?
|
||||||
end
|
end
|
||||||
@ -87,12 +87,12 @@ class TestGemSecurityTrustDir < Gem::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_verify_wrong_permissions
|
def test_verify_wrong_permissions
|
||||||
FileUtils.mkdir_p @dest_dir, :mode => 0777
|
FileUtils.mkdir_p @dest_dir, :mode => 0o777
|
||||||
|
|
||||||
@trust_dir.verify
|
@trust_dir.verify
|
||||||
|
|
||||||
mask = 040700 & (~File.umask)
|
mask = 0o40700 & (~File.umask)
|
||||||
mask |= 0200000 if RUBY_PLATFORM.include?("aix")
|
mask |= 0o200000 if RUBY_PLATFORM.include?("aix")
|
||||||
|
|
||||||
assert_equal mask, File.stat(@dest_dir).mode unless Gem.win_platform?
|
assert_equal mask, File.stat(@dest_dir).mode unless Gem.win_platform?
|
||||||
end
|
end
|
||||||
|
@ -41,12 +41,12 @@ class TestGemSpecFetcher < Gem::TestCase
|
|||||||
def test_initialize_unwritable_home_dir
|
def test_initialize_unwritable_home_dir
|
||||||
pend "chmod not supported" if Gem.win_platform?
|
pend "chmod not supported" if Gem.win_platform?
|
||||||
|
|
||||||
FileUtils.chmod 0000, Gem.user_home
|
FileUtils.chmod 0o000, Gem.user_home
|
||||||
|
|
||||||
begin
|
begin
|
||||||
assert Gem::SpecFetcher.new
|
assert Gem::SpecFetcher.new
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0755, Gem.user_home
|
FileUtils.chmod 0o755, Gem.user_home
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1445,15 +1445,15 @@ dependencies: []
|
|||||||
end
|
end
|
||||||
|
|
||||||
FileUtils.mkdir_p File.join @ext.base_dir, "extensions"
|
FileUtils.mkdir_p File.join @ext.base_dir, "extensions"
|
||||||
FileUtils.chmod 0555, @ext.base_dir
|
FileUtils.chmod 0o555, @ext.base_dir
|
||||||
FileUtils.chmod 0555, File.join(@ext.base_dir, "extensions")
|
FileUtils.chmod 0o555, File.join(@ext.base_dir, "extensions")
|
||||||
|
|
||||||
@ext.build_extensions
|
@ext.build_extensions
|
||||||
assert_path_not_exist @ext.extension_dir
|
assert_path_not_exist @ext.extension_dir
|
||||||
ensure
|
ensure
|
||||||
unless $DEBUG || Gem.win_platform? || Process.uid.zero? || Gem.java_platform?
|
unless $DEBUG || Gem.win_platform? || Process.uid.zero? || Gem.java_platform?
|
||||||
FileUtils.chmod 0755, File.join(@ext.base_dir, "extensions")
|
FileUtils.chmod 0o755, File.join(@ext.base_dir, "extensions")
|
||||||
FileUtils.chmod 0755, @ext.base_dir
|
FileUtils.chmod 0o755, @ext.base_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1478,14 +1478,14 @@ dependencies: []
|
|||||||
end
|
end
|
||||||
|
|
||||||
FileUtils.rm_r File.join @gemhome, "extensions"
|
FileUtils.rm_r File.join @gemhome, "extensions"
|
||||||
FileUtils.chmod 0555, @gemhome
|
FileUtils.chmod 0o555, @gemhome
|
||||||
|
|
||||||
@ext.build_extensions
|
@ext.build_extensions
|
||||||
|
|
||||||
gem_make_out = File.join @ext.extension_dir, "gem_make.out"
|
gem_make_out = File.join @ext.extension_dir, "gem_make.out"
|
||||||
assert_path_not_exist gem_make_out
|
assert_path_not_exist gem_make_out
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0755, @gemhome
|
FileUtils.chmod 0o755, @gemhome
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_build_extensions_none
|
def test_build_extensions_none
|
||||||
@ -1593,12 +1593,12 @@ dependencies: []
|
|||||||
|
|
||||||
def test_date_tolerates_hour_sec_zulu
|
def test_date_tolerates_hour_sec_zulu
|
||||||
@a1.date = "2012-01-12 11:22:33.4444444 Z"
|
@a1.date = "2012-01-12 11:22:33.4444444 Z"
|
||||||
assert_equal Time.utc(2012,01,12,0,0,0), @a1.date
|
assert_equal Time.utc(2012,1,12,0,0,0), @a1.date
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_tolerates_hour_sec_and_timezone
|
def test_date_tolerates_hour_sec_and_timezone
|
||||||
@a1.date = "2012-01-12 11:22:33.4444444 +02:33"
|
@a1.date = "2012-01-12 11:22:33.4444444 +02:33"
|
||||||
assert_equal Time.utc(2012,01,12,0,0,0), @a1.date
|
assert_equal Time.utc(2012,1,12,0,0,0), @a1.date
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_use_env_source_date_epoch
|
def test_date_use_env_source_date_epoch
|
||||||
@ -3317,8 +3317,8 @@ Did you mean 'Ruby'?
|
|||||||
util_setup_validate
|
util_setup_validate
|
||||||
|
|
||||||
Dir.chdir @tempdir do
|
Dir.chdir @tempdir do
|
||||||
File.chmod 0640, File.join("lib", "code.rb")
|
File.chmod 0o640, File.join("lib", "code.rb")
|
||||||
File.chmod 0640, File.join("bin", "exec")
|
File.chmod 0o640, File.join("bin", "exec")
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@a1.validate
|
@a1.validate
|
||||||
@ -3812,7 +3812,7 @@ end
|
|||||||
FileUtils.touch File.join("lib", "code.rb")
|
FileUtils.touch File.join("lib", "code.rb")
|
||||||
FileUtils.touch File.join("test", "suite.rb")
|
FileUtils.touch File.join("test", "suite.rb")
|
||||||
|
|
||||||
File.open "bin/exec", "w", 0755 do |fp|
|
File.open "bin/exec", "w", 0o755 do |fp|
|
||||||
fp.puts "#!#{Gem.ruby}"
|
fp.puts "#!#{Gem.ruby}"
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
|
@ -41,7 +41,7 @@ class TestGemUtil < Gem::TestCase
|
|||||||
FileUtils.mkdir_p "d/e/f"
|
FileUtils.mkdir_p "d/e/f"
|
||||||
# remove 'execute' permission from "e" directory and make it
|
# remove 'execute' permission from "e" directory and make it
|
||||||
# impossible to cd into it and its children
|
# impossible to cd into it and its children
|
||||||
FileUtils.chmod(0666, "d/e")
|
FileUtils.chmod(0o666, "d/e")
|
||||||
|
|
||||||
pend "skipped in root privilege" if Process.uid.zero?
|
pend "skipped in root privilege" if Process.uid.zero?
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class TestGemUtil < Gem::TestCase
|
|||||||
assert_equal File.realpath("../..", @tempdir), paths[3]
|
assert_equal File.realpath("../..", @tempdir), paths[3]
|
||||||
ensure
|
ensure
|
||||||
# restore default permissions, allow the directory to be removed
|
# restore default permissions, allow the directory to be removed
|
||||||
FileUtils.chmod(0775, "d/e") unless Gem.win_platform? || Gem.java_platform?
|
FileUtils.chmod(0o775, "d/e") unless Gem.win_platform? || Gem.java_platform?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_glob_files_in_dir
|
def test_glob_files_in_dir
|
||||||
|
Loading…
x
Reference in New Issue
Block a user