rubygems-update 2.0.17 → 2.1.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -0
  4. data/.autotest +1 -1
  5. data/History.txt +82 -153
  6. data/Manifest.txt +35 -9
  7. data/Rakefile +35 -36
  8. data/lib/rubygems.rb +106 -18
  9. data/lib/rubygems/available_set.rb +68 -0
  10. data/lib/rubygems/basic_specification.rb +139 -0
  11. data/lib/rubygems/command_manager.rb +37 -40
  12. data/lib/rubygems/commands/cert_command.rb +78 -29
  13. data/lib/rubygems/commands/cleanup_command.rb +2 -2
  14. data/lib/rubygems/commands/contents_command.rb +101 -58
  15. data/lib/rubygems/commands/dependency_command.rb +94 -53
  16. data/lib/rubygems/commands/environment_command.rb +70 -53
  17. data/lib/rubygems/commands/fetch_command.rb +1 -2
  18. data/lib/rubygems/commands/help_command.rb +85 -55
  19. data/lib/rubygems/commands/install_command.rb +84 -42
  20. data/lib/rubygems/commands/outdated_command.rb +2 -12
  21. data/lib/rubygems/commands/owner_command.rb +6 -0
  22. data/lib/rubygems/commands/pristine_command.rb +26 -16
  23. data/lib/rubygems/commands/sources_command.rb +85 -70
  24. data/lib/rubygems/commands/uninstall_command.rb +32 -2
  25. data/lib/rubygems/commands/update_command.rb +111 -75
  26. data/lib/rubygems/config_file.rb +15 -3
  27. data/lib/rubygems/core_ext/kernel_require.rb +9 -31
  28. data/lib/rubygems/defaults.rb +8 -0
  29. data/lib/rubygems/dependency.rb +4 -2
  30. data/lib/rubygems/dependency_installer.rb +180 -170
  31. data/lib/rubygems/dependency_resolver.rb +191 -526
  32. data/lib/rubygems/dependency_resolver/activation_request.rb +109 -0
  33. data/lib/rubygems/dependency_resolver/api_set.rb +65 -0
  34. data/lib/rubygems/dependency_resolver/api_specification.rb +36 -0
  35. data/lib/rubygems/dependency_resolver/composed_set.rb +18 -0
  36. data/lib/rubygems/dependency_resolver/current_set.rb +16 -0
  37. data/lib/rubygems/dependency_resolver/dependency_conflict.rb +85 -0
  38. data/lib/rubygems/dependency_resolver/dependency_request.rb +51 -0
  39. data/lib/rubygems/dependency_resolver/index_set.rb +59 -0
  40. data/lib/rubygems/dependency_resolver/index_specification.rb +53 -0
  41. data/lib/rubygems/dependency_resolver/installed_specification.rb +38 -0
  42. data/lib/rubygems/dependency_resolver/installer_set.rb +130 -0
  43. data/lib/rubygems/exceptions.rb +88 -1
  44. data/lib/rubygems/ext/builder.rb +1 -1
  45. data/lib/rubygems/gem_runner.rb +17 -9
  46. data/lib/rubygems/gemcutter_utilities.rb +72 -42
  47. data/lib/rubygems/install_default_message.rb +12 -0
  48. data/lib/rubygems/install_update_options.rb +3 -0
  49. data/lib/rubygems/installer.rb +55 -30
  50. data/lib/rubygems/name_tuple.rb +18 -7
  51. data/lib/rubygems/package.rb +50 -25
  52. data/lib/rubygems/package/tar_test_case.rb +9 -9
  53. data/lib/rubygems/package/tar_writer.rb +35 -12
  54. data/lib/rubygems/package_task.rb +2 -5
  55. data/lib/rubygems/path_support.rb +10 -0
  56. data/lib/rubygems/platform.rb +9 -3
  57. data/lib/rubygems/psych_additions.rb +1 -1
  58. data/lib/rubygems/remote_fetcher.rb +9 -276
  59. data/lib/rubygems/request.rb +267 -0
  60. data/lib/rubygems/request_set.rb +123 -125
  61. data/lib/rubygems/request_set/gem_dependency_api.rb +39 -0
  62. data/lib/rubygems/security.rb +32 -23
  63. data/lib/rubygems/security/policy.rb +35 -9
  64. data/lib/rubygems/security/signer.rb +2 -2
  65. data/lib/rubygems/server.rb +8 -16
  66. data/lib/rubygems/source.rb +25 -14
  67. data/lib/rubygems/source/installed.rb +28 -0
  68. data/lib/rubygems/source/local.rb +122 -0
  69. data/lib/rubygems/source/specific_file.rb +28 -0
  70. data/lib/rubygems/source_local.rb +2 -89
  71. data/lib/rubygems/source_specific_file.rb +2 -26
  72. data/lib/rubygems/spec_fetcher.rb +11 -11
  73. data/lib/rubygems/specification.rb +186 -198
  74. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
  75. data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
  76. data/lib/rubygems/ssl_certs/{GeoTrustGlobalCA.pem → GeoTrust_Global_CA.pem} +20 -20
  77. data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
  78. data/lib/rubygems/stub_specification.rb +119 -0
  79. data/lib/rubygems/test_case.rb +117 -49
  80. data/lib/rubygems/uninstaller.rb +14 -9
  81. data/lib/rubygems/uri_formatter.rb +39 -0
  82. data/lib/rubygems/util/list.rb +44 -0
  83. data/lib/rubygems/version.rb +15 -5
  84. data/lib/rubygems/version_option.rb +8 -2
  85. data/test/rubygems/ca_cert.pem +23 -0
  86. data/test/rubygems/client.pem +49 -0
  87. data/test/rubygems/encrypted_private_key.pem +30 -0
  88. data/test/rubygems/invalid_client.pem +49 -0
  89. data/test/rubygems/specifications/bar-0.0.2.gemspec +9 -0
  90. data/test/rubygems/specifications/foo-0.0.1.gemspec +0 -0
  91. data/test/rubygems/test_gem.rb +76 -454
  92. data/test/rubygems/test_gem_command_manager.rb +23 -21
  93. data/test/rubygems/test_gem_commands_cert_command.rb +154 -14
  94. data/test/rubygems/test_gem_commands_cleanup_command.rb +15 -0
  95. data/test/rubygems/test_gem_commands_contents_command.rb +32 -4
  96. data/test/rubygems/test_gem_commands_environment_command.rb +9 -1
  97. data/test/rubygems/test_gem_commands_fetch_command.rb +2 -28
  98. data/test/rubygems/test_gem_commands_help_command.rb +6 -3
  99. data/test/rubygems/test_gem_commands_install_command.rb +2 -65
  100. data/test/rubygems/test_gem_commands_owner_command.rb +49 -0
  101. data/test/rubygems/test_gem_commands_pristine_command.rb +30 -0
  102. data/test/rubygems/test_gem_commands_sources_command.rb +1 -1
  103. data/test/rubygems/test_gem_commands_uninstall_command.rb +33 -0
  104. data/test/rubygems/test_gem_commands_update_command.rb +2 -1
  105. data/test/rubygems/test_gem_config_file.rb +12 -0
  106. data/test/rubygems/test_gem_dependency_installer.rb +58 -65
  107. data/test/rubygems/test_gem_dependency_resolver.rb +6 -3
  108. data/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb +36 -0
  109. data/test/rubygems/test_gem_ext_builder.rb +2 -4
  110. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +7 -2
  111. data/test/rubygems/test_gem_gem_runner.rb +17 -13
  112. data/test/rubygems/test_gem_gemcutter_utilities.rb +6 -19
  113. data/test/rubygems/test_gem_impossible_dependencies_error.rb +41 -0
  114. data/test/rubygems/test_gem_install_update_options.rb +4 -1
  115. data/test/rubygems/test_gem_installer.rb +31 -2
  116. data/test/rubygems/test_gem_name_tuple.rb +22 -0
  117. data/test/rubygems/test_gem_package.rb +122 -11
  118. data/test/rubygems/test_gem_package_old.rb +8 -0
  119. data/test/rubygems/test_gem_package_tar_reader.rb +9 -8
  120. data/test/rubygems/test_gem_package_tar_reader_entry.rb +1 -1
  121. data/test/rubygems/test_gem_package_tar_writer.rb +78 -56
  122. data/test/rubygems/test_gem_package_task.rb +2 -23
  123. data/test/rubygems/test_gem_path_support.rb +17 -0
  124. data/test/rubygems/test_gem_platform.rb +18 -0
  125. data/test/rubygems/test_gem_remote_fetcher.rb +106 -385
  126. data/test/rubygems/test_gem_request.rb +239 -0
  127. data/test/rubygems/test_gem_requirement.rb +9 -11
  128. data/test/rubygems/test_gem_security.rb +58 -2
  129. data/test/rubygems/test_gem_security_policy.rb +42 -1
  130. data/test/rubygems/test_gem_security_signer.rb +13 -1
  131. data/test/rubygems/test_gem_security_trust_dir.rb +5 -1
  132. data/test/rubygems/test_gem_server.rb +1 -105
  133. data/test/rubygems/test_gem_source.rb +4 -14
  134. data/test/rubygems/test_gem_source_local.rb +4 -4
  135. data/test/rubygems/test_gem_source_specific_file.rb +1 -1
  136. data/test/rubygems/test_gem_spec_fetcher.rb +0 -12
  137. data/test/rubygems/test_gem_specification.rb +452 -28
  138. data/test/rubygems/test_gem_stub_specification.rb +30 -0
  139. data/test/rubygems/test_gem_uninstaller.rb +14 -0
  140. data/test/rubygems/test_gem_uri_formatter.rb +20 -0
  141. data/test/rubygems/test_gem_version.rb +23 -13
  142. data/test/rubygems/test_gem_version_option.rb +63 -1
  143. data/test/rubygems/test_require.rb +0 -12
  144. data/util/create_encrypted_key.rb +16 -0
  145. metadata +161 -23
  146. metadata.gz.sig +0 -0
  147. data/CVE-2013-4287.txt +0 -36
  148. data/CVE-2013-4363.txt +0 -45
  149. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
  150. data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
  151. data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
  152. data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
  153. data/test/rubygems/test_bundled_ca.rb +0 -59
  154. data/util/update_bundled_ca_certificates.rb +0 -103
