mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
[rubygems/rubygems] Remove test-only & unused methods from Checksum::Store
79636dec12
This commit is contained in:
parent
0a31cb1a37
commit
1cfe874ef8
2 changed files with 13 additions and 21 deletions
|
@ -163,21 +163,10 @@ module Bundler
|
||||||
@store = {}
|
@store = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_copy(other)
|
|
||||||
@store = {}
|
|
||||||
other.store.each do |lock_name, checksums|
|
|
||||||
store[lock_name] = checksums.dup
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
"#<#{self.class}:#{object_id} size=#{store.size}>"
|
"#<#{self.class}:#{object_id} size=#{store.size}>"
|
||||||
end
|
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.
|
# Replace when the new checksum is from the same source.
|
||||||
# The primary purpose of this registering checksums from gems where there are
|
# The primary purpose of this registering checksums from gems where there are
|
||||||
# duplicates of the same gem (according to full_name) in the index.
|
# duplicates of the same gem (according to full_name) in the index.
|
||||||
|
|
|
@ -119,12 +119,13 @@ RSpec.describe Bundler::LockfileParser do
|
||||||
let(:bundler_version) { Gem::Version.new("1.12.0.rc.2") }
|
let(:bundler_version) { Gem::Version.new("1.12.0.rc.2") }
|
||||||
let(:ruby_version) { "ruby 2.1.3p242" }
|
let(:ruby_version) { "ruby 2.1.3p242" }
|
||||||
let(:lockfile_path) { Bundler.default_lockfile.relative_path_from(Dir.pwd) }
|
let(:lockfile_path) { Bundler.default_lockfile.relative_path_from(Dir.pwd) }
|
||||||
let(:rake_checksum) do
|
let(:rake_sha256_checksum) do
|
||||||
Bundler::Checksum.from_lock(
|
Bundler::Checksum.from_lock(
|
||||||
"sha256=814828c34f1315d7e7b7e8295184577cc4e969bad6156ac069d02d63f58d82e8",
|
"sha256=814828c34f1315d7e7b7e8295184577cc4e969bad6156ac069d02d63f58d82e8",
|
||||||
"#{lockfile_path}:20:17"
|
"#{lockfile_path}:20:17"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
let(:rake_checksums) { [rake_sha256_checksum] }
|
||||||
|
|
||||||
shared_examples_for "parsing" do
|
shared_examples_for "parsing" do
|
||||||
it "parses correctly" do
|
it "parses correctly" do
|
||||||
|
@ -135,9 +136,9 @@ RSpec.describe Bundler::LockfileParser do
|
||||||
expect(subject.platforms).to eq platforms
|
expect(subject.platforms).to eq platforms
|
||||||
expect(subject.bundler_version).to eq bundler_version
|
expect(subject.bundler_version).to eq bundler_version
|
||||||
expect(subject.ruby_version).to eq ruby_version
|
expect(subject.ruby_version).to eq ruby_version
|
||||||
checksum = subject.sources.last.checksum_store.fetch(specs.last)
|
rake_spec = specs.last
|
||||||
expect(checksum).to be_match(rake_checksum)
|
checksums = subject.sources.last.checksum_store.to_lock(specs.last)
|
||||||
expect(checksum.sources.first.to_s).to match(/the lockfile CHECKSUMS at #{Regexp.escape(lockfile_path.to_s)}:\d+:\d+/)
|
expect(checksums).to eq("#{rake_spec.name_tuple.lock_name} #{rake_checksums.map(&:to_lock).sort.join(",")}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -174,18 +175,20 @@ RSpec.describe Bundler::LockfileParser do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the checksum is of an unknown algorithm" do
|
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
|
let(:lockfile_contents) do
|
||||||
super().sub(
|
super().sub(
|
||||||
"sha256=",
|
"sha256=",
|
||||||
"sha512=pVDn9GLmcFkz8vj1ueiVxj5uGKkAyaqYjEX8zG6L5O4BeVg3wANaKbQdpj/B82Nd/MHVszy6polHcyotUdwilQ==,sha256="
|
"sha512=pVDn9GLmcFkz8vj1ueiVxj5uGKkAyaqYjEX8zG6L5O4BeVg3wANaKbQdpj/B82Nd/MHVszy6polHcyotUdwilQ==,sha256="
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
let(:rake_checksums) { [rake_sha256_checksum, rake_sha512_checksum] }
|
||||||
include_examples "parsing"
|
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
|
end
|
||||||
|
|
||||||
context "when CHECKSUMS has duplicate checksums in the lockfile that don't match" do
|
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.
|
Bundler found mismatched checksums. This is a potential security risk.
|
||||||
rake (10.3.2) #{bad_checksum}
|
rake (10.3.2) #{bad_checksum}
|
||||||
from the lockfile CHECKSUMS at #{lockfile_path}:20:17
|
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
|
from the lockfile CHECKSUMS at #{lockfile_path}:21:17
|
||||||
|
|
||||||
To resolve this issue you can either:
|
To resolve this issue you can either:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue