aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_commands_sources_command.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2022-06-23 11:22:36 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2022-06-24 10:52:02 +0900
commit12a5fa408bd318f8fb242e86beb225f2dcae8df9 (patch)
treef132650f5999535da69ee998956f260007afd371 /test/rubygems/test_gem_commands_sources_command.rb
parent333754ace8ae9bc5d2dfb4aee160fcfa0f38350d (diff)
downloadruby-12a5fa408bd318f8fb242e86beb225f2dcae8df9.tar.gz
Sync RubyGems & Bundler with upstream repo
Diffstat (limited to 'test/rubygems/test_gem_commands_sources_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb51
1 files changed, 50 insertions, 1 deletions
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
index 7bca0f3803..f10347a6dc 100644
--- a/test/rubygems/test_gem_commands_sources_command.rb
+++ b/test/rubygems/test_gem_commands_sources_command.rb
@@ -161,7 +161,6 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
ui = Gem::MockGemUi.new("n")
use_ui ui do
-
assert_raise Gem::MockGemUi::TermError do
@cmd.execute
end
@@ -202,6 +201,56 @@ Error fetching http://beta-gems.example.com:
assert_equal '', @ui.error
end
+ def test_execute_add_existent_source_invalid_uri
+ spec_fetcher
+
+ uri = "https://u:p@example.com/specs.#{@marshal_version}.gz"
+
+ @cmd.handle_options %w[--add https://u:p@example.com]
+ @fetcher.data[uri] = proc do
+ raise Gem::RemoteFetcher::FetchError.new('it died', uri)
+ end
+
+ use_ui @ui do
+ assert_raise Gem::MockGemUi::TermError do
+ @cmd.execute
+ end
+ end
+
+ expected = <<-EOF
+Error fetching https://u:REDACTED@example.com:
+\tit died (https://u:REDACTED@example.com/specs.#{@marshal_version}.gz)
+ EOF
+
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
+ end
+
+ def test_execute_add_existent_source_invalid_uri_with_error_by_chance_including_the_uri_password
+ spec_fetcher
+
+ uri = "https://u:secret@example.com/specs.#{@marshal_version}.gz"
+
+ @cmd.handle_options %w[--add https://u:secret@example.com]
+ @fetcher.data[uri] = proc do
+ raise Gem::RemoteFetcher::FetchError.new('it secretly died', uri)
+ end
+
+ use_ui @ui do
+ assert_raise Gem::MockGemUi::TermError do
+ @cmd.execute
+ end
+ end
+
+ expected = <<-EOF
+Error fetching https://u:REDACTED@example.com:
+\tit secretly died (https://u:REDACTED@example.com/specs.#{@marshal_version}.gz)
+ EOF
+
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
+ end
+
def test_execute_add_redundant_source
spec_fetcher