aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Emde <martin.emde@gmail.com>2023-12-14 12:41:08 -0800
committergit <svn-admin@ruby-lang.org>2023-12-15 19:36:24 +0000
commit1cfe874ef83cdb7776ecf892c470af634532501c (patch)
tree9c89cd8fe82def82ce011d8e11e9d19a2c36e968
parent0a31cb1a37f184daa7c2839abd6a827793fdd2f3 (diff)
downloadruby-1cfe874ef83cdb7776ecf892c470af634532501c.tar.gz
[rubygems/rubygems] Remove test-only & unused methods from Checksum::Store
https://github.com/rubygems/rubygems/commit/79636dec12
-rw-r--r--lib/bundler/checksum.rb11
-rw-r--r--spec/bundler/bundler/lockfile_parser_spec.rb23
2 files changed, 13 insertions, 21 deletions
diff --git a/lib/bundler/checksum.rb b/lib/bundler/checksum.rb
index 633aab5f10..742df42a74 100644
--- a/lib/bundler/checksum.rb
+++ b/lib/bundler/checksum.rb
@@ -163,21 +163,10 @@ module Bundler
@store = {}
end
- def initialize_copy(other)
- @store = {}
- other.store.each do |lock_name, checksums|
- store[lock_name] = checksums.dup
- end
- end
-
def inspect
"#<#{self.class}:#{object_id} size=#{store.size}>"
end
- def fetch(spec, algo = DEFAULT_ALGORITHM)
- store[spec.name_tuple.lock_name]&.fetch(algo, nil)
- end
-
# Replace when the new checksum is from the same source.
# The primary purpose of this registering checksums from gems where there are
# duplicates of the same gem (according to full_name) in the index.
diff --git a/spec/bundler/bundler/lockfile_parser_spec.rb b/spec/bundler/bundler/lockfile_parser_spec.rb
index 6d306da916..88932bf009 100644
--- a/spec/bundler/bundler/lockfile_parser_spec.rb
+++ b/spec/bundler/bundler/lockfile_parser_spec.rb
@@ -119,12 +119,13 @@ RSpec.describe Bundler::LockfileParser do
let(:bundler_version) { Gem::Version.new("1.12.0.rc.2") }
let(:ruby_version) { "ruby 2.1.3p242" }
let(:lockfile_path) { Bundler.default_lockfile.relative_path_from(Dir.pwd) }
- let(:rake_checksum) do
+ let(:rake_sha256_checksum) do
Bundler::Checksum.from_lock(
"sha256=814828c34f1315d7e7b7e8295184577cc4e969bad6156ac069d02d63f58d82e8",
"#{lockfile_path}:20:17"
)
end
+ let(:rake_checksums) { [rake_sha256_checksum] }
shared_examples_for "parsing" do
it "parses correctly" do
@@ -135,9 +136,9 @@ RSpec.describe Bundler::LockfileParser do
expect(subject.platforms).to eq platforms
expect(subject.bundler_version).to eq bundler_version
expect(subject.ruby_version).to eq ruby_version
- checksum = subject.sources.last.checksum_store.fetch(specs.last)
- expect(checksum).to be_match(rake_checksum)
- expect(checksum.sources.first.to_s).to match(/the lockfile CHECKSUMS at #{Regexp.escape(lockfile_path.to_s)}:\d+:\d+/)
+ rake_spec = specs.last
+ checksums = subject.sources.last.checksum_store.to_lock(specs.last)
+ expect(checksums).to eq("#{rake_spec.name_tuple.lock_name} #{rake_checksums.map(&:to_lock).sort.join(",")}")
end
end
@@ -174,18 +175,20 @@ RSpec.describe Bundler::LockfileParser do
end
context "when the checksum is of an unknown algorithm" do
+ let(:rake_sha512_checksum) do
+ Bundler::Checksum.from_lock(
+ "sha512=pVDn9GLmcFkz8vj1ueiVxj5uGKkAyaqYjEX8zG6L5O4BeVg3wANaKbQdpj/B82Nd/MHVszy6polHcyotUdwilQ==",
+ "#{lockfile_path}:20:17"
+ )
+ end
let(:lockfile_contents) do
super().sub(
"sha256=",
"sha512=pVDn9GLmcFkz8vj1ueiVxj5uGKkAyaqYjEX8zG6L5O4BeVg3wANaKbQdpj/B82Nd/MHVszy6polHcyotUdwilQ==,sha256="
)
end
+ let(:rake_checksums) { [rake_sha256_checksum, rake_sha512_checksum] }
include_examples "parsing"
-
- it "preserves the checksum as is" do
- checksum = subject.sources.last.checksum_store.fetch(specs.last, "sha512")
- expect(checksum.algo).to eq("sha512")
- end
end
context "when CHECKSUMS has duplicate checksums in the lockfile that don't match" do
@@ -198,7 +201,7 @@ RSpec.describe Bundler::LockfileParser do
Bundler found mismatched checksums. This is a potential security risk.
rake (10.3.2) #{bad_checksum}
from the lockfile CHECKSUMS at #{lockfile_path}:20:17
- rake (10.3.2) #{rake_checksum.to_lock}
+ rake (10.3.2) #{rake_sha256_checksum.to_lock}
from the lockfile CHECKSUMS at #{lockfile_path}:21:17
To resolve this issue you can either: