Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Commit

Permalink
accomodate SHA-1 as the default checksum algorithm; closes #1555
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Coble committed Jan 21, 2016
1 parent 5106fd1 commit 453aa9d
Show file tree
Hide file tree
Showing 25 changed files with 479 additions and 479 deletions.
8 changes: 4 additions & 4 deletions app/services/build_batch_from_folder_ingest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(user, filesystem, content_modeler, metadata_provider, checksum_pr
@filesystem = filesystem
@content_modeler = content_modeler
@metadata_provider = metadata_provider
@checksum_provider = checksum_provider
@checksum_provider = checksum_provider
@batch_name = batch_name
@batch_description = batch_description
end
Expand All @@ -17,7 +17,7 @@ def call
@batch = create_batch
traverse_filesystem
batch.update_attributes(status: Ddr::Batch::Batch::STATUS_READY)
batch
batch
end

private
Expand Down Expand Up @@ -85,7 +85,7 @@ def add_content_datastream(batch_object, node)
payload: full_filepath,
payload_type: Ddr::Batch::BatchObjectDatastream::PAYLOAD_TYPE_FILENAME,
checksum: checksum_provider.checksum(rel_filepath),
checksum_type: Ddr::Datastreams::CHECKSUM_TYPE_SHA256
checksum_type: Ddr::Datastreams::CHECKSUM_TYPE_SHA1
)
batch_object.batch_object_datastreams << ds
end
Expand All @@ -99,4 +99,4 @@ def create_relationship(relationship_name, relationship_target_pid)
)
end

end
end
2 changes: 1 addition & 1 deletion app/views/application/_select_content_file.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="col-md-3">
<div class="form-group">
<%= label_tag "content_checksum_type", "Checksum Type" %>
<%= select_tag "content[checksum_type]", options_for_select(Ddr::Datastreams::CHECKSUM_TYPES, "SHA-256"), class: "form-control" %>
<%= select_tag "content[checksum_type]", options_for_select(Ddr::Datastreams::CHECKSUM_TYPES, "SHA-1"), class: "form-control" %>
</div>
</div>
<div class="col-md-9">
Expand Down
2 changes: 1 addition & 1 deletion config/folder_ingest.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ config:
target_folder: targets
checksum_file:
location: /dir/fixity/fedora_ingest/
type: SHA-256
type: SHA-1
files:
included_extensions:
- .pdf
Expand Down
438 changes: 219 additions & 219 deletions fedora_conf/conf/development/fedora.fcfg

Large diffs are not rendered by default.

438 changes: 219 additions & 219 deletions fedora_conf/conf/test/fedora.fcfg

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/dul_hydra/batch/scripts/process_simple_ingest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ProcessSimpleIngest

attr_reader :batch_user, :configuration, :filepath

CHECKSUM_FILE = 'manifest-sha256.txt'
CHECKSUM_FILE = 'manifest-sha1.txt'
METADATA_FILE = 'metadata.txt'
DEFAULT_CONFIG_FILE = Rails.root.join('config', 'simple_ingest.yml')
DEFAULT_ARGUMENTS = { config_file: DEFAULT_CONFIG_FILE }
Expand Down Expand Up @@ -81,4 +81,4 @@ def build_batch(filesystem)
end

end
end
end
2 changes: 1 addition & 1 deletion lib/dul_hydra/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module DulHydra
VERSION = "4.2.1"
VERSION = "4.2.2"
end
2 changes: 1 addition & 1 deletion spec/controllers/attachments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def create_attachment opts={}
end
it "should validate the checksum when provided" do
expect(controller).to receive(:validate_checksum)
create_attachment(checksum: "b3f5fc721b5b7ea0c1756a68ed4626463c610170aa199f798fb630ddbea87b18", checksum_type: "SHA-256")
create_attachment(checksum: "ff01aab0eada29d35bb423c5c73a9f67a22bc1fd", checksum_type: "SHA-1")
end
end
describe "user cannot add attachments to object" do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/components_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def create_component opts={}
end
it "should validate the checksum when provided" do
expect(controller).to receive(:validate_checksum)
create_component(checksum: "bda5fda452d0047c27e9e0048ed59428cb9e6d5d46fe9c27dff5c8e39b75a59e", checksum_type: "SHA-256")
create_component(checksum: "75e2e0cec6e807f6ae63610d46448f777591dd6b", checksum_type: "SHA-1")
end
end
context "when the user cannot add children to the item" do
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/ingest_folders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
expect(assigns[:ingest_folder].model).to eql(IngestFolder.default_file_model)
expect(assigns[:ingest_folder].base_path).to eql("base/path/")
expect(assigns[:ingest_folder].sub_path).to eql('/subpath/subsubpath/')
expect(assigns[:ingest_folder].checksum_file).to eql(File.join(IngestFolder.default_checksum_file_location, "subpath-base-sha256.txt"))
expect(assigns[:ingest_folder].checksum_type).to eql(Ddr::Datastreams::CHECKSUM_TYPE_SHA256)
expect(assigns[:ingest_folder].checksum_file).to eql(File.join(IngestFolder.default_checksum_file_location, "subpath-base-sha1.txt"))
expect(assigns[:ingest_folder].checksum_type).to eql(Ddr::Datastreams::CHECKSUM_TYPE_SHA1)
end

