From d0a54673202458455244f79ed212a97727f0c7c7 Mon Sep 17 00:00:00 2001 From: David Rodríguez Date: Fri, 26 Apr 2019 13:26:21 +0200 Subject: Update rubygems with latest upstream changes Closes: https://github.com/ruby/ruby/pull/2154 --- test/rubygems/test_gem_commands_build_command.rb | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'test/rubygems/test_gem_commands_build_command.rb') diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb index 02d1b98e8f..6441587cf6 100644 --- a/test/rubygems/test_gem_commands_build_command.rb +++ b/test/rubygems/test_gem_commands_build_command.rb @@ -351,4 +351,45 @@ class TestGemCommandsBuildCommand < Gem::TestCase assert_equal(28, cert_days_to_expire) end + def test_build_auto_resign_cert + skip 'openssl is missing' unless defined?(OpenSSL::SSL) + + gem_path = File.join Gem.user_home, ".gem" + Dir.mkdir gem_path + + Gem::Security.trust_dir + + tmp_expired_cert_file = File.join gem_path, "gem-public_cert.pem" + File.write(tmp_expired_cert_file, File.read(EXPIRED_CERT_FILE)) + + tmp_private_key_file = File.join gem_path, "gem-private_key.pem" + File.write(tmp_private_key_file, File.read(PRIVATE_KEY_FILE)) + + spec = util_spec 'some_gem' do |s| + s.signing_key = tmp_private_key_file + s.cert_chain = [tmp_expired_cert_file] + end + + gemspec_file = File.join(@tempdir, spec.spec_name) + + File.open gemspec_file, 'w' do |gs| + gs.write spec.to_ruby + end + + @cmd.options[:args] = [gemspec_file] + + Gem.configuration.cert_expiration_length_days = 28 + + use_ui @ui do + Dir.chdir @tempdir do + @cmd.execute + end + end + + output = @ui.output.split "\n" + assert_equal "INFO: Your certificate has expired, trying to re-sign it...", output.shift + assert_equal "INFO: Your cert: #{tmp_expired_cert_file } has been auto re-signed with the key: #{tmp_private_key_file}", output.shift + assert_match /INFO: Your expired cert will be located at: .+\Wgem-public_cert\.pem\.expired\.[0-9]+/, output.shift + end + end -- cgit v1.2.3