rubygems-update 1.8.30 → 2.0.0.preview2

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 (241) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +3 -0
  4. data/.autotest +6 -3
  5. data/History.txt +137 -63
  6. data/LICENSE.txt +1 -5
  7. data/Manifest.txt +69 -32
  8. data/README.rdoc +11 -9
  9. data/Rakefile +24 -38
  10. data/bin/gem +0 -9
  11. data/bin/update_rubygems +1 -0
  12. data/lib/rubygems.rb +193 -405
  13. data/lib/rubygems/available_set.rb +95 -0
  14. data/lib/rubygems/command.rb +88 -45
  15. data/lib/rubygems/command_manager.rb +67 -40
  16. data/lib/rubygems/commands/build_command.rb +5 -23
  17. data/lib/rubygems/commands/cert_command.rb +199 -57
  18. data/lib/rubygems/commands/check_command.rb +14 -39
  19. data/lib/rubygems/commands/cleanup_command.rb +9 -1
  20. data/lib/rubygems/commands/contents_command.rb +30 -12
  21. data/lib/rubygems/commands/dependency_command.rb +3 -8
  22. data/lib/rubygems/commands/environment_command.rb +13 -8
  23. data/lib/rubygems/commands/fetch_command.rb +3 -16
  24. data/lib/rubygems/commands/generate_index_command.rb +7 -47
  25. data/lib/rubygems/commands/help_command.rb +1 -1
  26. data/lib/rubygems/commands/install_command.rb +69 -36
  27. data/lib/rubygems/commands/list_command.rb +6 -4
  28. data/lib/rubygems/commands/lock_command.rb +1 -1
  29. data/lib/rubygems/commands/mirror_command.rb +17 -0
  30. data/lib/rubygems/commands/outdated_command.rb +6 -3
  31. data/lib/rubygems/commands/owner_command.rb +13 -5
  32. data/lib/rubygems/commands/pristine_command.rb +19 -4
  33. data/lib/rubygems/commands/push_command.rb +12 -1
  34. data/lib/rubygems/commands/query_command.rb +43 -27
  35. data/lib/rubygems/commands/rdoc_command.rb +23 -28
  36. data/lib/rubygems/commands/search_command.rb +4 -18
  37. data/lib/rubygems/commands/server_command.rb +1 -1
  38. data/lib/rubygems/commands/setup_command.rb +124 -38
  39. data/lib/rubygems/commands/sources_command.rb +16 -16
  40. data/lib/rubygems/commands/specification_command.rb +11 -13
  41. data/lib/rubygems/commands/uninstall_command.rb +24 -7
  42. data/lib/rubygems/commands/unpack_command.rb +7 -3
  43. data/lib/rubygems/commands/update_command.rb +22 -36
  44. data/lib/rubygems/commands/yank_command.rb +98 -0
  45. data/lib/rubygems/compatibility.rb +51 -0
  46. data/lib/rubygems/config_file.rb +82 -54
  47. data/lib/rubygems/core_ext/kernel_gem.rb +53 -0
  48. data/lib/rubygems/core_ext/kernel_require.rb +119 -0
  49. data/lib/rubygems/defaults.rb +10 -21
  50. data/lib/rubygems/dependency.rb +61 -10
  51. data/lib/rubygems/dependency_installer.rb +157 -69
  52. data/lib/rubygems/dependency_list.rb +11 -19
  53. data/lib/rubygems/dependency_resolver.rb +562 -0
  54. data/lib/rubygems/deprecate.rb +40 -40
  55. data/lib/rubygems/errors.rb +77 -24
  56. data/lib/rubygems/exceptions.rb +25 -7
  57. data/lib/rubygems/ext/builder.rb +20 -23
  58. data/lib/rubygems/ext/configure_builder.rb +2 -2
  59. data/lib/rubygems/ext/ext_conf_builder.rb +5 -45
  60. data/lib/rubygems/ext/rake_builder.rb +2 -2
  61. data/lib/rubygems/gem_runner.rb +3 -16
  62. data/lib/rubygems/gemcutter_utilities.rb +22 -7
  63. data/lib/rubygems/indexer.rb +6 -159
  64. data/lib/rubygems/install_message.rb +12 -0
  65. data/lib/rubygems/install_update_options.rb +56 -18
  66. data/lib/rubygems/installer.rb +244 -134
  67. data/lib/rubygems/installer_test_case.rb +71 -19
  68. data/lib/rubygems/mock_gem_ui.rb +17 -0
  69. data/lib/rubygems/name_tuple.rb +110 -0
  70. data/lib/rubygems/package.rb +514 -43
  71. data/lib/rubygems/package/digest_io.rb +64 -0
  72. data/lib/rubygems/package/old.rb +147 -0
  73. data/lib/rubygems/package/tar_header.rb +18 -55
  74. data/lib/rubygems/package/tar_reader.rb +20 -3
  75. data/lib/rubygems/package/tar_writer.rb +63 -7
  76. data/lib/rubygems/package_task.rb +3 -4
  77. data/lib/rubygems/path_support.rb +14 -7
  78. data/lib/rubygems/platform.rb +19 -26
  79. data/lib/rubygems/rdoc.rb +316 -0
  80. data/lib/rubygems/remote_fetcher.rb +117 -54
  81. data/lib/rubygems/request_set.rb +182 -0
  82. data/lib/rubygems/requirement.rb +63 -26
  83. data/lib/rubygems/security.rb +295 -555
  84. data/lib/rubygems/security/policies.rb +115 -0
  85. data/lib/rubygems/security/policy.rb +227 -0
  86. data/lib/rubygems/security/signer.rb +136 -0
  87. data/lib/rubygems/security/trust_dir.rb +104 -0
  88. data/lib/rubygems/server.rb +45 -55
  89. data/lib/rubygems/source.rb +144 -0
  90. data/lib/rubygems/source_list.rb +87 -0
  91. data/lib/rubygems/source_local.rb +92 -0
  92. data/lib/rubygems/source_specific_file.rb +28 -0
  93. data/lib/rubygems/spec_fetcher.rb +116 -184
  94. data/lib/rubygems/specification.rb +731 -335
  95. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
  96. data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
  97. data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
  98. data/lib/rubygems/syck_hack.rb +2 -0
  99. data/lib/rubygems/test_case.rb +199 -109
  100. data/lib/rubygems/test_utilities.rb +25 -5
  101. data/lib/rubygems/uninstaller.rb +62 -20
  102. data/lib/rubygems/user_interaction.rb +10 -0
  103. data/lib/rubygems/validator.rb +33 -40
  104. data/lib/rubygems/version.rb +19 -8
  105. data/setup.rb +8 -1
  106. data/test/rubygems/alternate_cert.pem +9 -0
  107. data/test/rubygems/alternate_cert_32.pem +9 -0
  108. data/test/rubygems/alternate_key.pem +9 -0
  109. data/test/rubygems/bad_rake.rb +1 -0
  110. data/test/rubygems/child_cert.pem +9 -0
  111. data/test/rubygems/child_cert_32.pem +9 -0
  112. data/test/rubygems/child_key.pem +9 -0
  113. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  114. data/test/rubygems/expired_cert.pem +9 -0
  115. data/test/rubygems/future_cert.pem +9 -0
  116. data/test/rubygems/future_cert_32.pem +9 -0
  117. data/test/rubygems/good_rake.rb +1 -0
  118. data/test/rubygems/grandchild_cert.pem +9 -0
  119. data/test/rubygems/grandchild_cert_32.pem +9 -0
  120. data/test/rubygems/grandchild_key.pem +9 -0
  121. data/test/rubygems/invalid_issuer_cert.pem +9 -0
  122. data/test/rubygems/invalid_issuer_cert_32.pem +9 -0
  123. data/test/rubygems/invalid_key.pem +9 -0
  124. data/test/rubygems/invalid_signer_cert.pem +9 -0
  125. data/test/rubygems/invalid_signer_cert_32.pem +9 -0
  126. data/test/rubygems/invalidchild_cert.pem +9 -0
  127. data/test/rubygems/invalidchild_cert_32.pem +9 -0
  128. data/test/rubygems/invalidchild_key.pem +9 -0
  129. data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
  130. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
  131. data/test/rubygems/private_key.pem +7 -25
  132. data/test/rubygems/public_cert.pem +8 -18
  133. data/test/rubygems/public_cert_32.pem +10 -0
  134. data/test/rubygems/public_key.pem +4 -0
  135. data/test/rubygems/rubygems/commands/crash_command.rb +1 -1
  136. data/test/rubygems/test_config.rb +4 -6
  137. data/test/rubygems/test_deprecate.rb +76 -0
  138. data/test/rubygems/test_gem.rb +318 -83
  139. data/test/rubygems/test_gem_available_set.rb +106 -0
  140. data/test/rubygems/test_gem_command.rb +10 -0
  141. data/test/rubygems/test_gem_command_manager.rb +55 -9
  142. data/test/rubygems/test_gem_commands_build_command.rb +11 -19
  143. data/test/rubygems/test_gem_commands_cert_command.rb +441 -42
  144. data/test/rubygems/test_gem_commands_cleanup_command.rb +29 -1
  145. data/test/rubygems/test_gem_commands_contents_command.rb +23 -0
  146. data/test/rubygems/test_gem_commands_dependency_command.rb +5 -0
  147. data/test/rubygems/test_gem_commands_fetch_command.rb +19 -20
  148. data/test/rubygems/test_gem_commands_generate_index_command.rb +2 -83
  149. data/test/rubygems/test_gem_commands_help_command.rb +2 -1
  150. data/test/rubygems/test_gem_commands_install_command.rb +647 -48
  151. data/test/rubygems/test_gem_commands_mirror.rb +32 -0
  152. data/test/rubygems/test_gem_commands_owner_command.rb +4 -8
  153. data/test/rubygems/test_gem_commands_pristine_command.rb +99 -4
  154. data/test/rubygems/test_gem_commands_push_command.rb +62 -8
  155. data/test/rubygems/test_gem_commands_query_command.rb +51 -0
  156. data/test/rubygems/test_gem_commands_search_command.rb +25 -0
  157. data/test/rubygems/test_gem_commands_setup_command.rb +45 -0
  158. data/test/rubygems/test_gem_commands_sources_command.rb +21 -6
  159. data/test/rubygems/test_gem_commands_specification_command.rb +33 -1
  160. data/test/rubygems/test_gem_commands_uninstall_command.rb +91 -31
  161. data/test/rubygems/test_gem_commands_unpack_command.rb +3 -3
  162. data/test/rubygems/test_gem_commands_update_command.rb +56 -38
  163. data/test/rubygems/test_gem_commands_which_command.rb +4 -4
  164. data/test/rubygems/test_gem_commands_yank_command.rb +97 -0
  165. data/test/rubygems/test_gem_config_file.rb +66 -21
  166. data/test/rubygems/test_gem_dependency.rb +46 -0
  167. data/test/rubygems/test_gem_dependency_installer.rb +228 -18
  168. data/test/rubygems/test_gem_dependency_list.rb +0 -9
  169. data/test/rubygems/test_gem_dependency_resolver.rb +327 -0
  170. data/test/rubygems/test_gem_ext_configure_builder.rb +4 -4
  171. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +21 -49
  172. data/test/rubygems/test_gem_ext_rake_builder.rb +13 -13
  173. data/test/rubygems/test_gem_gem_runner.rb +27 -5
  174. data/test/rubygems/test_gem_gemcutter_utilities.rb +19 -0
  175. data/test/rubygems/test_gem_indexer.rb +14 -227
  176. data/test/rubygems/test_gem_install_update_options.rb +83 -3
  177. data/test/rubygems/test_gem_installer.rb +211 -236
  178. data/test/rubygems/test_gem_local_remote_options.rb +8 -2
  179. data/test/rubygems/test_gem_name_tuple.rb +15 -0
  180. data/test/rubygems/test_gem_package.rb +547 -0
  181. data/test/rubygems/test_gem_package_old.rb +37 -0
  182. data/test/rubygems/test_gem_package_tar_reader.rb +32 -0
  183. data/test/rubygems/test_gem_package_tar_writer.rb +84 -1
  184. data/test/rubygems/test_gem_path_support.rb +4 -30
  185. data/test/rubygems/test_gem_platform.rb +3 -6
  186. data/test/rubygems/test_gem_rdoc.rb +245 -0
  187. data/test/rubygems/test_gem_remote_fetcher.rb +51 -5
  188. data/test/rubygems/test_gem_request_set.rb +70 -0
  189. data/test/rubygems/test_gem_requirement.rb +53 -24
  190. data/test/rubygems/test_gem_security.rb +189 -43
  191. data/test/rubygems/test_gem_security_policy.rb +376 -0
  192. data/test/rubygems/test_gem_security_signer.rb +184 -0
  193. data/test/rubygems/test_gem_security_trust_dir.rb +94 -0
  194. data/test/rubygems/test_gem_server.rb +31 -36
  195. data/test/rubygems/test_gem_silent_ui.rb +2 -2
  196. data/test/rubygems/test_gem_source.rb +188 -0
  197. data/test/rubygems/test_gem_source_list.rb +87 -0
  198. data/test/rubygems/test_gem_source_local.rb +83 -0
  199. data/test/rubygems/test_gem_source_specific_file.rb +33 -0
  200. data/test/rubygems/test_gem_spec_fetcher.rb +91 -255
  201. data/test/rubygems/test_gem_specification.rb +293 -39
  202. data/test/rubygems/test_gem_uninstaller.rb +136 -13
  203. data/test/rubygems/test_gem_validator.rb +14 -41
  204. data/test/rubygems/test_gem_version.rb +15 -21
  205. data/test/rubygems/test_require.rb +193 -0
  206. data/test/rubygems/wrong_key_cert.pem +9 -0
  207. data/test/rubygems/wrong_key_cert_32.pem +9 -0
  208. metadata +171 -83
  209. metadata.gz.sig +1 -0
  210. data/CVE-2013-4287.txt +0 -36
  211. data/CVE-2013-4363.txt +0 -45
  212. data/ci_build.sh +0 -27
  213. data/cruise_config.rb +0 -32
  214. data/lib/rbconfig/datadir.rb +0 -13
  215. data/lib/rubygems/builder.rb +0 -99
  216. data/lib/rubygems/custom_require.rb +0 -69
  217. data/lib/rubygems/doc_manager.rb +0 -243
  218. data/lib/rubygems/format.rb +0 -82
  219. data/lib/rubygems/gem_openssl.rb +0 -90
  220. data/lib/rubygems/gem_path_searcher.rb +0 -172
  221. data/lib/rubygems/old_format.rb +0 -153
  222. data/lib/rubygems/package/f_sync_dir.rb +0 -23
  223. data/lib/rubygems/package/tar_input.rb +0 -234
  224. data/lib/rubygems/package/tar_output.rb +0 -146
  225. data/lib/rubygems/require_paths_builder.rb +0 -18
  226. data/lib/rubygems/source_index.rb +0 -406
  227. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
  228. data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
  229. data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
  230. data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
  231. data/lib/rubygems/ssl_certs/GeoTrustGlobalCA.pem +0 -20
  232. data/test/rubygems/test_bundled_ca.rb +0 -59
  233. data/test/rubygems/test_gem_builder.rb +0 -44
  234. data/test/rubygems/test_gem_doc_manager.rb +0 -32
  235. data/test/rubygems/test_gem_ext_builder.rb +0 -58
  236. data/test/rubygems/test_gem_format.rb +0 -88
  237. data/test/rubygems/test_gem_gem_path_searcher.rb +0 -94
  238. data/test/rubygems/test_gem_package_tar_input.rb +0 -129
  239. data/test/rubygems/test_gem_package_tar_output.rb +0 -101
  240. data/test/rubygems/test_gem_source_index.rb +0 -250
  241. data/util/update_bundled_ca_certificates.rb +0 -103
