Skip to content

Commit

Permalink
Test for more than one type of whitespace character in aws_checksum_u…
Browse files Browse the repository at this point in the history
…tils_spec.rb
  • Loading branch information
elohanlon committed May 14, 2024
1 parent 22ce9dc commit e5d4487
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions spec/atc/utils/aws_checksum_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
end

# NOTE: We ran into this issue in the past, so that's why this test exists
it 'properly handles chunks that are made entirely of line tabulation (0x0B) elements' do
it 'properly handles parts that are made entirely of whitespace characters (0x0B line tab, 0x0C form feed, etc.)' do
Tempfile.create('example-file-to-checksum') do |f|
f.write('A' * multipart_threshold)
f.write(Atc::Utils::HexUtils.hex_to_bin('0B') * multipart_threshold)
f.write(Atc::Utils::HexUtils.hex_to_bin('0B') * multipart_threshold)
f.write(Atc::Utils::HexUtils.hex_to_bin('0B') * (multipart_threshold - 10))
f.write(Atc::Utils::HexUtils.hex_to_bin('0C') * 10)
f.write('A' * multipart_threshold)
expect(described_class.checksum_string_for_file(f.path, multipart_threshold)).to eq('YjA5PQ==-4')
expect(described_class.checksum_string_for_file(f.path, multipart_threshold)).to eq('OdsyWA==-3')
end
end
end
Expand All @@ -45,18 +45,18 @@
let(:part_size) { 5.megabytes }

# NOTE: We ran into this issue in the past, so that's why this test exists
it 'properly handles chunks that are made entirely of line tabulation (0x0B) elements' do
it 'properly handles parts that are made entirely of whitespace characters (0x0B line tab, 0x0C form feed, etc.)' do
Tempfile.create('example-file-to-checksum') do |f|
f.write('A' * part_size)
f.write(Atc::Utils::HexUtils.hex_to_bin('0B') * part_size)
f.write(Atc::Utils::HexUtils.hex_to_bin('0B') * part_size)
f.write(Atc::Utils::HexUtils.hex_to_bin('0B') * (part_size - 10))
f.write(Atc::Utils::HexUtils.hex_to_bin('0C') * 10)
f.write('A' * part_size)
described_class.digest_file(f.path, part_size, crc32c_accumulator, whole_object_digester)
end
expect(
crc32c_accumulator.map { |checksum_bin_value| Base64.strict_encode64(checksum_bin_value) }
).to eq(['MDaLrw==', '6TPWQg==', '6TPWQg==', 'MDaLrw=='])
expect(whole_object_digester.base64digest).to eq('vobXrQ==')
).to eq(['MDaLrw==', 'X/yhqA==', 'MDaLrw=='])
expect(whole_object_digester.base64digest).to eq('NIRe3g==')
end
end

Expand Down

0 comments on commit e5d4487

Please sign in to comment.