rubygems-update 2.7.11 → 3.0.0

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 (350) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +66 -0
  3. data/.travis.yml +22 -18
  4. data/CONTRIBUTING.md +141 -0
  5. data/History.txt +289 -19
  6. data/MAINTAINERS.txt +1 -0
  7. data/Manifest.txt +16 -11
  8. data/POLICIES.md +92 -0
  9. data/README.md +47 -26
  10. data/Rakefile +47 -207
  11. data/{UPGRADING.rdoc → UPGRADING.md} +31 -32
  12. data/appveyor.yml +20 -45
  13. data/bin/gem +1 -2
  14. data/bin/update_rubygems +2 -3
  15. data/bundler/CHANGELOG.md +54 -0
  16. data/bundler/bundler.gemspec +7 -1
  17. data/bundler/lib/bundler.rb +26 -8
  18. data/bundler/lib/bundler/build_metadata.rb +2 -2
  19. data/bundler/lib/bundler/cli.rb +63 -21
  20. data/bundler/lib/bundler/cli/add.rb +15 -5
  21. data/bundler/lib/bundler/cli/binstubs.rb +8 -2
  22. data/bundler/lib/bundler/cli/doctor.rb +47 -1
  23. data/bundler/lib/bundler/cli/install.rb +8 -5
  24. data/bundler/lib/bundler/cli/list.rb +41 -5
  25. data/bundler/lib/bundler/cli/outdated.rb +7 -1
  26. data/bundler/lib/bundler/cli/pristine.rb +4 -0
  27. data/bundler/lib/bundler/cli/remove.rb +18 -0
  28. data/bundler/lib/bundler/definition.rb +15 -16
  29. data/bundler/lib/bundler/dependency.rb +2 -2
  30. data/bundler/lib/bundler/dsl.rb +19 -3
  31. data/bundler/lib/bundler/feature_flag.rb +7 -0
  32. data/bundler/lib/bundler/gem_version_promoter.rb +4 -2
  33. data/bundler/lib/bundler/injector.rb +168 -9
  34. data/bundler/lib/bundler/installer.rb +29 -6
  35. data/bundler/lib/bundler/installer/parallel_installer.rb +5 -0
  36. data/bundler/lib/bundler/plugin.rb +10 -3
  37. data/bundler/lib/bundler/plugin/events.rb +61 -0
  38. data/bundler/lib/bundler/resolver.rb +2 -2
  39. data/bundler/lib/bundler/runtime.rb +8 -2
  40. data/bundler/lib/bundler/settings.rb +24 -3
  41. data/bundler/lib/bundler/settings/validator.rb +23 -0
  42. data/bundler/lib/bundler/shared_helpers.rb +19 -3
  43. data/bundler/lib/bundler/source.rb +9 -9
  44. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
  45. data/bundler/lib/bundler/version.rb +1 -1
  46. data/bundler/man/bundle-add.ronn +13 -2
  47. data/bundler/man/bundle-config.ronn +21 -0
  48. data/bundler/man/bundle-install.ronn +1 -1
  49. data/bundler/man/bundle-list.ronn +19 -1
  50. data/bundler/man/bundle-outdated.ronn +4 -0
  51. data/bundler/man/bundle-remove.ronn +23 -0
  52. data/bundler/man/bundle-update.ronn +1 -1
  53. data/lib/rubygems.rb +70 -96
  54. data/lib/rubygems/available_set.rb +1 -1
  55. data/lib/rubygems/basic_specification.rb +12 -12
  56. data/lib/rubygems/bundler_version_finder.rb +3 -3
  57. data/lib/rubygems/command.rb +22 -15
  58. data/lib/rubygems/command_manager.rb +20 -11
  59. data/lib/rubygems/commands/build_command.rb +27 -8
  60. data/lib/rubygems/commands/cert_command.rb +45 -24
  61. data/lib/rubygems/commands/check_command.rb +1 -1
  62. data/lib/rubygems/commands/cleanup_command.rb +14 -7
  63. data/lib/rubygems/commands/contents_command.rb +14 -15
  64. data/lib/rubygems/commands/dependency_command.rb +17 -17
  65. data/lib/rubygems/commands/environment_command.rb +20 -1
  66. data/lib/rubygems/commands/fetch_command.rb +2 -3
  67. data/lib/rubygems/commands/generate_index_command.rb +2 -3
  68. data/lib/rubygems/commands/help_command.rb +12 -13
  69. data/lib/rubygems/commands/info_command.rb +33 -0
  70. data/lib/rubygems/commands/install_command.rb +21 -17
  71. data/lib/rubygems/commands/list_command.rb +0 -1
  72. data/lib/rubygems/commands/lock_command.rb +3 -4
  73. data/lib/rubygems/commands/open_command.rb +16 -10
  74. data/lib/rubygems/commands/owner_command.rb +20 -11
  75. data/lib/rubygems/commands/pristine_command.rb +23 -16
  76. data/lib/rubygems/commands/push_command.rb +17 -8
  77. data/lib/rubygems/commands/query_command.rb +24 -24
  78. data/lib/rubygems/commands/rdoc_command.rb +3 -4
  79. data/lib/rubygems/commands/search_command.rb +0 -1
  80. data/lib/rubygems/commands/server_command.rb +1 -2
  81. data/lib/rubygems/commands/setup_command.rb +78 -38
  82. data/lib/rubygems/commands/signin_command.rb +2 -1
  83. data/lib/rubygems/commands/signout_command.rb +2 -2
  84. data/lib/rubygems/commands/sources_command.rb +11 -12
  85. data/lib/rubygems/commands/specification_command.rb +7 -7
  86. data/lib/rubygems/commands/uninstall_command.rb +41 -19
  87. data/lib/rubygems/commands/unpack_command.rb +16 -7
  88. data/lib/rubygems/commands/update_command.rb +28 -23
  89. data/lib/rubygems/commands/which_command.rb +4 -5
  90. data/lib/rubygems/commands/yank_command.rb +1 -2
  91. data/lib/rubygems/compatibility.rb +1 -21
  92. data/lib/rubygems/config_file.rb +36 -36
  93. data/lib/rubygems/core_ext/kernel_require.rb +6 -6
  94. data/lib/rubygems/core_ext/kernel_warn.rb +45 -0
  95. data/lib/rubygems/defaults.rb +31 -12
  96. data/lib/rubygems/dependency.rb +14 -14
  97. data/lib/rubygems/dependency_installer.rb +29 -31
  98. data/lib/rubygems/dependency_list.rb +8 -9
  99. data/lib/rubygems/deprecate.rb +2 -3
  100. data/lib/rubygems/doctor.rb +5 -6
  101. data/lib/rubygems/errors.rb +3 -3
  102. data/lib/rubygems/exceptions.rb +11 -4
  103. data/lib/rubygems/ext.rb +0 -1
  104. data/lib/rubygems/ext/build_error.rb +0 -1
  105. data/lib/rubygems/ext/builder.rb +50 -23
  106. data/lib/rubygems/ext/cmake_builder.rb +2 -2
  107. data/lib/rubygems/ext/configure_builder.rb +2 -3
  108. data/lib/rubygems/ext/ext_conf_builder.rb +8 -7
  109. data/lib/rubygems/ext/rake_builder.rb +16 -18
  110. data/lib/rubygems/gem_runner.rb +2 -2
  111. data/lib/rubygems/gemcutter_utilities.rb +40 -13
  112. data/lib/rubygems/indexer.rb +19 -12
  113. data/lib/rubygems/install_default_message.rb +0 -1
  114. data/lib/rubygems/install_message.rb +0 -1
  115. data/lib/rubygems/install_update_options.rb +2 -28
  116. data/lib/rubygems/installer.rb +95 -75
  117. data/lib/rubygems/installer_test_case.rb +0 -14
  118. data/lib/rubygems/local_remote_options.rb +5 -4
  119. data/lib/rubygems/mock_gem_ui.rb +3 -4
  120. data/lib/rubygems/name_tuple.rb +4 -4
  121. data/lib/rubygems/package.rb +90 -73
  122. data/lib/rubygems/package/digest_io.rb +3 -4
  123. data/lib/rubygems/package/file_source.rb +3 -4
  124. data/lib/rubygems/package/io_source.rb +1 -2
  125. data/lib/rubygems/package/old.rb +8 -16
  126. data/lib/rubygems/package/source.rb +0 -1
  127. data/lib/rubygems/package/tar_header.rb +2 -2
  128. data/lib/rubygems/package/tar_reader.rb +2 -4
  129. data/lib/rubygems/package/tar_reader/entry.rb +20 -4
  130. data/lib/rubygems/package/tar_test_case.rb +2 -8
  131. data/lib/rubygems/package/tar_writer.rb +13 -15
  132. data/lib/rubygems/package_task.rb +0 -1
  133. data/lib/rubygems/path_support.rb +16 -6
  134. data/lib/rubygems/platform.rb +4 -5
  135. data/lib/rubygems/psych_tree.rb +1 -1
  136. data/lib/rubygems/rdoc.rb +0 -311
  137. data/lib/rubygems/remote_fetcher.rb +34 -48
  138. data/lib/rubygems/request.rb +16 -15
  139. data/lib/rubygems/request/connection_pools.rb +24 -13
  140. data/lib/rubygems/request/http_pool.rb +3 -4
  141. data/lib/rubygems/request/https_pool.rb +1 -3
  142. data/lib/rubygems/request_set.rb +52 -25
  143. data/lib/rubygems/request_set/gem_dependency_api.rb +36 -40
  144. data/lib/rubygems/request_set/lockfile.rb +12 -12
  145. data/lib/rubygems/request_set/lockfile/parser.rb +18 -29
  146. data/lib/rubygems/request_set/lockfile/tokenizer.rb +9 -9
  147. data/lib/rubygems/requirement.rb +16 -16
  148. data/lib/rubygems/resolver.rb +10 -15
  149. data/lib/rubygems/resolver/activation_request.rb +6 -6
  150. data/lib/rubygems/resolver/api_set.rb +5 -6
  151. data/lib/rubygems/resolver/api_specification.rb +2 -3
  152. data/lib/rubygems/resolver/best_set.rb +5 -6
  153. data/lib/rubygems/resolver/composed_set.rb +5 -6
  154. data/lib/rubygems/resolver/conflict.rb +5 -5
  155. data/lib/rubygems/resolver/current_set.rb +1 -2
  156. data/lib/rubygems/resolver/dependency_request.rb +4 -4
  157. data/lib/rubygems/resolver/git_set.rb +5 -6
  158. data/lib/rubygems/resolver/git_specification.rb +4 -5
  159. data/lib/rubygems/resolver/index_set.rb +5 -6
  160. data/lib/rubygems/resolver/index_specification.rb +3 -4
  161. data/lib/rubygems/resolver/installed_specification.rb +3 -4
  162. data/lib/rubygems/resolver/installer_set.rb +12 -12
  163. data/lib/rubygems/resolver/local_specification.rb +1 -2
  164. data/lib/rubygems/resolver/lock_set.rb +5 -6
  165. data/lib/rubygems/resolver/lock_specification.rb +7 -8
  166. data/lib/rubygems/resolver/requirement_list.rb +1 -1
  167. data/lib/rubygems/resolver/set.rb +2 -2
  168. data/lib/rubygems/resolver/source_set.rb +4 -5
  169. data/lib/rubygems/resolver/spec_specification.rb +1 -2
  170. data/lib/rubygems/resolver/specification.rb +10 -7
  171. data/lib/rubygems/resolver/stats.rb +1 -1
  172. data/lib/rubygems/resolver/vendor_set.rb +4 -5
  173. data/lib/rubygems/resolver/vendor_specification.rb +2 -3
  174. data/lib/rubygems/safe_yaml.rb +18 -10
  175. data/lib/rubygems/security.rb +21 -22
  176. data/lib/rubygems/security/policies.rb +1 -2
  177. data/lib/rubygems/security/policy.rb +25 -25
  178. data/lib/rubygems/security/signer.rb +72 -24
  179. data/lib/rubygems/security/trust_dir.rb +10 -10
  180. data/lib/rubygems/server.rb +21 -21
  181. data/lib/rubygems/source.rb +16 -25
  182. data/lib/rubygems/source/git.rb +9 -10
  183. data/lib/rubygems/source/installed.rb +3 -4
  184. data/lib/rubygems/source/local.rb +7 -7
  185. data/lib/rubygems/source/lock.rb +4 -4
  186. data/lib/rubygems/source/specific_file.rb +5 -5
  187. data/lib/rubygems/source/vendor.rb +2 -3
  188. data/lib/rubygems/source_list.rb +2 -2
  189. data/lib/rubygems/source_local.rb +0 -1
  190. data/lib/rubygems/spec_fetcher.rb +5 -6
  191. data/lib/rubygems/specification.rb +199 -536
  192. data/lib/rubygems/specification_policy.rb +407 -0
  193. data/lib/rubygems/ssl_certs/{rubygems.org → index.rubygems.org}/GlobalSignRootCA.pem +0 -0
  194. data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
  195. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
  196. data/lib/rubygems/stub_specification.rb +11 -15
  197. data/lib/rubygems/test_case.rb +141 -66
  198. data/lib/rubygems/test_utilities.rb +20 -35
  199. data/lib/rubygems/text.rb +6 -6
  200. data/lib/rubygems/uninstaller.rb +37 -26
  201. data/lib/rubygems/uri_formatter.rb +1 -2
  202. data/lib/rubygems/user_interaction.rb +38 -93
  203. data/lib/rubygems/util.rb +20 -14
  204. data/lib/rubygems/util/licenses.rb +27 -1
  205. data/lib/rubygems/util/list.rb +1 -1
  206. data/lib/rubygems/validator.rb +4 -5
  207. data/lib/rubygems/version.rb +15 -15
  208. data/lib/rubygems/version_option.rb +2 -3
  209. data/rubygems-update.gemspec +43 -0
  210. data/setup.rb +2 -8
  211. data/test/rubygems/rubygems_plugin.rb +0 -1
  212. data/test/rubygems/simple_gem.rb +1 -1
  213. data/test/rubygems/test_bundled_ca.rb +4 -7
  214. data/test/rubygems/test_config.rb +7 -2
  215. data/test/rubygems/test_gem.rb +161 -130
  216. data/test/rubygems/test_gem_command.rb +0 -1
  217. data/test/rubygems/test_gem_command_manager.rb +8 -3
  218. data/test/rubygems/test_gem_commands_build_command.rb +219 -15
  219. data/test/rubygems/test_gem_commands_cert_command.rb +69 -8
  220. data/test/rubygems/test_gem_commands_check_command.rb +1 -1
  221. data/test/rubygems/test_gem_commands_cleanup_command.rb +27 -1
  222. data/test/rubygems/test_gem_commands_contents_command.rb +1 -2
  223. data/test/rubygems/test_gem_commands_dependency_command.rb +33 -34
  224. data/test/rubygems/test_gem_commands_environment_command.rb +1 -0
  225. data/test/rubygems/test_gem_commands_fetch_command.rb +0 -1
  226. data/test/rubygems/test_gem_commands_generate_index_command.rb +0 -1
  227. data/test/rubygems/test_gem_commands_help_command.rb +7 -4
  228. data/test/rubygems/test_gem_commands_info_command.rb +44 -0
  229. data/test/rubygems/test_gem_commands_install_command.rb +79 -12
  230. data/test/rubygems/test_gem_commands_lock_command.rb +0 -1
  231. data/test/rubygems/test_gem_commands_open_command.rb +29 -0
  232. data/test/rubygems/test_gem_commands_outdated_command.rb +0 -1
  233. data/test/rubygems/test_gem_commands_owner_command.rb +93 -57
  234. data/test/rubygems/test_gem_commands_pristine_command.rb +65 -30
  235. data/test/rubygems/test_gem_commands_push_command.rb +39 -0
  236. data/test/rubygems/test_gem_commands_query_command.rb +102 -100
  237. data/test/rubygems/test_gem_commands_search_command.rb +0 -1
  238. data/test/rubygems/test_gem_commands_server_command.rb +0 -1
  239. data/test/rubygems/test_gem_commands_setup_command.rb +39 -8
  240. data/test/rubygems/test_gem_commands_signin_command.rb +1 -1
  241. data/test/rubygems/test_gem_commands_sources_command.rb +0 -1
  242. data/test/rubygems/test_gem_commands_specification_command.rb +2 -3
  243. data/test/rubygems/test_gem_commands_stale_command.rb +3 -2
  244. data/test/rubygems/test_gem_commands_uninstall_command.rb +81 -7
  245. data/test/rubygems/test_gem_commands_unpack_command.rb +17 -1
  246. data/test/rubygems/test_gem_commands_update_command.rb +19 -2
  247. data/test/rubygems/test_gem_commands_which_command.rb +0 -1
  248. data/test/rubygems/test_gem_commands_yank_command.rb +0 -1
  249. data/test/rubygems/test_gem_config_file.rb +4 -2
  250. data/test/rubygems/test_gem_dependency.rb +0 -1
  251. data/test/rubygems/test_gem_dependency_installer.rb +8 -5
  252. data/test/rubygems/test_gem_dependency_list.rb +6 -7
  253. data/test/rubygems/test_gem_dependency_resolution_error.rb +0 -1
  254. data/test/rubygems/test_gem_doctor.rb +1 -2
  255. data/test/rubygems/test_gem_ext_builder.rb +10 -23
  256. data/test/rubygems/test_gem_ext_cmake_builder.rb +5 -4
  257. data/test/rubygems/test_gem_ext_configure_builder.rb +3 -3
  258. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +8 -9
  259. data/test/rubygems/test_gem_ext_rake_builder.rb +20 -5
  260. data/test/rubygems/test_gem_gem_runner.rb +0 -1
  261. data/test/rubygems/test_gem_gemcutter_utilities.rb +32 -6
  262. data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -1
  263. data/test/rubygems/test_gem_indexer.rb +1 -2
  264. data/test/rubygems/test_gem_install_update_options.rb +1 -20
  265. data/test/rubygems/test_gem_installer.rb +69 -203
  266. data/test/rubygems/test_gem_local_remote_options.rb +3 -3
  267. data/test/rubygems/test_gem_name_tuple.rb +0 -1
  268. data/test/rubygems/test_gem_package.rb +59 -50
  269. data/test/rubygems/test_gem_package_old.rb +0 -1
  270. data/test/rubygems/test_gem_package_tar_header.rb +1 -2
  271. data/test/rubygems/test_gem_package_tar_reader.rb +0 -1
  272. data/test/rubygems/test_gem_package_tar_reader_entry.rb +11 -0
  273. data/test/rubygems/test_gem_package_tar_writer.rb +40 -7
  274. data/test/rubygems/test_gem_package_task.rb +2 -2
  275. data/test/rubygems/test_gem_path_support.rb +28 -11
  276. data/test/rubygems/test_gem_platform.rb +4 -5
  277. data/test/rubygems/test_gem_rdoc.rb +1 -2
  278. data/test/rubygems/test_gem_remote_fetcher.rb +111 -130
  279. data/test/rubygems/test_gem_request.rb +5 -5
  280. data/test/rubygems/test_gem_request_connection_pools.rb +24 -3
  281. data/test/rubygems/test_gem_request_set.rb +5 -5
  282. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +2 -7
  283. data/test/rubygems/test_gem_request_set_lockfile.rb +1 -2
  284. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +4 -9
  285. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +1 -1
  286. data/test/rubygems/test_gem_requirement.rb +18 -4
  287. data/test/rubygems/test_gem_resolver.rb +13 -17
  288. data/test/rubygems/test_gem_resolver_activation_request.rb +0 -1
  289. data/test/rubygems/test_gem_resolver_api_set.rb +0 -1
  290. data/test/rubygems/test_gem_resolver_api_specification.rb +0 -1
  291. data/test/rubygems/test_gem_resolver_best_set.rb +0 -1
  292. data/test/rubygems/test_gem_resolver_composed_set.rb +0 -1
  293. data/test/rubygems/test_gem_resolver_conflict.rb +0 -1
  294. data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -1
  295. data/test/rubygems/test_gem_resolver_git_set.rb +0 -1
  296. data/test/rubygems/test_gem_resolver_git_specification.rb +0 -1
  297. data/test/rubygems/test_gem_resolver_index_set.rb +0 -1
  298. data/test/rubygems/test_gem_resolver_index_specification.rb +0 -1
  299. data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -1
  300. data/test/rubygems/test_gem_resolver_installer_set.rb +2 -3
  301. data/test/rubygems/test_gem_resolver_local_specification.rb +0 -1
  302. data/test/rubygems/test_gem_resolver_lock_set.rb +0 -1
  303. data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -1
  304. data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -1
  305. data/test/rubygems/test_gem_resolver_specification.rb +1 -2
  306. data/test/rubygems/test_gem_resolver_vendor_set.rb +0 -1
  307. data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -1
  308. data/test/rubygems/test_gem_security.rb +1 -3
  309. data/test/rubygems/test_gem_security_policy.rb +4 -5
  310. data/test/rubygems/test_gem_security_signer.rb +4 -3
  311. data/test/rubygems/test_gem_security_trust_dir.rb +1 -2
  312. data/test/rubygems/test_gem_server.rb +4 -4
  313. data/test/rubygems/test_gem_source.rb +0 -13
  314. data/test/rubygems/test_gem_source_fetch_problem.rb +0 -1
  315. data/test/rubygems/test_gem_source_git.rb +0 -1
  316. data/test/rubygems/test_gem_source_installed.rb +0 -1
  317. data/test/rubygems/test_gem_source_lock.rb +0 -1
  318. data/test/rubygems/test_gem_source_vendor.rb +0 -1
  319. data/test/rubygems/test_gem_spec_fetcher.rb +0 -1
  320. data/test/rubygems/test_gem_specification.rb +334 -198
  321. data/test/rubygems/test_gem_stream_ui.rb +13 -30
  322. data/test/rubygems/test_gem_stub_specification.rb +0 -2
  323. data/test/rubygems/test_gem_text.rb +4 -5
  324. data/test/rubygems/test_gem_uninstaller.rb +21 -1
  325. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -1
  326. data/test/rubygems/test_gem_uri_formatter.rb +0 -1
  327. data/test/rubygems/test_gem_util.rb +6 -11
  328. data/test/rubygems/test_gem_validator.rb +0 -1
  329. data/test/rubygems/test_gem_version.rb +11 -11
  330. data/test/rubygems/test_gem_version_option.rb +0 -1
  331. data/test/rubygems/test_remote_fetch_error.rb +0 -1
  332. data/test/rubygems/test_require.rb +67 -52
  333. data/util/CL2notes +1 -2
  334. data/util/ci +15 -12
  335. data/util/create_certs.rb +6 -7
  336. data/util/create_encrypted_key.rb +0 -1
  337. data/util/patch_with_prs.rb +1 -1
  338. data/util/rubocop +8 -0
  339. data/util/update_bundled_ca_certificates.rb +15 -14
  340. data/util/update_changelog.rb +1 -1
  341. metadata +67 -59
  342. data/.autotest +0 -71
  343. data/.document +0 -5
  344. data/CONTRIBUTING.rdoc +0 -130
  345. data/CVE-2013-4287.txt +0 -35
  346. data/CVE-2013-4363.txt +0 -45
  347. data/CVE-2015-3900.txt +0 -40
  348. data/POLICIES.rdoc +0 -74
  349. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +0 -21
  350. data/test/rubygems/fix_openssl_warnings.rb +0 -13
