rubygems-update 3.4.20 → 3.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/Manifest.txt +1 -0
  4. data/bundler/CHANGELOG.md +34 -3
  5. data/bundler/lib/bundler/build_metadata.rb +3 -3
  6. data/bundler/lib/bundler/cli/check.rb +1 -1
  7. data/bundler/lib/bundler/cli/gem.rb +1 -3
  8. data/bundler/lib/bundler/cli/install.rb +2 -2
  9. data/bundler/lib/bundler/cli/lock.rb +26 -23
  10. data/bundler/lib/bundler/cli/open.rb +5 -7
  11. data/bundler/lib/bundler/definition.rb +42 -25
  12. data/bundler/lib/bundler/env.rb +2 -2
  13. data/bundler/lib/bundler/gem_version_promoter.rb +2 -2
  14. data/bundler/lib/bundler/injector.rb +1 -1
  15. data/bundler/lib/bundler/installer/parallel_installer.rb +0 -26
  16. data/bundler/lib/bundler/installer/standalone.rb +13 -6
  17. data/bundler/lib/bundler/lockfile_parser.rb +29 -24
  18. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  19. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  20. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  21. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  22. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  23. data/bundler/lib/bundler/man/bundle-config.1 +1 -1
  24. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  25. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  26. data/bundler/lib/bundler/man/bundle-exec.1 +2 -2
  27. data/bundler/lib/bundler/man/bundle-exec.1.ronn +2 -3
  28. data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
  29. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  30. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  31. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  32. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  33. data/bundler/lib/bundler/man/bundle-install.1 +1 -1
  34. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  39. data/bundler/lib/bundler/man/bundle-plugin.1 +17 -17
  40. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +5 -5
  41. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  42. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  43. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  45. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  46. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  47. data/bundler/lib/bundler/man/bundle.1 +1 -1
  48. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  49. data/bundler/lib/bundler/resolver/package.rb +5 -0
  50. data/bundler/lib/bundler/resolver.rb +27 -7
  51. data/bundler/lib/bundler/ruby_version.rb +8 -1
  52. data/bundler/lib/bundler/settings.rb +53 -16
  53. data/bundler/lib/bundler/shared_helpers.rb +16 -1
  54. data/bundler/lib/bundler/source/git/git_proxy.rb +13 -4
  55. data/bundler/lib/bundler/spec_set.rb +2 -2
  56. data/bundler/lib/bundler/stub_specification.rb +4 -2
  57. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +6 -2
  58. data/bundler/lib/bundler/version.rb +1 -1
  59. data/bundler/lib/bundler/yaml_serializer.rb +6 -7
  60. data/lib/rubygems/basic_specification.rb +1 -1
  61. data/lib/rubygems/command.rb +2 -2
  62. data/lib/rubygems/command_manager.rb +1 -1
  63. data/lib/rubygems/commands/cert_command.rb +2 -2
  64. data/lib/rubygems/commands/check_command.rb +5 -1
  65. data/lib/rubygems/commands/cleanup_command.rb +1 -1
  66. data/lib/rubygems/commands/contents_command.rb +1 -1
  67. data/lib/rubygems/commands/help_command.rb +2 -2
  68. data/lib/rubygems/commands/open_command.rb +1 -3
  69. data/lib/rubygems/commands/owner_command.rb +1 -1
  70. data/lib/rubygems/commands/setup_command.rb +8 -8
  71. data/lib/rubygems/commands/specification_command.rb +5 -1
  72. data/lib/rubygems/commands/stale_command.rb +1 -1
  73. data/lib/rubygems/commands/update_command.rb +3 -3
  74. data/lib/rubygems/commands/yank_command.rb +1 -1
  75. data/lib/rubygems/config_file.rb +60 -13
  76. data/lib/rubygems/core_ext/kernel_gem.rb +1 -1
  77. data/lib/rubygems/core_ext/kernel_require.rb +1 -1
  78. data/lib/rubygems/defaults.rb +6 -2
  79. data/lib/rubygems/deprecate.rb +2 -1
  80. data/lib/rubygems/doctor.rb +1 -1
  81. data/lib/rubygems/errors.rb +1 -1
  82. data/lib/rubygems/exceptions.rb +1 -1
  83. data/lib/rubygems/ext/builder.rb +5 -4
  84. data/lib/rubygems/ext/cargo_builder.rb +2 -2
  85. data/lib/rubygems/gem_runner.rb +5 -1
  86. data/lib/rubygems/gemcutter_utilities.rb +2 -2
  87. data/lib/rubygems/indexer.rb +1 -1
  88. data/lib/rubygems/install_update_options.rb +1 -1
  89. data/lib/rubygems/installer.rb +8 -8
  90. data/lib/rubygems/package/old.rb +1 -1
  91. data/lib/rubygems/package/tar_writer.rb +1 -1
  92. data/lib/rubygems/package.rb +8 -8
  93. data/lib/rubygems/platform.rb +6 -2
  94. data/lib/rubygems/query_utils.rb +4 -4
  95. data/lib/rubygems/remote_fetcher.rb +10 -2
  96. data/lib/rubygems/request_set.rb +2 -1
  97. data/lib/rubygems/requirement.rb +1 -1
  98. data/lib/rubygems/resolver/api_set.rb +2 -1
  99. data/lib/rubygems/resolver/api_specification.rb +1 -1
  100. data/lib/rubygems/security/signer.rb +10 -2
  101. data/lib/rubygems/security/trust_dir.rb +4 -4
  102. data/lib/rubygems/security.rb +1 -1
  103. data/lib/rubygems/security_option.rb +1 -1
  104. data/lib/rubygems/source.rb +5 -1
  105. data/lib/rubygems/specification.rb +9 -10
  106. data/lib/rubygems/specification_policy.rb +5 -5
  107. data/lib/rubygems/uninstaller.rb +1 -1
  108. data/lib/rubygems/update_suggestion.rb +1 -1
  109. data/lib/rubygems/util.rb +5 -1
  110. data/lib/rubygems/version.rb +3 -2
  111. data/lib/rubygems/yaml_serializer.rb +88 -0
  112. data/lib/rubygems.rb +4 -4
  113. data/rubygems-update.gemspec +1 -1
  114. data/setup.rb +2 -0
  115. data/test/rubygems/bundler_test_gem.rb +6 -3
  116. data/test/rubygems/helper.rb +23 -15
  117. data/test/rubygems/package/tar_test_case.rb +2 -2
  118. data/test/rubygems/test_gem.rb +51 -26
  119. data/test/rubygems/test_gem_command.rb +3 -1
  120. data/test/rubygems/test_gem_commands_cert_command.rb +22 -22
  121. data/test/rubygems/test_gem_commands_cleanup_command.rb +2 -2
  122. data/test/rubygems/test_gem_commands_environment_command.rb +2 -1
  123. data/test/rubygems/test_gem_commands_exec_command.rb +5 -1
  124. data/test/rubygems/test_gem_commands_install_command.rb +3 -3
  125. data/test/rubygems/test_gem_commands_open_command.rb +5 -2
  126. data/test/rubygems/test_gem_commands_pristine_command.rb +2 -2
  127. data/test/rubygems/test_gem_commands_push_command.rb +7 -6
  128. data/test/rubygems/test_gem_commands_signin_command.rb +8 -8
  129. data/test/rubygems/test_gem_commands_uninstall_command.rb +1 -1
  130. data/test/rubygems/test_gem_commands_unpack_command.rb +2 -2
  131. data/test/rubygems/test_gem_config_file.rb +46 -12
  132. data/test/rubygems/test_gem_ext_cargo_builder.rb +2 -2
  133. data/test/rubygems/test_gem_gemcutter_utilities.rb +8 -5
  134. data/test/rubygems/test_gem_install_update_options.rb +3 -3
  135. data/test/rubygems/test_gem_installer.rb +15 -15
  136. data/test/rubygems/test_gem_package.rb +35 -34
  137. data/test/rubygems/test_gem_package_old.rb +1 -1
  138. data/test/rubygems/test_gem_package_tar_header.rb +3 -3
  139. data/test/rubygems/test_gem_package_tar_reader.rb +4 -4
  140. data/test/rubygems/test_gem_package_tar_writer.rb +28 -28
  141. data/test/rubygems/test_gem_rdoc.rb +2 -2
  142. data/test/rubygems/test_gem_remote_fetcher.rb +13 -9
  143. data/test/rubygems/test_gem_request.rb +5 -5
  144. data/test/rubygems/test_gem_request_connection_pools.rb +2 -1
  145. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +14 -7
  146. data/test/rubygems/test_gem_security.rb +2 -2
  147. data/test/rubygems/test_gem_security_signer.rb +2 -2
  148. data/test/rubygems/test_gem_security_trust_dir.rb +6 -6
  149. data/test/rubygems/test_gem_spec_fetcher.rb +2 -2
  150. data/test/rubygems/test_gem_specification.rb +29 -29
  151. data/test/rubygems/test_gem_update_suggestion.rb +12 -6
  152. data/test/rubygems/test_gem_util.rb +2 -2
  153. data/test/rubygems/test_gem_version.rb +4 -2
  154. data/test/rubygems/utilities.rb +2 -1
  155. metadata +4 -3
