rubygems-update 3.3.22 → 3.3.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/Manifest.txt +1 -0
  4. data/POLICIES.md +38 -5
  5. data/bundler/CHANGELOG.md +18 -0
  6. data/bundler/lib/bundler/build_metadata.rb +2 -2
  7. data/bundler/lib/bundler/cli/init.rb +5 -1
  8. data/bundler/lib/bundler/definition.rb +2 -12
  9. data/bundler/lib/bundler/dsl.rb +0 -1
  10. data/bundler/lib/bundler/gem_version_promoter.rb +6 -7
  11. data/bundler/lib/bundler/index.rb +3 -26
  12. data/bundler/lib/bundler/resolver.rb +7 -11
  13. data/bundler/lib/bundler/rubygems_ext.rb +12 -1
  14. data/bundler/lib/bundler/spec_set.rb +1 -1
  15. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +5 -4
  16. data/bundler/lib/bundler/version.rb +1 -1
  17. data/lib/rubygems/gemcutter_utilities.rb +8 -1
  18. data/lib/rubygems/package.rb +9 -4
  19. data/lib/rubygems/platform.rb +17 -1
  20. data/lib/rubygems/resolver.rb +1 -1
  21. data/lib/rubygems.rb +1 -1
  22. data/rubygems-update.gemspec +1 -1
  23. data/test/rubygems/helper.rb +23 -17
  24. data/test/rubygems/packages/Bluebie-legs-0.6.2.gem +0 -0
  25. data/test/rubygems/test_gem.rb +254 -212
  26. data/test/rubygems/test_gem_commands_owner_command.rb +105 -24
  27. data/test/rubygems/test_gem_commands_push_command.rb +44 -23
  28. data/test/rubygems/test_gem_commands_signin_command.rb +28 -3
  29. data/test/rubygems/test_gem_commands_yank_command.rb +9 -9
  30. data/test/rubygems/test_gem_gemcutter_utilities.rb +16 -12
  31. data/test/rubygems/test_gem_package.rb +15 -0
  32. data/test/rubygems/test_gem_platform.rb +35 -0
  33. data/test/rubygems/test_gem_resolver.rb +33 -0
  34. data/test/rubygems/test_require.rb +5 -5
  35. data/test/rubygems/utilities.rb +36 -14
  36. metadata +4 -3
@@ -93,7 +93,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
93
93
 
94
94
  def test_sign_in
95
95
  api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
96
- util_sign_in [api_key, 200, "OK"]
96
+ util_sign_in HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
97
97
 
98
98
  assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
99
99
  assert @fetcher.last_request["authorization"]
@@ -106,7 +106,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
106
106
  def test_sign_in_with_host
107
107
  api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
108
108
 
109
- util_sign_in [api_key, 200, "OK"], "http://example.com", ["http://example.com"]
109
+ util_sign_in HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK"), "http://example.com", ["http://example.com"]
110
110
 
111
111
  assert_match "Enter your http://example.com credentials.",
112
112
  @sign_in_ui.output
@@ -120,7 +120,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
120
120
  def test_sign_in_with_host_nil
121
121
  api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
122
122
 
123
- util_sign_in [api_key, 200, "OK"], nil, [nil]
123
+ util_sign_in HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK"), nil, [nil]
124
124
 
125
125
  assert_match "Enter your RubyGems.org credentials.",
126
126
  @sign_in_ui.output
@@ -133,7 +133,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
133
133
 
134
134
  def test_sign_in_with_host_ENV
135
135
  api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
136
- util_sign_in [api_key, 200, "OK"], "http://example.com"
136
+ util_sign_in HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK"), "http://example.com"
137
137
 
138
138
  assert_match "Enter your http://example.com credentials.",
139
139
  @sign_in_ui.output
@@ -148,7 +148,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
148
148
  api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
149
149
  Gem.configuration.rubygems_api_key = api_key
150
150
 
151
- util_sign_in [api_key, 200, "OK"]
151
+ util_sign_in HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
152
152
 
153
153
  assert_equal "", @sign_in_ui.output
154
154
  end
@@ -157,7 +157,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
157
157
  api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
158
158
  Gem.configuration.api_keys[:KEY] = "other"
159
159
  @cmd.options[:key] = :KEY
160
- util_sign_in [api_key, 200, "OK"]
160
+ util_sign_in HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
161
161
 
162
162
  assert_equal "", @sign_in_ui.output
163
163
  end
@@ -169,7 +169,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
169
169
  File.open Gem.configuration.credentials_path, "w" do |f|
170
170
  f.write Hash[:other_api_key, other_api_key].to_yaml
171
171
  end
172
- util_sign_in [api_key, 200, "OK"]
172
+ util_sign_in HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
173
173
 
174
174
  assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
175
175
  assert_match %r{Signed in.}, @sign_in_ui.output
@@ -181,7 +181,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
181
181
 
182
182
  def test_sign_in_with_bad_credentials
183
183
  assert_raise Gem::MockGemUi::TermError do
184
- util_sign_in ["Access Denied.", 403, "Forbidden"]
184
+ util_sign_in HTTPResponseFactory.create(body: "Access Denied.", code: 403, msg: "Forbidden")
185
185
  end
186
186
 
187
187
  assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
@@ -192,7 +192,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
192
192
  ENV["GEM_HOST_OTP_CODE"] = "111111"
193
193
  api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
194
194
 
195
- util_sign_in [api_key, 200, "OK"]
195
+ util_sign_in HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
196
196
 
197
197
  assert_match "Signed in with API key:", @sign_in_ui.output
198
198
  assert_equal "111111", @fetcher.last_request["OTP"]
@@ -204,7 +204,11 @@ class TestGemGemcutterUtilities < Gem::TestCase
204
204
 
205
205
  util_sign_in(proc do
206
206
  @call_count ||= 0
207
- (@call_count += 1).odd? ? [response_fail, 401, "Unauthorized"] : [api_key, 200, "OK"]
207
+ if (@call_count += 1).odd?
208
+ HTTPResponseFactory.create(body: response_fail, code: 401, msg: "Unauthorized")
209
+ else
210
+ HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
211
+ end
208
212
  end, nil, [], "111111\n")
209
213
 
210
214
  assert_match "You have enabled multi-factor authentication. Please enter OTP code.", @sign_in_ui.output
@@ -217,7 +221,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
217
221
  response = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
218
222
 
219
223
  assert_raise Gem::MockGemUi::TermError do
220
- util_sign_in [response, 401, "Unauthorized"], nil, [], "111111\n"
224
+ util_sign_in HTTPResponseFactory.create(body: response, code: 401, msg: "Unauthorized"), nil, [], "111111\n"
221
225
  end
222
226
 
223
227
  assert_match "You have enabled multi-factor authentication. Please enter OTP code.", @sign_in_ui.output
@@ -229,7 +233,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
229
233
  def util_sign_in(response, host = nil, args = [], extra_input = "")
230
234
  email = "you@example.com"
231
235
  password = "secret"
232
- profile_response = [ "mfa: disabled\n" , 200, "OK"]
236
+ profile_response = HTTPResponseFactory.create(body: "mfa: disabled\n", code: 200, msg: "OK")
233
237
 
234
238
  if host
235
239
  ENV["RUBYGEMS_HOST"] = host
@@ -510,6 +510,21 @@ class TestGemPackage < Gem::Package::TarTestCase
510
510
  assert_path_exist @destination
511
511
  end
512
512
 
513
+ def test_extract_file_permissions
514
+ pend "chmod not supported" if win_platform?
515
+
516
+ gem_with_long_permissions = File.expand_path("packages/Bluebie-legs-0.6.2.gem", __dir__)
517
+
518
+ package = Gem::Package.new gem_with_long_permissions
519
+
520
+ package.extract_files @destination
521
+
522
+ filepath = File.join @destination, "README.rdoc"
523
+ assert_path_exist filepath
524
+
525
+ assert_equal 0104444, File.stat(filepath).mode
526
+ end
527
+
513
528
  def test_extract_tar_gz_absolute
514
529
  package = Gem::Package.new @gem
515
530
 
@@ -333,6 +333,34 @@ class TestGemPlatform < Gem::TestCase
333
333
  refute(arm_linux_uclibceabi === arm_linux_eabi, "linux-uclibceabi =~ linux-eabi")
334
334
  end
335
335
 
