rubygems-update 3.4.22 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (528) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +99 -2
  3. data/Manifest.txt +34 -221
  4. data/README.md +1 -3
  5. data/bundler/CHANGELOG.md +53 -0
  6. data/bundler/bundler.gemspec +4 -2
  7. data/bundler/exe/bundle +1 -10
  8. data/bundler/lib/bundler/build_metadata.rb +3 -3
  9. data/bundler/lib/bundler/capistrano.rb +1 -1
  10. data/bundler/lib/bundler/checksum.rb +245 -0
  11. data/bundler/lib/bundler/ci_detector.rb +75 -0
  12. data/bundler/lib/bundler/cli/add.rb +3 -3
  13. data/bundler/lib/bundler/cli/binstubs.rb +4 -4
  14. data/bundler/lib/bundler/cli/cache.rb +1 -1
  15. data/bundler/lib/bundler/cli/check.rb +1 -1
  16. data/bundler/lib/bundler/cli/common.rb +9 -1
  17. data/bundler/lib/bundler/cli/config.rb +8 -7
  18. data/bundler/lib/bundler/cli/console.rb +3 -2
  19. data/bundler/lib/bundler/cli/doctor.rb +2 -2
  20. data/bundler/lib/bundler/cli/exec.rb +1 -1
  21. data/bundler/lib/bundler/cli/gem.rb +28 -23
  22. data/bundler/lib/bundler/cli/info.rb +2 -13
  23. data/bundler/lib/bundler/cli/install.rb +5 -4
  24. data/bundler/lib/bundler/cli/issue.rb +1 -1
  25. data/bundler/lib/bundler/cli/lock.rb +4 -4
  26. data/bundler/lib/bundler/cli/open.rb +1 -1
  27. data/bundler/lib/bundler/cli/outdated.rb +6 -6
  28. data/bundler/lib/bundler/cli/plugin.rb +7 -14
  29. data/bundler/lib/bundler/cli/pristine.rb +38 -30
  30. data/bundler/lib/bundler/cli/show.rb +2 -2
  31. data/bundler/lib/bundler/cli/update.rb +5 -5
  32. data/bundler/lib/bundler/cli.rb +215 -263
  33. data/bundler/lib/bundler/compact_index_client/cache.rb +29 -9
  34. data/bundler/lib/bundler/compact_index_client/cache_file.rb +153 -0
  35. data/bundler/lib/bundler/compact_index_client/gem_parser.rb +7 -3
  36. data/bundler/lib/bundler/compact_index_client/updater.rb +79 -81
  37. data/bundler/lib/bundler/compact_index_client.rb +14 -7
  38. data/bundler/lib/bundler/constants.rb +1 -1
  39. data/bundler/lib/bundler/current_ruby.rb +5 -21
  40. data/bundler/lib/bundler/definition.rb +42 -15
  41. data/bundler/lib/bundler/dependency.rb +16 -12
  42. data/bundler/lib/bundler/digest.rb +2 -2
  43. data/bundler/lib/bundler/dsl.rb +43 -25
  44. data/bundler/lib/bundler/endpoint_specification.rb +5 -1
  45. data/bundler/lib/bundler/env.rb +1 -3
  46. data/bundler/lib/bundler/errors.rb +43 -0
  47. data/bundler/lib/bundler/fetcher/base.rb +3 -1
  48. data/bundler/lib/bundler/fetcher/compact_index.rb +4 -4
  49. data/bundler/lib/bundler/fetcher/downloader.rb +13 -11
  50. data/bundler/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
  51. data/bundler/lib/bundler/fetcher/index.rb +1 -1
  52. data/bundler/lib/bundler/fetcher.rb +28 -25
  53. data/bundler/lib/bundler/friendly_errors.rb +5 -5
  54. data/bundler/lib/bundler/gem_helper.rb +1 -1
  55. data/bundler/lib/bundler/gem_helpers.rb +5 -2
  56. data/bundler/lib/bundler/graph.rb +9 -9
  57. data/bundler/lib/bundler/index.rb +1 -2
  58. data/bundler/lib/bundler/injector.rb +1 -1
  59. data/bundler/lib/bundler/inline.rb +3 -3
  60. data/bundler/lib/bundler/installer/gem_installer.rb +5 -5
  61. data/bundler/lib/bundler/installer/parallel_installer.rb +16 -8
  62. data/bundler/lib/bundler/installer/standalone.rb +2 -3
  63. data/bundler/lib/bundler/installer.rb +9 -9
  64. data/bundler/lib/bundler/lazy_specification.rb +24 -17
  65. data/bundler/lib/bundler/lockfile_generator.rb +9 -0
  66. data/bundler/lib/bundler/lockfile_parser.rb +81 -10
  67. data/bundler/lib/bundler/man/bundle-add.1 +3 -26
  68. data/bundler/lib/bundler/man/bundle-binstubs.1 +4 -16
  69. data/bundler/lib/bundler/man/bundle-cache.1 +3 -24
  70. data/bundler/lib/bundler/man/bundle-check.1 +3 -12
  71. data/bundler/lib/bundler/man/bundle-clean.1 +3 -10
  72. data/bundler/lib/bundler/man/bundle-config.1 +20 -211
  73. data/bundler/lib/bundler/man/bundle-config.1.ronn +6 -0
  74. data/bundler/lib/bundler/man/bundle-console.1 +4 -22
  75. data/bundler/lib/bundler/man/bundle-doctor.1 +4 -18
  76. data/bundler/lib/bundler/man/bundle-exec.1 +12 -73
  77. data/bundler/lib/bundler/man/bundle-gem.1 +13 -49
  78. data/bundler/lib/bundler/man/bundle-help.1 +3 -7
  79. data/bundler/lib/bundler/man/bundle-info.1 +3 -9
  80. data/bundler/lib/bundler/man/bundle-init.1 +3 -12
  81. data/bundler/lib/bundler/man/bundle-inject.1 +6 -19
  82. data/bundler/lib/bundler/man/bundle-install.1 +27 -125
  83. data/bundler/lib/bundler/man/bundle-install.1.ronn +1 -0
  84. data/bundler/lib/bundler/man/bundle-list.1 +4 -19
  85. data/bundler/lib/bundler/man/bundle-lock.1 +5 -29
  86. data/bundler/lib/bundler/man/bundle-open.1 +7 -27
  87. data/bundler/lib/bundler/man/bundle-outdated.1 +3 -55
  88. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +1 -0
  89. data/bundler/lib/bundler/man/bundle-platform.1 +5 -27
  90. data/bundler/lib/bundler/man/bundle-plugin.1 +3 -29
  91. data/bundler/lib/bundler/man/bundle-pristine.1 +5 -16
  92. data/bundler/lib/bundler/man/bundle-remove.1 +4 -14
  93. data/bundler/lib/bundler/man/bundle-show.1 +3 -10
  94. data/bundler/lib/bundler/man/bundle-update.1 +18 -137
  95. data/bundler/lib/bundler/man/bundle-version.1 +3 -16
  96. data/bundler/lib/bundler/man/bundle-viz.1 +4 -16
  97. data/bundler/lib/bundler/man/bundle.1 +5 -44
  98. data/bundler/lib/bundler/man/gemfile.5 +24 -301
  99. data/bundler/lib/bundler/man/gemfile.5.ronn +4 -0
  100. data/bundler/lib/bundler/match_metadata.rb +4 -0
  101. data/bundler/lib/bundler/match_platform.rb +1 -1
  102. data/bundler/lib/bundler/plugin/api/source.rb +3 -2
  103. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  104. data/bundler/lib/bundler/plugin.rb +3 -3
  105. data/bundler/lib/bundler/resolver/base.rb +1 -1
  106. data/bundler/lib/bundler/resolver/incompatibility.rb +1 -1
  107. data/bundler/lib/bundler/resolver/spec_group.rb +1 -4
  108. data/bundler/lib/bundler/resolver.rb +16 -16
  109. data/bundler/lib/bundler/ruby_dsl.rb +20 -12
  110. data/bundler/lib/bundler/ruby_version.rb +1 -1
  111. data/bundler/lib/bundler/rubygems_ext.rb +24 -50
  112. data/bundler/lib/bundler/rubygems_gem_installer.rb +6 -56
  113. data/bundler/lib/bundler/rubygems_integration.rb +25 -94
  114. data/bundler/lib/bundler/runtime.rb +2 -2
  115. data/bundler/lib/bundler/self_manager.rb +23 -7
  116. data/bundler/lib/bundler/settings.rb +27 -7
  117. data/bundler/lib/bundler/setup.rb +4 -1
  118. data/bundler/lib/bundler/shared_helpers.rb +35 -13
  119. data/bundler/lib/bundler/source/git/git_proxy.rb +15 -15
  120. data/bundler/lib/bundler/source/git.rb +4 -3
  121. data/bundler/lib/bundler/source/metadata.rb +15 -15
  122. data/bundler/lib/bundler/source/path.rb +7 -6
  123. data/bundler/lib/bundler/source/rubygems.rb +21 -14
  124. data/bundler/lib/bundler/source.rb +2 -0
  125. data/bundler/lib/bundler/spec_set.rb +38 -10
  126. data/bundler/lib/bundler/stub_specification.rb +1 -0
  127. data/bundler/lib/bundler/templates/Executable.bundler +1 -1
  128. data/bundler/lib/bundler/templates/newgem/README.md.tt +3 -3
  129. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +2 -6
  130. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  131. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +1 -1
  132. data/bundler/lib/bundler/ui/shell.rb +1 -1
  133. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  134. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +53 -6
  135. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +8 -20
  136. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +3 -3
  137. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +2 -2
  138. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
  139. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +35 -35
  140. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +3 -0
  141. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +256 -132
  142. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1 -0
  143. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +95 -31
  144. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  145. data/bundler/lib/bundler/vendored_net_http.rb +8 -0
  146. data/bundler/lib/bundler/vendored_persistent.rb +0 -4
  147. data/bundler/lib/bundler/vendored_timeout.rb +8 -0
  148. data/bundler/lib/bundler/version.rb +1 -1
  149. data/bundler/lib/bundler/vlad.rb +1 -1
  150. data/bundler/lib/bundler/yaml_serializer.rb +3 -3
  151. data/bundler/lib/bundler.rb +38 -27
  152. data/lib/rubygems/available_set.rb +4 -4
  153. data/lib/rubygems/basic_specification.rb +35 -37
  154. data/lib/rubygems/bundler_version_finder.rb +4 -4
  155. data/lib/rubygems/ci_detector.rb +75 -0
  156. data/lib/rubygems/command.rb +13 -15
  157. data/lib/rubygems/command_manager.rb +5 -4
  158. data/lib/rubygems/commands/build_command.rb +2 -2
  159. data/lib/rubygems/commands/cert_command.rb +1 -2
  160. data/lib/rubygems/commands/check_command.rb +4 -4
  161. data/lib/rubygems/commands/cleanup_command.rb +12 -14
  162. data/lib/rubygems/commands/contents_command.rb +4 -4
  163. data/lib/rubygems/commands/dependency_command.rb +4 -5
  164. data/lib/rubygems/commands/environment_command.rb +1 -3
  165. data/lib/rubygems/commands/exec_command.rb +1 -1
  166. data/lib/rubygems/commands/fetch_command.rb +2 -2
  167. data/lib/rubygems/commands/generate_index_command.rb +39 -74
  168. data/lib/rubygems/commands/help_command.rb +3 -3
  169. data/lib/rubygems/commands/info_command.rb +2 -2
  170. data/lib/rubygems/commands/install_command.rb +8 -16
  171. data/lib/rubygems/commands/list_command.rb +2 -2
  172. data/lib/rubygems/commands/lock_command.rb +1 -1
  173. data/lib/rubygems/commands/open_command.rb +1 -1
  174. data/lib/rubygems/commands/owner_command.rb +1 -1
  175. data/lib/rubygems/commands/pristine_command.rb +13 -15
  176. data/lib/rubygems/commands/push_command.rb +2 -2
  177. data/lib/rubygems/commands/query_command.rb +4 -5
  178. data/lib/rubygems/commands/rdoc_command.rb +2 -2
  179. data/lib/rubygems/commands/search_command.rb +2 -2
  180. data/lib/rubygems/commands/setup_command.rb +31 -34
  181. data/lib/rubygems/commands/sources_command.rb +12 -12
  182. data/lib/rubygems/commands/specification_command.rb +10 -10
  183. data/lib/rubygems/commands/stale_command.rb +1 -1
  184. data/lib/rubygems/commands/uninstall_command.rb +9 -10
  185. data/lib/rubygems/commands/unpack_command.rb +4 -4
  186. data/lib/rubygems/commands/update_command.rb +10 -12
  187. data/lib/rubygems/commands/which_command.rb +1 -1
  188. data/lib/rubygems/commands/yank_command.rb +1 -1
  189. data/lib/rubygems/compatibility.rb +5 -6
  190. data/lib/rubygems/config_file.rb +4 -4
  191. data/lib/rubygems/core_ext/kernel_gem.rb +0 -2
  192. data/lib/rubygems/core_ext/kernel_require.rb +19 -48
  193. data/lib/rubygems/core_ext/kernel_warn.rb +1 -1
  194. data/lib/rubygems/core_ext/tcpsocket_init.rb +1 -1
  195. data/lib/rubygems/defaults.rb +15 -3
  196. data/lib/rubygems/dependency.rb +12 -14
  197. data/lib/rubygems/dependency_installer.rb +29 -30
  198. data/lib/rubygems/dependency_list.rb +1 -1
  199. data/lib/rubygems/deprecate.rb +16 -15
  200. data/lib/rubygems/doctor.rb +5 -5
  201. data/lib/rubygems/errors.rb +2 -6
  202. data/lib/rubygems/exceptions.rb +2 -1
  203. data/lib/rubygems/ext/builder.rb +15 -10
  204. data/lib/rubygems/ext/cargo_builder.rb +5 -5
  205. data/lib/rubygems/ext/ext_conf_builder.rb +1 -3
  206. data/lib/rubygems/gem_runner.rb +4 -4
  207. data/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb +3 -3
  208. data/lib/rubygems/gemcutter_utilities/webauthn_poller.rb +3 -3
  209. data/lib/rubygems/gemcutter_utilities.rb +18 -19
  210. data/lib/rubygems/install_update_options.rb +18 -19
  211. data/lib/rubygems/installer.rb +59 -33
  212. data/lib/rubygems/installer_uninstaller_utils.rb +0 -2
  213. data/lib/rubygems/local_remote_options.rb +7 -10
  214. data/lib/rubygems/name_tuple.rb +7 -9
  215. data/lib/rubygems/net/http.rb +3 -0
  216. data/lib/rubygems/net-http/LICENSE.txt +22 -0
  217. data/lib/rubygems/net-http/lib/net/http/backward.rb +40 -0
  218. data/lib/rubygems/net-http/lib/net/http/exceptions.rb +34 -0
  219. data/lib/rubygems/net-http/lib/net/http/generic_request.rb +414 -0
  220. data/lib/rubygems/net-http/lib/net/http/header.rb +981 -0
  221. data/lib/rubygems/net-http/lib/net/http/proxy_delta.rb +17 -0
  222. data/lib/rubygems/net-http/lib/net/http/request.rb +88 -0
  223. data/lib/rubygems/net-http/lib/net/http/requests.rb +425 -0
  224. data/lib/rubygems/net-http/lib/net/http/response.rb +738 -0
  225. data/lib/rubygems/net-http/lib/net/http/responses.rb +1174 -0
  226. data/lib/rubygems/net-http/lib/net/http/status.rb +84 -0
  227. data/lib/rubygems/net-http/lib/net/http.rb +2496 -0
  228. data/lib/rubygems/net-http/lib/net/https.rb +23 -0
  229. data/lib/rubygems/net-protocol/LICENSE.txt +22 -0
  230. data/lib/rubygems/net-protocol/lib/net/protocol.rb +544 -0
  231. data/lib/rubygems/optparse/lib/optparse.rb +39 -17
  232. data/lib/rubygems/package/old.rb +2 -2
  233. data/lib/rubygems/package/tar_header.rb +45 -39
  234. data/lib/rubygems/package/tar_reader/entry.rb +5 -4
  235. data/lib/rubygems/package/tar_reader.rb +5 -3
  236. data/lib/rubygems/package/tar_writer.rb +19 -17
  237. data/lib/rubygems/package.rb +27 -26
  238. data/lib/rubygems/package_task.rb +2 -2
  239. data/lib/rubygems/path_support.rb +9 -10
  240. data/lib/rubygems/platform.rb +60 -45
  241. data/lib/rubygems/query_utils.rb +7 -9
  242. data/lib/rubygems/remote_fetcher.rb +15 -15
  243. data/lib/rubygems/request/connection_pools.rb +3 -3
  244. data/lib/rubygems/request.rb +20 -17
  245. data/lib/rubygems/request_set/gem_dependency_api.rb +119 -122
  246. data/lib/rubygems/request_set/lockfile/parser.rb +9 -9
  247. data/lib/rubygems/request_set/lockfile/tokenizer.rb +20 -12
  248. data/lib/rubygems/request_set/lockfile.rb +6 -11
  249. data/lib/rubygems/request_set.rb +5 -5
  250. data/lib/rubygems/requirement.rb +7 -7
  251. data/lib/rubygems/resolv/LICENSE.txt +22 -0
  252. data/lib/rubygems/resolv/lib/resolv.rb +3387 -0
  253. data/lib/rubygems/resolver/activation_request.rb +1 -3
  254. data/lib/rubygems/resolver/api_set/gem_parser.rb +7 -3
  255. data/lib/rubygems/resolver/best_set.rb +1 -1
  256. data/lib/rubygems/resolver/composed_set.rb +1 -1
  257. data/lib/rubygems/resolver/conflict.rb +4 -12
  258. data/lib/rubygems/resolver/index_set.rb +4 -4
  259. data/lib/rubygems/resolver/index_specification.rb +2 -2
  260. data/lib/rubygems/resolver/installer_set.rb +5 -6
  261. data/lib/rubygems/resolver/lock_set.rb +1 -1
  262. data/lib/rubygems/resolver.rb +3 -10
  263. data/lib/rubygems/s3_uri_signer.rb +6 -6
  264. data/lib/rubygems/safe_marshal/elements.rb +138 -0
  265. data/lib/rubygems/safe_marshal/reader.rb +306 -0
  266. data/lib/rubygems/safe_marshal/visitors/stream_printer.rb +31 -0
  267. data/lib/rubygems/safe_marshal/visitors/to_ruby.rb +385 -0
  268. data/lib/rubygems/safe_marshal/visitors/visitor.rb +74 -0
  269. data/lib/rubygems/safe_marshal.rb +74 -0
  270. data/lib/rubygems/safe_yaml.rb +5 -28
  271. data/lib/rubygems/security/policies.rb +36 -38
  272. data/lib/rubygems/security/policy.rb +7 -11
  273. data/lib/rubygems/security/signer.rb +1 -1
  274. data/lib/rubygems/security/trust_dir.rb +3 -3
  275. data/lib/rubygems/security.rb +8 -22
  276. data/lib/rubygems/source/git.rb +1 -3
  277. data/lib/rubygems/source/installed.rb +0 -2
  278. data/lib/rubygems/source/local.rb +5 -8
  279. data/lib/rubygems/source/lock.rb +1 -3
  280. data/lib/rubygems/source/specific_file.rb +0 -1
  281. data/lib/rubygems/source/vendor.rb +0 -2
  282. data/lib/rubygems/source.rb +12 -12
  283. data/lib/rubygems/source_list.rb +4 -4
  284. data/lib/rubygems/spec_fetcher.rb +29 -29
  285. data/lib/rubygems/specification.rb +125 -138
  286. data/lib/rubygems/specification_policy.rb +55 -25
  287. data/lib/rubygems/stub_specification.rb +4 -5
  288. data/lib/rubygems/text.rb +1 -2
  289. data/lib/rubygems/timeout/LICENSE.txt +22 -0
  290. data/lib/rubygems/timeout/lib/timeout.rb +199 -0
  291. data/lib/rubygems/timeout.rb +3 -0
  292. data/lib/rubygems/tsort/lib/tsort.rb +3 -0
  293. data/lib/rubygems/uninstaller.rb +7 -9
  294. data/lib/rubygems/update_suggestion.rb +5 -18
  295. data/lib/rubygems/uri_formatter.rb +1 -1
  296. data/lib/rubygems/user_interaction.rb +15 -21
  297. data/lib/rubygems/util/licenses.rb +65 -35
  298. data/lib/rubygems/util/list.rb +3 -1
  299. data/lib/rubygems/util.rb +2 -4
  300. data/lib/rubygems/validator.rb +5 -3
  301. data/lib/rubygems/version.rb +34 -28
  302. data/lib/rubygems/version_option.rb +2 -5
  303. data/lib/rubygems/yaml_serializer.rb +3 -3
  304. data/lib/rubygems.rb +37 -37
  305. data/rubygems-update.gemspec +4 -4
  306. data/setup.rb +2 -2
  307. metadata +38 -225
  308. data/lib/rubygems/indexer.rb +0 -428
  309. data/lib/rubygems/mock_gem_ui.rb +0 -86
  310. data/test/rubygems/alternate_cert.pem +0 -19
  311. data/test/rubygems/alternate_cert_32.pem +0 -19
  312. data/test/rubygems/alternate_key.pem +0 -27
  313. data/test/rubygems/bad_rake.rb +0 -3
  314. data/test/rubygems/bundler_test_gem.rb +0 -424
  315. data/test/rubygems/ca_cert.pem +0 -77
  316. data/test/rubygems/child_cert.pem +0 -19
  317. data/test/rubygems/child_cert_32.pem +0 -19
  318. data/test/rubygems/child_key.pem +0 -27
  319. data/test/rubygems/client.pem +0 -107
  320. data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
  321. data/test/rubygems/data/gem-private_key.pem +0 -27
  322. data/test/rubygems/data/gem-public_cert.pem +0 -20
  323. data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
  324. data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
  325. data/test/rubygems/data/pry-0.4.7.gemspec.rz +0 -0
  326. data/test/rubygems/encrypted_private_key.pem +0 -30
  327. data/test/rubygems/expired_cert.pem +0 -19
  328. data/test/rubygems/fake_certlib/openssl.rb +0 -9
  329. data/test/rubygems/foo/discover.rb +0 -1
  330. data/test/rubygems/future_cert.pem +0 -19
  331. data/test/rubygems/future_cert_32.pem +0 -19
  332. data/test/rubygems/good_rake.rb +0 -3
  333. data/test/rubygems/grandchild_cert.pem +0 -19
  334. data/test/rubygems/grandchild_cert_32.pem +0 -19
  335. data/test/rubygems/grandchild_key.pem +0 -27
  336. data/test/rubygems/helper.rb +0 -1649
  337. data/test/rubygems/installer_test_case.rb +0 -248
  338. data/test/rubygems/invalid_client.pem +0 -49
  339. data/test/rubygems/invalid_issuer_cert.pem +0 -20
  340. data/test/rubygems/invalid_issuer_cert_32.pem +0 -20
  341. data/test/rubygems/invalid_key.pem +0 -27
  342. data/test/rubygems/invalid_signer_cert.pem +0 -19
  343. data/test/rubygems/invalid_signer_cert_32.pem +0 -19
  344. data/test/rubygems/invalidchild_cert.pem +0 -19
  345. data/test/rubygems/invalidchild_cert_32.pem +0 -19
  346. data/test/rubygems/invalidchild_key.pem +0 -27
  347. data/test/rubygems/multifactor_auth_utilities.rb +0 -111
  348. data/test/rubygems/package/tar_test_case.rb +0 -175
  349. data/test/rubygems/packages/Bluebie-legs-0.6.2.gem +0 -0
  350. data/test/rubygems/packages/ascii_binder-0.1.10.1.gem +0 -0
  351. data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
  352. data/test/rubygems/plugin/exception/rubygems_plugin.rb +0 -4
  353. data/test/rubygems/plugin/load/rubygems_plugin.rb +0 -5
  354. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +0 -4
  355. data/test/rubygems/private3072_key.pem +0 -40
  356. data/test/rubygems/private_ec_key.pem +0 -9
  357. data/test/rubygems/private_key.pem +0 -27
  358. data/test/rubygems/public3072_cert.pem +0 -25
  359. data/test/rubygems/public_cert.pem +0 -20
  360. data/test/rubygems/public_cert_32.pem +0 -19
  361. data/test/rubygems/public_key.pem +0 -9
  362. data/test/rubygems/rubygems/commands/crash_command.rb +0 -5
  363. data/test/rubygems/rubygems_plugin.rb +0 -24
  364. data/test/rubygems/sff/discover.rb +0 -1
  365. data/test/rubygems/simple_gem.rb +0 -68
  366. data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -9
  367. data/test/rubygems/specifications/foo-0.0.1-x86-mswin32.gemspec +0 -0
  368. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +0 -14
  369. data/test/rubygems/ssl_cert.pem +0 -80
  370. data/test/rubygems/ssl_key.pem +0 -27
  371. data/test/rubygems/test_bundled_ca.rb +0 -61
  372. data/test/rubygems/test_config.rb +0 -28
  373. data/test/rubygems/test_deprecate.rb +0 -158
  374. data/test/rubygems/test_exit.rb +0 -17
  375. data/test/rubygems/test_gem.rb +0 -1799
  376. data/test/rubygems/test_gem_available_set.rb +0 -130
  377. data/test/rubygems/test_gem_bundler_version_finder.rb +0 -127
  378. data/test/rubygems/test_gem_command.rb +0 -403
  379. data/test/rubygems/test_gem_command_manager.rb +0 -400
  380. data/test/rubygems/test_gem_commands_build_command.rb +0 -739
  381. data/test/rubygems/test_gem_commands_cert_command.rb +0 -866
  382. data/test/rubygems/test_gem_commands_check_command.rb +0 -68
  383. data/test/rubygems/test_gem_commands_cleanup_command.rb +0 -292
  384. data/test/rubygems/test_gem_commands_contents_command.rb +0 -271
  385. data/test/rubygems/test_gem_commands_dependency_command.rb +0 -228
  386. data/test/rubygems/test_gem_commands_environment_command.rb +0 -169
  387. data/test/rubygems/test_gem_commands_exec_command.rb +0 -857
  388. data/test/rubygems/test_gem_commands_fetch_command.rb +0 -258
  389. data/test/rubygems/test_gem_commands_generate_index_command.rb +0 -81
  390. data/test/rubygems/test_gem_commands_help_command.rb +0 -94
  391. data/test/rubygems/test_gem_commands_info_command.rb +0 -70
  392. data/test/rubygems/test_gem_commands_install_command.rb +0 -1573
  393. data/test/rubygems/test_gem_commands_list_command.rb +0 -33
  394. data/test/rubygems/test_gem_commands_lock_command.rb +0 -67
  395. data/test/rubygems/test_gem_commands_mirror.rb +0 -20
  396. data/test/rubygems/test_gem_commands_open_command.rb +0 -101
  397. data/test/rubygems/test_gem_commands_outdated_command.rb +0 -50
  398. data/test/rubygems/test_gem_commands_owner_command.rb +0 -503
  399. data/test/rubygems/test_gem_commands_pristine_command.rb +0 -708
  400. data/test/rubygems/test_gem_commands_push_command.rb +0 -603
  401. data/test/rubygems/test_gem_commands_query_command.rb +0 -858
  402. data/test/rubygems/test_gem_commands_search_command.rb +0 -16
  403. data/test/rubygems/test_gem_commands_server_command.rb +0 -20
  404. data/test/rubygems/test_gem_commands_setup_command.rb +0 -474
  405. data/test/rubygems/test_gem_commands_signin_command.rb +0 -259
  406. data/test/rubygems/test_gem_commands_signout_command.rb +0 -30
  407. data/test/rubygems/test_gem_commands_sources_command.rb +0 -534
  408. data/test/rubygems/test_gem_commands_specification_command.rb +0 -277
  409. data/test/rubygems/test_gem_commands_stale_command.rb +0 -43
  410. data/test/rubygems/test_gem_commands_uninstall_command.rb +0 -542
  411. data/test/rubygems/test_gem_commands_unpack_command.rb +0 -224
  412. data/test/rubygems/test_gem_commands_update_command.rb +0 -836
  413. data/test/rubygems/test_gem_commands_which_command.rb +0 -85
  414. data/test/rubygems/test_gem_commands_yank_command.rb +0 -299
  415. data/test/rubygems/test_gem_config_file.rb +0 -551
  416. data/test/rubygems/test_gem_dependency.rb +0 -398
  417. data/test/rubygems/test_gem_dependency_installer.rb +0 -1190
  418. data/test/rubygems/test_gem_dependency_list.rb +0 -265
  419. data/test/rubygems/test_gem_dependency_resolution_error.rb +0 -27
  420. data/test/rubygems/test_gem_doctor.rb +0 -195
  421. data/test/rubygems/test_gem_ext_builder.rb +0 -337
  422. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/.gitignore +0 -1
  423. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +0 -10
  424. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock +0 -249
  425. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml +0 -10
  426. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/src/lib.rs +0 -27
  427. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/lib/custom_name.rb +0 -3
  428. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/.gitignore +0 -1
  429. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +0 -249
  430. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +0 -10
  431. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec +0 -10
  432. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +0 -51
  433. data/test/rubygems/test_gem_ext_cargo_builder.rb +0 -167
  434. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +0 -34
  435. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +0 -60
  436. data/test/rubygems/test_gem_ext_cmake_builder.rb +0 -84
  437. data/test/rubygems/test_gem_ext_configure_builder.rb +0 -80
  438. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +0 -229
  439. data/test/rubygems/test_gem_ext_rake_builder.rb +0 -113
  440. data/test/rubygems/test_gem_gem_runner.rb +0 -119
  441. data/test/rubygems/test_gem_gemcutter_utilities.rb +0 -361
  442. data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -60
  443. data/test/rubygems/test_gem_indexer.rb +0 -381
  444. data/test/rubygems/test_gem_install_update_options.rb +0 -208
  445. data/test/rubygems/test_gem_installer.rb +0 -2512
  446. data/test/rubygems/test_gem_local_remote_options.rb +0 -133
  447. data/test/rubygems/test_gem_name_tuple.rb +0 -43
  448. data/test/rubygems/test_gem_package.rb +0 -1306
  449. data/test/rubygems/test_gem_package_old.rb +0 -91
  450. data/test/rubygems/test_gem_package_tar_header.rb +0 -226
  451. data/test/rubygems/test_gem_package_tar_reader.rb +0 -150
  452. data/test/rubygems/test_gem_package_tar_reader_entry.rb +0 -350
  453. data/test/rubygems/test_gem_package_tar_writer.rb +0 -331
  454. data/test/rubygems/test_gem_package_task.rb +0 -118
  455. data/test/rubygems/test_gem_path_support.rb +0 -139
  456. data/test/rubygems/test_gem_platform.rb +0 -497
  457. data/test/rubygems/test_gem_rdoc.rb +0 -137
  458. data/test/rubygems/test_gem_remote_fetcher.rb +0 -1227
  459. data/test/rubygems/test_gem_request.rb +0 -547
  460. data/test/rubygems/test_gem_request_connection_pools.rb +0 -152
  461. data/test/rubygems/test_gem_request_set.rb +0 -672
  462. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +0 -853
  463. data/test/rubygems/test_gem_request_set_lockfile.rb +0 -469
  464. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +0 -544
  465. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +0 -307
  466. data/test/rubygems/test_gem_requirement.rb +0 -505
  467. data/test/rubygems/test_gem_resolver.rb +0 -859
  468. data/test/rubygems/test_gem_resolver_activation_request.rb +0 -43
  469. data/test/rubygems/test_gem_resolver_api_set.rb +0 -210
  470. data/test/rubygems/test_gem_resolver_api_specification.rb +0 -167
  471. data/test/rubygems/test_gem_resolver_best_set.rb +0 -159
  472. data/test/rubygems/test_gem_resolver_composed_set.rb +0 -44
  473. data/test/rubygems/test_gem_resolver_conflict.rb +0 -82
  474. data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -83
  475. data/test/rubygems/test_gem_resolver_git_set.rb +0 -188
  476. data/test/rubygems/test_gem_resolver_git_specification.rb +0 -114
  477. data/test/rubygems/test_gem_resolver_index_set.rb +0 -88
  478. data/test/rubygems/test_gem_resolver_index_specification.rb +0 -93
  479. data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -47
  480. data/test/rubygems/test_gem_resolver_installer_set.rb +0 -320
  481. data/test/rubygems/test_gem_resolver_local_specification.rb +0 -44
  482. data/test/rubygems/test_gem_resolver_lock_set.rb +0 -62
  483. data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -98
  484. data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -19
  485. data/test/rubygems/test_gem_resolver_specification.rb +0 -63
  486. data/test/rubygems/test_gem_resolver_vendor_set.rb +0 -82
  487. data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -82
  488. data/test/rubygems/test_gem_security.rb +0 -341
  489. data/test/rubygems/test_gem_security_policy.rb +0 -535
  490. data/test/rubygems/test_gem_security_signer.rb +0 -218
  491. data/test/rubygems/test_gem_security_trust_dir.rb +0 -99
  492. data/test/rubygems/test_gem_silent_ui.rb +0 -123
  493. data/test/rubygems/test_gem_source.rb +0 -254
  494. data/test/rubygems/test_gem_source_fetch_problem.rb +0 -37
  495. data/test/rubygems/test_gem_source_git.rb +0 -310
  496. data/test/rubygems/test_gem_source_installed.rb +0 -35
  497. data/test/rubygems/test_gem_source_list.rb +0 -119
  498. data/test/rubygems/test_gem_source_local.rb +0 -107
  499. data/test/rubygems/test_gem_source_lock.rb +0 -113
  500. data/test/rubygems/test_gem_source_specific_file.rb +0 -76
  501. data/test/rubygems/test_gem_source_subpath_problem.rb +0 -50
  502. data/test/rubygems/test_gem_source_vendor.rb +0 -30
  503. data/test/rubygems/test_gem_spec_fetcher.rb +0 -338
  504. data/test/rubygems/test_gem_specification.rb +0 -3856
  505. data/test/rubygems/test_gem_stream_ui.rb +0 -255
  506. data/test/rubygems/test_gem_stub_specification.rb +0 -278
  507. data/test/rubygems/test_gem_text.rb +0 -103
  508. data/test/rubygems/test_gem_uninstaller.rb +0 -675
  509. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -31
  510. data/test/rubygems/test_gem_update_suggestion.rb +0 -209
  511. data/test/rubygems/test_gem_uri.rb +0 -41
  512. data/test/rubygems/test_gem_uri_formatter.rb +0 -27
  513. data/test/rubygems/test_gem_util.rb +0 -91
  514. data/test/rubygems/test_gem_validator.rb +0 -42
  515. data/test/rubygems/test_gem_version.rb +0 -305
  516. data/test/rubygems/test_gem_version_option.rb +0 -165
  517. data/test/rubygems/test_kernel.rb +0 -124
  518. data/test/rubygems/test_project_sanity.rb +0 -49
  519. data/test/rubygems/test_remote_fetch_error.rb +0 -20
  520. data/test/rubygems/test_require.rb +0 -732
  521. data/test/rubygems/test_rubygems.rb +0 -76
  522. data/test/rubygems/test_webauthn_listener.rb +0 -143
  523. data/test/rubygems/test_webauthn_listener_response.rb +0 -93
  524. data/test/rubygems/test_webauthn_poller.rb +0 -124
  525. data/test/rubygems/utilities.rb +0 -436
  526. data/test/rubygems/wrong_key_cert.pem +0 -19
  527. data/test/rubygems/wrong_key_cert_32.pem +0 -19
  528. data/test/test_changelog_generator.rb +0 -17
@@ -1,1306 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "package/tar_test_case"
4
- require "rubygems/openssl"
5
-
6
- class TestGemPackage < Gem::Package::TarTestCase
7
- def setup
8
- super
9
-
10
- @spec = quick_gem "a" do |s|
11
- s.description = "π"
12
- s.files = %w[lib/code.rb]
13
- end
14
-
15
- util_build_gem @spec
16
-
17
- @gem = @spec.cache_file
18
-
19
- @destination = File.join @tempdir, "extract"
20
-
21
- FileUtils.mkdir_p @destination
22
- end
23
-
24
- def test_class_new_old_format
25
- pend "jruby can't require the simple_gem file" if Gem.java_platform?
26
- require_relative "simple_gem"
27
- File.open "old_format.gem", "wb" do |io|
28
- io.write SIMPLE_GEM
29
- end
30
-
31
- package = Gem::Package.new "old_format.gem"
32
-
33
- assert package.spec
34
- end
35
-
36
- def test_add_checksums
37
- gem_io = StringIO.new
38
-
39
- spec = Gem::Specification.new "build", "1"
40
- spec.summary = "build"
41
- spec.authors = "build"
42
- spec.files = ["lib/code.rb"]
43
- spec.date = Time.at 0
44
- spec.rubygems_version = Gem::Version.new "0"
45
-
46
- FileUtils.mkdir "lib"
47
-
48
- File.open "lib/code.rb", "w" do |io|
49
- io.write "# lib/code.rb"
50
- end
51
-
52
- package = Gem::Package.new spec.file_name
53
- package.spec = spec
54
- package.build_time = 1 # 0 uses current time
55
- package.setup_signer
56
-
57
- Gem::Package::TarWriter.new gem_io do |gem|
58
- package.add_metadata gem
59
- package.add_contents gem
60
- package.add_checksums gem
61
- end
62
-
63
- gem_io.rewind
64
-
65
- reader = Gem::Package::TarReader.new gem_io
66
-
67
- checksums = nil
68
- tar = nil
69
-
70
- reader.each_entry do |entry|
71
- case entry.full_name
72
- when "checksums.yaml.gz" then
73
- Zlib::GzipReader.wrap entry do |io|
74
- checksums = io.read
75
- end
76
- when "data.tar.gz" then
77
- tar = entry.read
78
- end
79
- end
80
-
81
- s = StringIO.new
82
-
83
- package.gzip_to s do |io|
84
- io.write spec.to_yaml
85
- end
86
-
87
- metadata_sha256 = OpenSSL::Digest::SHA256.hexdigest s.string
88
- metadata_sha512 = OpenSSL::Digest::SHA512.hexdigest s.string
89
-
90
- expected = {
91
- "SHA512" => {
92
- "metadata.gz" => metadata_sha512,
93
- "data.tar.gz" => OpenSSL::Digest::SHA512.hexdigest(tar),
94
- },
95
- "SHA256" => {
96
- "metadata.gz" => metadata_sha256,
97
- "data.tar.gz" => OpenSSL::Digest::SHA256.hexdigest(tar),
98
- },
99
- }
100
-
101
- assert_equal expected, load_yaml(checksums)
102
- end
103
-
104
- def test_build_time_uses_source_date_epoch
105
- epoch = ENV["SOURCE_DATE_EPOCH"]
106
- ENV["SOURCE_DATE_EPOCH"] = "123456789"
107
-
108
- spec = Gem::Specification.new "build", "1"
109
- spec.summary = "build"
110
- spec.authors = "build"
111
- spec.files = ["lib/code.rb"]
112
- spec.date = Time.at 0
113
- spec.rubygems_version = Gem::Version.new "0"
114
-
115
- package = Gem::Package.new spec.file_name
116
-
117
- assert_equal Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc, package.build_time
118
- ensure
119
- ENV["SOURCE_DATE_EPOCH"] = epoch
120
- end
121
-
122
- def test_build_time_without_source_date_epoch
123
- epoch = ENV["SOURCE_DATE_EPOCH"]
124
- ENV["SOURCE_DATE_EPOCH"] = nil
125
-
126
- spec = Gem::Specification.new "build", "1"
127
- spec.summary = "build"
128
- spec.authors = "build"
129
- spec.files = ["lib/code.rb"]
130
- spec.rubygems_version = Gem::Version.new "0"
131
-
132
- package = Gem::Package.new spec.file_name
133
-
134
- assert_kind_of Time, package.build_time
135
-
136
- build_time = package.build_time.to_i
137
-
138
- assert_equal Gem.source_date_epoch.to_i, build_time
139
- ensure
140
- ENV["SOURCE_DATE_EPOCH"] = epoch
141
- end
142
-
143
- def test_add_files
144
- spec = Gem::Specification.new
145
- spec.files = %w[lib/code.rb lib/empty]
146
-
147
- FileUtils.mkdir_p "lib/empty"
148
-
149
- File.open "lib/code.rb", "w" do |io|
150
- io.write "# lib/code.rb"
151
- end
152
-
153
- File.open "lib/extra.rb", "w" do |io|
154
- io.write "# lib/extra.rb"
155
- end
156
-
157
- package = Gem::Package.new "bogus.gem"
158
- package.spec = spec
159
-
160
- tar = util_tar do |tar_io|
161
- package.add_files tar_io
162
- end
163
-
164
- tar.rewind
165
-
166
- files = []
167
-
168
- Gem::Package::TarReader.new tar do |tar_io|
169
- tar_io.each_entry do |entry|
170
- files << entry.full_name
171
- end
172
- end
173
-
174
- assert_equal %w[lib/code.rb], files
175
- end
176
-
177
- def test_add_files_symlink
178
- spec = Gem::Specification.new
179
- spec.files = %w[lib/code.rb lib/code_sym.rb lib/code_sym2.rb]
180
-
181
- FileUtils.mkdir_p "lib"
182
-
183
- File.open "lib/code.rb", "w" do |io|
184
- io.write "# lib/code.rb"
185
- end
186
-
187
- # NOTE: 'code.rb' is correct, because it's relative to lib/code_sym.rb
188
- begin
189
- File.symlink("code.rb", "lib/code_sym.rb")
190
- File.symlink("../lib/code.rb", "lib/code_sym2.rb")
191
- rescue Errno::EACCES => e
192
- if win_platform?
193
- pend "symlink - must be admin with no UAC on Windows"
194
- else
195
- raise e
196
- end
197
- end
198
-
199
- package = Gem::Package.new "bogus.gem"
200
- package.spec = spec
201
-
202
- tar = util_tar do |tar_io|
203
- package.add_files tar_io
204
- end
205
-
206
- tar.rewind
207
-
208
- files = []
209
- symlinks = []
210
-
211
- Gem::Package::TarReader.new tar do |tar_io|
212
- tar_io.each_entry do |entry|
213
- if entry.symlink?
214
- symlinks << { entry.full_name => entry.header.linkname }
215
- else
216
- files << entry.full_name
217
- end
218
- end
219
- end
220
-
221
- assert_equal %w[lib/code.rb], files
222
- assert_equal [{ "lib/code_sym.rb" => "code.rb" }, { "lib/code_sym2.rb" => "../lib/code.rb" }], symlinks
223
- end
224
-
225
- def test_build
226
- spec = Gem::Specification.new "build", "1"
227
- spec.summary = "build"
228
- spec.authors = "build"
229
- spec.files = ["lib/code.rb"]
230
- spec.rubygems_version = :junk
231
-
232
- FileUtils.mkdir "lib"
233
-
234
- File.open "lib/code.rb", "w" do |io|
235
- io.write "# lib/code.rb"
236
- end
237
-
238
- package = Gem::Package.new spec.file_name
239
- package.spec = spec
240
-
241
- package.build
242
-
243
- assert_equal Gem::VERSION, spec.rubygems_version
244
- assert_path_exist spec.file_name
245
-
246
- reader = Gem::Package.new spec.file_name
247
- assert_equal spec, reader.spec
248
-
249
- assert_equal %w[metadata.gz data.tar.gz checksums.yaml.gz],
250
- reader.files
251
-
252
- assert_equal %w[lib/code.rb], reader.contents
253
- end
254
-
255
- def test_build_auto_signed
256
- pend "openssl is missing" unless Gem::HAVE_OPENSSL
257
-
258
- FileUtils.mkdir_p File.join(Gem.user_home, ".gem")
259
-
260
- private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem"
261
- Gem::Security.write PRIVATE_KEY, private_key_path
262
-
263
- public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem"
264
- FileUtils.cp PUBLIC_CERT_PATH, public_cert_path
265
-
266
- spec = Gem::Specification.new "build", "1"
267
- spec.summary = "build"
268
- spec.authors = "build"
269
- spec.files = ["lib/code.rb"]
270
-
271
- FileUtils.mkdir "lib"
272
-
273
- File.open "lib/code.rb", "w" do |io|
274
- io.write "# lib/code.rb"
275
- end
276
-
277
- package = Gem::Package.new spec.file_name
278
- package.spec = spec
279
-
280
- package.build
281
-
282
- assert_equal Gem::VERSION, spec.rubygems_version
283
- assert_path_exist spec.file_name
284
-
285
- reader = Gem::Package.new spec.file_name
286
- assert reader.verify
287
-
288
- assert_equal [PUBLIC_CERT.to_pem], reader.spec.cert_chain
289
-
290
- assert_equal %w[metadata.gz metadata.gz.sig
291
- data.tar.gz data.tar.gz.sig
292
- checksums.yaml.gz checksums.yaml.gz.sig],
293
- reader.files
294
-
295
- assert_equal %w[lib/code.rb], reader.contents
296
- end
297
-
298
- def test_build_auto_signed_encrypted_key
299
- pend "openssl is missing" unless Gem::HAVE_OPENSSL
300
-
301
- FileUtils.mkdir_p File.join(Gem.user_home, ".gem")
302
-
303
- private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem"
304
- FileUtils.cp ENCRYPTED_PRIVATE_KEY_PATH, private_key_path
305
-
306
- public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem"
307
- Gem::Security.write PUBLIC_CERT, public_cert_path
308
-
309
- spec = Gem::Specification.new "build", "1"
310
- spec.summary = "build"
311
- spec.authors = "build"
312
- spec.files = ["lib/code.rb"]
313
-
314
- FileUtils.mkdir "lib"
315
-
316
- File.open "lib/code.rb", "w" do |io|
317
- io.write "# lib/code.rb"
318
- end
319
-
320
- package = Gem::Package.new spec.file_name
321
- package.spec = spec
322
-
323
- package.build
324
-
325
- assert_equal Gem::VERSION, spec.rubygems_version
326
- assert_path_exist spec.file_name
327
-
328
- reader = Gem::Package.new spec.file_name
329
- assert reader.verify
330
-
331
- assert_equal [PUBLIC_CERT.to_pem], reader.spec.cert_chain
332
-
333
- assert_equal %w[metadata.gz metadata.gz.sig
334
- data.tar.gz data.tar.gz.sig
335
- checksums.yaml.gz checksums.yaml.gz.sig],
336
- reader.files
337
-
338
- assert_equal %w[lib/code.rb], reader.contents
339
- end
340
-
341
- def test_build_invalid
342
- spec = Gem::Specification.new "build", "1"
343
-
344
- package = Gem::Package.new spec.file_name
345
- package.spec = spec
346
-
347
- e = assert_raise Gem::InvalidSpecificationException do
348
- package.build
349
- end
350
-
351
- assert_equal "missing value for attribute summary", e.message
352
- end
353
-
354
- def test_build_invalid_arguments
355
- spec = Gem::Specification.new "build", "1"
356
-
357
- package = Gem::Package.new spec.file_name
358
- package.spec = spec
359
-
360
- e = assert_raise ArgumentError do
361
- package.build true, true
362
- end
363
-
364
- assert_equal "skip_validation = true and strict_validation = true are incompatible", e.message
365
- end
366
-
367
- def test_build_signed
368
- pend "openssl is missing" unless Gem::HAVE_OPENSSL
369
-
370
- spec = Gem::Specification.new "build", "1"
371
- spec.summary = "build"
372
- spec.authors = "build"
373
- spec.files = ["lib/code.rb"]
374
- spec.cert_chain = [PUBLIC_CERT.to_pem]
375
- spec.signing_key = PRIVATE_KEY
376
-
377
- FileUtils.mkdir "lib"
378
-
379
- File.open "lib/code.rb", "w" do |io|
380
- io.write "# lib/code.rb"
381
- end
382
-
383
- package = Gem::Package.new spec.file_name
384
- package.spec = spec
385
-
386
- package.build
387
-
388
- assert_equal Gem::VERSION, spec.rubygems_version
389
- assert_path_exist spec.file_name
390
-
391
- reader = Gem::Package.new spec.file_name
392
- assert reader.verify
393
-
394
- assert_equal spec, reader.spec
395
-
396
- assert_equal %w[metadata.gz metadata.gz.sig
397
- data.tar.gz data.tar.gz.sig
398
- checksums.yaml.gz checksums.yaml.gz.sig],
399
- reader.files
400
-
401
- assert_equal %w[lib/code.rb], reader.contents
402
- end
403
-
404
- def test_build_signed_encrypted_key
405
- pend "openssl is missing" unless Gem::HAVE_OPENSSL
406
-
407
- spec = Gem::Specification.new "build", "1"
408
- spec.summary = "build"
409
- spec.authors = "build"
410
- spec.files = ["lib/code.rb"]
411
- spec.cert_chain = [PUBLIC_CERT.to_pem]
412
- spec.signing_key = ENCRYPTED_PRIVATE_KEY
413
-
414
- FileUtils.mkdir "lib"
415
-
416
- File.open "lib/code.rb", "w" do |io|
417
- io.write "# lib/code.rb"
418
- end
419
-
420
- package = Gem::Package.new spec.file_name
421
- package.spec = spec
422
-
423
- package.build
424
-
425
- assert_equal Gem::VERSION, spec.rubygems_version
426
- assert_path_exist spec.file_name
427
-
428
- reader = Gem::Package.new spec.file_name
429
- assert reader.verify
430
-
431
- assert_equal spec, reader.spec
432
-
433
- assert_equal %w[metadata.gz metadata.gz.sig
434
- data.tar.gz data.tar.gz.sig
435
- checksums.yaml.gz checksums.yaml.gz.sig],
436
- reader.files
437
-
438
- assert_equal %w[lib/code.rb], reader.contents
439
- end
440
-
441
- def test_raw_spec
442
- data_tgz = util_tar_gz {}
443
-
444
- gem = util_tar do |tar|
445
- tar.add_file "data.tar.gz", 0o644 do |io|
446
- io.write data_tgz.string
447
- end
448
-
449
- tar.add_file "metadata.gz", 0o644 do |io|
450
- Zlib::GzipWriter.wrap io do |gzio|
451
- gzio.write @spec.to_yaml
452
- end
453
- end
454
- end
455
-
456
- gem_path = "#{@destination}/test.gem"
457
-
458
- File.open gem_path, "wb" do |io|
459
- io.write gem.string
460
- end
461
-
462
- spec, metadata = Gem::Package.raw_spec(gem_path)
463
-
464
- assert_equal @spec, spec
465
- assert_match @spec.to_yaml, metadata.force_encoding("UTF-8")
466
- end
467
-
468
- def test_contents
469
- package = Gem::Package.new @gem
470
-
471
- assert_equal %w[lib/code.rb], package.contents
472
- end
473
-
474
- def test_extract_files
475
- package = Gem::Package.new @gem
476
-
477
- package.extract_files @destination
478
-
479
- extracted = File.join @destination, "lib/code.rb"
480
- assert_path_exist extracted
481
-
482
- mask = 0o100666 & (~File.umask)
483
-
484
- assert_equal mask.to_s(8), File.stat(extracted).mode.to_s(8) unless
485
- win_platform?
486
- end
487
-
488
- def test_extract_files_empty
489
- data_tgz = util_tar_gz {}
490
-
491
- gem = util_tar do |tar|
492
- tar.add_file "data.tar.gz", 0o644 do |io|
493
- io.write data_tgz.string
494
- end
495
-
496
- tar.add_file "metadata.gz", 0o644 do |io|
497
- Zlib::GzipWriter.wrap io do |gzio|
498
- gzio.write @spec.to_yaml
499
- end
500
- end
501
- end
502
-
503
- File.open "empty.gem", "wb" do |io|
504
- io.write gem.string
505
- end
506
-
507
- package = Gem::Package.new "empty.gem"
508
-
509
- package.extract_files @destination
510
-
511
- assert_path_exist @destination
512
- end
513
-
514
- def test_extract_file_permissions
515
- pend "chmod not supported" if win_platform?
516
-
517
- gem_with_long_permissions = File.expand_path("packages/Bluebie-legs-0.6.2.gem", __dir__)
518
-
519
- package = Gem::Package.new gem_with_long_permissions
520
-
521
- package.extract_files @destination
522
-
523
- filepath = File.join @destination, "README.rdoc"
524
- assert_path_exist filepath
525
-
526
- assert_equal 0o104444, File.stat(filepath).mode
527
- end
528
-
529
- def test_extract_tar_gz_absolute
530
- package = Gem::Package.new @gem
531
-
532
- tgz_io = util_tar_gz do |tar|
533
- tar.add_file "/absolute.rb", 0o644 do |io|
534
- io.write "hi"
535
- end
536
- end
537
-
538
- e = assert_raise Gem::Package::PathError do
539
- package.extract_tar_gz tgz_io, @destination
540
- end
541
-
542
- assert_equal("installing into parent path /absolute.rb of " +
543
- "#{@destination} is not allowed", e.message)
544
- end
545
-
546
- def test_extract_tar_gz_symlink_relative_path
547
- package = Gem::Package.new @gem
548
- package.verify
549
-
550
- tgz_io = util_tar_gz do |tar|
551
- tar.add_file "relative.rb", 0o644 do |io|
552
- io.write "hi"
553
- end
554
-
555
- tar.mkdir "lib", 0o755
556
- tar.add_symlink "lib/foo.rb", "../relative.rb", 0o644
557
- end
558
-
559
- begin
560
- package.extract_tar_gz tgz_io, @destination
561
- rescue Errno::EACCES => e
562
- if win_platform?
563
- pend "symlink - must be admin with no UAC on Windows"
564
- else
565
- raise e
566
- end
567
- end
568
-
569
- extracted = File.join @destination, "lib/foo.rb"
570
- assert_path_exist extracted
571
- assert_equal "../relative.rb",
572
- File.readlink(extracted)
573
- assert_equal "hi",
574
- File.read(extracted)
575
- end
576
-
577
- def test_extract_symlink_into_symlink_dir
578
- package = Gem::Package.new @gem
579
- tgz_io = util_tar_gz do |tar|
580
- tar.mkdir "lib", 0o755
581
- tar.add_symlink "lib/link", "./inside.rb", 0o644
582
- tar.add_file "lib/inside.rb", 0o644 do |io|
583
- io.write "hi"
584
- end
585
- end
586
-
587
- destination_subdir = File.join @destination, "subdir"
588
- FileUtils.mkdir_p destination_subdir
589
-
590
- destination_linkdir = File.join @destination, "linkdir"
591
- File.symlink(destination_subdir, destination_linkdir)
592
-
593
- package.extract_tar_gz tgz_io, destination_linkdir
594
-
595
- extracted = File.join destination_subdir, "lib/link"
596
- assert_path_exist extracted
597
- assert_equal "./inside.rb",
598
- File.readlink(extracted)
599
- assert_equal "hi",
600
- File.read(extracted)
601
- end
602
-
603
- def test_extract_tar_gz_symlink_broken_relative_path
604
- package = Gem::Package.new @gem
605
- package.verify
606
-
607
- tgz_io = util_tar_gz do |tar|
608
- tar.mkdir "lib", 0o755
609
- tar.add_symlink "lib/foo.rb", "../broken.rb", 0o644
610
- end
611
-
612
- ui = Gem::MockGemUi.new
613
-
614
- use_ui ui do
615
- package.extract_tar_gz tgz_io, @destination
616
- end
617
-
618
- assert_equal "WARNING: a-2 ships with a dangling symlink named lib/foo.rb pointing to missing ../broken.rb file. Ignoring\n", ui.error
619
-
620
- extracted = File.join @destination, "lib/foo.rb"
621
- assert_path_not_exist extracted
622
- end
623
-
624
- def test_extract_symlink_parent
625
- package = Gem::Package.new @gem
626
-
627
- tgz_io = util_tar_gz do |tar|
628
- tar.mkdir "lib", 0o755
629
- tar.add_symlink "lib/link", "../..", 0o644
630
- tar.add_file "lib/link/outside.txt", 0o644 do |io|
631
- io.write "hi"
632
- end
633
- end
634
-
635
- # Extract into a subdirectory of @destination; if this test fails it writes
636
- # a file outside destination_subdir, but we want the file to remain inside
637
- # @destination so it will be cleaned up.
638
- destination_subdir = File.join @destination, "subdir"
639
- FileUtils.mkdir_p destination_subdir
640
-
641
- expected_exceptions = win_platform? ? [Gem::Package::SymlinkError, Errno::EACCES] : [Gem::Package::SymlinkError]
642
-
643
- e = assert_raise(*expected_exceptions) do
644
- package.extract_tar_gz tgz_io, destination_subdir
645
- end
646
-
647
- pend "symlink - must be admin with no UAC on Windows" if Errno::EACCES === e
648
-
649
- assert_equal("installing symlink 'lib/link' pointing to parent path #{@destination} of " +
650
- "#{destination_subdir} is not allowed", e.message)
651
-
652
- assert_path_not_exist File.join(@destination, "outside.txt")
653
- assert_path_not_exist File.join(destination_subdir, "lib/link")
654
- end
655
-
656
- def test_extract_symlink_parent_doesnt_delete_user_dir
657
- package = Gem::Package.new @gem
658
-
659
- # Extract into a subdirectory of @destination; if this test fails it writes
660
- # a file outside destination_subdir, but we want the file to remain inside
661
- # @destination so it will be cleaned up.
662
- destination_subdir = File.join @destination, "subdir"
663
- FileUtils.mkdir_p destination_subdir
664
-
665
- destination_user_dir = File.join @destination, "user"
666
- destination_user_subdir = File.join destination_user_dir, "dir"
667
- FileUtils.mkdir_p destination_user_subdir
668
-
669
- pend "TMPDIR seems too long to add it as symlink into tar" if destination_user_dir.size > 90
670
-
671
- tgz_io = util_tar_gz do |tar|
672
- tar.add_symlink "link", destination_user_dir, 16_877
673
- tar.add_symlink "link/dir", ".", 16_877
674
- end
675
-
676
- expected_exceptions = win_platform? ? [Gem::Package::SymlinkError, Errno::EACCES] : [Gem::Package::SymlinkError]
677
-
678
- e = assert_raise(*expected_exceptions) do
679
- package.extract_tar_gz tgz_io, destination_subdir
680
- end
681
-
682
- pend "symlink - must be admin with no UAC on Windows" if Errno::EACCES === e
683
-
684
- assert_equal("installing symlink 'link' pointing to parent path #{destination_user_dir} of " +
685
- "#{destination_subdir} is not allowed", e.message)
686
-
687
- assert_path_exist destination_user_subdir
688
- assert_path_not_exist File.join(destination_subdir, "link/dir")
689
- assert_path_not_exist File.join(destination_subdir, "link")
690
- end
691
-
692
- def test_extract_tar_gz_directory
693
- package = Gem::Package.new @gem
694
-
695
- tgz_io = util_tar_gz do |tar|
696
- tar.mkdir "lib", 0o755
697
- tar.add_file "lib/foo.rb", 0o644 do |io|
698
- io.write "hi"
699
- end
700
- tar.mkdir "lib/foo", 0o755
701
- end
702
-
703
- package.extract_tar_gz tgz_io, @destination
704
-
705
- extracted = File.join @destination, "lib/foo.rb"
706
- assert_path_exist extracted
707
-
708
- extracted = File.join @destination, "lib/foo"
709
- assert_path_exist extracted
710
- end
711
-
712
- def test_extract_tar_gz_dot_slash
713
- package = Gem::Package.new @gem
714
-
715
- tgz_io = util_tar_gz do |tar|
716
- tar.add_file "./dot_slash.rb", 0o644 do |io|
717
- io.write "hi"
718
- end
719
- end
720
-
721
- package.extract_tar_gz tgz_io, @destination
722
-
723
- extracted = File.join @destination, "dot_slash.rb"
724
- assert_path_exist extracted
725
- end
726
-
727
- def test_extract_tar_gz_dot_file
728
- package = Gem::Package.new @gem
729
-
730
- tgz_io = util_tar_gz do |tar|
731
- tar.add_file ".dot_file.rb", 0o644 do |io|
732
- io.write "hi"
733
- end
734
- end
735
-
736
- package.extract_tar_gz tgz_io, @destination
737
-
738
- extracted = File.join @destination, ".dot_file.rb"
739
- assert_path_exist extracted
740
- end
741
-
742
- if Gem.win_platform?
743
- def test_extract_tar_gz_case_insensitive
744
- package = Gem::Package.new @gem
745
-
746
- tgz_io = util_tar_gz do |tar|
747
- tar.add_file "foo/file.rb", 0o644 do |io|
748
- io.write "hi"
749
- end
750
- end
751
-
752
- package.extract_tar_gz tgz_io, @destination.upcase
753
-
754
- extracted = File.join @destination, "foo/file.rb"
755
- assert_path_exist extracted
756
- end
757
- end
758
-
759
- def test_install_location
760
- package = Gem::Package.new @gem
761
-
762
- file = "file.rb".dup
763
- file.taint if RUBY_VERSION < "2.7"
764
-
765
- destination = package.install_location file, @destination
766
-
767
- assert_equal File.join(@destination, "file.rb"), destination
768
- refute destination.tainted? if RUBY_VERSION < "2.7"
769
- end
770
-
771
- def test_install_location_absolute
772
- package = Gem::Package.new @gem
773
-
774
- e = assert_raise Gem::Package::PathError do
775
- package.install_location "/absolute.rb", @destination
776
- end
777
-
778
- assert_equal("installing into parent path /absolute.rb of " +
779
- "#{@destination} is not allowed", e.message)
780
- end
781
-
782
- def test_install_location_dots
783
- package = Gem::Package.new @gem
784
-
785
- file = "file.rb"
786
-
787
- destination = File.join @destination, "foo", "..", "bar"
788
-
789
- FileUtils.mkdir_p File.join @destination, "foo"
790
- FileUtils.mkdir_p File.expand_path destination
791
-
792
- destination = package.install_location file, destination
793
-
794
- # this test only fails on ruby missing File.realpath
795
- assert_equal File.join(@destination, "bar", "file.rb"), destination
796
- end
797
-
798
- def test_install_location_extra_slash
799
- package = Gem::Package.new @gem
800
-
801
- file = "foo//file.rb".dup
802
- file.taint if RUBY_VERSION < "2.7"
803
-
804
- destination = package.install_location file, @destination
805
-
806
- assert_equal File.join(@destination, "foo", "file.rb"), destination
807
- refute destination.tainted? if RUBY_VERSION < "2.7"
808
- end
809
-
810
- def test_install_location_relative
811
- package = Gem::Package.new @gem
812
-
813
- e = assert_raise Gem::Package::PathError do
814
- package.install_location "../relative.rb", @destination
815
- end
816
-
817
- parent = File.expand_path File.join @destination, "../relative.rb"
818
-
819
- assert_equal("installing into parent path #{parent} of " +
820
- "#{@destination} is not allowed", e.message)
821
- end
822
-
823
- def test_install_location_suffix
824
- package = Gem::Package.new @gem
825
-
826
- filename = "../#{File.basename(@destination)}suffix.rb"
827
-
828
- e = assert_raise Gem::Package::PathError do
829
- package.install_location filename, @destination
830
- end
831
-
832
- parent = File.expand_path File.join @destination, filename
833
-
834
- assert_equal("installing into parent path #{parent} of " +
835
- "#{@destination} is not allowed", e.message)
836
- end
837
-
838
- def test_load_spec
839
- entry = StringIO.new Gem::Util.gzip @spec.to_yaml
840
- def entry.full_name() "metadata.gz" end
841
-
842
- package = Gem::Package.new "nonexistent.gem"
843
-
844
- spec = package.load_spec entry
845
-
846
- assert_equal @spec, spec
847
- end
848
-
849
- def test_verify
850
- package = Gem::Package.new @gem
851
-
852
- package.verify
853
-
854
- assert_equal @spec, package.spec
855
- assert_equal %w[checksums.yaml.gz data.tar.gz metadata.gz],
856
- package.files.sort
857
- end
858
-
859
- def test_verify_checksum_bad
860
- data_tgz = util_tar_gz do |tar|
861
- tar.add_file "lib/code.rb", 0o444 do |io|
862
- io.write "# lib/code.rb"
863
- end
864
- end
865
-
866
- data_tgz = data_tgz.string
867
-
868
- gem = util_tar do |tar|
869
- metadata_gz = Gem::Util.gzip @spec.to_yaml
870
-
871
- tar.add_file "metadata.gz", 0o444 do |io|
872
- io.write metadata_gz
873
- end
874
-
875
- tar.add_file "data.tar.gz", 0o444 do |io|
876
- io.write data_tgz
877
- end
878
-
879
- bogus_checksums = {
880
- "SHA1" => {
881
- "data.tar.gz" => "bogus",
882
- "metadata.gz" => "bogus",
883
- },
884
- }
885
- tar.add_file "checksums.yaml.gz", 0o444 do |io|
886
- Zlib::GzipWriter.wrap io do |gz_io|
887
- gz_io.write Psych.dump bogus_checksums
888
- end
889
- end
890
- end
891
-
892
- File.open "mismatch.gem", "wb" do |io|
893
- io.write gem.string
894
- end
895
-
896
- package = Gem::Package.new "mismatch.gem"
897
-
898
- e = assert_raise Gem::Package::FormatError do
899
- package.verify
900
- end
901
-
902
- assert_equal "SHA1 checksum mismatch for data.tar.gz in mismatch.gem",
903
- e.message
904
- end
905
-
906
- def test_verify_checksum_missing
907
- data_tgz = util_tar_gz do |tar|
908
- tar.add_file "lib/code.rb", 0o444 do |io|
909
- io.write "# lib/code.rb"
910
- end
911
- end
912
-
913
- data_tgz = data_tgz.string
914
-
915
- gem = util_tar do |tar|
916
- metadata_gz = Gem::Util.gzip @spec.to_yaml
917
-
918
- tar.add_file "metadata.gz", 0o444 do |io|
919
- io.write metadata_gz
920
- end
921
-
922
- digest = OpenSSL::Digest::SHA1.new
923
- digest << metadata_gz
924
-
925
- checksums = {
926
- "SHA1" => {
927
- "metadata.gz" => digest.hexdigest,
928
- },
929
- }
930
-
931
- tar.add_file "checksums.yaml.gz", 0o444 do |io|
932
- Zlib::GzipWriter.wrap io do |gz_io|
933
- gz_io.write Psych.dump checksums
934
- end
935
- end
936
-
937
- tar.add_file "data.tar.gz", 0o444 do |io|
938
- io.write data_tgz
939
- end
940
- end
941
-
942
- File.open "data_checksum_missing.gem", "wb" do |io|
943
- io.write gem.string
944
- end
945
-
946
- package = Gem::Package.new "data_checksum_missing.gem"
947
-
948
- assert package.verify
949
- end
950
-
951
- def test_verify_corrupt
952
- pend "jruby strips the null byte and does not think it's corrupt" if Gem.java_platform?
953
- tf = Tempfile.open "corrupt" do |io|
954
- data = Gem::Util.gzip "a" * 10
955
- io.write \
956
- tar_file_header("metadata.gz", "\000x", 0o644, data.length, Time.now)
957
- io.write data
958
- io.rewind
959
-
960
- package = Gem::Package.new io.path
961
-
962
- e = assert_raise Gem::Package::FormatError do
963
- package.verify
964
- end
965
-
966
- assert_equal "tar is corrupt, name contains null byte in #{io.path}",
967
- e.message
968
- io
969
- end
970
- tf.close!
971
- end
972
-
973
- def test_verify_corrupt_tar_metadata_entry
974
- gem = tar_file_header("metadata.gz", "", 0, 999, Time.now)
975
-
976
- File.open "corrupt.gem", "wb" do |io|
977
- io.write gem
978
- end
979
-
980
- package = Gem::Package.new "corrupt.gem"
981
-
982
- e = nil
983
- out_err = capture_output do
984
- e = assert_raise Gem::Package::FormatError do
985
- package.verify
986
- end
987
- end
988
-
989
- assert_match(/(EOFError|end of file reached) in corrupt.gem/i, e.message)
990
- assert_equal(["", "Exception while verifying corrupt.gem\n"], out_err)
991
- end
992
-
993
- def test_verify_corrupt_tar_checksums_entry
994
- gem = tar_file_header("checksums.yaml.gz", "", 0, 100, Time.now)
995
-
996
- File.open "corrupt.gem", "wb" do |io|
997
- io.write gem
998
- end
999
-
1000
- package = Gem::Package.new "corrupt.gem"
1001
-
1002
- e = assert_raise Gem::Package::FormatError do
1003
- package.verify
1004
- end
1005
-
1006
- assert_equal "not in gzip format in corrupt.gem", e.message
1007
- end
1008
-
1009
- def test_verify_corrupt_tar_data_entry
1010
- gem = tar_file_header("data.tar.gz", "", 0, 100, Time.now)
1011
-
1012
- File.open "corrupt.gem", "wb" do |io|
1013
- io.write gem
1014
- end
1015
-
1016
- package = Gem::Package.new "corrupt.gem"
1017
-
1018
- e = nil
1019
- out_err = capture_output do
1020
- e = assert_raise Gem::Package::FormatError do
1021
- package.verify
1022
- end
1023
- end
1024
-
1025
- assert_match(/(EOFError|end of file reached) in corrupt.gem/i, e.message)
1026
- assert_equal(["", "Exception while verifying corrupt.gem\n"], out_err)
1027
- end
1028
-
1029
- def test_corrupt_data_tar_gz
1030
- data_tgz = util_gzip tar_file_header("lib/code.rb", "", 0, 100, Time.now)
1031
- metadata_gz = util_gzip @spec.to_yaml
1032
-
1033
- gem = util_tar do |tar|
1034
- tar.add_file "data.tar.gz", 0o444 do |io|
1035
- io.write data_tgz
1036
- end
1037
-
1038
- tar.add_file "metadata.gz", 0o644 do |io|
1039
- io.write metadata_gz
1040
- end
1041
- end
1042
-
1043
- File.open "corrupt.gem", "wb" do |io|
1044
- io.write gem.string
1045
- end
1046
-
1047
- package = Gem::Package.new "corrupt.gem"
1048
-
1049
- e = assert_raise Gem::Package::FormatError do
1050
- package.contents
1051
- end
1052
-
1053
- assert_match(/(EOFError|end of file reached) in corrupt.gem/i, e.message)
1054
-
1055
- e = assert_raise Gem::Package::FormatError do
1056
- package.extract_files @destination
1057
- end
1058
-
1059
- assert_match(/(EOFError|end of file reached) in corrupt.gem/i, e.message)
1060
- end
1061
-
1062
- def test_verify_empty
1063
- FileUtils.touch "empty.gem"
1064
-
1065
- package = Gem::Package.new "empty.gem"
1066
-
1067
- e = assert_raise Gem::Package::FormatError do
1068
- package.verify
1069
- end
1070
-
1071
- assert_equal "package metadata is missing in empty.gem", e.message
1072
- end
1073
-
1074
- def test_verify_nonexistent
1075
- package = Gem::Package.new "nonexistent.gem"
1076
-
1077
- e = assert_raise Gem::Package::FormatError do
1078
- package.verify
1079
- end
1080
-
1081
- assert_match %r{^No such file or directory}, e.message
1082
- assert_match %r{nonexistent.gem$}, e.message
1083
- end
1084
-
1085
- def test_verify_duplicate_file
1086
- FileUtils.mkdir_p "lib"
1087
- FileUtils.touch "lib/code.rb"
1088
-
1089
- build = Gem::Package.new @gem
1090
- build.spec = @spec
1091
- build.setup_signer
1092
- File.open @gem, "wb" do |gem_io|
1093
- Gem::Package::TarWriter.new gem_io do |gem|
1094
- build.add_metadata gem
1095
- build.add_contents gem
1096
-
1097
- gem.add_file_simple "a.sig", 0o444, 0
1098
- gem.add_file_simple "a.sig", 0o444, 0
1099
- end
1100
- end
1101
-
1102
- package = Gem::Package.new @gem
1103
-
1104
- e = assert_raise Gem::Security::Exception do
1105
- package.verify
1106
- end
1107
-
1108
- assert_equal 'duplicate files in the package: ("a.sig")', e.message
1109
- end
1110
-
1111
- def test_verify_security_policy
1112
- pend "openssl is missing" unless Gem::HAVE_OPENSSL
1113
-
1114
- package = Gem::Package.new @gem
1115
- package.security_policy = Gem::Security::HighSecurity
1116
-
1117
- e = assert_raise Gem::Security::Exception do
1118
- package.verify
1119
- end
1120
-
1121
- assert_equal "unsigned gems are not allowed by the High Security policy",
1122
- e.message
1123
-
1124
- refute package.instance_variable_get(:@spec), "@spec must not be loaded"
1125
- assert_empty package.instance_variable_get(:@files), "@files must empty"
1126
- end
1127
-
1128
- def test_verify_security_policy_low_security
1129
- pend "openssl is missing" unless Gem::HAVE_OPENSSL
1130
-
1131
- @spec.cert_chain = [PUBLIC_CERT.to_pem]
1132
- @spec.signing_key = PRIVATE_KEY
1133
-
1134
- FileUtils.mkdir_p "lib"
1135
- FileUtils.touch "lib/code.rb"
1136
-
1137
- build = Gem::Package.new @gem
1138
- build.spec = @spec
1139
-
1140
- build.build
1141
-
1142
- package = Gem::Package.new @gem
1143
- package.security_policy = Gem::Security::LowSecurity
1144
-
1145
- assert package.verify
1146
- end
1147
-
1148
- def test_verify_security_policy_checksum_missing
1149
- pend "openssl is missing" unless Gem::HAVE_OPENSSL
1150
-
1151
- @spec.cert_chain = [PUBLIC_CERT.to_pem]
1152
- @spec.signing_key = PRIVATE_KEY
1153
-
1154
- build = Gem::Package.new @gem
1155
- build.spec = @spec
1156
- build.setup_signer
1157
-
1158
- FileUtils.mkdir "lib"
1159
- FileUtils.touch "lib/code.rb"
1160
-
1161
- File.open @gem, "wb" do |gem_io|
1162
- Gem::Package::TarWriter.new gem_io do |gem|
1163
- build.add_metadata gem
1164
- build.add_contents gem
1165
-
1166
- # write bogus data.tar.gz to foil signature
1167
- bogus_data = Gem::Util.gzip "hello"
1168
- fake_signer = Class.new do
1169
- def digest_name; "SHA512"; end
1170
- def digest_algorithm; OpenSSL::Digest(:SHA512).new; end
1171
- def key; "key"; end
1172
- def sign(*); "fake_sig"; end
1173
- end
1174
- gem.add_file_signed "data2.tar.gz", 0o444, fake_signer.new do |io|
1175
- io.write bogus_data
1176
- end
1177
-
1178
- # pre rubygems 2.0 gems do not add checksums
1179
- end
1180
- end
1181
-
1182
- Gem::Security.trust_dir.trust_cert PUBLIC_CERT
1183
-
1184
- package = Gem::Package.new @gem
1185
- package.security_policy = Gem::Security::HighSecurity
1186
-
1187
- e = assert_raise Gem::Security::Exception do
1188
- package.verify
1189
- end
1190
-
1191
- assert_equal "invalid signature", e.message
1192
-
1193
- refute package.instance_variable_get(:@spec), "@spec must not be loaded"
1194
- assert_empty package.instance_variable_get(:@files), "@files must empty"
1195
- end
1196
-
1197
- def test_verify_truncate
1198
- File.open "bad.gem", "wb" do |io|
1199
- io.write File.read(@gem, 1024) # don't care about newlines
1200
- end
1201
-
1202
- package = Gem::Package.new "bad.gem"
1203
-
1204
- e = assert_raise Gem::Package::FormatError do
1205
- package.verify
1206
- end
1207
-
1208
- assert_equal "package content (data.tar.gz) is missing in bad.gem",
1209
- e.message
1210
- end
1211
-
1212
- # end #verify tests
1213
-
1214
- def test_verify_entry
1215
- entry = Object.new
1216
- def entry.full_name() raise ArgumentError, "whatever" end
1217
-
1218
- package = Gem::Package.new @gem
1219
-
1220
- _, err = use_ui @ui do
1221
- e = nil
1222
-
1223
- out_err = capture_output do
1224
- e = assert_raise ArgumentError do
1225
- package.verify_entry entry
1226
- end
1227
- end
1228
-
1229
- assert_equal "whatever", e.message
1230
- assert_equal "full_name", e.backtrace_locations.first.label
1231
-
1232
- out_err
1233
- end
1234
-
1235
- assert_equal "Exception while verifying #{@gem}\n", err
1236
-
1237
- valid_metadata = ["metadata", "metadata.gz"]
1238
- valid_metadata.each do |vm|
1239
- $spec_loaded = false
1240
- $good_name = vm
1241
-
1242
- entry = Object.new
1243
- def entry.full_name() $good_name end
1244
-
1245
- package = Gem::Package.new(@gem)
1246
- package.instance_variable_set(:@files, [])
1247
- def package.load_spec(entry) $spec_loaded = true end
1248
-
1249
- package.verify_entry(entry)
1250
-
1251
- assert $spec_loaded
1252
- end
1253
-
1254
- invalid_metadata = ["metadataxgz", "foobar\nmetadata", "metadata\nfoobar"]
1255
- invalid_metadata.each do |vm|
1256
- $spec_loaded = false
1257
- $bad_name = vm
1258
-
1259
- entry = Object.new
1260
- def entry.full_name() $bad_name end
1261
-
1262
- package = Gem::Package.new(@gem)
1263
- package.instance_variable_set(:@files, [])
1264
- def package.load_spec(entry) $spec_loaded = true end
1265
-
1266
- package.verify_entry(entry)
1267
-
1268
- refute $spec_loaded
1269
- end
1270
- end
1271
-
1272
- def test_spec
1273
- package = Gem::Package.new @gem
1274
-
1275
- assert_equal @spec, package.spec
1276
- end
1277
-
1278
- def test_gem_attr
1279
- package = Gem::Package.new(@gem)
1280
- assert_equal(@gem, package.gem.path)
1281
- end
1282
-
1283
- def test_spec_from_io
1284
- # This functionality is used by rubygems.org to extract spec data from an
1285
- # uploaded gem before it is written to storage.
1286
- io = StringIO.new Gem.read_binary @gem
1287
- package = Gem::Package.new io
1288
-
1289
- assert_equal @spec, package.spec
1290
- end
1291
-
1292
- def test_spec_from_io_raises_gem_error_for_io_not_at_start
1293
- io = StringIO.new Gem.read_binary @gem
1294
- io.read(1)
1295
- assert_raise(Gem::Package::Error) do
1296
- Gem::Package.new io
1297
- end
1298
- end
1299
-
1300
- def test_contents_from_io
1301
- io = StringIO.new Gem.read_binary @gem
1302
- package = Gem::Package.new io
1303
-
1304
- assert_equal %w[lib/code.rb], package.contents
1305
- end
1306
- end