@@ -41,19 +41,19 @@ class TestGemCommandsWhichCommand < Gem::TestCase
41
41
 
42
42
  util_foo_bar
43
43
 
44
- @cmd.handle_options %w[foo_bar missing]
44
+ @cmd.handle_options %w[foo_bar missinglib]
45
45
 
46
46
  use_ui @ui do
47
47
  @cmd.execute
48
48
  end
49
49
 
50
50
  assert_equal "#{@foo_bar.full_gem_path}/lib/foo_bar.rb\n", @ui.output
51
- assert_match %r%Can.t find ruby library file or shared library missing\n%,
51
+ assert_match %r%Can.t find ruby library file or shared library missinglib\n%,
52
52
  @ui.error
53
53
  end
54
54
 
55
55
  def test_execute_missing
56
- @cmd.handle_options %w[missing]
56
+ @cmd.handle_options %w[missinglib]
57
57
 
58
58
  use_ui @ui do
59
59
  assert_raises Gem::MockGemUi::TermError do
@@ -62,7 +62,7 @@ class TestGemCommandsWhichCommand < Gem::TestCase
62
62
  end
63
63
 
64
64
  assert_equal '', @ui.output
65
- assert_match %r%Can.t find ruby library file or shared library missing\n%,
65
+ assert_match %r%Can.t find ruby library file or shared library missinglib\n%,
66
66
  @ui.error
