diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-12-08 16:33:39 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-12-08 17:30:02 +0900 |
commit | 4aca77edde91f826aa243e268bf1ef5214530583 (patch) | |
tree | ef0cf1a95fcced00ca5fa40f3412c567bf95d705 /test/rubygems/test_gem_commands_sources_command.rb | |
parent | 6a6a24df9b72750d12f9b15192bdb7517e668efb (diff) | |
download | ruby-4aca77edde91f826aa243e268bf1ef5214530583.tar.gz |
Merge prepare version of RubyGems 3.2.0
Diffstat (limited to 'test/rubygems/test_gem_commands_sources_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_sources_command.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb index ff00b9aa23..59acfb1ed6 100644 --- a/test/rubygems/test_gem_commands_sources_command.rb +++ b/test/rubygems/test_gem_commands_sources_command.rb @@ -107,6 +107,36 @@ class TestGemCommandsSourcesCommand < Gem::TestCase assert_empty ui.error end + def test_execute_add_allow_typo_squatting_source_forced + rubygems_org = "https://rubyems.org" + + spec_fetcher do |fetcher| + fetcher.spec("a", 1) + end + + specs = Gem::Specification.map do |spec| + [spec.name, spec.version, spec.original_platform] + end + + specs_dump_gz = StringIO.new + Zlib::GzipWriter.wrap(specs_dump_gz) do |io| + Marshal.dump(specs, io) + end + + @fetcher.data["#{rubygems_org}/specs.#{@marshal_version}.gz"] = specs_dump_gz.string + @cmd.handle_options %W[--force --add #{rubygems_org}] + + @cmd.execute + + expected = "https://rubyems.org added to sources\n" + assert_equal expected, ui.output + + source = Gem::Source.new(rubygems_org) + assert Gem.sources.include?(source) + + assert_empty ui.error + end + def test_execute_add_deny_typo_squatting_source rubygems_org = "https://rubyems.org" @@ -283,6 +313,36 @@ source http://gems.example.com/ already present in the cache assert_empty @ui.error end + def test_execute_add_http_rubygems_org_forced + rubygems_org = "http://rubygems.org" + + spec_fetcher do |fetcher| + fetcher.spec("a", 1) + end + + specs = Gem::Specification.map do |spec| + [spec.name, spec.version, spec.original_platform] + end + + specs_dump_gz = StringIO.new + Zlib::GzipWriter.wrap(specs_dump_gz) do |io| + Marshal.dump(specs, io) + end + + @fetcher.data["#{rubygems_org}/specs.#{@marshal_version}.gz"] = specs_dump_gz.string + @cmd.handle_options %W[--force --add #{rubygems_org}] + + @cmd.execute + + expected = "http://rubygems.org added to sources\n" + assert_equal expected, ui.output + + source = Gem::Source.new(rubygems_org) + assert Gem.sources.include?(source) + + assert_empty ui.error + end + def test_execute_add_https_rubygems_org https_rubygems_org = 'https://rubygems.org/' |