@@ -66,4 +66,3 @@ gem 'd', '= 1'
66
66
  end
67
67
 
68
68
  end
69
-
@@ -68,4 +68,33 @@ class TestGemCommandsOpenCommand < Gem::TestCase
68
68
  assert_equal "", @ui.error
69
69
  end
70
70
 
71
+ def test_default_gem
72
+ @cmd.options[:version] = "1.0"
73
+ @cmd.options[:args] = %w[foo]
74
+
75
+ version = @cmd.options[:version]
76
+ @cmd.define_singleton_method(:spec_for) do |name|
77
+ spec = Gem::Specification.find_all_by_name(name, version).first
78
+
79
+ spec.define_singleton_method(:default_gem?) do
80
+ true
81
+ end
82
+
83
+ return spec if spec
84
+
85
+ say "Unable to find gem '#{name}'"
86
+ end
87
+
88
+ gem("foo", "1.0")
89
+
90
+ assert_raises Gem::MockGemUi::TermError do
91
+ use_ui @ui do
92
+ @cmd.execute
93
+ end
94
+ end
95
+
96
+ assert_match %r|'foo' is a default gem and can't be opened\.| , @ui.output
97
+ assert_equal "", @ui.error
98
+ end
99
+
71
100
  end
@@ -30,4 +30,3 @@ class TestGemCommandsOutdatedCommand < Gem::TestCase
30
30
  assert_equal "", @ui.error
