Skip to content

Commit

Permalink
refs LibraryOfCongress#119 - changed sha-1 to sha1 to be more inline …
Browse files Browse the repository at this point in the history
…with bagit-python. Also added tests for valid bags of each standard algorithm
  • Loading branch information
jscancella authored and Richard van Heest committed Feb 20, 2019
1 parent 3cc8f2f commit ce98451
Show file tree
Hide file tree
Showing 28 changed files with 87 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
public enum StandardSupportedAlgorithms implements SupportedAlgorithm{
MD5("MD5"),
SHA1("SHA-1"),
SHA1("SHA1"),
SHA224("SHA224"),
SHA256("SHA256"),
SHA512("SHA512");
Expand Down
35 changes: 35 additions & 0 deletions src/test/java/gov/loc/repository/bagit/verify/BagVerifierTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,41 @@ public void testStandardSupportedAlgorithms() throws Exception{
}
}

@Test
public void testMD5Bag() throws Exception{
Path bagDir = Paths.get("src", "test", "resources", "md5Bag");
Bag bag = reader.read(bagDir);
sut.isValid(bag, true);
}

@Test
public void testSHA1Bag() throws Exception{
Path bagDir = Paths.get("src", "test", "resources", "sha1Bag");
Bag bag = reader.read(bagDir);
sut.isValid(bag, true);
}

@Test
public void testSHA224Bag() throws Exception{
Path bagDir = Paths.get("src", "test", "resources", "sha224Bag");
Bag bag = reader.read(bagDir);
sut.isValid(bag, true);
}

@Test
public void testSHA256Bag() throws Exception{
Path bagDir = Paths.get("src", "test", "resources", "sha256Bag");
Bag bag = reader.read(bagDir);
sut.isValid(bag, true);
}

@Test
public void testSHA512Bag() throws Exception{
Path bagDir = Paths.get("src", "test", "resources", "sha512Bag");
Bag bag = reader.read(bagDir);
sut.isValid(bag, true);
}