@@ -129,9 +129,9 @@ Added '/CN=alternate/DC=example'
129
129
  output.shift
130
130
  assert_equal "Please repeat the passphrase for your Private Key: ",
131
131
  output.shift
132
- assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
132
+ assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
133
133
  output.shift
134
- assert_equal "Private Key: #{File.join @tempdir, 'gem-private_key.pem'}",
134
+ assert_equal "Private Key: #{File.join @tempdir, "gem-private_key.pem"}",
135
135
  output.shift
136
136
 
137
137
  assert_equal "Don't forget to move the key file to somewhere private!",
@@ -161,9 +161,9 @@ Added '/CN=alternate/DC=example'
161
161
  output.shift
162
162
  assert_equal "Please repeat the passphrase for your Private Key: ",
163
163
  output.shift
164
- assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
164
+ assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
165
165
  output.shift
166
- assert_equal "Private Key: #{File.join @tempdir, 'gem-private_key.pem'}",
166
+ assert_equal "Private Key: #{File.join @tempdir, "gem-private_key.pem"}",
167
167
  output.shift
168
168
 
169
169
  assert_equal "Don't forget to move the key file to somewhere private!",
@@ -221,9 +221,9 @@ Added '/CN=alternate/DC=example'
221
221
  output.shift
222
222
  assert_equal "Please repeat the passphrase for your Private Key: ",
223
223
  output.shift
224
- assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
224
+ assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
225
225
  output.shift
226
- assert_equal "Private Key: #{File.join @tempdir, 'gem-private_key.pem'}",
226
+ assert_equal "Private Key: #{File.join @tempdir, "gem-private_key.pem"}",
227
227
  output.shift
228
228
 
229
229
  assert_equal "Don't forget to move the key file to somewhere private!",
@@ -284,7 +284,7 @@ Added '/CN=alternate/DC=example'
284
284
 
285
285
  output = @ui.output.split "\n"
286
286
 
287
- assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
287
+ assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
288
288
  output.shift
289
289
 
290
290
  assert_empty output
@@ -306,7 +306,7 @@ Added '/CN=alternate/DC=example'
306
306
 
307
307
  output = @ui.output.split "\n"
308
308
 
309
- assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
309
+ assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
310
310
  output.shift
311
311
 
312
312
  assert_empty output
@@ -327,7 +327,7 @@ Added '/CN=alternate/DC=example'
327
327
 
328
328
  output = @ui.output.split "\n"
329
329
 
330
- assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
330
+ assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
331
331
  output.shift
332
332
 
333
333
  assert_empty output
@@ -476,7 +476,7 @@ Removed '/CN=alternate/DC=example'
476
476
 
477
477
  def test_execute_sign
478
478
  path = File.join @tempdir, "cert.pem"
479
- Gem::Security.write ALTERNATE_CERT, path, 0600
479
+ Gem::Security.write ALTERNATE_CERT, path, 0o600
480
480
 
481
481
  assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
482
482
 
@@ -498,14 +498,14 @@ Removed '/CN=alternate/DC=example'
498
498
 
499
499
  assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
500
500
 
501
- mask = 0100600 & (~File.umask)
501
+ mask = 0o100600 & (~File.umask)
502
502
 
503
503
  assert_equal mask, File.stat(path).mode unless win_platform?
504
504
  end
505
505
 
506
506
  def test_execute_sign_encrypted_key
507
507
  path = File.join @tempdir, "cert.pem"
508
- Gem::Security.write ALTERNATE_CERT, path, 0600
508
+ Gem::Security.write ALTERNATE_CERT, path, 0o600
509
509
 
510
510
  assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
511
511
 
@@ -527,7 +527,7 @@ Removed '/CN=alternate/DC=example'
527
527
 
528
528
  assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
529
529
 
530
- mask = 0100600 & (~File.umask)
530
+ mask = 0o100600 & (~File.umask)
531
531
 
532
532
  assert_equal mask, File.stat(path).mode unless win_platform?
533
533
  end
@@ -542,7 +542,7 @@ Removed '/CN=alternate/DC=example'
542
542
  Gem::Security.write PUBLIC_CERT, public_cert_path
543
543
 
544
544
  path = File.join @tempdir, "cert.pem"
545
- Gem::Security.write ALTERNATE_CERT, path, 0600
545
+ Gem::Security.write ALTERNATE_CERT, path, 0o600
546
546
 
547
547
  assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
548
548
 
@@ -559,7 +559,7 @@ Removed '/CN=alternate/DC=example'
559
559
 
560
560
  assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
561
561
 
562
- mask = 0100600 & (~File.umask)
562
+ mask = 0o100600 & (~File.umask)
563
563
 
564
564
  assert_equal mask, File.stat(path).mode unless win_platform?
565
565
  end
@@ -568,13 +568,13 @@ Removed '/CN=alternate/DC=example'
568
568
  FileUtils.mkdir_p File.join(Gem.user_home, ".gem")
569
569
 
570
570
  private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem"
571
- Gem::Security.write ENCRYPTED_PRIVATE_KEY, private_key_path, 0600, PRIVATE_KEY_PASSPHRASE
571
+ Gem::Security.write ENCRYPTED_PRIVATE_KEY, private_key_path, 0o600, PRIVATE_KEY_PASSPHRASE
572
572
 
