From a73afcd2dbd65ef054c376a65b7b4bc03ea66d69 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Wed, 25 Jul 2018 07:11:08 -0700 Subject: [PATCH 1/2] Get the checksum file from archive.apache.org Previously, when a mirror was set it was trying to get the checksum from www.us.apache.org which only had the checksums for the three supported versions. --- lib/solr_wrapper/checksum_validator.rb | 6 +----- spec/lib/solr_wrapper/checksum_validator_spec.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 spec/lib/solr_wrapper/checksum_validator_spec.rb diff --git a/lib/solr_wrapper/checksum_validator.rb b/lib/solr_wrapper/checksum_validator.rb index 49a020f..c4228b7 100644 --- a/lib/solr_wrapper/checksum_validator.rb +++ b/lib/solr_wrapper/checksum_validator.rb @@ -25,11 +25,7 @@ def validate!(file) private def checksumurl(suffix) - if config.default_download_url == config.static_config.archive_download_url - "#{config.default_download_url}.#{suffix}" - else - "http://www.us.apache.org/dist/lucene/solr/#{config.static_config.version}/solr-#{config.static_config.version}.zip.#{suffix}" - end + "http://archive.apache.org/dist/lucene/solr/#{config.static_config.version}/solr-#{config.static_config.version}.zip.#{suffix}" end def checksum_path(suffix) diff --git a/spec/lib/solr_wrapper/checksum_validator_spec.rb b/spec/lib/solr_wrapper/checksum_validator_spec.rb new file mode 100644 index 0000000..5684d52 --- /dev/null +++ b/spec/lib/solr_wrapper/checksum_validator_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +RSpec.describe SolrWrapper::ChecksumValidator do + let(:validator) { described_class.new(settings) } + let(:settings) { SolrWrapper::Settings.new(config) } + let(:config) { SolrWrapper::Configuration.new(options) } + let(:options) { { version: '6.6.0'} } + + describe '#checksumurl' do + subject { validator.send(:checksumurl, described_class::ALGORITHM) } + + it { is_expected.to eq 'http://archive.apache.org/dist/lucene/solr/6.6.0/solr-6.6.0.zip.sha1' } + end +end From c80a277a3028296d2201a454910769e23eb87eb3 Mon Sep 17 00:00:00 2001 From: Collin Brittle Date: Thu, 6 Sep 2018 20:56:18 +0000 Subject: [PATCH 2/2] Allow checksum URLs from the checksum option If the checksum option is a URL, use it to get the checksum, rather than the archive.apache.org URL. --- lib/solr_wrapper/checksum_validator.rb | 10 +++++++++- spec/lib/solr_wrapper/checksum_validator_spec.rb | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/solr_wrapper/checksum_validator.rb b/lib/solr_wrapper/checksum_validator.rb index c4228b7..5b34f4b 100644 --- a/lib/solr_wrapper/checksum_validator.rb +++ b/lib/solr_wrapper/checksum_validator.rb @@ -25,7 +25,15 @@ def validate!(file) private def checksumurl(suffix) - "http://archive.apache.org/dist/lucene/solr/#{config.static_config.version}/solr-#{config.static_config.version}.zip.#{suffix}" + if remote_checksum?(suffix) + config.checksum + else + "http://archive.apache.org/dist/lucene/solr/#{config.static_config.version}/solr-#{config.static_config.version}.zip.#{suffix}" + end + end + + def remote_checksum?(alg) + config.checksum && config.checksum.match(/http.*#{alg}/, 0) end def checksum_path(suffix) diff --git a/spec/lib/solr_wrapper/checksum_validator_spec.rb b/spec/lib/solr_wrapper/checksum_validator_spec.rb index 5684d52..cc74b8c 100644 --- a/spec/lib/solr_wrapper/checksum_validator_spec.rb +++ b/spec/lib/solr_wrapper/checksum_validator_spec.rb @@ -4,11 +4,23 @@ let(:validator) { described_class.new(settings) } let(:settings) { SolrWrapper::Settings.new(config) } let(:config) { SolrWrapper::Configuration.new(options) } - let(:options) { { version: '6.6.0'} } describe '#checksumurl' do subject { validator.send(:checksumurl, described_class::ALGORITHM) } - it { is_expected.to eq 'http://archive.apache.org/dist/lucene/solr/6.6.0/solr-6.6.0.zip.sha1' } + context 'when the checksum option is not set' do + let(:options) { { version: '6.6.0'} } + it { is_expected.to eq 'http://archive.apache.org/dist/lucene/solr/6.6.0/solr-6.6.0.zip.sha1' } + end + + context 'when the checksum option is not a URL' do + let(:options) { { version: '6.6.1', checksum: './just/a/path.sha1'} } + it { is_expected.to eq 'http://archive.apache.org/dist/lucene/solr/6.6.1/solr-6.6.1.zip.sha1' } + end + + context 'when the checksum option is a URL' do + let(:options) { { version: '6.6.2', checksum: 'http://lib-solr-mirror.princeton.edu/dist/lucene/solr/6.6.2/solr-6.6.2.zip.sha1'} } + it { is_expected.to eq 'http://lib-solr-mirror.princeton.edu/dist/lucene/solr/6.6.2/solr-6.6.2.zip.sha1' } + end end end