31
31
  end
32
32
  end
33
-
@@ -8,8 +8,10 @@ class TestGemCommandsOwnerCommand < Gem::TestCase
8
8
  super
9
9
 
10
10
  ENV["RUBYGEMS_HOST"] = nil
11
- @fetcher = Gem::FakeFetcher.new
12
- Gem::RemoteFetcher.fetcher = @fetcher
11
+ @stub_ui = Gem::MockGemUi.new
12
+ @stub_fetcher = Gem::FakeFetcher.new
13
+ Gem::RemoteFetcher.fetcher = @stub_fetcher
14
+ Gem.configuration = nil
13
15
  Gem.configuration.rubygems_api_key = "ed244fbf2b1a52e012da8616c512fa47f9aa5250"
14
16
 
15
17
  @cmd = Gem::Commands::OwnerCommand.new
@@ -27,20 +29,20 @@ class TestGemCommandsOwnerCommand < Gem::TestCase
27
29
  - id: 4
28
30
  EOF
29
31
 
30
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
32
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
31
33
 
32
- use_ui @ui do
34
+ use_ui @stub_ui do
33
35
  @cmd.show_owners("freewill")
34
36
  end
35
37
 
36
- assert_equal Net::HTTP::Get, @fetcher.last_request.class
37
- assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
38
+ assert_equal Net::HTTP::Get, @stub_fetcher.last_request.class
39
+ assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"]
38
40
 
39
- assert_match %r{Owners for gem: freewill}, @ui.output
40
- assert_match %r{- user1@example.com}, @ui.output
41
- assert_match %r{- user2@example.com}, @ui.output
42
- assert_match %r{- user3}, @ui.output
43
- assert_match %r{- 4}, @ui.output
41
+ assert_match %r{Owners for gem: freewill}, @stub_ui.output
42
+ assert_match %r{- user1@example.com}, @stub_ui.output
43
+ assert_match %r{- user2@example.com}, @stub_ui.output
44
+ assert_match %r{- user3}, @stub_ui.output
45
+ assert_match %r{- 4}, @stub_ui.output
44
46
  end
45
47
 
46
48
  def test_show_owners_dont_load_objects
@@ -57,14 +59,13 @@ EOF
57
59
  - id: 4
58
60
  EOF
59
61
 
60
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
62
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
61
63
 
62
64
  assert_raises Psych::DisallowedClass do
63
65
  use_ui @ui do
64
66
  @cmd.show_owners("freewill")
65
67
  end
66
68
  end
67
-
68
69
  end
69
70
 
70
71
 
@@ -73,14 +74,14 @@ EOF
73
74
  host = "http://rubygems.example"
74
75
  ENV["RUBYGEMS_HOST"] = host
75
76
 
76
- @fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
77
+ @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
77
78
 
78
- use_ui @ui do
79
+ use_ui @stub_ui do
79
80
  @cmd.show_owners("freewill")
80
81
  end
81
82
 
82
- assert_match %r{Owners for gem: freewill}, @ui.output
83
- assert_match %r{- user1@example.com}, @ui.output
83
+ assert_match %r{Owners for gem: freewill}, @stub_ui.output
84
+ assert_match %r{- user1@example.com}, @stub_ui.output
84
85
  end
85
86
 
86
87
  def test_show_owners_setting_up_host
@@ -88,32 +89,32 @@ EOF
88
89
  host = "http://rubygems.example"
89
90
  @cmd.host = host
90
91
 
91
- @fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
92
+ @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
92
93
 
93
- use_ui @ui do
94
+ use_ui @stub_ui do
94
95
  @cmd.show_owners("freewill")
95
96
  end
96
97
 
97
- assert_match %r{Owners for gem: freewill}, @ui.output
98
- assert_match %r{- user1@example.com}, @ui.output
98
+ assert_match %r{Owners for gem: freewill}, @stub_ui.output
99
+ assert_match %r{- user1@example.com}, @stub_ui.output
99
100
  end
100
101
 
101
102
  def test_show_owners_denied