@Test
public void testVersion0_97IsValid() throws Exception{
Bag bag = reader.read(rootDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import gov.loc.repository.bagit.hash.StandardBagitAlgorithmNameToSupportedAlgorithmMapping;
import gov.loc.repository.bagit.reader.BagReader;

public class PayloadVerifierTest {
public class ManifestVerifierTest {

private Path rootDir = Paths.get(new File("src/test/resources/bags/v0_97/bag").toURI());
private BagReader reader = new BagReader();
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/md5Bag/bag-info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bag-Software-Agent: bagit.py v1.7.0 <https://github.com/LibraryOfCongress/bagit-python>
Bagging-Date: 2018-07-24
Payload-Oxum: 52.1
2 changes: 2 additions & 0 deletions src/test/resources/md5Bag/bagit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BagIt-Version: 0.97
Tag-File-Character-Encoding: UTF-8
1 change: 1 addition & 0 deletions src/test/resources/md5Bag/data/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is a valid md5 bag used for testing valid bags
1 change: 1 addition & 0 deletions src/test/resources/md5Bag/manifest-md5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aee452eebfbd978228775bf7b0e808dc data/readme.txt
3 changes: 3 additions & 0 deletions src/test/resources/md5Bag/tagmanifest-md5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
59044a83bd40ec50b7ee927bf1e672a9 bag-info.txt
9e5ad981e0d29adc278f6a294b8c2aca bagit.txt
f1578aeea7f57af650f0a94565e40ceb manifest-md5.txt
3 changes: 3 additions & 0 deletions src/test/resources/sha1Bag/bag-info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bag-Software-Agent: bagit.py v1.7.0 <https://github.com/LibraryOfCongress/bagit-python>
Bagging-Date: 2018-07-24
Payload-Oxum: 43.1
2 changes: 2 additions & 0 deletions src/test/resources/sha1Bag/bagit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BagIt-Version: 0.97
Tag-File-Character-Encoding: UTF-8
1 change: 1 addition & 0 deletions src/test/resources/sha1Bag/data/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is a sha1 bag used to test valid bags
1 change: 1 addition & 0 deletions src/test/resources/sha1Bag/manifest-sha1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2f0973b52379ea88967e5e319941ff167d680ee9 data/readme.txt
3 changes: 3 additions & 0 deletions src/test/resources/sha1Bag/tagmanifest-sha1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
27bfaef124e06412f40c75bf6e5aa1cf4dbb9774 bag-info.txt
e2924b081506bac23f5fffe650ad1848a1c8ac1d bagit.txt
54adcabf9b1038d090d145d9315070c5493db1e6 manifest-sha1.txt
3 changes: 3 additions & 0 deletions src/test/resources/sha224Bag/bag-info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bag-Software-Agent: bagit.py v1.7.0 <https://github.com/LibraryOfCongress/bagit-python>
Bagging-Date: 2018-07-24
Payload-Oxum: 45.1
2 changes: 2 additions & 0 deletions src/test/resources/sha224Bag/bagit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BagIt-Version: 0.97
Tag-File-Character-Encoding: UTF-8
1 change: 1 addition & 0 deletions src/test/resources/sha224Bag/data/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is a sha224 valid bag, used for testing
1 change: 1 addition & 0 deletions src/test/resources/sha224Bag/manifest-sha224.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
476ba7f2f92170790679502b1f1bad48a9d0ae74b561cf558370a5fb data/readme.txt
3 changes: 3 additions & 0 deletions src/test/resources/sha224Bag/tagmanifest-sha224.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
34458393a69d3c6a5ec82743e1817032b3dc875ae10ff19b2c55ed1c bag-info.txt
fe7e72d15c56a8e8017246f52765a93ce4823d1fa3ed1e0d1ac3695f bagit.txt
8c717410c037477322cdd4069feeff2aa09eb0991989807724defaae manifest-sha224.txt
3 changes: 3 additions & 0 deletions src/test/resources/sha256Bag/bag-info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bag-Software-Agent: bagit.py v1.7.0 <https://github.com/LibraryOfCongress/bagit-python>
Bagging-Date: 2018-07-24
Payload-Oxum: 44.1
2 changes: 2 additions & 0 deletions src/test/resources/sha256Bag/bagit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BagIt-Version: 0.97
Tag-File-Character-Encoding: UTF-8
1 change: 1 addition & 0 deletions src/test/resources/sha256Bag/data/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is a valid sha256 bag used for testing
1 change: 1 addition & 0 deletions src/test/resources/sha256Bag/manifest-sha256.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
694d56447888829536b5782536f2bbe5c83325b1b2fd56a5ca676c991f196bf7 data/readme.txt
3 changes: 3 additions & 0 deletions src/test/resources/sha256Bag/tagmanifest-sha256.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
d0d7117f5662fe588aab40c61c66163e961c930ffec5fd52d64d39a6aa8f8e38 bag-info.txt
e91f941be5973ff71f1dccbdd1a32d598881893a7f21be516aca743da38b1689 bagit.txt
ba57368e0165a727b0b6cc5f040c5cbd3e3ac28d1d52f94d111d64382c6f0466 manifest-sha256.txt
3 changes: 3 additions & 0 deletions src/test/resources/sha512Bag/bag-info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bag-Software-Agent: bagit.py v1.7.0 <https://github.com/LibraryOfCongress/bagit-python>
Bagging-Date: 2018-07-24
Payload-Oxum: 44.1
2 changes: 2 additions & 0 deletions src/test/resources/sha512Bag/bagit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BagIt-Version: 0.97
Tag-File-Character-Encoding: UTF-8
1 change: 1 addition & 0 deletions src/test/resources/sha512Bag/data/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is a valid sha512 bag used for testing
1 change: 1 addition & 0 deletions src/test/resources/sha512Bag/manifest-sha512.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6e464149951ad3e3975c326ccb5c6e4ce306516fcc99689d90094e3bfbd87e87e0f7dbb4efd8e59456b808ca2b7a22bb14fa0b1edb76e11964a181850b45a628 data/readme.txt
3 changes: 3 additions & 0 deletions src/test/resources/sha512Bag/tagmanifest-sha512.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bede8e68c6fef4be00b54e5a5c2e104501444531679948187926a84a4e5c85d466959f34dae9ac4c81ccea4ec28e3f0ea7b661c0f100e457b3a568a08661cc01 bag-info.txt
418dcfbe17d5f4b454b18630be795462cf7da4ceb6313afa49451aa2568e41f7ca3d34cf0280c7d056dc5681a70c37586aa1755620520b9198eede905ba2d0f6 bagit.txt
82e79660ff0335b94f56a0b837b1564291b3eb2242a8c28c51d32efc6db9db5ab6fe7656d975bf16989c67ef3a3fa5cbd066eb1bcf422207ec41a20ed0f98943 manifest-sha512.txt

0 comments on commit ce98451

Please sign in to comment.