336
+ def test_eabi_and_nil_version_combination_strictness
337
+ arm_linux = Gem::Platform.new "arm-linux"
338
+ arm_linux_eabi = Gem::Platform.new "arm-linux-eabi"
339
+ arm_linux_eabihf = Gem::Platform.new "arm-linux-eabihf"
340
+ arm_linux_gnueabi = Gem::Platform.new "arm-linux-gnueabi"
341
+ arm_linux_gnueabihf = Gem::Platform.new "arm-linux-gnueabihf"
342
+ arm_linux_musleabi = Gem::Platform.new "arm-linux-musleabi"
343
+ arm_linux_musleabihf = Gem::Platform.new "arm-linux-musleabihf"
344
+ arm_linux_uclibceabi = Gem::Platform.new "arm-linux-uclibceabi"
345
+ arm_linux_uclibceabihf = Gem::Platform.new "arm-linux-uclibceabihf"
346
+
347
+ # generic arm host runtime with eabi modifier accepts generic arm gems
348
+ assert(arm_linux === arm_linux_eabi, "arm-linux =~ arm-linux-eabi")
349
+ assert(arm_linux === arm_linux_eabihf, "arm-linux =~ arm-linux-eabihf")
350
+
351
+ # explicit gnu arm host runtime with eabi modifier accepts generic arm gems
352
+ assert(arm_linux === arm_linux_gnueabi, "arm-linux =~ arm-linux-gnueabi")
353
+ assert(arm_linux === arm_linux_gnueabihf, "arm-linux =~ arm-linux-gnueabihf")
354
+
355
+ # musl arm host runtime accepts libc-generic or statically linked gems...
356
+ assert(arm_linux === arm_linux_musleabi, "arm-linux =~ arm-linux-musleabi")
357
+ assert(arm_linux === arm_linux_musleabihf, "arm-linux =~ arm-linux-musleabihf")
358
+
359
+ # other libc arm hosts are not glibc compatible
360
+ refute(arm_linux === arm_linux_uclibceabi, "arm-linux =~ arm-linux-uclibceabi")
361
+ refute(arm_linux === arm_linux_uclibceabihf, "arm-linux =~ arm-linux-uclibceabihf")
362
+ end
363
+
336
364
  def test_equals3_cpu_arm
337
365
  arm = Gem::Platform.new "arm-linux"
338
366
  armv5 = Gem::Platform.new "armv5-linux"
@@ -452,6 +480,13 @@ class TestGemPlatform < Gem::TestCase
452
480
  assert_equal 1, result.scan(/@version=/).size
453
481
  end
454
482
 
483
+ def test_gem_platform_match_with_string_argument
484
+ util_set_arch "x86_64-linux-musl"
485
+
486
+ assert(Gem::Platform.match(Gem::Platform.new("x86_64-linux")), "should match Gem::Platform")
487
+ assert(Gem::Platform.match("x86_64-linux"), "should match String platform")
488
+ end
489
+
455
490
  def assert_local_match(name)
456
491
  assert_match Gem::Platform.local, name
457
492
  end
@@ -391,6 +391,39 @@ class TestGemResolver < Gem::TestCase
391
391
  end
392
392
  end
393
393
 
394
+ def test_pick_generic_linux_variants_on_musl_linux
395
+ util_set_arch "aarch64-linux-musl" do
396
+ is = Gem::Resolver::IndexSpecification
397
+
398
+ linux = Gem::Platform.new("aarch64-linux")
399
+
400
+ spec_fetcher do |fetcher|
401
+ fetcher.spec "libv8-node", "15.14.0.1" do |s|
402
+ s.platform = linux
403
+ end
404
+
405
+ fetcher.spec "libv8-node", "15.14.0.1"
406
+ end
407
+
408
+ v15 = v("15.14.0.1")
409
+ source = Gem::Source.new @gem_repo
410
+
411
+ s = set
412
+
413
+ v15_ruby = is.new s, "libv8-node", v15, source, Gem::Platform::RUBY
414
+ v15_linux = is.new s, "libv8-node", v15, source, linux.to_s
415
+
416
+ s.add v15_linux
417
+ s.add v15_ruby
418
+
419
+ ad = make_dep "libv8-node", "= 15.14.0.1"
420
+
421
+ res = Gem::Resolver.new([ad], s)
422
+
423
+ assert_resolves_to [v15_linux.spec], res
424
+ end
425
+ end
426
+
394
427
  def test_only_returns_spec_once
395
428
  a1 = util_spec "a", "1", "c" => "= 1"
396
429
  b1 = util_spec "b", "1", "c" => "= 1"
@@ -252,9 +252,9 @@ class TestGemRequire < Gem::TestCase
252
252
  # Activates a-1, but not b-1 and b-2
253
253
  assert_require "test_gem_require_a"
254
254
  assert_equal %w[a-1], loaded_spec_names
255
- assert $LOAD_PATH.include? a1.load_paths[0]
256
- refute $LOAD_PATH.include? b1.load_paths[0]
257
- refute $LOAD_PATH.include? b2.load_paths[0]
255
+ assert $LOAD_PATH.include? a1.full_require_paths[0]
256
+ refute $LOAD_PATH.include? b1.full_require_paths[0]
257
+ refute $LOAD_PATH.include? b2.full_require_paths[0]
258
258
 
259
259
  assert_equal unresolved_names, ["b (>= 1)"]
260
260
 
@@ -265,13 +265,13 @@ class TestGemRequire < Gem::TestCase
265
265
  # and as a result #gem_original_require returns false.
266
266
  refute require("benchmark"), "the benchmark stdlib should be recognized as already loaded"
267
267
 
268
- assert_includes $LOAD_PATH, b2.load_paths[0]
268
+ assert_includes $LOAD_PATH, b2.full_require_paths[0]
269
269
  assert_includes $LOAD_PATH, rubylibdir
