Skip to content

Commit

Permalink
Make methods internal to validate_signature_catalog private
Browse files Browse the repository at this point in the history
  Keeping their specs around by .send-ing them to
  the checksum validator object
  • Loading branch information
tallenaz committed Mar 7, 2018
1 parent 4017fd6 commit e384155
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/services/checksum_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def validate_signature_catalog
validate_signature_catalog_listing
end

private

def validate_signature_catalog_listing
begin
latest_signature_catalog_entries.each { |entry| validate_signature_catalog_entry(entry) }
Expand All @@ -53,8 +55,6 @@ def flag_unexpected_data_content_files
checksum_results.report_results
end

private

# This method adds to the AuditResults object for any errors in checksum validation it encounters.
def validate_manifest_inventory(moab_version)
manifest_file_path = "#{moab_version.version_pathname}/#{MANIFESTS}/#{MANIFESTS_XML}"
Expand Down
20 changes: 10 additions & 10 deletions spec/services/checksum_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@

it 'instantiates storage_object from druid and druid_path' do
expect(Moab::StorageObject).to receive(:new).with(cv.druid, a_string_matching(object_dir)).and_call_original
cv.validate_signature_catalog_listing
cv.send(:validate_signature_catalog_listing)
end

it 'calls validate_signature_catalog_entry for each signatureCatalog entry' do
Expand All @@ -142,14 +142,14 @@
entry_list.each do |entry|
expect(cv).to receive(:validate_signature_catalog_entry).with(entry)
end
cv.validate_signature_catalog_listing
cv.send(:validate_signature_catalog_listing)
end

it 'calls AuditResults.report_results' do
results = instance_double(AuditResults, add_result: nil, :actual_version= => nil, :check_name= => nil)
allow(AuditResults).to receive(:new).and_return(results)
expect(results).to receive(:report_results)
cv.validate_signature_catalog_listing
cv.send(:validate_signature_catalog_listing)
end

context 'file checksums in singatureCatalog.xml do not match' do
Expand All @@ -162,7 +162,7 @@
expect(results).to receive(:add_result).with(
AuditResults::MOAB_FILE_CHECKSUM_MISMATCH, file_path: file_path, version: 1
)
cv.validate_signature_catalog_listing
cv.send(:validate_signature_catalog_listing)
end
end

Expand All @@ -177,7 +177,7 @@
expect(results).to receive(:add_result).with(
AuditResults::FILE_NOT_IN_MOAB, manifest_file_path: manifest_file_path, file_path: file_path
)
cv.validate_signature_catalog_listing
cv.send(:validate_signature_catalog_listing)
end
end

Expand All @@ -190,7 +190,7 @@
expect(results).to receive(:add_result).with(
AuditResults::MANIFEST_NOT_IN_MOAB, manifest_file_path: 'spec/fixtures/checksum_root01/moab_storage_trunk/vv/333/vv/3333/vv333vv3333/v0002/manifests/signatureCatalog.xml'
)
cv.validate_signature_catalog_listing
cv.send(:validate_signature_catalog_listing)
end
end

Expand All @@ -203,7 +203,7 @@
expect(results).to receive(:add_result).with(
AuditResults::INVALID_MANIFEST, manifest_file_path: 'spec/fixtures/checksum_root01/moab_storage_trunk/xx/444/xx/4444/xx444xx4444/v0001/manifests/signatureCatalog.xml'
)
cv.validate_signature_catalog_listing
cv.send(:validate_signature_catalog_listing)
end
end
end
Expand All @@ -219,14 +219,14 @@
files.each do |file|
expect(cv).to receive(:validate_against_signature_catalog).with(file)
end
cv.flag_unexpected_data_content_files
cv.send(:flag_unexpected_data_content_files)
end

it 'calls AuditResults.report_results' do
results = instance_double(AuditResults, add_result: nil, :actual_version= => nil, :check_name= => nil)
allow(AuditResults).to receive(:new).and_return(results)
expect(results).to receive(:report_results)
cv.flag_unexpected_data_content_files
cv.send(:flag_unexpected_data_content_files)
end

context 'file is on disk, but not present in signatureCatalog.xml' do
Expand All @@ -240,7 +240,7 @@
expect(results).to receive(:add_result).with(
AuditResults::FILE_NOT_IN_MANIFEST, file_path: file_path, manifest_file_path: manifest_file_path
)
cv.flag_unexpected_data_content_files
cv.send(:flag_unexpected_data_content_files)
end
end
end
Expand Down

0 comments on commit e384155

Please sign in to comment.