573
573
  public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem"
574
574
  Gem::Security.write PUBLIC_CERT, public_cert_path
575
575
 
576
576
  path = File.join @tempdir, "cert.pem"
577
- Gem::Security.write ALTERNATE_CERT, path, 0600
577
+ Gem::Security.write ALTERNATE_CERT, path, 0o600
578
578
 
579
579
  assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
580
580
 
@@ -591,7 +591,7 @@ Removed '/CN=alternate/DC=example'
591
591
 
592
592
  assert_equal "/CN=nobody/DC=example", cert.issuer.to_s
593
593
 
594
- mask = 0100600 & (~File.umask)
594
+ mask = 0o100600 & (~File.umask)
595
595
 
596
596
  assert_equal mask, File.stat(path).mode unless win_platform?
597
597
  end
@@ -603,7 +603,7 @@ Removed '/CN=alternate/DC=example'
603
603
  Gem::Security.write PRIVATE_KEY, private_key_path
604
604
 
605
605
  path = File.join @tempdir, "cert.pem"
606
- Gem::Security.write ALTERNATE_CERT, path, 0600
606
+ Gem::Security.write ALTERNATE_CERT, path, 0o600
607
607
 
608
608
  assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
609
609
 
@@ -631,7 +631,7 @@ ERROR: --certificate not specified and ~/.gem/gem-public_cert.pem does not exis
631
631
  Gem::Security.write PUBLIC_CERT, public_cert_path
632
632
 
633
633
  path = File.join @tempdir, "cert.pem"
634
- Gem::Security.write ALTERNATE_CERT, path, 0600
634
+ Gem::Security.write ALTERNATE_CERT, path, 0o600
635
635
 
636
636
  assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s
637
637
 
@@ -657,7 +657,7 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
657
657
  Dir.mkdir gem_path
658
658
 
659
659
  path = File.join @tempdir, "cert.pem"
660
- Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600
660
+ Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0o600
661
661
 
662
662
  assert_equal "/CN=nobody/DC=example", EXPIRED_PUBLIC_CERT.issuer.to_s
663
663
 
@@ -689,7 +689,7 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
689
689
  Dir.mkdir gem_path
690
690
 
691
691
  path = File.join @tempdir, "cert.pem"
692
- Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600
692
+ Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0o600
693
693
 
694
694
  assert_equal "/CN=nobody/DC=example", EXPIRED_PUBLIC_CERT.issuer.to_s
695
695
 
@@ -166,7 +166,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
166
166
  end
167
167
 
168
168
  def test_execute_all_user_no_sudo
169
- FileUtils.chmod 0555, @gemhome
169
+ FileUtils.chmod 0o555, @gemhome
170
170
 
171
171
  @a_1_1, = util_gem "a", "1.1"
172
172
  @a_1_1 = install_gem @a_1_1, :user_install => true # pick up user install path
@@ -183,7 +183,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
183
183
  assert_path_exist @a_1.gem_dir
184
184
  assert_path_exist @a_1_1.gem_dir
185
185
  ensure
186
- FileUtils.chmod 0755, @gemhome
186
+ FileUtils.chmod 0o755, @gemhome
187
187
  end unless win_platform? || Process.uid.zero?
188
188
 
189
189
  def test_execute_dry_run
@@ -12,7 +12,8 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
12
12
 
13
13
  def test_execute
14
14
  orig_sources = Gem.sources.dup
