From ec6c07570237b209d47b7690a5b5a6774301242b Mon Sep 17 00:00:00 2001 From: hsbt Date: Tue, 18 Sep 2018 08:37:18 +0000 Subject: Merge upstream revision of rubygems/rubygems. This commits includes tiny bugfix and new features listed here: * Add --re-sign flag to cert command by bronzdoc: https://github.com/rubygems/rubygems/pull/2391 * Download gems with threads. by indirect: https://github.com/rubygems/rubygems/pull/1898 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rubygems/test_gem_commands_cert_command.rb | 39 +++++++++++++++++++++++-- test/rubygems/test_gem_stream_ui.rb | 16 +++++----- 2 files changed, 44 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb index 3f67513c3f..3d9bbeb1df 100644 --- a/test/rubygems/test_gem_commands_cert_command.rb +++ b/test/rubygems/test_gem_commands_cert_command.rb @@ -9,14 +9,16 @@ end class TestGemCommandsCertCommand < Gem::TestCase ALTERNATE_CERT = load_cert 'alternate' + EXPIRED_PUBLIC_CERT = load_cert 'expired' ALTERNATE_KEY_FILE = key_path 'alternate' PRIVATE_KEY_FILE = key_path 'private' PUBLIC_KEY_FILE = key_path 'public' - ALTERNATE_CERT_FILE = cert_path 'alternate' - CHILD_CERT_FILE = cert_path 'child' - PUBLIC_CERT_FILE = cert_path 'public' + ALTERNATE_CERT_FILE = cert_path 'alternate' + CHILD_CERT_FILE = cert_path 'child' + PUBLIC_CERT_FILE = cert_path 'public' + EXPIRED_PUBLIC_CERT_FILE = cert_path 'expired' def setup super @@ -582,6 +584,37 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis assert_equal expected, @ui.error end + def test_execute_re_sign + 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 + ] + + use_ui @ui do + @cmd.execute + end + + expected_path = File.join(gem_path, "#{File.basename(tmp_expired_cert_file)}.expired") + + assert_match( + /INFO: Your certificate #{tmp_expired_cert_file} has been re-signed\nINFO: Your expired certificate will be located at: #{expected_path}\.[0-9]+/, + @ui.output + ) + assert_equal '', @ui.error + end + def test_handle_options @cmd.handle_options %W[ --add #{PUBLIC_CERT_FILE} diff --git a/test/rubygems/test_gem_stream_ui.rb b/test/rubygems/test_gem_stream_ui.rb index 56ab1cee5b..5735bbc9a9 100644 --- a/test/rubygems/test_gem_stream_ui.rb +++ b/test/rubygems/test_gem_stream_ui.rb @@ -156,14 +156,14 @@ class TestGemStreamUI < Gem::TestCase def test_download_reporter_anything @cfg.verbose = 0 reporter = @sui.download_reporter - assert_kind_of Gem::StreamUI::VerboseDownloadReporter, reporter + assert_kind_of Gem::StreamUI::ThreadedDownloadReporter, reporter end - def test_verbose_download_reporter + def test_threaded_download_reporter @cfg.verbose = true reporter = @sui.download_reporter reporter.fetch 'a.gem', 1024 - assert_equal "Fetching: a.gem", @out.string + assert_equal "Fetching a.gem\n", @out.string end def test_verbose_download_reporter_progress @@ -171,7 +171,7 @@ class TestGemStreamUI < Gem::TestCase reporter = @sui.download_reporter reporter.fetch 'a.gem', 1024 reporter.update 512 - assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)", @out.string + assert_equal "Fetching a.gem\n", @out.string end def test_verbose_download_reporter_progress_once @@ -180,7 +180,7 @@ class TestGemStreamUI < Gem::TestCase reporter.fetch 'a.gem', 1024 reporter.update 510 reporter.update 512 - assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)", @out.string + assert_equal "Fetching a.gem\n", @out.string end def test_verbose_download_reporter_progress_complete @@ -189,7 +189,7 @@ class TestGemStreamUI < Gem::TestCase reporter.fetch 'a.gem', 1024 reporter.update 510 reporter.done - assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)\rFetching: a.gem (100%)\n", @out.string + assert_equal "Fetching a.gem\n", @out.string end def test_verbose_download_reporter_progress_nil_length @@ -198,7 +198,7 @@ class TestGemStreamUI < Gem::TestCase reporter.fetch 'a.gem', nil reporter.update 1024 reporter.done - assert_equal "Fetching: a.gem\rFetching: a.gem (1024B)\rFetching: a.gem (1024B)\n", @out.string + assert_equal "Fetching a.gem\n", @out.string end def test_verbose_download_reporter_progress_zero_length @@ -207,7 +207,7 @@ class TestGemStreamUI < Gem::TestCase reporter.fetch 'a.gem', 0 reporter.update 1024 reporter.done - assert_equal "Fetching: a.gem\rFetching: a.gem (1024B)\rFetching: a.gem (1024B)\n", @out.string + assert_equal "Fetching a.gem\n", @out.string end def test_verbose_download_reporter_no_tty -- cgit v1.2.3