diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-22 00:27:02 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-22 00:27:02 +0000 |
commit | 615ac3593499f54fde4b1eb0fba66b6bd944821b (patch) | |
tree | 1f0b0e97ee3dd51798658d53cee7eec976a83a97 /test/rubygems/test_gem_commands_cert_command.rb | |
parent | ff31b35f6a66f3c1548e3356d506ff65a574be7f (diff) |
Merge rubygems master branch from github.com/rubygems/rubygems.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_commands_cert_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_cert_command.rb | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb index 3d9bbeb1df..97c081e110 100644 --- a/test/rubygems/test_gem_commands_cert_command.rb +++ b/test/rubygems/test_gem_commands_cert_command.rb @@ -159,7 +159,7 @@ Added '/CN=alternate/DC=example' @cmd.handle_options %W[ --build nobody@example.com --days 26 - ] + ] @build_ui = Gem::MockGemUi.new "#{passphrase}\n#{passphrase}" @@ -615,6 +615,37 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis assert_equal '', @ui.error end + def test_execute_re_sign_with_cert_expiration_length_days + gem_path = File.join Gem.user_home, ".gem" + Dir.mkdir gem_path + + path = File.join @tempdir, 'cert.pem' + Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600 + + assert_equal '/CN=nobody/DC=example', EXPIRED_PUBLIC_CERT.issuer.to_s + + tmp_expired_cert_file = File.join(Dir.tmpdir, File.basename(EXPIRED_PUBLIC_CERT_FILE)) + File.write(tmp_expired_cert_file, File.read(EXPIRED_PUBLIC_CERT_FILE)) + + @cmd.handle_options %W[ + --private-key #{PRIVATE_KEY_FILE} + --certificate #{tmp_expired_cert_file} + --re-sign + ] + + Gem.configuration.cert_expiration_length_days = 28 + + use_ui @ui do + @cmd.execute + end + + re_signed_cert = OpenSSL::X509::Certificate.new(File.read(tmp_expired_cert_file)) + cert_days_to_expire = (re_signed_cert.not_after - re_signed_cert.not_before).to_i / (24 * 60 * 60) + + assert_equal(28, cert_days_to_expire) + assert_equal '', @ui.error + end + def test_handle_options @cmd.handle_options %W[ --add #{PUBLIC_CERT_FILE} |