15
- orig_path, ENV["PATH"] = ENV["PATH"], %w[/usr/local/bin /usr/bin /bin].join(File::PATH_SEPARATOR)
15
+ orig_path = ENV["PATH"]
16
+ ENV["PATH"] = %w[/usr/local/bin /usr/bin /bin].join(File::PATH_SEPARATOR)
16
17
  Gem.sources.replace %w[http://gems.example.com]
17
18
  Gem.configuration["gemcutter_key"] = "blah"
18
19
 
@@ -731,7 +731,11 @@ class TestGemCommandsExecCommand < Gem::TestCase
731
731
  assert_includes @ui.output, "a (2)\n"
732
732
  assert_includes @ui.output, "b (2)\n"
733
733
 
734
- invoke "gem", "uninstall", "--verbose", "-x", "a" rescue nil
734
+ begin
735
+ invoke "gem", "uninstall", "--verbose", "-x", "a"
736
+ rescue StandardError
737
+ nil
738
+ end
735
739
  refute_includes @ui.output, "running gem exec with"
736
740
  assert_includes @ui.output, "Successfully uninstalled a-2\n"
737
741
 
@@ -205,8 +205,8 @@ ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in a
205
205
  use_ui @ui do
206
206
  orig_dir = Dir.pwd
207
207
  begin
208
- FileUtils.chmod 0755, @userhome
209
- FileUtils.chmod 0555, @gemhome
208
+ FileUtils.chmod 0o755, @userhome
209
+ FileUtils.chmod 0o555, @gemhome
210
210
 
211
211
  Dir.chdir @tempdir
212
212
  assert_raise Gem::FilePermissionError do
@@ -214,7 +214,7 @@ ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in a
214
214
  end
215
215
  ensure
216
216
  Dir.chdir orig_dir
217
- FileUtils.chmod 0755, @gemhome
217
+ FileUtils.chmod 0o755, @gemhome
218
218
  end
219
219
  end
220
220
  end
@@ -22,20 +22,23 @@ class TestGemCommandsOpenCommand < Gem::TestCase
22
22
 
23
23
  def test_execute
24
24
  @cmd.options[:args] = %w[foo]
25
- @cmd.options[:editor] = "#{ruby_with_rubygems_in_load_path} -eexit --"
25
+ @cmd.options[:editor] = (ruby_with_rubygems_in_load_path + ["-e", "puts(ARGV,Dir.pwd)", "--"]).join(" ")
26
26
 
27
27
  gem "foo", "1.0.0"
28
28
  spec = gem "foo", "1.0.1"
29
29
 
30
30
  assert_nothing_raised Gem::MockGemUi::TermError do
31
- Dir.stub(:chdir, spec.full_gem_path) do
31
+ stdout, stderr = capture_subprocess_io do
32
32
  use_ui @ui do
33
33
  @cmd.execute
34
34
  end
35
35
  end
36
+ assert_equal [spec.full_gem_path, spec.full_gem_path], stdout.split("\n")
37
+ assert_equal "", stderr
36
38
  end
37
39
 
38
40
  assert_equal "", @ui.error
41
+ assert_equal "", @ui.output
39
42
  end
40
43
 
41
44
  def test_wrong_version
@@ -54,7 +54,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
54
54
  end
55
55
 
56
56
  def test_execute_user_install
57
- FileUtils.chmod 0555, @gemhome
57
+ FileUtils.chmod 0o555, @gemhome
58
58
 
59
59
  a = util_spec "a" do |s|
60
60
  s.executables = %w[foo]
@@ -99,7 +99,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
99
99
  assert_equal "Restored #{a.full_name}", out.shift
100
100
  assert_empty out, out.inspect
101
101
  ensure
102
- FileUtils.chmod(0755, @gemhome)
102
+ FileUtils.chmod(0o755, @gemhome)
103
103
  end
104
104
 
105
105
  def test_execute_all
@@ -3,6 +3,7 @@
3
3
  require_relative "helper"
4
4
  require_relative "multifactor_auth_utilities"
5
5
  require "rubygems/commands/push_command"
6
+ require "rubygems/config_file"
6
7
 
7
8
  class TestGemCommandsPushCommand < Gem::TestCase
8
9
  def setup
@@ -107,7 +108,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
107
108
  end
108
109
 
109
110
  @response = "Successfully registered gem: freewill (1.0.0)"
110
- @fetcher.data["#{@spec.metadata['allowed_push_host']}/api/v1/gems"] = HTTPResponseFactory.create(body: @response, code: 200, msg: "OK")
111
+ @fetcher.data["#{@spec.metadata["allowed_push_host"]}/api/v1/gems"] = HTTPResponseFactory.create(body: @response, code: 200, msg: "OK")
111
112
  @fetcher.data["#{Gem.host}/api/v1/gems"] =
112
113
  ["fail", 500, "Internal Server Error"]
113
114
 
@@ -158,7 +159,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
158
159
  }
159
160
 
160
161
  File.open Gem.configuration.credentials_path, "w" do |f|
161
- f.write keys.to_yaml
162
+ f.write Gem::ConfigFile.dump_with_rubygems_yaml(keys)
162
163
  end
163
164
  Gem.configuration.load_api_keys
164
165
 
@@ -192,7 +193,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
192
193
  }
193
194
 
194
195
  File.open Gem.configuration.credentials_path, "w" do |f|
195
- f.write keys.to_yaml
196
+ f.write Gem::ConfigFile.dump_with_rubygems_yaml(keys)
196
197
  end
197
198
  Gem.configuration.load_api_keys
198
199
 
@@ -233,7 +234,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
233
234
  }
234
235
 
235
236
  File.open Gem.configuration.credentials_path, "w" do |f|
236
- f.write keys.to_yaml
237
+ f.write Gem::ConfigFile.dump_with_rubygems_yaml(keys)
237
238
  end
238
239
  Gem.configuration.load_api_keys
239
240
 
@@ -274,7 +275,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
274
275
  }
275
276
 
276
277
  File.open Gem.configuration.credentials_path, "w" do |f|
277
- f.write keys.to_yaml
278
+ f.write Gem::ConfigFile.dump_with_rubygems_yaml(keys)
278
279
  end
279
280
  Gem.configuration.load_api_keys
280
281
 
@@ -304,7 +305,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
304
305
  }
305
306
 