67
67
  end
68
68
 
@@ -0,0 +1,97 @@
1
+ require 'rubygems/test_case'
2
+ require 'rubygems/commands/yank_command'
3
+
4
+ class TestGemCommandsYankCommand < Gem::TestCase
5
+ def setup
6
+ super
7
+
8
+ @cmd = Gem::Commands::YankCommand.new
9
+ @cmd.host = 'http://example'
10
+
11
+ @fetcher = Gem::RemoteFetcher.fetcher
12
+
13
+ Gem.configuration.rubygems_api_key = 'key'
14
+ Gem.configuration.api_keys[:KEY] = 'other'
15
+ end
16
+
17
+ def test_handle_options
18
+ @cmd.handle_options %w[a --version 1.0 --platform x86-darwin -k KEY]
19
+
20
+ assert_equal %w[a], @cmd.options[:args]
21
+ assert_equal 'KEY', @cmd.options[:key]
22
+ assert_nil @cmd.options[:platform]
23
+ assert_equal req('= 1.0'), @cmd.options[:version]
24
+ end
25
+
26
+ def test_handle_options_missing_argument
27
+ %w[-v --version -p --platform].each do |option|
28
+ assert_raises OptionParser::MissingArgument do
29
+ @cmd.handle_options %W[a #{option}]
30
+ end
31
+ end
32
+ end
33
+
34
+ def test_execute
35
+ yank_uri = 'http://example/api/v1/gems/yank'
36
+ @fetcher.data[yank_uri] = ['Successfully yanked', 200, 'OK']
37
+
38
+ @cmd.options[:args] = %w[a]
39
+ @cmd.options[:added_platform] = true
40
+ @cmd.options[:version] = req('= 1.0')
41
+
42
+ use_ui @ui do
43
+ @cmd.execute
44
+ end
45
+
46
+ assert_match %r%Yanking gem from http://example%, @ui.output
47
+ assert_match %r%Successfully yanked%, @ui.output
48
+
49
+ platform = Gem.platforms[1]
50
+ body = @fetcher.last_request.body.split('&').sort
51
+ assert_equal %W[gem_name=a platform=#{platform} version=1.0], body
52
+
53
+ assert_equal 'key', @fetcher.last_request['Authorization']
54
+
55
+ assert_equal [yank_uri], @fetcher.paths
56
+ end
57
+
58
+ def test_execute_key
59
+ yank_uri = 'http://example/api/v1/gems/yank'
60
+ @fetcher.data[yank_uri] = ['Successfully yanked', 200, 'OK']
61
+
62
+ @cmd.options[:args] = %w[a]
63
+ @cmd.options[:version] = req('= 1.0')
64
+ @cmd.options[:key] = 'KEY'
65
+
66
+ use_ui @ui do
67
+ @cmd.execute
68
+ end
69
+
70
+ body = @fetcher.last_request.body.split('&').sort
71
+ assert_equal %w[gem_name=a version=1.0], body
72
+ assert_equal 'other', @fetcher.last_request['Authorization']
73
+ end
74
+
75
+ def test_execute_undo
76
+ unyank_uri = 'http://example/api/v1/gems/unyank'
77
+ @fetcher.data[unyank_uri] = ['Successfully unyanked', 200, 'OK']
78
+
79
+ @cmd.options[:args] = %w[a]
80
+ @cmd.options[:version] = req('= 1.0')
81
+ @cmd.options[:undo] = true
82
+
83
+ use_ui @ui do
84
+ @cmd.execute
85
+ end
86
+
87
+ assert_match %r%Unyanking gem from http://example%, @ui.output
88
+ assert_match %r%Successfully unyanked%, @ui.output
89
+
90
+ body = @fetcher.last_request.body.split('&').sort
91
+ assert_equal %w[gem_name=a version=1.0], body
92
+
93
+ assert_equal [unyank_uri], @fetcher.paths
94
+ end
95
+
96
+ end
97
+
@@ -17,6 +17,9 @@ class TestGemConfigFile < Gem::TestCase
17
17
  Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear
18
18
  Gem::ConfigFile::PLATFORM_DEFAULTS.clear
19
19
 
20
+ @env_gemrc = ENV['GEMRC']
21
+ ENV['GEMRC'] = ''
22
+
20
23
  util_config_file
21
24
  end
22
25
 
@@ -27,6 +30,8 @@ class TestGemConfigFile < Gem::TestCase
27
30
  Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
28
31
  @orig_SYSTEM_WIDE_CONFIG_FILE
29
32
 
33
+ ENV['GEMRC'] = @env_gemrc
34
+
30
35
  super
31
36
  end
32
37
 
@@ -35,7 +40,6 @@ class TestGemConfigFile < Gem::TestCase
35
40
 
36
41
  assert_equal false, @cfg.backtrace
37
42
  assert_equal true, @cfg.update_sources
38
- assert_equal false, @cfg.benchmark
39
43
  assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold
40
44
  assert_equal true, @cfg.verbose
41
45
  assert_equal [@gem_repo], Gem.sources
@@ -43,7 +47,6 @@ class TestGemConfigFile < Gem::TestCase
43
47
  File.open @temp_conf, 'w' do |fp|
44
48
  fp.puts ":backtrace: true"
45
49
  fp.puts ":update_sources: false"
46
- fp.puts ":benchmark: true"
47
50
  fp.puts ":bulk_threshold: 10"
48
51
  fp.puts ":verbose: false"
49
52
  fp.puts ":sources:"
@@ -59,7 +62,6 @@ class TestGemConfigFile < Gem::TestCase
59
62
  util_config_file
60
63
 
61
64
  assert_equal true, @cfg.backtrace
62
- assert_equal true, @cfg.benchmark
63
65
  assert_equal 10, @cfg.bulk_threshold
64
66
  assert_equal false, @cfg.verbose
65
67
  assert_equal false, @cfg.update_sources
@@ -131,6 +133,37 @@ class TestGemConfigFile < Gem::TestCase
131
133
  assert_equal true, @cfg.backtrace
132
134
  end
133
135
 
136
+ def test_initialize_environment_variable_override
137
+ File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, 'w' do |fp|
138
+ fp.puts ':backtrace: false'
139
+ fp.puts ':verbose: false'
140
+ fp.puts ':bulk_threshold: 2048'
141
+ end
142
+
143
+ conf1 = File.join @tempdir, 'gemrc1'
144
+ File.open conf1, 'w' do |fp|
145
+ fp.puts ':backtrace: true'
146
+ end
147
+
148
+ conf2 = File.join @tempdir, 'gemrc2'
149
+ File.open conf2, 'w' do |fp|
150
+ fp.puts ':verbose: true'
151
+ end
152
+
153
+ conf3 = File.join @tempdir, 'gemrc3'
154
+ File.open conf3, 'w' do |fp|
155
+ fp.puts ':verbose: :loud'
156
+ end
157
+
158
+ ENV['GEMRC'] = conf1 + ':' + conf2 + ';' + conf3
159
+
160
+ util_config_file
161
+
162
+ assert_equal true, @cfg.backtrace
163
+ assert_equal :loud, @cfg.verbose
164
+ assert_equal 2048, @cfg.bulk_threshold
165
+ end
166
+
134
167
  def test_handle_arguments
135
168
  args = %w[--backtrace --bunch --of --args here]
136
169
 
@@ -149,16 +182,6 @@ class TestGemConfigFile < Gem::TestCase
149
182
  assert_equal true, @cfg.backtrace
150
183
  end
151
184
 
152
- def test_handle_arguments_benchmark
153
- assert_equal false, @cfg.benchmark
154
-
155
- args = %w[--benchmark]
156
-
157
- @cfg.handle_arguments args
158
-
159
- assert_equal true, @cfg.benchmark
160
- end
161
-
162
185
  def test_handle_arguments_debug
163
186
  old_dollar_DEBUG = $DEBUG
164
187
  assert_equal false, $DEBUG
@@ -174,12 +197,12 @@ class TestGemConfigFile < Gem::TestCase
174
197
 
175
198
  def test_handle_arguments_override
176
199
  File.open @temp_conf, 'w' do |fp|
177
- fp.puts ":benchmark: false"
200
+ fp.puts ":backtrace: false"
178
201
  end
179
202
 
180
- util_config_file %W[--benchmark --config-file=#{@temp_conf}]
203
+ util_config_file %W[--backtrace --config-file=#{@temp_conf}]
181
204
 
182
- assert_equal true, @cfg.benchmark
205
+ assert_equal true, @cfg.backtrace
183
206
  end
184
207
 
185
208
  def test_handle_arguments_traceback
@@ -206,7 +229,6 @@ class TestGemConfigFile < Gem::TestCase
206
229
 
207
230
  def test_write
208
231
  @cfg.backtrace = true
209
- @cfg.benchmark = true
210
232
  @cfg.update_sources = false
211
233
  @cfg.bulk_threshold = 10
212
234
  @cfg.verbose = false
@@ -219,7 +241,6 @@ class TestGemConfigFile < Gem::TestCase
219
241
 
220
242
  # These should not be written out to the config file.
221
243
  assert_equal false, @cfg.backtrace, 'backtrace'
222
- assert_equal false, @cfg.benchmark, 'benchmark'
223
244
  assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold,
224
245
  'bulk_threshold'
225
246
  assert_equal true, @cfg.update_sources, 'update_sources'
@@ -234,7 +255,6 @@ class TestGemConfigFile < Gem::TestCase
234
255
  def test_write_from_hash
235
256
  File.open @temp_conf, 'w' do |fp|
236
257
  fp.puts ":backtrace: true"
237
- fp.puts ":benchmark: true"
238
258
  fp.puts ":bulk_threshold: 10"
239
259
  fp.puts ":update_sources: false"
240
260
  fp.puts ":verbose: false"
@@ -246,7 +266,6 @@ class TestGemConfigFile < Gem::TestCase
246
266
  util_config_file
247
267
 
248
268
  @cfg.backtrace = :junk
249
- @cfg.benchmark = :junk
250
269
  @cfg.update_sources = :junk
251
270
  @cfg.bulk_threshold = 20
252
271
  @cfg.verbose = :junk
@@ -259,7 +278,6 @@ class TestGemConfigFile < Gem::TestCase
259
278
 
260
279
  # These should not be written out to the config file
261
280
  assert_equal true, @cfg.backtrace, 'backtrace'
262
- assert_equal true, @cfg.benchmark, 'benchmark'
263
281
  assert_equal 10, @cfg.bulk_threshold, 'bulk_threshold'
264
282
  assert_equal false, @cfg.update_sources, 'update_sources'
265
283
  assert_equal false, @cfg.verbose, 'verbose'
@@ -295,6 +313,26 @@ class TestGemConfigFile < Gem::TestCase
295
313
  :other => 'a5fdbb6ba150cbb83aad2bb2fede64c'}, @cfg.api_keys)
296
314
  end
297
315
 
316
+ def test_save_credentials_file_with_strict_permissions
317
+ util_config_file
318
+ FileUtils.mkdir File.dirname(@cfg.credentials_path)
319
+ @cfg.rubygems_api_key = '701229f217cdf23b1344c7b4b54ca97'
320
+ mode = 0100600 & (~File.umask)
321
+ assert_equal mode, File.stat(@cfg.credentials_path).mode unless win_platform?
322
+ end
323
+
324
+ def test_ignore_invalid_config_file
325
+ File.open @temp_conf, 'w' do |fp|
326
+ fp.puts "some-non-yaml-hash-string"
327
+ end
328
+
329
+ # Avoid writing stuff to output when running tests
330
+ Gem::ConfigFile.class_eval { def warn(args); end }
331
+
332
+ # This should not raise exception
333
+ util_config_file
334
+ end
335
+
298
336
  def test_load_ssl_verify_mode_from_config
299
337
  File.open @temp_conf, 'w' do |fp|
300
338
  fp.puts ":ssl_verify_mode: 1"
@@ -315,5 +353,12 @@ class TestGemConfigFile < Gem::TestCase
315
353
  @cfg = Gem::ConfigFile.new args
316
354
  end
317
355
 
356
+ def test_disable_default_gem_server
357
+ File.open @temp_conf, 'w' do |fp|
358
+ fp.puts ":disable_default_gem_server: true"
359
+ end
360
+ util_config_file
361
+ assert_equal(true, @cfg.disable_default_gem_server)
362
+ end
318
363
  end
319
364
 
@@ -9,6 +9,15 @@ class TestGemDependency < Gem::TestCase
9
9
  assert_equal req("> 1.0"), d.requirement
10
10
  end
11
11
 
12
+ def test_initialize_type_bad
13
+ e = assert_raises ArgumentError do
14
+ Gem::Dependency.new 'monkey' => '1.0'
15
+ end
16
+
17
+ assert_equal 'dependency name must be a String, was {"monkey"=>"1.0"}',
18
+ e.message
19
+ end
20
+
12
21
  def test_initialize_double
13
22
  d = dep "pkg", "> 1.0", "< 2.0"
14
23
  assert_equal req("> 1.0", "< 2.0"), d.requirement
@@ -173,5 +182,42 @@ class TestGemDependency < Gem::TestCase
173
182
  assert dep('a', '= 1').specific?
174
183
  end
175
184
 
185
+ def test_to_specs_suggests_other_versions
186
+ a = util_spec 'a', '1.0', 'b' => '>= 1.0'
187
+
188
+ a_file = File.join a.gem_dir, 'lib', 'a_file.rb'
189
+
190
+ write_file a_file do |io|
191
+ io.puts '# a_file.rb'
192
+ end
193
+
194
+ dep = Gem::Dependency.new "a", "= 2.0"
195
+
196
+ e = assert_raises Gem::LoadError do
197
+ dep.to_specs
198
+ end
199
+
200
+ assert_equal "Could not find 'a' (= 2.0) - did find: [a-1.0]", e.message
201
+ end
202
+
203
+ def test_to_specs_indicates_total_gem_set_size
204
+ a = util_spec 'a', '1.0', 'b' => '>= 1.0'
205
+
206
+ a_file = File.join a.gem_dir, 'lib', 'a_file.rb'
207
+
208
+ write_file a_file do |io|
209
+ io.puts '# a_file.rb'
210
+ end
211
+
212
+ dep = Gem::Dependency.new "b", "= 2.0"
213
+
214
+ e = assert_raises Gem::LoadError do
215
+ dep.to_specs
216
+ end
217
+
218
+ assert_equal "Could not find 'b' (= 2.0) among 1 total gem(s)", e.message
219
+ end
220
+
221
+
176
222
  end
177
223
 
@@ -23,6 +23,14 @@ class TestGemDependencyInstaller < Gem::TestCase
23
23
  s.add_development_dependency 'aa'
24
24
  end
25
25
 
26
+ @c1, @c1_gem = util_gem 'c', '1' do |s|
27
+ s.add_development_dependency 'b'
28
+ end
29
+
30
+ @d1, @d1_gem = util_gem 'd', '1' do |s|
31
+ s.add_development_dependency 'c'
32
+ end
33
+
26
34
  util_clear_gems
27
35
  util_reset_gems
28
36
  end
@@ -42,6 +50,62 @@ class TestGemDependencyInstaller < Gem::TestCase
42
50
  assert_equal [@a1], inst.installed_gems
43
51
  end
44
52
 
53
+ def test_install_prerelease
54
+ util_setup_gems
55
+
56
+ p1a, gem = util_gem 'a', '10.a'
57
+
58
+ util_setup_spec_fetcher(p1a, @a1, @a1_pre)
59
+ util_clear_gems
60
+
61
+ p1a_data = Gem.read_binary(gem)
62
+
63
+ @fetcher.data['http://gems.example.com/gems/a-10.a.gem'] = p1a_data
64
+
65
+ dep = Gem::Dependency.new "a"
66
+ inst = Gem::DependencyInstaller.new :prerelease => true
67
+ inst.install dep
68
+
69
+ assert_equal %w[a-10.a], Gem::Specification.map(&:full_name)
70
+ assert_equal [p1a], inst.installed_gems
71
+ end
72
+
73
+ def test_install_when_only_prerelease
74
+ p1a, gem = util_gem 'p', '1.a'
75
+
76
+ util_setup_spec_fetcher(p1a)
77
+ util_clear_gems
78
+
79
+ p1a_data = Gem.read_binary(gem)
80
+
81
+ @fetcher.data['http://gems.example.com/gems/p-1.a.gem'] = p1a_data
82
+
83
+ dep = Gem::Dependency.new "p"
84
+ inst = Gem::DependencyInstaller.new
85
+ inst.install dep
86
+
87
+ assert_equal %w[], Gem::Specification.map(&:full_name)
88
+ assert_equal [], inst.installed_gems
89
+ end
90
+
91
+ def test_install_prerelease_skipped_when_normal_ver
92
+ util_setup_gems
93
+
94
+ util_setup_spec_fetcher(@a1, @a1_pre)
95
+ util_clear_gems
96
+
97
+ p1a_data = Gem.read_binary(@a1_gem)
98
+
99
+ @fetcher.data['http://gems.example.com/gems/a-1.gem'] = p1a_data
100
+
101
+ dep = Gem::Dependency.new "a"
102
+ inst = Gem::DependencyInstaller.new :prerelease => true
103
+ inst.install dep
104
+
105
+ assert_equal %w[a-1], Gem::Specification.map(&:full_name)
106
+ assert_equal [@a1], inst.installed_gems
107
+ end
108
+
45
109
  def test_install_all_dependencies
46
110
  util_setup_gems
47
111
 
@@ -69,14 +133,44 @@ class TestGemDependencyInstaller < Gem::TestCase
69
133
  assert_equal %w[e-1 a-1], inst.installed_gems.map { |s| s.full_name }
70
134
  end
71
135
 
72
- def test_install_cache_dir
136
+ def test_install_ignore_satified_deps
73
137
  util_setup_gems
74
138
 
139
+ _, e1_gem = util_gem 'e', '1' do |s|
140
+ s.add_dependency 'b'
141
+ end
142
+
143
+ util_clear_gems
144
+
75
145
  FileUtils.mv @a1_gem, @tempdir
76
146
  FileUtils.mv @b1_gem, @tempdir
147
+ FileUtils.mv e1_gem, @tempdir
148
+
149
+ Dir.chdir @tempdir do
150
+ i = Gem::DependencyInstaller.new :ignore_dependencies => true
151
+ i.install 'b'
152
+ end
153
+
77
154
  inst = nil
78
155
 
79
156
  Dir.chdir @tempdir do
157
+ inst = Gem::DependencyInstaller.new :minimal_deps => true
158
+ inst.install 'e'
159
+ end
160
+
161
+ assert_equal %w[e-1], inst.installed_gems.map { |s| s.full_name }
162
+ end
163
+
164
+ def test_install_cache_dir
165
+ util_setup_gems
166
+
167
+ dir = "dir"
168
+ Dir.mkdir dir
169
+ FileUtils.mv @a1_gem, dir
170
+ FileUtils.mv @b1_gem, dir
171
+ inst = nil
172
+
173
+ Dir.chdir dir do
80
174
  inst = Gem::DependencyInstaller.new :cache_dir => @tempdir
81
175
  inst.install 'b'
82
176
  end
@@ -103,7 +197,7 @@ class TestGemDependencyInstaller < Gem::TestCase
103
197
 
104
198
  Dir.chdir @tempdir do
105
199
  inst = Gem::DependencyInstaller.new
106
- inst.install 'a-2'
200
+ inst.install 'a', Gem::Requirement.create("= 2")
107
201
  end
108
202
 
109
203
  FileUtils.rm File.join(@tempdir, a2.file_name)
@@ -117,19 +211,67 @@ class TestGemDependencyInstaller < Gem::TestCase
117
211
  assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
118
212
  end
119
213
 
120
- def test_install_dependency
214
+ # This asserts that if a gem's dependency is satisfied by an
215
+ # already installed gem, RubyGems doesn't installed a newer
216
+ # version
217
+ def test_install_doesnt_upgrade_installed_depedencies
121
218
  util_setup_gems
122
219
 
220
+ a2, a2_gem = util_gem 'a', '2'
221
+ a3, a3_gem = util_gem 'a', '3'
222
+
223
+ util_setup_spec_fetcher @a1, a3, @b1
224
+
225
+ FileUtils.rm_rf File.join(@gemhome, 'gems')
226
+
227
+ Gem::Specification.reset
228
+
123
229
  FileUtils.mv @a1_gem, @tempdir
230
+ FileUtils.mv a2_gem, @tempdir # not in index
124
231
  FileUtils.mv @b1_gem, @tempdir
232
+ FileUtils.mv a3_gem, @tempdir
233
+
125
234
  inst = nil
126
235
 
236
+ Dir.chdir @tempdir do
237
+ inst = Gem::DependencyInstaller.new
238
+ inst.install 'a', Gem::Requirement.create("= 2")
239
+ end
240
+
241
+ FileUtils.rm File.join(@tempdir, a2.file_name)
242
+
127
243
  Dir.chdir @tempdir do
128
244
  inst = Gem::DependencyInstaller.new
129
245
  inst.install 'b'
130
246
  end
131
247
 
248
+ assert_equal %w[a-2 b-1], Gem::Specification.map(&:full_name)
249
+ assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
250
+ end
251
+
252
+ def test_install_dependency
253
+ util_setup_gems
254
+
255
+ done_installing_ran = false
256
+ inst = nil
257
+
258
+ Gem.done_installing do |installer, specs|
259
+ done_installing_ran = true
260
+ assert_equal inst, installer
261
+ assert_equal [@a1, @b1], specs
262
+ end
263
+
264
+ FileUtils.mv @a1_gem, @tempdir
265
+ FileUtils.mv @b1_gem, @tempdir
266
+
267
+ Dir.chdir @tempdir do
268
+ inst = Gem::DependencyInstaller.new(:build_docs_in_background => false)
269
+ inst.install 'b'
270
+ end
271
+
132
272
  assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
273
+
274
+ assert done_installing_ran, 'post installs hook was not run'
133
275
  end
134
276
 
135
277
  def test_install_dependency_development
@@ -152,6 +294,50 @@ class TestGemDependencyInstaller < Gem::TestCase
152
294
  assert_equal %w[a-1 aa-1 b-1], inst.installed_gems.map { |s| s.full_name }
153
295
  end
154
296
 
297
+ def test_install_dependency_development_deep
298
+ util_setup_gems
299
+
300
+ @aa1, @aa1_gem = util_gem 'aa', '1'
301
+
302
+ util_reset_gems
303
+
304
+ FileUtils.mv @a1_gem, @tempdir
305
+ FileUtils.mv @aa1_gem, @tempdir
306
+ FileUtils.mv @b1_gem, @tempdir
307
+ FileUtils.mv @c1_gem, @tempdir
308
+ FileUtils.mv @d1_gem, @tempdir
309
+ inst = nil
310
+
311
+ Dir.chdir @tempdir do
312
+ inst = Gem::DependencyInstaller.new(:development => true)
313
+ inst.install 'd'
314
+ end
315
+
316
+ assert_equal %w[a-1 aa-1 b-1 c-1 d-1], inst.installed_gems.map { |s| s.full_name }
317
+ end
318
+
319
+ def test_install_dependency_development_shallow
320
+ util_setup_gems
321
+
322
+ @aa1, @aa1_gem = util_gem 'aa', '1'
323
+
324
+ util_reset_gems
325
+
326
+ FileUtils.mv @a1_gem, @tempdir
327
+ FileUtils.mv @aa1_gem, @tempdir
328
+ FileUtils.mv @b1_gem, @tempdir
329
+ FileUtils.mv @c1_gem, @tempdir
330
+ FileUtils.mv @d1_gem, @tempdir
331
+ inst = nil
332
+
333
+ Dir.chdir @tempdir do
334
+ inst = Gem::DependencyInstaller.new(:development => true, :dev_shallow => true)
335
+ inst.install 'd'
336
+ end
337
+
338
+ assert_equal %w[c-1 d-1], inst.installed_gems.map { |s| s.full_name }
339
+ end
340
+
155
341
  def test_install_dependency_existing
156
342
  util_setup_gems
157
343
 
@@ -517,11 +703,12 @@ class TestGemDependencyInstaller < Gem::TestCase
517
703
  policy = Gem::Security::HighSecurity
518
704
  inst = Gem::DependencyInstaller.new :security_policy => policy
519
705
 
520
- e = assert_raises Gem::Exception do
706
+ e = assert_raises Gem::Security::Exception do
521
707
  inst.install 'b'
522
708
  end
523
709
 
524
- assert_equal 'Unsigned gem', e.message
710
+ assert_equal 'unsigned gems are not allowed by the High Security policy',
711
+ e.message
525
712
 
526
713
  assert_equal %w[], inst.installed_gems.map { |s| s.full_name }
527
714
  end
@@ -581,7 +768,14 @@ class TestGemDependencyInstaller < Gem::TestCase
581
768
 
582
769
  Gem::Specification.reset
583
770
 
584
- assert_equal [[@b1, @gem_repo]], inst.find_gems_with_sources(dep)
771
+ set = inst.find_gems_with_sources(dep)
772
+
773
+ assert_kind_of Gem::AvailableSet, set
774
+
775
+ s = set.set.first
776
+
777
+ assert_equal @b1, s.spec
778
+ assert_equal Gem::Source.new(@gem_repo), s.source
585
779
  end
586
780
 
587
781
  def test_find_gems_with_sources_local
@@ -590,21 +784,24 @@ class TestGemDependencyInstaller < Gem::TestCase
590
784
  FileUtils.mv @a1_gem, @tempdir
591
785
  inst = Gem::DependencyInstaller.new
592
786
  dep = Gem::Dependency.new 'a', '>= 0'
593
- gems = nil
787
+ set = nil
594
788
 
595
789
  Dir.chdir @tempdir do
596
- gems = inst.find_gems_with_sources dep
790
+ set = inst.find_gems_with_sources dep
597
791
  end
598
792
 
599
- assert_equal 2, gems.length
600
- remote = gems.first
601
- assert_equal 'a-1', remote.first.full_name, 'remote spec'
602
- assert_equal @gem_repo, remote.last, 'remote path'
793
+ gems = set.sorted
603
794
 
604
- local = gems.last
605
- assert_equal 'a-1', local.first.full_name, 'local spec'
795
+ assert_equal 2, gems.length
796
+ local = gems.first
797
+ assert_equal 'a-1', local.spec.full_name, 'local spec'
606
798
  assert_equal File.join(@tempdir, @a1.file_name),
607
- local.last, 'local path'
799
+ local.source.download(local.spec), 'local path'
800
+
801
+ remote = gems.last
802
+ assert_equal 'a-1', remote.spec.full_name, 'remote spec'
803
+ assert_equal Gem::Source.new(@gem_repo), remote.source, 'remote path'
804
+
608
805
  end
609
806
 
610
807
  def test_find_gems_with_sources_prerelease
@@ -615,7 +812,7 @@ class TestGemDependencyInstaller < Gem::TestCase
615
812
  dependency = Gem::Dependency.new('a', Gem::Requirement.default)
616
813
 
617
814
  releases =
618
- installer.find_gems_with_sources(dependency).map { |gems, *| gems }
815
+ installer.find_gems_with_sources(dependency).all_specs
619
816
 
620
817
  assert releases.any? { |s| s.name == 'a' and s.version.to_s == '1' }
621
818
  refute releases.any? { |s| s.name == 'a' and s.version.to_s == '1.a' }
@@ -623,9 +820,22 @@ class TestGemDependencyInstaller < Gem::TestCase
623
820
  dependency.prerelease = true
624
821
 
625
822
  prereleases =
626
- installer.find_gems_with_sources(dependency).map { |gems, *| gems }
823
+ installer.find_gems_with_sources(dependency).all_specs
824
+
825
+ assert_equal [@a1_pre, @a1], prereleases
826
+ end
827
+
828
+ def test_find_gems_with_sources_with_bad_source
829
+ Gem.sources.replace ["http://not-there.nothing"]
830
+
831
+ installer = Gem::DependencyInstaller.new
832
+
833
+ dep = Gem::Dependency.new('a')
834
+
835
+ out = installer.find_gems_with_sources(dep)
627
836
 
628
- assert_equal [@a1_pre], prereleases
837
+ assert out.empty?
838
+ assert_kind_of Gem::SourceFetchProblem, installer.errors.first
629
839
  end
630
840
 
631
841
  def assert_resolve expected, *specs