end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/items_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def create_item_and_component opts={}
end
it "should validate the checksum if provided" do
expect_any_instance_of(Component).to receive(:validate_checksum!)
create_item_and_component(checksum: "bda5fda452d0047c27e9e0048ed59428cb9e6d5d46fe9c27dff5c8e39b75a59e", checksum_type: "SHA-256")
create_item_and_component(checksum: "75e2e0cec6e807f6ae63610d46448f777591dd6b", checksum_type: "SHA-1")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/batch_object_datastream_factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
name Ddr::Datastreams::CONTENT
payload File.join(Rails.root, 'spec', 'fixtures', 'batch_ingest', 'miscellaneous', 'id001.tif')
payload_type Ddr::Batch::BatchObjectDatastream::PAYLOAD_TYPE_FILENAME
checksum "120ad0814f207c45d968b05f7435034ecfee8ac1a0958cd984a070dad31f66f3"
checksum_type Ddr::Datastreams::CHECKSUM_TYPE_SHA256
checksum "257fa1025245d2d2a60ae81ac7922ca9581ca314"
checksum_type Ddr::Datastreams::CHECKSUM_TYPE_SHA1
end

end
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/ingest_folder_factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
model "TestChild"
base_path "base/path/"
sub_path "subpath"
checksum_type Ddr::Datastreams::CHECKSUM_TYPE_SHA256
checksum_type Ddr::Datastreams::CHECKSUM_TYPE_SHA1
collection_pid "test:456"
add_parents true
parent_id_length 1
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/batch_ingest/miscellaneous/checksums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<checksums>
<checksum>
<id>id001</id>
<value>120ad0814f207c45d968b05f7435034ecfee8ac1a0958cd984a070dad31f66f3</value>
<type>SHA-256</type>
<value>257fa1025245d2d2a60ae81ac7922ca9581ca314</value>
<type>SHA-1</type>
<filename>id001.tif</filename>
</checksum>
</checksums>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<checksums>
<checksum>
<id>id001</id>
<misnamedvalue>120ad0814f207c45d968b05f7435034ecfee8ac1a0958cd984a070dad31f66f3</misnamedvalue>
<misnamedtype>SHA-256</misnamedtype>
<misnamedvalue>257fa1025245d2d2a60ae81ac7922ca9581ca314</misnamedvalue>
<misnamedtype>SHA-1</misnamedtype>
<filename>id001.tif</filename>
</checksum>
</checksums>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<checksums>
<checksum>
<componentid>id001</componentid>
<value>badad0814f207c45d968b05f7435034ecfee8ac1a0958cd984a070dad31f66f3</value>
<type>SHA-256</type>
<value>badfa1025245d2d2a60ae81ac7922ca9581ca314</value>
<type>SHA-1</type>
<filename>id001.tif</filename>
</checksum>
</checksums>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
548bd2678027f3acb4d4c5ccedf6f92ca07f74bd data/itemA/image1.tiff

This file was deleted.

5 changes: 5 additions & 0 deletions spec/fixtures/batch_ingest/simple_ingest/manifest-sha1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
7cc5abd7ed8c1c907d86bba5e6e18ed6c6ec995c data/file01001.tif
75e2e0cec6e807f6ae63610d46448f777591dd6b data/file01002.tif
a6ae0d815c1a2aef551b45fe34a35ceea1828a4d data/pdf/file01.pdf
2cf23f0035c12b6242093e93d0f7eeba0b1e08e8 data/targets/T001.tiff
ff01aab0eada29d35bb423c5c73a9f67a22bc1fd data/targets/T002.tiff
5 changes: 0 additions & 5 deletions spec/fixtures/batch_ingest/simple_ingest/manifest-sha256.txt