306
307
  File.open Gem.configuration.credentials_path, "w" do |f|
307
- f.write keys.to_yaml
308
+ f.write Gem::ConfigFile.dump_with_rubygems_yaml(keys)
308
309
  end
309
310
  Gem.configuration.load_api_keys
310
311
 
@@ -109,7 +109,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
109
109
  def test_execute_with_key_name_and_scope
110
110
  email = "you@example.com"
111
111
  password = "secret"
112
- api_key = "1234"
112
+ api_key = "1234abcd"
113
113
  fetcher = Gem::RemoteFetcher.fetcher
114
114
 
115
115
  key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\ny\n\n\n\n\n\n"
@@ -134,7 +134,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
134
134
  def test_execute_with_key_name_scope_and_mfa_level_of_ui_only
135
135
  email = "you@example.com"
136
136
  password = "secret"
137
- api_key = "1234"
137
+ api_key = "1234abcd"
138
138
  fetcher = Gem::RemoteFetcher.fetcher
139
139
  mfa_level = "ui_only"
140
140
 
@@ -161,7 +161,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
161
161
  def test_execute_with_key_name_scope_and_mfa_level_of_gem_signin
162
162
  email = "you@example.com"
163
163
  password = "secret"
164
- api_key = "1234"
164
+ api_key = "1234abcd"
165
165
  fetcher = Gem::RemoteFetcher.fetcher
166
166
  mfa_level = "ui_and_gem_signin"
167
167
 
@@ -188,7 +188,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
188
188
  def test_execute_with_warnings
189
189
  email = "you@example.com"
190
190
  password = "secret"
191
- api_key = "1234"
191
+ api_key = "1234abcd"
192
192
  fetcher = Gem::RemoteFetcher.fetcher
193
193
  mfa_level = "disabled"
194
194
  warning = "/[WARNING/] For protection of your account and gems"
@@ -204,14 +204,14 @@ class TestGemCommandsSigninCommand < Gem::TestCase
204
204
 
205
205
  email = "you@example.com"
206
206
  password = "secret"
207
- api_key = "1234"
207
+ api_key = "1234abcd"
208
208
  fetcher = Gem::RemoteFetcher.fetcher
209
209
 
210
210
  key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\ny\n\n\n\n\n\ny"
211
211
 
212
212
  # Set the expected response for the Web-API supplied
213
213
  ENV["RUBYGEMS_HOST"] = host
214
- data_key = "#{ENV['RUBYGEMS_HOST']}/api/v1/api_key"
214
+ data_key = "#{ENV["RUBYGEMS_HOST"]}/api/v1/api_key"
215
215
  fetcher.data[data_key] = HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
216
216
 
217
217
  use_ui key_name_ui do
@@ -242,9 +242,9 @@ class TestGemCommandsSigninCommand < Gem::TestCase
242
242
 
243
243
  # Set the expected response for the Web-API supplied
244
244
  ENV["RUBYGEMS_HOST"] = host || Gem::DEFAULT_HOST
245
- data_key = "#{ENV['RUBYGEMS_HOST']}/api/v1/api_key"
245
+ data_key = "#{ENV["RUBYGEMS_HOST"]}/api/v1/api_key"
246
246
  fetcher.data[data_key] = response
247
- profile = "#{ENV['RUBYGEMS_HOST']}/api/v1/profile/me.yaml"
247
+ profile = "#{ENV["RUBYGEMS_HOST"]}/api/v1/profile/me.yaml"
248
248
  fetcher.data[profile] = profile_response
249
249
  Gem::RemoteFetcher.fetcher = fetcher
250
250
 
@@ -158,7 +158,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
158
158
  @cmd.execute
159
159
 
160
160
  assert_equal false, File.exist?(formatted_executable)
161
- rescue
161
+ rescue StandardError
162
162
  Gem::Installer.exec_format = nil
163
163
  end
164
164
 
@@ -156,7 +156,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
156
156
 
157
157
  util_make_gems
158
158
 
159
- FileUtils.chmod 0555, @gemhome
159
+ FileUtils.chmod 0o555, @gemhome
160
160
 
161
161
  @cmd.options[:args] = %w[b]
162
162
 
@@ -168,7 +168,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
168
168
 
169
169
  assert File.exist?(File.join(@tempdir, "b-2")), "b should be unpacked"
170
170
  ensure
171
- FileUtils.chmod 0755, @gemhome
171
+ FileUtils.chmod 0o755, @gemhome
172
172
  end
173
173
 
174
174
  def test_execute_with_target_option
@@ -185,7 +185,7 @@ class TestGemConfigFile < Gem::TestCase
185
185
 
186
186
  temp_cred = File.join Gem.user_home, ".gem", "credentials"
187
187
  FileUtils.mkdir_p File.dirname(temp_cred)
188
- File.open temp_cred, "w", 0600 do |fp|
188
+ File.open temp_cred, "w", 0o600 do |fp|
189
189
  fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