102
103
  response = "You don't have permission to push to this gem"
103
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden']
104
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden']
104
105
 
105
106
  assert_raises Gem::MockGemUi::TermError do
106
- use_ui @ui do
107
+ use_ui @stub_ui do
107
108
  @cmd.show_owners("freewill")
108
109
  end
109
110
  end
110
111
 
111
- assert_match response, @ui.output
112
+ assert_match response, @stub_ui.output
112
113
  end
113
114
 
114
115
  def test_show_owners_key
115
116
  response = "- email: user1@example.com\n"
116
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
117
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
117
118
  File.open Gem.configuration.credentials_path, 'a' do |f|
118
119
  f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
119
120
  end
@@ -122,56 +123,56 @@ EOF
122
123
  @cmd.handle_options %w(-k other)
123
124
  @cmd.show_owners('freewill')
124
125
 
125
- assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
126
+ assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization']
126
127
  end
127
128
 
128
129
  def test_add_owners
129
130
  response = "Owner added successfully."
130
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
131
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
131
132
 
132
- use_ui @ui do
133
+ use_ui @stub_ui do
133
134
  @cmd.add_owners("freewill", ["user-new1@example.com"])
134
135
  end
135
136
 
136
- assert_equal Net::HTTP::Post, @fetcher.last_request.class
137
- assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
138
- assert_equal "email=user-new1%40example.com", @fetcher.last_request.body
137
+ assert_equal Net::HTTP::Post, @stub_fetcher.last_request.class
138
+ assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"]
139
+ assert_equal "email=user-new1%40example.com", @stub_fetcher.last_request.body
139
140
 