This file was deleted.

2 changes: 1 addition & 1 deletion spec/models/ingest_folder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
let(:mount_point_path) { "/mount/" }
let(:base_path) { File.join(mount_point_name, "base/path/") }
let(:checksum_directory) { "/fixity/fedora_ingest/" }
let(:checksum_type) { "sha256" }
let(:checksum_type) { "sha1" }
let(:user) { FactoryGirl.create(:user) }
before do
allow(File).to receive(:readable?).and_return(true)
Expand Down
8 changes: 4 additions & 4 deletions spec/models/simple_ingest_checksum_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

RSpec.describe SimpleIngestChecksum, type: :model, batch: true, simple_ingest: true do

let(:checksum_filepath) { Rails.root.join('spec', 'fixtures', 'batch_ingest', 'simple_ingest', 'manifest-sha256.txt') }
let(:checksum_filepath) { Rails.root.join('spec', 'fixtures', 'batch_ingest', 'simple_ingest', 'manifest-sha1.txt') }
let(:sic) { SimpleIngestChecksum.new(checksum_filepath) }

describe "checksum" do
it "should provide the recorded checksum" do
expect(sic.checksum('file01001.tif')).to eq('120ad0814f207c45d968b05f7435034ecfee8ac1a0958cd984a070dad31f66f3')
expect(sic.checksum('targets/T001.tiff')).to eq('6890139bcc7b9cc0341fee77e8149aad4c7368eb5d0511ae480609dabd48b0c5')
expect(sic.checksum('file01001.tif')).to eq('7cc5abd7ed8c1c907d86bba5e6e18ed6c6ec995c')
expect(sic.checksum('targets/T001.tiff')).to eq('2cf23f0035c12b6242093e93d0f7eeba0b1e08e8')
expect(sic.checksum('image001.tif')).to be nil
end
end

end
end
4 changes: 2 additions & 2 deletions spec/scripts/batch_fixity_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ module Scripts
createDate = Time.parse(row["dsCreateDate"])
expect(createDate).to be_a Time
expect(createDate).to_not be_utc
expect(row["dsChecksumType"]).to eq("SHA-256")
expect(row["dsChecksum"]).to match(/^\h{64}$/)
expect(row["dsChecksumType"]).to eq("SHA-1")
expect(row["dsChecksum"]).to match(/^\h{40}$/)
expect(row["dsChecksumValid"]).to match(/^(true|false)$/)
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/scripts/process_simple_ingest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ module DulHydra::Batch::Scripts
expect(batch_objects[2].batch_object_attributes.where(name: 'title').first.value).to eq('Component 1 Title')
content_ds = batch_objects[2].batch_object_datastreams.where(name: Ddr::Datastreams::CONTENT).first
expect(content_ds.payload).to eq(File.join(folder_path, 'data', 'itemA', 'image1.tiff'))
expect(content_ds.checksum).to eq('bda5fda452d0047c27e9e0048ed59428cb9e6d5d46fe9c27dff5c8e39b75a59e')
expect(content_ds.checksum).to eq('548bd2678027f3acb4d4c5ccedf6f92ca07f74bd')
end
end

end

end
end
6 changes: 3 additions & 3 deletions spec/services/build_batch_from_folder_ingest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

it "should build an appropriate batch" do
batch = batch_builder.call

# Batch expectations
expect(batch.id).to be_present
expect(batch.name).to eq(batch_name)
Expand Down Expand Up @@ -92,7 +92,7 @@
content_datastreams = obj.batch_object_datastreams.where(
name: Ddr::Datastreams::CONTENT)
expect(content_datastreams.size).to eq(1)
expect(content_datastreams.first.checksum_type).to eq(Ddr::Datastreams::CHECKSUM_TYPE_SHA256)
expect(content_datastreams.first.checksum_type).to eq(Ddr::Datastreams::CHECKSUM_TYPE_SHA1)
component_filepaths << content_datastreams.first.payload
component_checksums << content_datastreams.first.checksum
end
Expand All @@ -112,4 +112,4 @@

end

end
end

0 comments on commit 453aa9d

Please sign in to comment.