190
190
  end
191
191
 
@@ -200,7 +200,7 @@ class TestGemConfigFile < Gem::TestCase
200
200
 
201
201
  @cfg.rubygems_api_key = "x"
202
202
 
203
- File.chmod 0644, @cfg.credentials_path
203
+ File.chmod 0o644, @cfg.credentials_path
204
204
 
205
205
  use_ui @ui do
206
206
  assert_raise Gem::MockGemUi::TermError do
@@ -323,15 +323,20 @@ if you believe they were disclosed to a third party.
323
323
  def test_load_api_keys
324
324
  temp_cred = File.join Gem.user_home, ".gem", "credentials"
325
325
  FileUtils.mkdir_p File.dirname(temp_cred)
326
- File.open temp_cred, "w", 0600 do |fp|
327
- fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
328
- fp.puts ":other: a5fdbb6ba150cbb83aad2bb2fede64c"
326
+ File.open temp_cred, "w", 0o600 do |fp|
327
+ fp.puts ":rubygems_api_key: rubygems_b9ce70c306b3a2e248679fbbbd66722d408d3c8c4f00566c"
328
+ fp.puts ":other: rubygems_9636a120106ea8b81fbc792188251738665711d2ece160c5"
329
+ fp.puts "http://localhost:3000: rubygems_be293ad9dd71550a012b17d848893b41960b811ce9312b47"
329
330
  end
330
331
 
331
332
  util_config_file
332
333
 
333
- assert_equal({ :rubygems => "701229f217cdf23b1344c7b4b54ca97",
334
- :other => "a5fdbb6ba150cbb83aad2bb2fede64c" }, @cfg.api_keys)
334
+ assert_equal(
335
+ { :rubygems => "rubygems_b9ce70c306b3a2e248679fbbbd66722d408d3c8c4f00566c",
336
+ :other => "rubygems_9636a120106ea8b81fbc792188251738665711d2ece160c5",
337
+ "http://localhost:3000" => "rubygems_be293ad9dd71550a012b17d848893b41960b811ce9312b47" },
338
+ @cfg.api_keys
339
+ )
335
340
  end
336
341
 
337
342
  def test_load_api_keys_bad_permission
@@ -339,7 +344,7 @@ if you believe they were disclosed to a third party.
339
344
 
340
345
  @cfg.rubygems_api_key = "x"
341
346
 
342
- File.chmod 0644, @cfg.credentials_path
347
+ File.chmod 0o644, @cfg.credentials_path
343
348
 
344
349
  assert_raise Gem::MockGemUi::TermError do
345
350
  @cfg.load_api_keys
@@ -372,7 +377,7 @@ if you believe they were disclosed to a third party.
372
377
  unless win_platform?
373
378
  stat = File.stat @cfg.credentials_path
374
379
 
375
- assert_equal 0600, stat.mode & 0600
380
+ assert_equal 0o600, stat.mode & 0o600
376
381
  end
377
382
  end
378
383
 
@@ -381,7 +386,7 @@ if you believe they were disclosed to a third party.
381
386
 
382
387
  @cfg.rubygems_api_key = "x"
383
388
 
384
- File.chmod 0644, @cfg.credentials_path
389
+ File.chmod 0o644, @cfg.credentials_path
385
390
 
386
391
  assert_raise Gem::MockGemUi::TermError do
387
392
  @cfg.rubygems_api_key = "y"
@@ -395,7 +400,7 @@ if you believe they were disclosed to a third party.
395
400
 
396
401
  stat = File.stat @cfg.credentials_path
397
402
 
398
- assert_equal 0644, stat.mode & 0644
403
+ assert_equal 0o644, stat.mode & 0o644
399
404
  end
400
405
 
401
406
  def test_write
@@ -471,7 +476,8 @@ if you believe they were disclosed to a third party.
471
476
  end
472
477
 
473
478
  begin
474
- verbose, $VERBOSE = $VERBOSE, nil
479
+ verbose = $VERBOSE
480
+ $VERBOSE = nil
475
481
 
476
482
  util_config_file
477
483
  ensure
@@ -514,4 +520,32 @@ if you believe they were disclosed to a third party.
514
520
  util_config_file
515
521
  assert_equal(true, @cfg.disable_default_gem_server)
516
522
  end
523
+
524
+ def test_load_with_rubygems_config_hash
525
+ yaml = <<~YAML
526
+ ---
527
+ :foo: bar
528
+ bar: 100
529
+ buzz: true
530
+ alpha: :bravo
531
+ charlie: ""
532
+ delta:
533
+ YAML
534
+ actual = Gem::ConfigFile.load_with_rubygems_config_hash(yaml)
535
+
536
+ assert_equal "bar", actual[:foo]
537
+ assert_equal 100, actual["bar"]
538
+ assert_equal true, actual["buzz"]
539
+ assert_equal :bravo, actual["alpha"]
540
+ assert_equal nil, actual["charlie"]
541
+ assert_equal nil, actual["delta"]
542
+ end
543
+
544
+ def test_dump_with_rubygems_yaml
545
+ symbol_key_hash = { :foo => "bar" }
546
+
547
+ actual = Gem::ConfigFile.dump_with_rubygems_yaml(symbol_key_hash)
548
+
549
+ assert_equal("---\n:foo: \"bar\"\n", actual)
550
+ end
517
551
  end
@@ -36,7 +36,7 @@ class TestGemExtCargoBuilder < Gem::TestCase
36
36
  end
37
37
 
38
38
  output = output.join "\n"
39
- bundle = File.join(@dest_path, "rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")
39
+ bundle = File.join(@dest_path, "rust_ruby_example.#{RbConfig::CONFIG["DLEXT"]}")
40
40
 
41
41
  assert_match(/Finished/, output)
42
42
  assert_match(/release/, output)
@@ -62,7 +62,7 @@ class TestGemExtCargoBuilder < Gem::TestCase
62
62
  end
63
63
 
64
64
  output = output.join "\n"
65
- bundle = File.join(@dest_path, "rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")
65
+ bundle = File.join(@dest_path, "rust_ruby_example.#{RbConfig::CONFIG["DLEXT"]}")
66
66
 
67
67
  assert_ffi_handle bundle, "hello_from_rubygems"
68
68
  assert_ffi_handle bundle, "hello_from_rubygems_version"
@@ -5,6 +5,7 @@ require_relative "multifactor_auth_utilities"
5
5
  require "rubygems"
6
6
  require "rubygems/command"
7
7
  require "rubygems/gemcutter_utilities"
8
+ require "rubygems/config_file"
8
9
 
9
10
  class TestGemGemcutterUtilities < Gem::TestCase
10
11
  def setup
@@ -41,7 +42,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
41
42
  }
42
43
 
43
44
  File.open Gem.configuration.credentials_path, "w" do |f|
44
- f.write keys.to_yaml
45
+ f.write Gem::ConfigFile.dump_with_rubygems_yaml(keys)
45
46
  end
46
47
 
47
48
  ENV["RUBYGEMS_HOST"] = "http://rubygems.engineyard.com"
@@ -55,7 +56,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
55
56
  keys = { :rubygems_api_key => "KEY" }
56
57
 
57
58
  File.open Gem.configuration.credentials_path, "w" do |f|
58
- f.write keys.to_yaml
59
+ f.write Gem::ConfigFile.dump_with_rubygems_yaml(keys)
59
60
  end
60
61
 
61
62
  Gem.configuration.load_api_keys
@@ -67,7 +68,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
67
68
  keys = { :rubygems_api_key => "KEY", :other => "OTHER" }
68
69
 
69
70
  File.open Gem.configuration.credentials_path, "w" do |f|
70
- f.write keys.to_yaml
71
+ f.write Gem::ConfigFile.dump_with_rubygems_yaml(keys)
71
72
  end
72
73
 
73
74
  Gem.configuration.load_api_keys
@@ -163,8 +164,10 @@ class TestGemGemcutterUtilities < Gem::TestCase
163
164
  def test_sign_in_with_other_credentials_doesnt_overwrite_other_keys
164
165
  other_api_key = "f46dbb18bb6a9c97cdc61b5b85c186a17403cdcbf"
165
166
 
167
+ config = Hash[:other_api_key, other_api_key]
168
+
166
169
  File.open Gem.configuration.credentials_path, "w" do |f|
167
- f.write Hash[:other_api_key, other_api_key].to_yaml
170
+ f.write Gem::ConfigFile.dump_with_rubygems_yaml(config)
168
171
  end
169
172
  util_sign_in
170
173
 
@@ -317,7 +320,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
317
320
  def test_verify_api_key
318
321
  keys = { :other => "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" }
319
322
  File.open Gem.configuration.credentials_path, "w" do |f|
320
- f.write keys.to_yaml
323
+ f.write Gem::ConfigFile.dump_with_rubygems_yaml(keys)
321
324
  end
322
325
  Gem.configuration.load_api_keys
323
326
 
@@ -146,8 +146,8 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
146
146
 
147
147
  refute @cmd.options[:user_install]
148
148
 
149
- FileUtils.chmod 0755, @userhome
150
- FileUtils.chmod 0000, @gemhome
149
+ FileUtils.chmod 0o755, @userhome
150
+ FileUtils.chmod 0o000, @gemhome
151
151
 
152
152
  Gem.use_paths @gemhome, @userhome
153
153
 
@@ -156,7 +156,7 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
156
156
  end
157
157
  end
158
158
  ensure
159
- FileUtils.chmod 0755, @gemhome
159
+ FileUtils.chmod 0o755, @gemhome
160
160
  end
161
161
 
162
162
  def test_vendor