140
- assert_match response, @ui.output
141
+ assert_match response, @stub_ui.output
141
142
  end
142
143
 
143
144
  def test_add_owners_denied
144
145
  response = "You don't have permission to push to this gem"
145
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
146
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
146
147
 
147
- use_ui @ui do
148
+ use_ui @stub_ui do
148
149
  @cmd.add_owners("freewill", ["user-new1@example.com"])
149
150
  end
150
151
 
151
- assert_match response, @ui.output
152
+ assert_match response, @stub_ui.output
152
153
  end
153
154
 
154
155
  def test_add_owner_with_host_option_through_execute
155
156
  host = "http://rubygems.example"
156
157
  add_owner_response = "Owner added successfully."
157
158
  show_owners_response = "- email: user1@example.com\n"
158
- @fetcher.data["#{host}/api/v1/gems/freewill/owners"] = [add_owner_response, 200, 'OK']
159
- @fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [show_owners_response, 200, 'OK']
159
+ @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners"] = [add_owner_response, 200, 'OK']
160
+ @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [show_owners_response, 200, 'OK']
160
161
 
161
162
  @cmd.handle_options %W[--host #{host} --add user-new1@example.com freewill]
162
163
 
163
- use_ui @ui do
164
+ use_ui @stub_ui do
164
165
  @cmd.execute
165
166
  end
166
167
 
167
- assert_match add_owner_response, @ui.output
168
- assert_match %r{Owners for gem: freewill}, @ui.output
169
- assert_match %r{- user1@example.com}, @ui.output
168
+ assert_match add_owner_response, @stub_ui.output
169
+ assert_match %r{Owners for gem: freewill}, @stub_ui.output
170
+ assert_match %r{- user1@example.com}, @stub_ui.output
170
171
  end
171
172
 
172
173
  def test_add_owners_key
173
174
  response = "Owner added successfully."
174
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
175
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
175
176
  File.open Gem.configuration.credentials_path, 'a' do |f|
176
177
  f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
177
178
  end
@@ -180,38 +181,38 @@ EOF
180
181
  @cmd.handle_options %w(-k other)
181
182
  @cmd.add_owners('freewill', ['user-new1@example.com'])
182
183
 
183
- assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
184
+ assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization']
184
185
  end
185
186
 
186
187
  def test_remove_owners
187
188
  response = "Owner removed successfully."
188
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
189
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
189
190
 
190
- use_ui @ui do
191
+ use_ui @stub_ui do
191
192
  @cmd.remove_owners("freewill", ["user-remove1@example.com"])
192
193
  end
193
194
 
194
- assert_equal Net::HTTP::Delete, @fetcher.last_request.class
195
- assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
196
- assert_equal "email=user-remove1%40example.com", @fetcher.last_request.body
195
+ assert_equal Net::HTTP::Delete, @stub_fetcher.last_request.class
196
+ assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"]
197
+ assert_equal "email=user-remove1%40example.com", @stub_fetcher.last_request.body
197
198
 
198
- assert_match response, @ui.output
199
+ assert_match response, @stub_ui.output
199
200
  end
200
201
 
201
202
  def test_remove_owners_denied
202
203
  response = "You don't have permission to push to this gem"
203
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
204
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
204
205
 
205
- use_ui @ui do
206
+ use_ui @stub_ui do
206
207
  @cmd.remove_owners("freewill", ["user-remove1@example.com"])
207
208
  end
208
209
 
209
- assert_match response, @ui.output
210
+ assert_match response, @stub_ui.output
210
211
  end
211
212
 
212
213
  def test_remove_owners_key
213
214
  response = "Owner removed successfully."
214
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
215
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
215
216
  File.open Gem.configuration.credentials_path, 'a' do |f|
216
217
  f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
217
218
  end
@@ -220,18 +221,53 @@ EOF
220
221
  @cmd.handle_options %w(-k other)
221
222
  @cmd.remove_owners('freewill', ['user-remove1@example.com'])
222
223
 
223
- assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
224
+ assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization']
224
225
  end
225
226
 
226
227
  def test_remove_owners_missing
227
228
  response = 'Owner could not be found.'
228
- @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 404, 'Not Found']
229
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 404, 'Not Found']
229
230
 
230
- use_ui @ui do
231
+ use_ui @stub_ui do
231
232
  @cmd.remove_owners("freewill", ["missing@example"])
232
233
  end
233
234
 
234
- assert_equal "Removing missing@example: #{response}\n", @ui.output
235
+ assert_equal "Removing missing@example: #{response}\n", @stub_ui.output
236
+ end
237
+
238
+ def test_otp_verified_success
239
+ response_fail = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
240
+ response_success = "Owner added successfully."
241
+
242
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = proc do
243
+ @call_count ||= 0
244
+ (@call_count += 1).odd? ? [response_fail, 401, 'Unauthorized'] : [response_success, 200, 'OK']
245
+ end
246
+
247
+ @otp_ui = Gem::MockGemUi.new "111111\n"
248
+ use_ui @otp_ui do
249
+ @cmd.add_owners("freewill", ["user-new1@example.com"])
250
+ end
251
+
252
+ assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output
253
+ assert_match 'Code: ', @otp_ui.output
254
+ assert_match response_success, @otp_ui.output
255
+ assert_equal '111111', @stub_fetcher.last_request['OTP']
256
+ end
257
+
258
+ def test_otp_verified_failure
259
+ response = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
260
+ @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 401, 'Unauthorized']
261
+
262
+ @otp_ui = Gem::MockGemUi.new "111111\n"
263
+ use_ui @otp_ui do
264
+ @cmd.add_owners("freewill", ["user-new1@example.com"])
265
+ end
266
+
267
+ assert_match response, @otp_ui.output
268
+ assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output
269
+ assert_match 'Code: ', @otp_ui.output
270
+ assert_equal '111111', @stub_fetcher.last_request['OTP']
235
271
  end