270
270
  message = proc {
271
271
  "this test relies on the b-2 gem lib/ to be before stdlib to make sense\n" +
272
272
  $LOAD_PATH.pretty_inspect
273
273
  }
274
- assert_operator $LOAD_PATH.index(b2.load_paths[0]), :<, $LOAD_PATH.index(rubylibdir), message
274
+ assert_operator $LOAD_PATH.index(b2.full_require_paths[0]), :<, $LOAD_PATH.index(rubylibdir), message
275
275
 
276
276
  # We detected that we should activate b-2, so we did so, but
277
277
  # then #gem_original_require decided "I've already got some benchmark.rb" loaded.
@@ -54,13 +54,21 @@ class Gem::FakeFetcher
54
54
  raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
55
55
  end
56
56
 
57
- if @data[path].kind_of?(Array) && @data[path].first.kind_of?(Array)
57
+ if @data[path].kind_of?(Array)
58
58
  @data[path].shift
59
59
  else
60
60
  @data[path]
61
61
  end
62
62
  end
63
63
 
64
+ def create_response(uri)
65
+ data = find_data(uri)
66
+ response = data.respond_to?(:call) ? data.call : data
67
+ raise TypeError, "#{response.class} is not a type of Net::HTTPResponse" unless response.kind_of?(Net::HTTPResponse)
68
+
69
+ response
70
+ end
71
+
64
72
  def fetch_path(path, mtime = nil, head = false)
65
73
  data = find_data(path)
66
74
 
@@ -85,26 +93,16 @@ class Gem::FakeFetcher
85
93
 
86
94
  # Thanks, FakeWeb!
87
95
  def open_uri_or_path(path)
88
- data = find_data(path)
89
- body, code, msg = data
96
+ find_data(path)
90
97
 
91
- response = Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, msg)
92
- response.instance_variable_set(:@body, body)
93
- response.instance_variable_set(:@read, true)
94
- response
98
+ create_response(uri)
95
99
  end
96
100
 
97
101
  def request(uri, request_class, last_modified = nil)
98
- data = find_data(uri)
99
- body, code, msg = (data.respond_to?(:call) ? data.call : data)
100
-
101
102
  @last_request = request_class.new uri.request_uri
102
103
  yield @last_request if block_given?
103
104
 
104
- response = Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, msg)
105
- response.instance_variable_set(:@body, body)
106
- response.instance_variable_set(:@read, true)
107
- response
105
+ create_response(uri)
108
106
  end
109
107
 
110
108
  def pretty_print(q) # :nodoc:
@@ -164,6 +162,30 @@ class Gem::FakeFetcher
164
162
  end
165
163
  end
166
164
 
165
+ ##
166
+ # The HTTPResponseFactory allows easy creation of Net::HTTPResponse instances in RubyGems tests:
167
+ #
168
+ # Example:
169
+ #
170
+ # HTTPResponseFactory.create(
171
+ # body: "",
172
+ # code: 301,
173
+ # msg: "Moved Permanently",
174
+ # headers: { "location" => "http://example.com" }
175
+ # )
176
+ #
177
+
178
+ class HTTPResponseFactory
179
+ def self.create(body:, code:, msg:, headers: {})
180
+ response = Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, msg)
181
+ response.instance_variable_set(:@body, body)
182
+ response.instance_variable_set(:@read, true)
183
+ headers.each {|name, value| response[name] = value }
184
+
185
+ response
186
+ end
187
+ end
188
+
167
189
  # :stopdoc:
168
190
  class Gem::RemoteFetcher
169
191
  def self.fetcher=(fetcher)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-update
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.22
4
+ version: 3.3.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2022-09-07 00:00:00.000000000 Z
19
+ date: 2022-10-05 00:00:00.000000000 Z
20
20
  dependencies: []
21
21
  description: |-
22
22
  A package (also known as a library) contains a set of functionality
@@ -633,6 +633,7 @@ files:
633
633
  - test/rubygems/invalidchild_cert_32.pem
634
634
  - test/rubygems/invalidchild_key.pem
635
635
  - test/rubygems/package/tar_test_case.rb
636
+ - test/rubygems/packages/Bluebie-legs-0.6.2.gem
636
637
  - test/rubygems/packages/ascii_binder-0.1.10.1.gem
637
638
  - test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem
638
639
  - test/rubygems/plugin/exception/rubygems_plugin.rb
@@ -831,7 +832,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
831
832
  - !ruby/object:Gem::Version
832
833
  version: '0'
833
834
  requirements: []
834
- rubygems_version: 3.4.0.dev
835
+ rubygems_version: 3.3.23
835
836
  signing_key:
836
837
  specification_version: 4
837
838
  summary: RubyGems is a package management framework for Ruby.