@@ -11,6 +11,7 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
11
11
 
12
12
  def test_execute
13
13
  orig_sources = Gem.sources.dup
14
+ orig_path, ENV['PATH'] = ENV['PATH'], %w[/usr/local/bin /usr/bin /bin].join(File::PATH_SEPARATOR)
14
15
  Gem.sources.replace %w[http://gems.example.com]
15
16
  Gem.configuration['gemcutter_key'] = 'blah'
16
17
 
@@ -36,10 +37,17 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
36
37
  assert_match %r|"gemcutter_key" => "\*\*\*\*"|, @ui.output
37
38
  assert_match %r|:verbose => |, @ui.output
38
39
  assert_match %r|REMOTE SOURCES:|, @ui.output
39
- assert_equal '', @ui.error
40
+
41
+ assert_match %r|- SHELL PATH:|, @ui.output
42
+ assert_match %r|- /usr/local/bin$|, @ui.output
43
+ assert_match %r|- /usr/bin$|, @ui.output
44
+ assert_match %r|- /bin$|, @ui.output
45
+
46
+ assert_empty @ui.error
40
47
 
41
48
  ensure
42
49
  Gem.sources.replace orig_sources
50
+ ENV['PATH'] = orig_path
43
51
  end
44
52
 
45
53
  def test_execute_gemdir
@@ -34,32 +34,6 @@ class TestGemCommandsFetchCommand < Gem::TestCase
34
34
  'gem repository directories must not be created'
35
35
  end
36
36
 
37
- def test_execute_latest
38
- util_setup_fake_fetcher
39
- util_setup_spec_fetcher @a1, @a2
40
-
41
- @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
42
- File.read(@a1.cache_file)
43
- @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
44
- File.read(@a2.cache_file)
45
-
46
- refute_path_exists File.join(@tempdir, 'cache'), 'sanity check'
47
-
48
- @cmd.options[:args] = [@a2.name]
49
- @cmd.options[:version] = req('>= 0.1')
50
-
51
- use_ui @ui do
52
- Dir.chdir @tempdir do
53
- @cmd.execute
54
- end
55
- end
56
-
57
- assert_path_exists(File.join(@tempdir, @a2.file_name),
58
- "#{@a2.full_name} not fetched")
59
- refute_path_exists File.join(@tempdir, 'cache'),
60
- 'gem repository directories must not be created'
61
- end
62
-
63
37
  def test_execute_prerelease
64
38
  util_setup_fake_fetcher true
65
39
  util_clear_gems
@@ -79,8 +53,8 @@ class TestGemCommandsFetchCommand < Gem::TestCase
79
53
  end
80
54
  end
81
55
 
82
- assert_path_exists(File.join(@tempdir, @a2.file_name),
83
- "#{@a2.full_name} not fetched")
56
+ assert_path_exists(File.join(@tempdir, @a2_pre.file_name),
57
+ "#{@a2_pre.full_name} not fetched")
84
58
  end
85
59
 
86
60
  def test_execute_specific_prerelease
@@ -18,7 +18,7 @@ class TestGemCommandsHelpCommand < Gem::TestCase
18
18
  def test_gem_help_bad
19
19
  util_gem 'bad' do |out, err|
20
20
  assert_equal('', out)
21
- assert_match(/Unknown command bad. Try gem help commands\n/, err)
21
+ assert_match "Unknown command bad", err
22
22
  end
23
23
  end
24
24
 
@@ -36,9 +36,12 @@ class TestGemCommandsHelpCommand < Gem::TestCase
36
36
  mgr.command_names.each do |cmd|
37
37
  assert_match(/\s+#{cmd}\s+\S+/, out)
38
38
  end
39
- assert_equal '', err
40
39
 
41
- refute_match 'No command found for ', out
40
+ if defined?(OpenSSL::SSL) then
41
+ assert_empty err
42
+
43
+ refute_match 'No command found for ', out
44
+ end
42
45
  end
43
46
  end
44
47
 
@@ -1,11 +1,11 @@
1
1
  require 'rubygems/test_case'
2
2
  require 'rubygems/commands/install_command'
3
- require 'rubygems/rdoc'
4
3
 
5
4
  class TestGemCommandsInstallCommand < Gem::TestCase
6
5
 
7
6
  def setup
8
7
  super
8
+ common_installer_setup
9
9
 
10
10
  @cmd = Gem::Commands::InstallCommand.new
11
11
  @cmd.options[:document] = []
@@ -168,8 +168,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
168
168
 
169
169
  # This is needed because we need to exercise the cache path
170
170
  # within SpecFetcher
171
- path = File.join Gem.user_home, '.gem', 'specs', "not-there.nothing%80",
172
- "latest_specs.4.8"
171
+ path = File.join Gem.spec_cache_dir, "not-there.nothing%80", "latest_specs.4.8"
173
172
 
174
173
  FileUtils.mkdir_p File.dirname(path)
175
174
 
@@ -633,67 +632,6 @@ ERROR: Possible alternatives: non_existent_with_hint
633
632
  assert_equal x, e
634
633
  end
635
634
 
636
- def test_execute_installs_dependencies
637
- r, r_gem = util_gem 'r', '1', 'q' => '= 1'
638
- q, q_gem = util_gem 'q', '1'
639
-
640
- util_setup_fake_fetcher
641
- util_setup_spec_fetcher r, q
642
-
643
- Gem::Specification.reset
644
-
645
- @fetcher.data["#{@gem_repo}gems/#{q.file_name}"] = read_binary(q_gem)
646
- @fetcher.data["#{@gem_repo}gems/#{r.file_name}"] = read_binary(r_gem)
647
-
648
- @cmd.options[:args] = ["r"]
649
-
650
- e = nil
651
- use_ui @ui do
652
- e = assert_raises Gem::SystemExitException do
653
- capture_io do
654
- @cmd.execute
655
- end
656
- end
657
- end
658
-
659
- out = @ui.output.split "\n"
660
- assert_equal "2 gems installed", out.shift
661
- assert out.empty?, out.inspect
662
-
663
- assert_equal %w[q-1 r-1], @cmd.installed_specs.map { |spec| spec.full_name }
664
-
665
- assert_equal 0, e.exit_code
666
- end
667
-
668
- def test_execute_satisfy_deps_of_local_from_sources
669
- r, r_gem = util_gem 'r', '1', 'q' => '= 1'
670
- q, q_gem = util_gem 'q', '1'
671
-
672
- util_setup_fake_fetcher
673
- util_setup_spec_fetcher r, q
674
-
675
- Gem::Specification.reset
676
-
677
- @fetcher.data["#{@gem_repo}gems/#{q.file_name}"] = read_binary(q_gem)
678
-
679
- @cmd.options[:args] = [r_gem]
680
-
681
- use_ui @ui do
682
- e = assert_raises Gem::SystemExitException do
683
- capture_io do
684
- @cmd.execute
685
- end
686
- end
687
- assert_equal 0, e.exit_code
688
- end
689
-
690
- assert_equal %w[q-1 r-1], @cmd.installed_specs.map { |spec| spec.full_name }
691
-
692
- out = @ui.output.split "\n"
693
- assert_equal "2 gems installed", out.shift
694
- assert out.empty?, out.inspect
695
- end
696
-
697
635
  def test_execute_uses_from_a_gemdeps
698
636
  util_setup_fake_fetcher
699
637
  util_setup_spec_fetcher
@@ -951,4 +889,3 @@ ERROR: Possible alternatives: non_existent_with_hint
951
889
 
952
890
 
953
891
  end
954
-
@@ -6,6 +6,7 @@ class TestGemCommandsOwnerCommand < Gem::TestCase
6
6
  def setup
7
7
  super
8
8
 
9
+ ENV["RUBYGEMS_HOST"] = nil
9
10
  @fetcher = Gem::FakeFetcher.new
10
11
  Gem::RemoteFetcher.fetcher = @fetcher
11
12
  Gem.configuration.rubygems_api_key = "ed244fbf2b1a52e012da8616c512fa47f9aa5250"
@@ -34,6 +35,36 @@ EOF
34
35
  assert_match %r{- user2@example.com}, @ui.output
35
36
  end
36
37
 
38
+ def test_show_owners_setting_up_host_through_env_var
39
+ response = "- email: user1@example.com\n"
40
+ host = "http://rubygems.example"
41
+ ENV["RUBYGEMS_HOST"] = host
42
+
43
+ @fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
44
+
45
+ use_ui @ui do
46
+ @cmd.show_owners("freewill")
47
+ end
48
+
49
+ assert_match %r{Owners for gem: freewill}, @ui.output
50
+ assert_match %r{- user1@example.com}, @ui.output
51
+ end
52
+
53
+ def test_show_owners_setting_up_host
54
+ response = "- email: user1@example.com\n"
55
+ host = "http://rubygems.example"
56
+ @cmd.host = host
57
+
58
+ @fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
59
+
60
+ use_ui @ui do
61
+ @cmd.show_owners("freewill")
62
+ end
63
+
64
+ assert_match %r{Owners for gem: freewill}, @ui.output
65
+ assert_match %r{- user1@example.com}, @ui.output
66
+ end
67
+
37
68
  def test_show_owners_denied
38
69
  response = "You don't have permission to push to this gem"
39
70
  @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden']
@@ -87,6 +118,24 @@ EOF
87
118
  assert_match response, @ui.output
88
119
  end
89
120
 
121
+ def test_add_owner_with_host_option_through_execute
122
+ host = "http://rubygems.example"
123
+ add_owner_response = "Owner added successfully."
124
+ show_owners_response = "- email: user1@example.com\n"
125
+ @fetcher.data["#{host}/api/v1/gems/freewill/owners"] = [add_owner_response, 200, 'OK']
126
+ @fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [show_owners_response, 200, 'OK']
127
+
128
+ @cmd.handle_options %W[--host #{host} --add user-new1@example.com freewill]
129
+
130
+ use_ui @ui do
131
+ @cmd.execute
132
+ end
133
+
134
+ assert_match add_owner_response, @ui.output
135
+ assert_match %r{Owners for gem: freewill}, @ui.output
136
+ assert_match %r{- user1@example.com}, @ui.output
137
+ end
138
+
90
139
  def test_add_owners_key
91
140
  response = "Owner added successfully."
92
141
  @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
@@ -80,6 +80,36 @@ class TestGemCommandsPristineCommand < Gem::TestCase
80
80
  assert_empty out, out.inspect
81
81
  end
82
82
 
83
+ def test_execute_env_shebang
84
+ a = quick_spec 'a' do |s|
85
+ s.executables = %w[foo]
86
+ s.files = %w[bin/foo]
87
+ end
88
+ write_file File.join(@tempdir, 'bin', 'foo') do |fp|
89
+ fp.puts "#!/usr/bin/ruby"
90
+ end
91
+
92
+ install_gem a
93
+
94
+ gem_exec = File.join @gemhome, 'bin', 'foo'
95
+
96
+ FileUtils.rm gem_exec
97
+
98
+ @cmd.handle_options %w[--all --env-shebang]
99
+
100
+ use_ui @ui do
101
+ @cmd.execute
102
+ end
103
+
104
+ assert_path_exists gem_exec
105
+
106
+ if win_platform?
107
+ assert_match %r%\A#!\s*ruby%, File.read(gem_exec)
108
+ else
109
+ assert_match %r%\A#!\s*/usr/bin/env ruby%, File.read(gem_exec)
110
+ end
111
+ end
112
+
83
113
  def test_execute_no_extension
84
114
  a = quick_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
85
115
 
@@ -194,7 +194,7 @@ beta-gems.example.com is not a URI
194
194
  assert_equal expected, @ui.output
195
195
  assert_equal '', @ui.error
196
196
 
197
- dir = File.join Gem.user_home, '.gem', 'specs'
197
+ dir = Gem.spec_cache_dir
198
198
  refute File.exist?(dir), 'cache dir removed'
199
199
  end
200
200
 
@@ -16,6 +16,20 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
16
16
  @executable = File.join(@gemhome, 'bin', 'executable')
17
17
  end
18
18
 
19
+ def test_execute_all_gem_names
20
+ @cmd.options[:args] = %w[a b]
21
+ @cmd.options[:all] = true
22
+
23
+ assert_raises Gem::MockGemUi::TermError do
24
+ use_ui @ui do
25
+ @cmd.execute
26
+ end
27
+ end
28
+
29
+ assert_equal "ERROR: Gem names and --all may not be used together\n",
30
+ @ui.error
31
+ end
32
+
19
33
  def test_execute_dependency_order
20
34
  c = quick_gem 'c' do |spec|
21
35
  spec.add_dependency 'a'
@@ -43,6 +57,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
43
57
 
44
58
  def test_execute_removes_executable
45
59
  ui = Gem::MockGemUi.new
60
+
46
61
  util_setup_gem ui
47
62
 
48
63
  build_rake_in do
@@ -175,5 +190,23 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
175
190
  assert Gem::Specification.find_all_by_name('x').length == 0
176
191
  end
177
192
 
193
+ def test_execute_all
194
+ ui = Gem::MockGemUi.new "y\n"
195
+
196
+ util_make_gems
197
+ util_setup_gem ui
198
+
199
+ assert Gem::Specification.find_all_by_name('a').length > 1
200
+
201
+ @cmd.options[:all] = true
202
+ @cmd.options[:args] = []
203
+
204
+ use_ui ui do
205
+ @cmd.execute
206
+ end
207
+
208
+ refute_includes Gem::Specification.all_names, 'a'
209
+ end
210
+
178
211
  end
179
212
 
@@ -11,6 +11,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
11
11
 
12
12
  def setup
13
13
  super
14
+ common_installer_setup
14
15
 
15
16
  @cmd = Gem::Commands::UpdateCommand.new
16
17
 
@@ -253,7 +254,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
253
254
  out = @ui.output.split "\n"
254
255
  assert_equal "Updating installed gems", out.shift
255
256
  assert_equal "Updating #{@a2.name}", out.shift
256
- assert_equal "Gems updated: #{@c2.name} #{@b2.name} #{@a2.name}",
257
+ assert_equal "Gems updated: #{@a2.name} #{@b2.name} #{@c2.name}",
257
258
  out.shift
258
259
 
259
260
  assert_empty out
@@ -201,6 +201,10 @@ ERROR: Your gem push credentials file located at:
201
201
 
202
202
  has file permissions of 0644 but 0600 is required.
203
203
 
204
+ To fix this error run:
205
+
206
+ \tchmod 0600 #{@cfg.credentials_path}
207
+
204
208
  You should reset your credentials at:
205
209
 
206
210
  \thttps://rubygems.org/profile/edit
@@ -428,6 +432,14 @@ if you believe they were disclosed to a third party.
428
432
  assert_equal('/home/me/certs', @cfg.ssl_ca_cert)
429
433
  end
430
434
 
435
+ def test_load_ssl_client_cert_from_config
436
+ File.open @temp_conf, 'w' do |fp|
437
+ fp.puts ":ssl_client_cert: /home/me/mine.pem"
438
+ end
439
+ util_config_file
440
+ assert_equal('/home/me/mine.pem', @cfg.ssl_client_cert)
441
+ end
442
+
431
443
  def util_config_file(args = @cfg_args)
432
444
  @cfg = Gem::ConfigFile.new args
433
445
  end
@@ -6,6 +6,7 @@ class TestGemDependencyInstaller < Gem::TestCase
6
6
 
7
7
  def setup
8
8
  super
9
+ common_installer_setup
9
10
 
10
11
  @gems_dir = File.join @tempdir, 'gems'
11
12
  @cache_dir = File.join @gemhome, 'cache'
@@ -172,7 +173,8 @@ class TestGemDependencyInstaller < Gem::TestCase
172
173
 
173
174
  FileUtils.mv @a1_gem, @tempdir
174
175
  FileUtils.mv @b1_gem, @tempdir
175
- FileUtils.mv e1_gem, @tempdir
176
+ FileUtils.mv e1_gem, @tempdir
177
+
176
178
  inst = nil
177
179
 
178
180
  Dir.chdir @tempdir do
@@ -180,40 +182,15 @@ class TestGemDependencyInstaller < Gem::TestCase
180
182
  inst.install 'b'
181
183
  end
182
184
 
183
- Dir.chdir @tempdir do
184
- inst = Gem::DependencyInstaller.new
185
- inst.install 'e'
186
- end
187
-
188
- assert_equal %w[e-1 a-1], inst.installed_gems.map { |s| s.full_name }
189
- end
190
-
191
- def test_install_ignore_satified_deps
192
- util_setup_gems
193
-
194
- _, e1_gem = util_gem 'e', '1' do |s|
195
- s.add_dependency 'b'
196
- end
197
-
198
- util_clear_gems
199
-
200
- FileUtils.mv @a1_gem, @tempdir
201
- FileUtils.mv @b1_gem, @tempdir
202
- FileUtils.mv e1_gem, @tempdir
185
+ assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name },
186
+ 'sanity check'
203
187
 
204
188
  Dir.chdir @tempdir do
205
- i = Gem::DependencyInstaller.new :ignore_dependencies => true
206
- i.install 'b'
207
- end
208
-
209
- inst = nil
210
-
211
- Dir.chdir @tempdir do
212
- inst = Gem::DependencyInstaller.new :minimal_deps => true
189
+ inst = Gem::DependencyInstaller.new
213
190
  inst.install 'e'
214
191
  end
215
192
 
216
- assert_equal %w[e-1], inst.installed_gems.map { |s| s.full_name }
193
+ assert_equal %w[a-1 e-1], inst.installed_gems.map { |s| s.full_name }
217
194
  end
218
195
 
219
196
  def test_install_cache_dir
@@ -246,15 +223,18 @@ class TestGemDependencyInstaller < Gem::TestCase
246
223
  Gem::Specification.reset
247
224
 
248
225
  FileUtils.mv @a1_gem, @tempdir
249
- FileUtils.mv a2_gem, @tempdir # not in index
226
+ FileUtils.mv a2_gem, @tempdir # not in index
250
227
  FileUtils.mv @b1_gem, @tempdir
251
228
  inst = nil
252
229
 
253
230
  Dir.chdir @tempdir do
254
231
  inst = Gem::DependencyInstaller.new
255
- inst.install 'a', Gem::Requirement.create("= 2")
232
+ inst.install 'a', req("= 2")
256
233
  end
257
234
 
235
+ assert_equal %w[a-2], inst.installed_gems.map { |s| s.full_name },
236
+ 'sanity check'
237
+
258
238
  FileUtils.rm File.join(@tempdir, a2.file_name)
259
239
 
260
240
  Dir.chdir @tempdir do
@@ -282,19 +262,18 @@ class TestGemDependencyInstaller < Gem::TestCase
282
262
  Gem::Specification.reset
283
263
 
284
264
  FileUtils.mv @a1_gem, @tempdir
285
- FileUtils.mv a2_gem, @tempdir # not in index
265
+ FileUtils.mv a2_gem, @tempdir # not in index
286
266
  FileUtils.mv @b1_gem, @tempdir
287
- FileUtils.mv a3_gem, @tempdir
288
-
289
- inst = nil
267
+ FileUtils.mv a3_gem, @tempdir
290
268
 
291
269
  Dir.chdir @tempdir do
292
- inst = Gem::DependencyInstaller.new
293
- inst.install 'a', Gem::Requirement.create("= 2")
270
+ Gem::DependencyInstaller.new.install 'a', req("= 2")
294
271
  end
295
272
 
296
273
  FileUtils.rm File.join(@tempdir, a2.file_name)
297
274
 
275
+ inst = nil
276
+
298
277
  Dir.chdir @tempdir do
299
278
  inst = Gem::DependencyInstaller.new
300
279
  inst.install 'b'
@@ -488,6 +467,42 @@ class TestGemDependencyInstaller < Gem::TestCase
488
467
  assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
489
468
  end
490
469
 
470
+ def test_install_minimal_deps
471
+ util_setup_gems
472
+
473
+ _, e1_gem = util_gem 'e', '1' do |s|
474
+ s.add_dependency 'b'
475
+ end
476
+
477
+ _, b2_gem = util_gem 'b', '2' do |s|
478
+ s.add_dependency 'a'
479
+ end
480
+
481
+ util_clear_gems
482
+
483
+ FileUtils.mv @a1_gem, @tempdir
484
+ FileUtils.mv @b1_gem, @tempdir
485
+ FileUtils.mv b2_gem, @tempdir
486
+ FileUtils.mv e1_gem, @tempdir
487
+
488
+ inst = nil
489
+
490
+ Dir.chdir @tempdir do
491
+ inst = Gem::DependencyInstaller.new :ignore_dependencies => true
492
+ inst.install 'b', req('= 1')
493
+ end
494
+
495
+ assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name },
496
+ 'sanity check'
497
+
498
+ Dir.chdir @tempdir do
499
+ inst = Gem::DependencyInstaller.new :minimal_deps => true
500
+ inst.install 'e'
501
+ end
502
+
503
+ assert_equal %w[a-1 e-1], inst.installed_gems.map { |s| s.full_name }
504
+ end
505
+
491
506
  def test_install_env_shebang
492
507
  util_setup_gems
493
508
 
@@ -627,12 +642,12 @@ class TestGemDependencyInstaller < Gem::TestCase
627
642
  inst = nil
628
643
 
629
644
  Dir.chdir @tempdir do
630
- e = assert_raises Gem::DependencyError do
645
+ e = assert_raises Gem::UnsatisfiableDependencyError do
631
646
  inst = Gem::DependencyInstaller.new :domain => :local
632
647
  inst.install 'b'
633
648
  end
634
649
 
635
- expected = "Unable to resolve dependencies: b requires a (>= 0)"
650
+ expected = "Unable to resolve dependency: b (= 1) requires a (>= 0)"
636
651
  assert_equal expected, e.message
637
652
  end
638
653
 
@@ -854,29 +869,6 @@ class TestGemDependencyInstaller < Gem::TestCase
854
869
  assert_equal Gem::Source.new(@gem_repo), s.source
855
870
  end
856
871
 
857
- def test_find_spec_by_name_and_version_wildcard
858
- util_gem 'a', 1
859
- FileUtils.mv 'gems/a-1.gem', @tempdir
860
-
861
- FileUtils.touch 'rdoc.gem'
862
-
863
- inst = Gem::DependencyInstaller.new
864
-
865
- available = inst.find_spec_by_name_and_version('*.gem')
866
-
867
- assert_equal %w[a-1], available.all_specs.map { |spec| spec.full_name }
868
- end
869
-
870
- def test_find_spec_by_name_and_version_wildcard_bad_gem
871
- FileUtils.touch 'rdoc.gem'
872
-
873
- inst = Gem::DependencyInstaller.new
874
-
875
- assert_raises Gem::Package::FormatError do
876
- inst.find_spec_by_name_and_version '*.gem'
877
- end
878
- end
879
-
880
872
  def test_find_spec_by_name_and_version_bad_gem
881
873
  FileUtils.touch 'rdoc.gem'
882
874
 
@@ -933,12 +925,13 @@ class TestGemDependencyInstaller < Gem::TestCase
933
925
  gems = set.sorted
934
926
 
935
927
  assert_equal 2, gems.length
936
- local = gems.first
928
+
929
+ remote, local = gems
930
+
937
931
  assert_equal 'a-1', local.spec.full_name, 'local spec'
938
932
  assert_equal File.join(@tempdir, @a1.file_name),
939
933
  local.source.download(local.spec), 'local path'
940
934
 
941
- remote = gems.last
942
935
  assert_equal 'a-1', remote.spec.full_name, 'remote spec'
943
936
  assert_equal Gem::Source.new(@gem_repo), remote.source, 'remote path'
944
937