236
272
 
237
273
  end
@@ -253,6 +253,31 @@ class TestGemCommandsPristineCommand < Gem::TestCase
253
253
  assert_empty out, out.inspect
254
254
  end
255
255
 
256
+ def test_skip_many_gems
257
+ a = util_spec 'a'
258
+ b = util_spec 'b'
259
+ c = util_spec 'c'
260
+
261
+ install_gem a
262
+ install_gem b
263
+ install_gem c
264
+
265
+ @cmd.options[:args] = %w[a b c]
266
+ @cmd.options[:skip] = ['a', 'c']
267
+
268
+ use_ui @ui do
269
+ @cmd.execute
270
+ end
271
+
272
+ out = @ui.output.split "\n"
273
+
274
+ assert_equal "Restoring gems to pristine condition...", out.shift
275
+ assert_equal "Skipped #{a.full_name}, it was given through options", out.shift
276
+ assert_equal "Restored #{b.full_name}", out.shift
277
+ assert_equal "Skipped #{c.full_name}, it was given through options", out.shift
278
+ assert_empty out, out.inspect
279
+ end
280
+
256
281
  def test_execute_many_multi_repo
257
282
  a = util_spec 'a'
258
283
  install_gem a
@@ -408,6 +433,39 @@ class TestGemCommandsPristineCommand < Gem::TestCase
408
433
  refute File.exist? gem_lib
409
434
  end
410
435
 
436
+ def test_execute_bindir
437
+ a = util_spec 'a' do |s|
438
+ s.name = "test_gem"
439
+ s.executables = %w[foo]
440
+ s.files = %w[bin/foo]
441
+ end
442
+
443
+ write_file File.join(@tempdir, 'bin', 'foo') do |fp|
444
+ fp.puts "#!/usr/bin/ruby"
445
+ end
446
+
447
+ write_file File.join(@tempdir, 'test_bin', 'foo') do |fp|
448
+ fp.puts "#!/usr/bin/ruby"
449
+ end
450
+
451
+ install_gem a
452
+
453
+ gem_exec = File.join @gemhome, 'bin', 'foo'
454
+ gem_bindir = File.join @tempdir, 'test_bin', 'foo'
455
+
456
+ FileUtils.rm gem_exec
457
+ FileUtils.rm gem_bindir
458
+
459
+ @cmd.handle_options ["--all", "--only-executables", "--bindir", "#{gem_bindir}"]
460
+
461
+ use_ui @ui do
462
+ @cmd.execute
463
+ end
464
+
465
+ refute File.exist? gem_exec
466
+ assert File.exist? gem_bindir
467
+ end
468
+
411
469
  def test_execute_unknown_gem_at_remote_source
412
470
  install_specs util_spec 'a'
413
471
 
@@ -437,38 +495,16 @@ class TestGemCommandsPristineCommand < Gem::TestCase
437
495
  @cmd.execute
438
496
  end
439
497
 
440
- assert_equal([
441
- "Restoring gems to pristine condition...",
442
- "Skipped default-2.0.0.0, it is a default gem",
443
- ],
444
- @ui.output.split("\n"))
498
+ assert_equal(
499
+ [
500
+ "Restoring gems to pristine condition...",
501
+ "Skipped default-2.0.0.0, it is a default gem",
502
+ ],
503
+ @ui.output.split("\n")
504
+ )
445
505
  assert_empty(@ui.error)
446
506
  end
447
507
 
448
- def test_execute_bundled_gem_on_old_rubies
449
- util_set_RUBY_VERSION '1.9.3', 551
450
-
451
- spec = util_spec 'bigdecimal', '1.1.0' do |s|
452
- s.summary = "This bigdecimal is bundled with Ruby"
453
- end
454
- install_specs spec
455
-
456
- @cmd.options[:args] = %w[bigdecimal]
457
-
458
- use_ui @ui do
459
- @cmd.execute
460
- end
461
-
462
- assert_equal([
463
- "Restoring gems to pristine condition...",
464
- "Skipped bigdecimal-1.1.0, it is bundled with old Ruby"
465
- ], @ui.output.split("\n"))
466
-
467
- assert_empty @ui.error
468
- ensure
469
- util_restore_RUBY_VERSION
470
- end
471
-
472
508
  def test_handle_options
473
509
  @cmd.handle_options %w[]
474
510
 
@@ -488,4 +524,3 @@ class TestGemCommandsPristineCommand < Gem::TestCase
488
524
  end
489
525
 
490
526
  end
491
-