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,1227 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "helper"
4
-
5
- require "webrick"
6
- require "webrick/https" if Gem::HAVE_OPENSSL
7
-
8
- unless Gem::HAVE_OPENSSL
9
- warn "Skipping Gem::RemoteFetcher tests. openssl not found."
10
- end
11
-
12
- require "rubygems/remote_fetcher"
13
- require "rubygems/package"
14
-
15
- # = Testing Proxy Settings
16
- #
17
- # These tests check the proper proxy server settings by running two
18
- # web servers. The web server at http://localhost:#{SERVER_PORT}
19
- # represents the normal gem server and returns a gemspec with a rake
20
- # version of 0.4.11. The web server at http://localhost:#{PROXY_PORT}
21
- # represents the proxy server and returns a different dataset where
22
- # rake has version 0.4.2. This allows us to detect which server is
23
- # returning the data.
24
- #
25
- # Note that the proxy server is not a *real* proxy server. But our
26
- # software doesn't really care, as long as we hit the proxy URL when a
27
- # proxy is configured.
28
-
29
- class TestGemRemoteFetcher < Gem::TestCase
30
- include Gem::DefaultUserInteraction
31
-
32
- SERVER_DATA = <<-EOY
33
- --- !ruby/object:Gem::Cache
34
- gems:
35
- rake-0.4.11: !ruby/object:Gem::Specification
36
- rubygems_version: "0.7"
37
- specification_version: 1
38
- name: rake
39
- version: !ruby/object:Gem::Version
40
- version: 0.4.11
41
- date: 2004-11-12
42
- summary: Ruby based make-like utility.
43
- require_paths:
44
- - lib
45
- author: Jim Weirich
46
- email: jim@weirichhouse.org
47
- homepage: http://rake.rubyforge.org
48
- description: Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax.
49
- autorequire:
50
- bindir: bin
51
- has_rdoc: true
52
- required_ruby_version: !ruby/object:Gem::Version::Requirement
53
- requirements:
54
- -
55
- - ">"
56
- - !ruby/object:Gem::Version
57
- version: 0.0.0
58
- version:
59
- platform: ruby
60
- files:
61
- - README
62
- test_files: []
63
- library_stubs:
64
- rdoc_options:
65
- extra_rdoc_files:
66
- executables:
67
- - rake
68
- extensions: []
69
- requirements: []
70
- dependencies: []
71
- EOY
72
-
73
- PROXY_DATA = SERVER_DATA.gsub(/0.4.11/, "0.4.2")
74
-
75
- # Generated via:
76
- # x = OpenSSL::PKey::DH.new(2048) # wait a while...
77
- # x.to_s => pem
78
- TEST_KEY_DH2048 = OpenSSL::PKey::DH.new <<-_END_OF_PEM_
79
- -----BEGIN DH PARAMETERS-----
80
- MIIBCAKCAQEA3Ze2EHSfYkZLUn557torAmjBgPsqzbodaRaGZtgK1gEU+9nNJaFV
81
- G1JKhmGUiEDyIW7idsBpe4sX/Wqjnp48Lr8IeI/SlEzLdoGpf05iRYXC8Cm9o8aM
82
- cfmVgoSEAo9YLBpzoji2jHkO7Q5IPt4zxbTdlmmGFLc/GO9q7LGHhC+rcMcNTGsM
83
- 49AnILNn49pq4Y72jSwdmvq4psHZwwFBbPwLdw6bLUDDCN90jfqvYt18muwUxDiN
84
- NP0fuvVAIB158VnQ0liHSwcl6+9vE1mL0Jo/qEXQxl0+UdKDjaGfTsn6HIrwTnmJ
85
- PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
86
- -----END DH PARAMETERS-----
87
- _END_OF_PEM_
88
-
89
- def setup
90
- @proxies = %w[https_proxy http_proxy HTTP_PROXY http_proxy_user HTTP_PROXY_USER http_proxy_pass HTTP_PROXY_PASS no_proxy NO_PROXY]
91
- @old_proxies = @proxies.map {|k| ENV[k] }
92
- @proxies.each {|k| ENV[k] = nil }
93
-
94
- super
95
- start_servers
96
- self.enable_yaml = true
97
- self.enable_zip = false
98
-
99
- base_server_uri = "http://localhost:#{normal_server_port}"
100
- @proxy_uri = "http://localhost:#{proxy_server_port}"
101
-
102
- @server_uri = base_server_uri + "/yaml"
103
- @server_z_uri = base_server_uri + "/yaml.Z"
104
-
105
- @cache_dir = File.join @gemhome, "cache"
106
-
107
- # TODO: why does the remote fetcher need it written to disk?
108
- @a1, @a1_gem = util_gem "a", "1" do |s|
109
- s.executables << "a_bin"
110
- end
111
-
112
- @a1.loaded_from = File.join(@gemhome, "specifications", @a1.full_name)
113
-
114
- Gem::RemoteFetcher.fetcher = nil
115
- @stub_ui = Gem::MockGemUi.new
116
- @fetcher = Gem::RemoteFetcher.fetcher
117
- end
118
-
119
- def teardown
120
- @fetcher.close_all
121
- stop_servers
122
- super
123
- Gem.configuration[:http_proxy] = nil
124
- @proxies.each_with_index {|k, i| ENV[k] = @old_proxies[i] }
125
- end
126
-
127
- def test_self_fetcher
128
- fetcher = Gem::RemoteFetcher.fetcher
129
- refute_nil fetcher
130
- assert_kind_of Gem::RemoteFetcher, fetcher
131
- end
132
-
133
- def test_self_fetcher_with_proxy
134
- proxy_uri = "http://proxy.example.com"
135
- Gem.configuration[:http_proxy] = proxy_uri
136
- Gem::RemoteFetcher.fetcher = nil
137
-
138
- fetcher = Gem::RemoteFetcher.fetcher
139
-
140
- refute_nil fetcher
141
- assert_kind_of Gem::RemoteFetcher, fetcher
142
- assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy).to_s
143
- end
144
-
145
- def test_fetch_path_bad_uri
146
- fetcher = Gem::RemoteFetcher.new nil
147
- @fetcher = fetcher
148
-
149
- e = assert_raise ArgumentError do
150
- @fetcher.fetch_path("gems.example.com/yaml", nil, true)
151
- end
152
-
153
- assert_equal "uri scheme is invalid: nil", e.message
154
- end
155
-
156
- def test_no_proxy
157
- use_ui @stub_ui do
158
- assert_data_from_server @fetcher.fetch_path(@server_uri)
159
- response = @fetcher.fetch_path(@server_uri, nil, true)
160
- assert_equal SERVER_DATA.size, response["content-length"].to_i
161
- end
162
- end
163
-
164
- def test_cache_update_path
165
- uri = URI "http://example/file"
166
- path = File.join @tempdir, "file"
167
-
168
- fetcher = util_fuck_with_fetcher "hello"
169
-
170
- data = fetcher.cache_update_path uri, path
171
-
172
- assert_equal "hello", data
173
-
174
- assert_equal "hello", File.read(path)
175
- end
176
-
177
- def test_cache_update_path_with_utf8_internal_encoding
178
- with_internal_encoding("UTF-8") do
179
- uri = URI "http://example/file"
180
- path = File.join @tempdir, "file"
181
- data = String.new("\xC8").force_encoding(Encoding::BINARY)
182
-
183
- fetcher = util_fuck_with_fetcher data
184
-
185
- written_data = fetcher.cache_update_path uri, path
186
-
187
- assert_equal data, written_data
188
- assert_equal data, File.binread(path)
189
- end
190
- end
191
-
192
- def test_cache_update_path_no_update
193
- uri = URI "http://example/file"
194
- path = File.join @tempdir, "file"
195
-
196
- fetcher = util_fuck_with_fetcher "hello"
197
-
198
- data = fetcher.cache_update_path uri, path, false
199
-
200
- assert_equal "hello", data
201
-
202
- assert_path_not_exist path
203
- end
204
-
205
- def util_fuck_with_fetcher(data, blow = false)
206
- fetcher = Gem::RemoteFetcher.fetcher
207
- fetcher.instance_variable_set :@test_data, data
208
-
209
- unless blow
210
- def fetcher.fetch_path(arg, *rest)
211
- @test_arg = arg
212
- @test_data
213
- end
214
- else
215
- def fetcher.fetch_path(arg, *rest)
216
- # OMG I'm such an ass
217
- class << self; remove_method :fetch_path; end
218
- def self.fetch_path(arg, *rest)
219
- @test_arg = arg
220
- @test_data
221
- end
222
-
223
- raise Gem::RemoteFetcher::FetchError.new("haha!", "")
224
- end
225
- end
226
-
227
- fetcher
228
- end
229
-
230
- def test_download
231
- a1_data = nil
232
- File.open @a1_gem, "rb" do |fp|
233
- a1_data = fp.read
234
- end
235
-
236
- fetcher = util_fuck_with_fetcher a1_data
237
-
238
- a1_cache_gem = @a1.cache_file
239
- assert_equal a1_cache_gem, fetcher.download(@a1, "http://gems.example.com")
240
- assert_equal("http://gems.example.com/gems/a-1.gem",
241
- fetcher.instance_variable_get(:@test_arg).to_s)
242
- assert File.exist?(a1_cache_gem)
243
- end
244
-
245
- def test_download_with_auth
246
- a1_data = nil
247
- File.open @a1_gem, "rb" do |fp|
248
- a1_data = fp.read
249
- end
250
-
251
- fetcher = util_fuck_with_fetcher a1_data
252
-
253
- a1_cache_gem = @a1.cache_file
254
- assert_equal a1_cache_gem, fetcher.download(@a1, "http://user:password@gems.example.com")
255
- assert_equal("http://user:password@gems.example.com/gems/a-1.gem",
256
- fetcher.instance_variable_get(:@test_arg).to_s)
257
- assert File.exist?(a1_cache_gem)
258
- end
259
-
260
- def test_download_with_token
261
- a1_data = nil
262
- File.open @a1_gem, "rb" do |fp|
263
- a1_data = fp.read
264
- end
265
-
266
- fetcher = util_fuck_with_fetcher a1_data
267
-
268
- a1_cache_gem = @a1.cache_file
269
- assert_equal a1_cache_gem, fetcher.download(@a1, "http://token@gems.example.com")
270
- assert_equal("http://token@gems.example.com/gems/a-1.gem",
271
- fetcher.instance_variable_get(:@test_arg).to_s)
272
- assert File.exist?(a1_cache_gem)
273
- end
274
-
275
- def test_download_with_x_oauth_basic
276
- a1_data = nil
277
- File.open @a1_gem, "rb" do |fp|
278
- a1_data = fp.read
279
- end
280
-
281
- fetcher = util_fuck_with_fetcher a1_data
282
-
283
- a1_cache_gem = @a1.cache_file
284
- assert_equal a1_cache_gem, fetcher.download(@a1, "http://token:x-oauth-basic@gems.example.com")
285
- assert_equal("http://token:x-oauth-basic@gems.example.com/gems/a-1.gem",
286
- fetcher.instance_variable_get(:@test_arg).to_s)
287
- assert File.exist?(a1_cache_gem)
288
- end
289
-
290
- def test_download_with_encoded_auth
291
- a1_data = nil
292
- File.open @a1_gem, "rb" do |fp|
293
- a1_data = fp.read
294
- end
295
-
296
- fetcher = util_fuck_with_fetcher a1_data
297
-
298
- a1_cache_gem = @a1.cache_file
299
- assert_equal a1_cache_gem, fetcher.download(@a1, "http://user:%25pas%25sword@gems.example.com")
300
- assert_equal("http://user:%25pas%25sword@gems.example.com/gems/a-1.gem",
301
- fetcher.instance_variable_get(:@test_arg).to_s)
302
- assert File.exist?(a1_cache_gem)
303
- end
304
-
305
- def test_download_cached
306
- FileUtils.mv @a1_gem, @cache_dir
307
-
308
- inst = Gem::RemoteFetcher.fetcher
309
-
310
- assert_equal @a1.cache_file, inst.download(@a1, "http://gems.example.com")
311
- end
312
-
313
- def test_download_local
314
- FileUtils.mv @a1_gem, @tempdir
315
- local_path = File.join @tempdir, @a1.file_name
316
- inst = nil
317
-
318
- Dir.chdir @tempdir do
319
- inst = Gem::RemoteFetcher.fetcher
320
- end
321
-
322
- assert_equal @a1.cache_file, inst.download(@a1, local_path)
323
- end
324
-
325
- def test_download_local_space
326
- space_path = File.join @tempdir, "space path"
327
- FileUtils.mkdir space_path
328
- FileUtils.mv @a1_gem, space_path
329
- local_path = File.join space_path, @a1.file_name
330
- inst = nil
331
-
332
- Dir.chdir @tempdir do
333
- inst = Gem::RemoteFetcher.fetcher
334
- end
335
-
336
- assert_equal @a1.cache_file, inst.download(@a1, local_path)
337
- end
338
-
339
- def test_download_install_dir
340
- a1_data = File.open @a1_gem, "rb" do |fp|
341
- fp.read
342
- end
343
-
344
- fetcher = util_fuck_with_fetcher a1_data
345
-
346
- install_dir = File.join @tempdir, "more_gems"
347
-
348
- a1_cache_gem = File.join install_dir, "cache", @a1.file_name
349
- FileUtils.mkdir_p(File.dirname(a1_cache_gem))
350
- actual = fetcher.download(@a1, "http://gems.example.com", install_dir)
351
-
352
- assert_equal a1_cache_gem, actual
353
- assert_equal("http://gems.example.com/gems/a-1.gem",
354
- fetcher.instance_variable_get(:@test_arg).to_s)
355
-
356
- assert File.exist?(a1_cache_gem)
357
- end
358
-
359
- unless win_platform? || Process.uid.zero? # File.chmod doesn't work
360
- def test_download_local_read_only
361
- FileUtils.mv @a1_gem, @tempdir
362
- local_path = File.join @tempdir, @a1.file_name
363
- inst = nil
364
- FileUtils.chmod 0o555, @a1.cache_dir
365
- begin
366
- FileUtils.mkdir_p File.join(Gem.user_dir, "cache")
367
- rescue StandardError
368
- nil
369
- end
370
- FileUtils.chmod 0o555, File.join(Gem.user_dir, "cache")
371
-
372
- Dir.chdir @tempdir do
373
- inst = Gem::RemoteFetcher.fetcher
374
- end
375
-
376
- assert_equal(File.join(@tempdir, @a1.file_name),
377
- inst.download(@a1, local_path))
378
- ensure
379
- FileUtils.chmod 0o755, File.join(Gem.user_dir, "cache")
380
- FileUtils.chmod 0o755, @a1.cache_dir
381
- end
382
-
383
- def test_download_read_only
384
- FileUtils.chmod 0o555, @a1.cache_dir
385
- FileUtils.chmod 0o555, @gemhome
386
-
387
- fetcher = util_fuck_with_fetcher File.read(@a1_gem)
388
- fetcher.download(@a1, "http://gems.example.com")
389
- a1_cache_gem = File.join Gem.user_dir, "cache", @a1.file_name
390
- assert File.exist? a1_cache_gem
391
- ensure
392
- FileUtils.chmod 0o755, @gemhome
393
- FileUtils.chmod 0o755, @a1.cache_dir
394
- end
395
- end
396
-
397
- def test_download_platform_legacy
398
- original_platform = "old-platform"
399
-
400
- e1, e1_gem = util_gem "e", "1" do |s|
401
- s.platform = Gem::Platform::CURRENT
402
- s.instance_variable_set :@original_platform, original_platform
403
- end
404
- e1.loaded_from = File.join(@gemhome, "specifications", e1.full_name)
405
-
406
- e1_data = nil
407
- File.open e1_gem, "rb" do |fp|
408
- e1_data = fp.read
409
- end
410
-
411
- fetcher = util_fuck_with_fetcher e1_data, :blow_chunks
412
-
413
- e1_cache_gem = e1.cache_file
414
-
415
- assert_equal e1_cache_gem, fetcher.download(e1, "http://gems.example.com")
416
-
417
- assert_equal("http://gems.example.com/gems/#{e1.original_name}.gem",
418
- fetcher.instance_variable_get(:@test_arg).to_s)
419
- assert File.exist?(e1_cache_gem)
420
- end
421
-
422
- def test_download_same_file
423
- FileUtils.mv @a1_gem, @tempdir
424
- local_path = File.join @tempdir, @a1.file_name
425
- inst = nil
426
-
427
- Dir.chdir @tempdir do
428
- inst = Gem::RemoteFetcher.fetcher
429
- end
430
-
431
- cache_path = @a1.cache_file
432
- FileUtils.mv local_path, cache_path
433
-
434
- gem = Gem::Package.new cache_path
435
-
436
- assert_equal cache_path, inst.download(gem.spec, cache_path)
437
- end
438
-
439
- def test_download_unsupported
440
- inst = Gem::RemoteFetcher.fetcher
441
-
442
- e = assert_raise ArgumentError do
443
- inst.download @a1, "ftp://gems.rubyforge.org"
444
- end
445
-
446
- assert_equal "unsupported URI scheme ftp", e.message
447
- end
448
-
449
- def test_download_to_cache
450
- @a2, @a2_gem = util_gem "a", "2"
451
-
452
- util_setup_spec_fetcher @a1, @a2
453
- @fetcher.instance_variable_set :@a1, @a1
454
- @fetcher.instance_variable_set :@a2, @a2
455
- def @fetcher.fetch_path(uri, mtime = nil, head = false)
456
- case uri.request_uri
457
- when /#{@a1.spec_name}/ then
458
- Gem.deflate Marshal.dump @a1
459
- when /#{@a2.spec_name}/ then
460
- Gem.deflate Marshal.dump @a2
461
- else
462
- uri.to_s
463
- end
464
- end
465
-
466
- gem = Gem::RemoteFetcher.fetcher.download_to_cache dep "a"
467
-
468
- assert_equal @a2.file_name, File.basename(gem)
469
- end
470
-
471
- def test_fetch_path_gzip
472
- fetcher = Gem::RemoteFetcher.new nil
473
- @fetcher = fetcher
474
-
475
- def fetcher.fetch_http(uri, mtime, head = nil)
476
- Gem::Util.gzip "foo"
477
- end
478
-
479
- assert_equal "foo", fetcher.fetch_path(@uri + "foo.gz")
480
- end
481
-
482
- def test_fetch_path_gzip_unmodified
483
- fetcher = Gem::RemoteFetcher.new nil
484
- @fetcher = fetcher
485
-
486
- def fetcher.fetch_http(uri, mtime, head = nil)
487
- nil
488
- end
489
-
490
- assert_nil fetcher.fetch_path(@uri + "foo.gz", Time.at(0))
491
- end
492
-
493
- def test_fetch_path_io_error
494
- fetcher = Gem::RemoteFetcher.new nil
495
- @fetcher = fetcher
496
-
497
- def fetcher.fetch_http(*)
498
- raise EOFError
499
- end
500
-
501
- url = "http://example.com/uri"
502
-
503
- e = assert_raise Gem::RemoteFetcher::FetchError do
504
- fetcher.fetch_path url
505
- end
506
-
507
- assert_equal "EOFError: EOFError (#{url})", e.message
508
- assert_equal url, e.uri
509
- end
510
-
511
- def test_fetch_path_socket_error
512
- fetcher = Gem::RemoteFetcher.new nil
513
- @fetcher = fetcher
514
-
515
- def fetcher.fetch_http(uri, mtime, head = nil)
516
- raise SocketError
517
- end
518
-
519
- url = "http://example.com/uri"
520
-
521
- e = assert_raise Gem::RemoteFetcher::FetchError do
522
- fetcher.fetch_path url
523
- end
524
-
525
- assert_equal "SocketError: SocketError (#{url})", e.message
526
- assert_equal url, e.uri
527
- end
528
-
529
- def test_fetch_path_system_call_error
530
- fetcher = Gem::RemoteFetcher.new nil
531
- @fetcher = fetcher
532
-
533
- def fetcher.fetch_http(uri, mtime = nil, head = nil)
534
- raise Errno::ECONNREFUSED, "connect(2)"
535
- end
536
-
537
- url = "http://example.com/uri"
538
-
539
- e = assert_raise Gem::RemoteFetcher::FetchError do
540
- fetcher.fetch_path url
541
- end
542
-
543
- assert_match %r{ECONNREFUSED:.*connect\(2\) \(#{Regexp.escape url}\)\z},
544
- e.message
545
- assert_equal url, e.uri
546
- end
547
-
548
- def test_fetch_path_timeout_error
549
- fetcher = Gem::RemoteFetcher.new nil
550
- @fetcher = fetcher
551
-
552
- def fetcher.fetch_http(uri, mtime = nil, head = nil)
553
- raise Timeout::Error, "timed out"
554
- end
555
-
556
- url = "http://example.com/uri"
557
-
558
- e = assert_raise Gem::RemoteFetcher::FetchError do
559
- fetcher.fetch_path url
560
- end
561
-
562
- assert_match %r{Timeout::Error: timed out \(#{Regexp.escape url}\)\z},
563
- e.message
564
- assert_equal url, e.uri
565
- end
566
-
567
- def test_fetch_path_getaddrinfo_error
568
- fetcher = Gem::RemoteFetcher.new nil
569
- @fetcher = fetcher
570
-
571
- def fetcher.fetch_http(uri, mtime = nil, head = nil)
572
- raise SocketError, "getaddrinfo: nodename nor servname provided"
573
- end
574
-
575
- url = "http://example.com/uri"
576
-
577
- e = assert_raise Gem::RemoteFetcher::FetchError do
578
- fetcher.fetch_path url
579
- end
580
-
581
- assert_match %r{SocketError: getaddrinfo: nodename nor servname provided \(#{Regexp.escape url}\)\z},
582
- e.message
583
- assert_equal url, e.uri
584
- end
585
-
586
- def test_fetch_path_openssl_ssl_sslerror
587
- fetcher = Gem::RemoteFetcher.new nil
588
- @fetcher = fetcher
589
-
590
- def fetcher.fetch_http(uri, mtime = nil, head = nil)
591
- raise OpenSSL::SSL::SSLError
592
- end
593
-
594
- url = "http://example.com/uri"
595
-
596
- e = assert_raise Gem::RemoteFetcher::FetchError do
597
- fetcher.fetch_path url
598
- end
599
-
600
- assert_equal "OpenSSL::SSL::SSLError: OpenSSL::SSL::SSLError (#{url})", e.message
601
- assert_equal url, e.uri
602
- end
603
-
604
- def test_fetch_path_unmodified
605
- fetcher = Gem::RemoteFetcher.new nil
606
- @fetcher = fetcher
607
-
608
- def fetcher.fetch_http(uri, mtime, head = nil)
609
- nil
610
- end
611
-
612
- assert_nil fetcher.fetch_path(URI.parse(@gem_repo), Time.at(0))
613
- end
614
-
615
- def test_implicit_no_proxy
616
- use_ui @stub_ui do
617
- ENV["http_proxy"] = "http://fakeurl:12345"
618
- fetcher = Gem::RemoteFetcher.new :no_proxy
619
- @fetcher = fetcher
620
- assert_data_from_server fetcher.fetch_path(@server_uri)
621
- end
622
- end
623
-
624
- def test_implicit_proxy
625
- use_ui @stub_ui do
626
- ENV["http_proxy"] = @proxy_uri
627
- fetcher = Gem::RemoteFetcher.new nil
628
- @fetcher = fetcher
629
- assert_data_from_proxy fetcher.fetch_path(@server_uri)
630
- end
631
- end
632
-
633
- def test_implicit_upper_case_proxy
634
- use_ui @stub_ui do
635
- ENV["HTTP_PROXY"] = @proxy_uri
636
- fetcher = Gem::RemoteFetcher.new nil
637
- @fetcher = fetcher
638
- assert_data_from_proxy fetcher.fetch_path(@server_uri)
639
- end
640
- end
641
-
642
- def test_implicit_proxy_no_env
643
- use_ui @stub_ui do
644
- fetcher = Gem::RemoteFetcher.new nil
645
- @fetcher = fetcher
646
- assert_data_from_server fetcher.fetch_path(@server_uri)
647
- end
648
- end
649
-
650
- def test_fetch_http
651
- fetcher = Gem::RemoteFetcher.new nil
652
- @fetcher = fetcher
653
- url = "http://gems.example.com/redirect"
654
-
655
- def fetcher.request(uri, request_class, last_modified = nil)
656
- url = "http://gems.example.com/redirect"
657
- unless defined? @requested
658
- @requested = true
659
- res = Net::HTTPMovedPermanently.new nil, 301, nil
660
- res.add_field "Location", url
661
- res
662
- else
663
- res = Net::HTTPOK.new nil, 200, nil
664
- def res.body() "real_path" end
665
- res
666
- end
667
- end
668
-
669
- data = fetcher.fetch_http URI.parse(url)
670
-
671
- assert_equal "real_path", data
672
- end
673
-
674
- def test_fetch_http_redirects
675
- fetcher = Gem::RemoteFetcher.new nil
676
- @fetcher = fetcher
677
- url = "http://gems.example.com/redirect"
678
-
679
- def fetcher.request(uri, request_class, last_modified = nil)
680
- url = "http://gems.example.com/redirect"
681
- res = Net::HTTPMovedPermanently.new nil, 301, nil
682
- res.add_field "Location", url
683
- res
684
- end
685
-
686
- e = assert_raise Gem::RemoteFetcher::FetchError do
687
- fetcher.fetch_http URI.parse(url)
688
- end
689
-
690
- assert_equal "too many redirects (#{url})", e.message
691
- end
692
-
693
- def test_fetch_http_redirects_without_location
694
- fetcher = Gem::RemoteFetcher.new nil
695
- @fetcher = fetcher
696
- url = "http://gems.example.com/redirect"
697
-
698
- def fetcher.request(uri, request_class, last_modified = nil)
699
- res = Net::HTTPMovedPermanently.new nil, 301, nil
700
- res
701
- end
702
-
703
- e = assert_raise Gem::RemoteFetcher::FetchError do
704
- fetcher.fetch_http URI.parse(url)
705
- end
706
-
707
- assert_equal "redirecting but no redirect location was given (#{url})", e.message
708
- end
709
-
710
- def test_fetch_http_with_additional_headers
711
- ENV["http_proxy"] = @proxy_uri
712
- ENV["no_proxy"] = URI::parse(@server_uri).host
713
- fetcher = Gem::RemoteFetcher.new nil, nil, { "X-Captain" => "murphy" }
714
- @fetcher = fetcher
715
- assert_equal "murphy", fetcher.fetch_path(@server_uri)
716
- end
717
-
718
- def assert_fetch_s3(url, signature, token=nil, region="us-east-1", instance_profile_json=nil)
719
- fetcher = Gem::RemoteFetcher.new nil
720
- @fetcher = fetcher
721
- $fetched_uri = nil
722
- $instance_profile = instance_profile_json
723
-
724
- def fetcher.request(uri, request_class, last_modified = nil)
725
- $fetched_uri = uri
726
- res = Net::HTTPOK.new nil, 200, nil
727
- def res.body() "success" end
728
- res
729
- end
730
-
731
- def fetcher.s3_uri_signer(uri)
732
- require "json"
733
- s3_uri_signer = Gem::S3URISigner.new(uri)
734
- def s3_uri_signer.ec2_metadata_credentials_json
735
- JSON.parse($instance_profile)
736
- end
737
- # Running sign operation to make sure uri.query is not mutated
738
- s3_uri_signer.sign
739
- raise "URI query is not empty: #{uri.query}" unless uri.query.nil?
740
- s3_uri_signer
741
- end
742
-
743
- data = fetcher.fetch_s3 URI.parse(url)
744
-
745
- assert_equal "https://my-bucket.s3.#{region}.amazonaws.com/gems/specs.4.8.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=testuser%2F20190624%2F#{region}%2Fs3%2Faws4_request&X-Amz-Date=20190624T050641Z&X-Amz-Expires=86400#{token ? "&X-Amz-Security-Token=" + token : ""}&X-Amz-SignedHeaders=host&X-Amz-Signature=#{signature}", $fetched_uri.to_s
746
- assert_equal "success", data
747
- ensure
748
- $fetched_uri = nil
749
- end
750
-
751
- def test_fetch_s3_config_creds
752
- Gem.configuration[:s3_source] = {
753
- "my-bucket" => { :id => "testuser", :secret => "testpass" },
754
- }
755
- url = "s3://my-bucket/gems/specs.4.8.gz"
756
- Time.stub :now, Time.at(1_561_353_581) do
757
- assert_fetch_s3 url, "20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b"
758
- end
759
- ensure
760
- Gem.configuration[:s3_source] = nil
761
- end
762
-
763
- def test_fetch_s3_config_creds_with_region
764
- Gem.configuration[:s3_source] = {
765
- "my-bucket" => { :id => "testuser", :secret => "testpass", :region => "us-west-2" },
766
- }
767
- url = "s3://my-bucket/gems/specs.4.8.gz"
768
- Time.stub :now, Time.at(1_561_353_581) do
769
- assert_fetch_s3 url, "4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9", nil, "us-west-2"
770
- end
771
- ensure
772
- Gem.configuration[:s3_source] = nil
773
- end
774
-
775
- def test_fetch_s3_config_creds_with_token
776
- Gem.configuration[:s3_source] = {
777
- "my-bucket" => { :id => "testuser", :secret => "testpass", :security_token => "testtoken" },
778
- }
779
- url = "s3://my-bucket/gems/specs.4.8.gz"
780
- Time.stub :now, Time.at(1_561_353_581) do
781
- assert_fetch_s3 url, "935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c", "testtoken"
782
- end
783
- ensure
784
- Gem.configuration[:s3_source] = nil
785
- end
786
-
787
- def test_fetch_s3_env_creds
788
- ENV["AWS_ACCESS_KEY_ID"] = "testuser"
789
- ENV["AWS_SECRET_ACCESS_KEY"] = "testpass"
790
- ENV["AWS_SESSION_TOKEN"] = nil
791
- Gem.configuration[:s3_source] = {
792
- "my-bucket" => { :provider => "env" },
793
- }
794
- url = "s3://my-bucket/gems/specs.4.8.gz"
795
- Time.stub :now, Time.at(1_561_353_581) do
796
- assert_fetch_s3 url, "20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b"
797
- end
798
- ensure
799
- ENV.each_key {|key| ENV.delete(key) if key.start_with?("AWS") }
800
- Gem.configuration[:s3_source] = nil
801
- end
802
-
803
- def test_fetch_s3_env_creds_with_region
804
- ENV["AWS_ACCESS_KEY_ID"] = "testuser"
805
- ENV["AWS_SECRET_ACCESS_KEY"] = "testpass"
806
- ENV["AWS_SESSION_TOKEN"] = nil
807
- Gem.configuration[:s3_source] = {
808
- "my-bucket" => { :provider => "env", :region => "us-west-2" },
809
- }
810
- url = "s3://my-bucket/gems/specs.4.8.gz"
811
- Time.stub :now, Time.at(1_561_353_581) do
812
- assert_fetch_s3 url, "4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9", nil, "us-west-2"
813
- end
814
- ensure
815
- ENV.each_key {|key| ENV.delete(key) if key.start_with?("AWS") }
816
- Gem.configuration[:s3_source] = nil
817
- end
818
-
819
- def test_fetch_s3_env_creds_with_token
820
- ENV["AWS_ACCESS_KEY_ID"] = "testuser"
821
- ENV["AWS_SECRET_ACCESS_KEY"] = "testpass"
822
- ENV["AWS_SESSION_TOKEN"] = "testtoken"
823
- Gem.configuration[:s3_source] = {
824
- "my-bucket" => { :provider => "env" },
825
- }
826
- url = "s3://my-bucket/gems/specs.4.8.gz"
827
- Time.stub :now, Time.at(1_561_353_581) do
828
- assert_fetch_s3 url, "935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c", "testtoken"
829
- end
830
- ensure
831
- ENV.each_key {|key| ENV.delete(key) if key.start_with?("AWS") }
832
- Gem.configuration[:s3_source] = nil
833
- end
834
-
835
- def test_fetch_s3_url_creds
836
- url = "s3://testuser:testpass@my-bucket/gems/specs.4.8.gz"
837
- Time.stub :now, Time.at(1_561_353_581) do
838
- assert_fetch_s3 url, "20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b"
839
- end
840
- end
841
-
842
- def test_fetch_s3_instance_profile_creds
843
- Gem.configuration[:s3_source] = {
844
- "my-bucket" => { :provider => "instance_profile" },
845
- }
846
-
847
- url = "s3://my-bucket/gems/specs.4.8.gz"
848
- Time.stub :now, Time.at(1_561_353_581) do
849
- assert_fetch_s3 url, "20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b", nil, "us-east-1",
850
- '{"AccessKeyId": "testuser", "SecretAccessKey": "testpass"}'
851
- end
852
- ensure
853
- Gem.configuration[:s3_source] = nil
854
- end
855
-
856
- def test_fetch_s3_instance_profile_creds_with_region
857
- Gem.configuration[:s3_source] = {
858
- "my-bucket" => { :provider => "instance_profile", :region => "us-west-2" },
859
- }
860
-
861
- url = "s3://my-bucket/gems/specs.4.8.gz"
862
- Time.stub :now, Time.at(1_561_353_581) do
863
- assert_fetch_s3 url, "4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9", nil, "us-west-2",
864
- '{"AccessKeyId": "testuser", "SecretAccessKey": "testpass"}'
865
- end
866
- ensure
867
- Gem.configuration[:s3_source] = nil
868
- end
869
-
870
- def test_fetch_s3_instance_profile_creds_with_token
871
- Gem.configuration[:s3_source] = {
872
- "my-bucket" => { :provider => "instance_profile" },
873
- }
874
-
875
- url = "s3://my-bucket/gems/specs.4.8.gz"
876
- Time.stub :now, Time.at(1_561_353_581) do
877
- assert_fetch_s3 url, "935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c", "testtoken", "us-east-1",
878
- '{"AccessKeyId": "testuser", "SecretAccessKey": "testpass", "Token": "testtoken"}'
879
- end
880
- ensure
881
- Gem.configuration[:s3_source] = nil
882
- end
883
-
884
- def refute_fetch_s3(url, expected_message)
885
- fetcher = Gem::RemoteFetcher.new nil
886
- @fetcher = fetcher
887
-
888
- e = assert_raise Gem::RemoteFetcher::FetchError do
889
- fetcher.fetch_s3 URI.parse(url)
890
- end
891
-
892
- assert_match expected_message, e.message
893
- end
894
-
895
- def test_fetch_s3_no_source_key
896
- url = "s3://my-bucket/gems/specs.4.8.gz"
897
- refute_fetch_s3 url, "no s3_source key exists in .gemrc"
898
- end
899
-
900
- def test_fetch_s3_no_host
901
- Gem.configuration[:s3_source] = {
902
- "my-bucket" => { :id => "testuser", :secret => "testpass" },
903
- }
904
-
905
- url = "s3://other-bucket/gems/specs.4.8.gz"
906
- refute_fetch_s3 url, "no key for host other-bucket in s3_source in .gemrc"
907
- ensure
908
- Gem.configuration[:s3_source] = nil
909
- end
910
-
911
- def test_fetch_s3_no_id
912
- Gem.configuration[:s3_source] = { "my-bucket" => { :secret => "testpass" } }
913
-
914
- url = "s3://my-bucket/gems/specs.4.8.gz"
915
- refute_fetch_s3 url, "s3_source for my-bucket missing id or secret"
916
- ensure
917
- Gem.configuration[:s3_source] = nil
918
- end
919
-
920
- def test_fetch_s3_no_secret
921
- Gem.configuration[:s3_source] = { "my-bucket" => { :id => "testuser" } }
922
-
923
- url = "s3://my-bucket/gems/specs.4.8.gz"
924
- refute_fetch_s3 url, "s3_source for my-bucket missing id or secret"
925
- ensure
926
- Gem.configuration[:s3_source] = nil
927
- end
928
-
929
- def test_observe_no_proxy_env_single_host
930
- use_ui @stub_ui do
931
- ENV["http_proxy"] = @proxy_uri
932
- ENV["no_proxy"] = URI::parse(@server_uri).host
933
- fetcher = Gem::RemoteFetcher.new nil
934
- @fetcher = fetcher
935
- assert_data_from_server fetcher.fetch_path(@server_uri)
936
- end
937
- end
938
-
939
- def test_observe_no_proxy_env_list
940
- use_ui @stub_ui do
941
- ENV["http_proxy"] = @proxy_uri
942
- ENV["no_proxy"] = "fakeurl.com, #{URI::parse(@server_uri).host}"
943
- fetcher = Gem::RemoteFetcher.new nil
944
- @fetcher = fetcher
945
- assert_data_from_server fetcher.fetch_path(@server_uri)
946
- end
947
- end
948
-
949
- def test_request_block
950
- fetcher = Gem::RemoteFetcher.new nil
951
- @fetcher = fetcher
952
-
953
- assert_throws :block_called do
954
- fetcher.request URI("http://example"), Net::HTTP::Get do |req|
955
- assert_kind_of Net::HTTPGenericRequest, req
956
- throw :block_called
957
- end
958
- end
959
- end
960
-
961
- def test_yaml_error_on_size
962
- use_ui @stub_ui do
963
- self.enable_yaml = false
964
- fetcher = Gem::RemoteFetcher.new nil
965
- @fetcher = fetcher
966
- assert_error { fetcher.size }
967
- end
968
- end
969
-
970
- def test_ssl_connection
971
- ssl_server = start_ssl_server
972
- temp_ca_cert = File.join(__dir__, "ca_cert.pem")
973
- with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher|
974
- fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
975
- end
976
- end
977
-
978
- def test_ssl_client_cert_auth_connection
979
- ssl_server = start_ssl_server({
980
- :SSLVerifyClient =>
981
- OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT })
982
-
983
- temp_ca_cert = File.join(__dir__, "ca_cert.pem")
984
- temp_client_cert = File.join(__dir__, "client.pem")
985
-
986
- with_configured_fetcher(
987
- ":ssl_ca_cert: #{temp_ca_cert}\n" +
988
- ":ssl_client_cert: #{temp_client_cert}\n") do |fetcher|
989
- fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
990
- end
991
- end
992
-
993
- def test_do_not_allow_invalid_client_cert_auth_connection
994
- ssl_server = start_ssl_server({
995
- :SSLVerifyClient =>
996
- OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT })
997
-
998
- temp_ca_cert = File.join(__dir__, "ca_cert.pem")
999
- temp_client_cert = File.join(__dir__, "invalid_client.pem")
1000
-
1001
- with_configured_fetcher(
1002
- ":ssl_ca_cert: #{temp_ca_cert}\n" +
1003
- ":ssl_client_cert: #{temp_client_cert}\n") do |fetcher|
1004
- assert_raise Gem::RemoteFetcher::FetchError do
1005
- fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
1006
- end
1007
- end
1008
- end
1009
-
1010
- def test_do_not_allow_insecure_ssl_connection_by_default
1011
- ssl_server = start_ssl_server
1012
- with_configured_fetcher do |fetcher|
1013
- assert_raise Gem::RemoteFetcher::FetchError do
1014
- fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
1015
- end
1016
- end
1017
- end
1018
-
1019
- def test_ssl_connection_allow_verify_none
1020
- ssl_server = start_ssl_server
1021
- with_configured_fetcher(":ssl_verify_mode: 0") do |fetcher|
1022
- fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
1023
- end
1024
- end
1025
-
1026
- def test_do_not_follow_insecure_redirect
1027
- ssl_server = start_ssl_server
1028
- temp_ca_cert = File.join(__dir__, "ca_cert.pem")
1029
- expected_error_message =
1030
- "redirecting to non-https resource: #{@server_uri} (https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri})"
1031
-
1032
- with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher|
1033
- err = assert_raise Gem::RemoteFetcher::FetchError do
1034
- fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri}")
1035
- end
1036
-
1037
- assert_equal(err.message, expected_error_message)
1038
- end
1039
- end
1040
-
1041
- def test_nil_ca_cert
1042
- ssl_server = start_ssl_server
1043
- temp_ca_cert = nil
1044
-
1045
- with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher|
1046
- assert_raise Gem::RemoteFetcher::FetchError do
1047
- fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}")
1048
- end
1049
- end
1050
- end
1051
-
1052
- def with_configured_fetcher(config_str = nil, &block)
1053
- if config_str
1054
- temp_conf = File.join @tempdir, ".gemrc"
1055
- File.open temp_conf, "w" do |fp|
1056
- fp.puts config_str
1057
- end
1058
- Gem.configuration = Gem::ConfigFile.new %W[--config-file #{temp_conf}]
1059
- end
1060
- fetcher = Gem::RemoteFetcher.new
1061
- yield fetcher
1062
- ensure
1063
- fetcher.close_all
1064
- Gem.configuration = nil
1065
- end
1066
-
1067
- def assert_error(exception_class=Exception)
1068
- got_exception = false
1069
-
1070
- begin
1071
- yield
1072
- rescue exception_class
1073
- got_exception = true
1074
- end
1075
-
1076
- assert got_exception, "Expected exception conforming to #{exception_class}"
1077
- end
1078
-
1079
- def assert_data_from_server(data)
1080
- assert_match(/0\.4\.11/, data, "Data is not from server")
1081
- end
1082
-
1083
- def assert_data_from_proxy(data)
1084
- assert_match(/0\.4\.2/, data, "Data is not from proxy")
1085
- end
1086
-
1087
- class NilLog < WEBrick::Log
1088
- def log(level, data) #Do nothing
1089
- end
1090
- end
1091
-
1092
- private
1093
-
1094
- attr_reader :normal_server, :proxy_server
1095
- attr_accessor :enable_zip, :enable_yaml
1096
-
1097
- def start_servers
1098
- @normal_server ||= start_server(SERVER_DATA)
1099
- @proxy_server ||= start_server(PROXY_DATA)
1100
- @enable_yaml = true
1101
- @enable_zip = false
1102
- @ssl_server = nil
1103
- @ssl_server_thread = nil
1104
- end
1105
-
1106
- def stop_servers
1107
- if @normal_server
1108
- @normal_server.kill.join
1109
- @normal_server = nil
1110
- end
1111
- if @proxy_server
1112
- @proxy_server.kill.join
1113
- @proxy_server = nil
1114
- end
1115
- if @ssl_server
1116
- @ssl_server.stop
1117
- @ssl_server = nil
1118
- end
1119
- if @ssl_server_thread
1120
- @ssl_server_thread.kill.join
1121
- @ssl_server_thread = nil
1122
- end
1123
- utils = WEBrick::Utils # TimeoutHandler is since 1.9
1124
- utils::TimeoutHandler.terminate if defined?(utils::TimeoutHandler.terminate)
1125
- end
1126
-
1127
- def normal_server_port
1128
- @normal_server[:server].config[:Port]
1129
- end
1130
-
1131
- def proxy_server_port
1132
- @proxy_server[:server].config[:Port]
1133
- end
1134
-
1135
- def start_ssl_server(config = {})
1136
- pend "starting this test server fails randomly on jruby" if Gem.java_platform?
1137
-
1138
- null_logger = NilLog.new
1139
- server = WEBrick::HTTPServer.new({
1140
- :Port => 0,
1141
- :Logger => null_logger,
1142
- :AccessLog => [],
1143
- :SSLEnable => true,
1144
- :SSLCACertificateFile => File.join(__dir__, "ca_cert.pem"),
1145
- :SSLCertificate => cert("ssl_cert.pem"),
1146
- :SSLPrivateKey => key("ssl_key.pem"),
1147
- :SSLVerifyClient => nil,
1148
- :SSLCertName => nil,
1149
- }.merge(config))
1150
- server.mount_proc("/yaml") do |req, res|
1151
- res.body = "--- true\n"
1152
- end
1153
- server.mount_proc("/insecure_redirect") do |req, res|
1154
- res.set_redirect(WEBrick::HTTPStatus::MovedPermanently, req.query["to"])
1155
- end
1156
- server.ssl_context.tmp_dh_callback = proc { TEST_KEY_DH2048 }
1157
- t = Thread.new do
1158
- server.start
1159
- rescue Exception => ex
1160
- puts "ERROR during server thread: #{ex.message}"
1161
- raise
1162
- ensure
1163
- server.shutdown
1164
- end
1165
- while server.status != :Running
1166
- sleep 0.1
1167
- unless t.alive?
1168
- t.join
1169
- raise
1170
- end
1171
- end
1172
- @ssl_server = server
1173
- @ssl_server_thread = t
1174
- server
1175
- end
1176
-
1177
- def start_server(data)
1178
- null_logger = NilLog.new
1179
- s = WEBrick::HTTPServer.new(
1180
- :Port => 0,
1181
- :DocumentRoot => nil,
1182
- :Logger => null_logger,
1183
- :AccessLog => null_logger
1184
- )
1185
- s.mount_proc("/kill") {|req, res| s.shutdown }
1186
- s.mount_proc("/yaml") do |req, res|
1187
- if req["X-Captain"]
1188
- res.body = req["X-Captain"]
1189
- elsif @enable_yaml
1190
- res.body = data
1191
- res["Content-Type"] = "text/plain"
1192
- res["content-length"] = data.size
1193
- else
1194
- res.status = "404"
1195
- res.body = "<h1>NOT FOUND</h1>"
1196
- res["Content-Type"] = "text/html"
1197
- end
1198
- end
1199
- s.mount_proc("/yaml.Z") do |req, res|
1200
- if @enable_zip
1201
- res.body = Zlib::Deflate.deflate(data)
1202
- res["Content-Type"] = "text/plain"
1203
- else
1204
- res.status = "404"
1205
- res.body = "<h1>NOT FOUND</h1>"
1206
- res["Content-Type"] = "text/html"
1207
- end
1208
- end
1209
- th = Thread.new do
1210
- s.start
1211
- rescue Exception => ex
1212
- abort "ERROR during server thread: #{ex.message}"
1213
- ensure
1214
- s.shutdown
1215
- end
1216
- th[:server] = s
1217
- th
1218
- end
1219
-
1220
- def cert(filename)
1221
- OpenSSL::X509::Certificate.new(File.read(File.join(__dir__, filename)))
1222
- end
1223
-
1224
- def key(filename)
1225
- OpenSSL::PKey::RSA.new(File.read(File.join(__dir__, filename)))
1226
- end
1227
- end if Gem::HAVE_OPENSSL