Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various fixes #125

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ private static void checkManifestPayload(final Path manifestFile, final Charset
String path = parsePath(line);

path = checkForManifestCreatedWithMD5SumTools(path, warnings, warningsToIgnore);
paths.add(path.toLowerCase());

checkForDifferentCase(path, paths, manifestFile, warnings, warningsToIgnore);
paths.add(path.toLowerCase());

if(encoding.name().startsWith("UTF")){
checkNormalization(path, manifestFile.getParent(), warnings, warningsToIgnore);
}
Expand Down Expand Up @@ -256,7 +257,7 @@ static void checkAlgorthm(final String algorithm, final Set<BagitWarning> warnin
warnings.add(BagitWarning.WEAK_CHECKSUM_ALGORITHM);
}

else if(!warningsToIgnore.contains(BagitWarning.NON_STANDARD_ALGORITHM) && !"SHA-512".equals(upperCaseAlg)){
else if(!warningsToIgnore.contains(BagitWarning.NON_STANDARD_ALGORITHM) && !"SHA512".equals(upperCaseAlg)){
logger.warn(messages.getString("non_standard_algorithm_warning"), algorithm);
warnings.add(BagitWarning.NON_STANDARD_ALGORITHM);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
public enum StandardSupportedAlgorithms implements SupportedAlgorithm{
MD5("MD5"),
SHA1("SHA-1"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this "SHA-1" now different than the others? Now the others don't have this dash anymore, but this one still has it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I will update to include sha1 as well as tests on very basic valid test bags

SHA224("SHA-224"),
SHA256("SHA-256"),
SHA512("SHA-512");
SHA224("SHA224"),
SHA256("SHA256"),
SHA512("SHA512");

private final String messageDigestName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public void testClassIsWellDefined() throws NoSuchMethodException, InvocationTar
assertUtilityClassWellDefined(BagLinter.class);
}

@Test
public void testConformantBag() throws Exception{
Path goodBag = Paths.get("src", "test", "resources", "bags", "v1_0", "bag");
Set<BagitWarning> warnings = BagLinter.lintBag(goodBag);
Assertions.assertTrue(warnings.size() == 0);
}

@Test
public void testLintBag() throws Exception{
Set<BagitWarning> expectedWarnings = new HashSet<>();
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/bags/v1_0/bag/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-22
Payload-Oxum: 6.1
2 changes: 2 additions & 0 deletions src/test/resources/bags/v1_0/bag/bagit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BagIt-Version: 1.0
Tag-File-Character-Encoding: UTF-8
1 change: 1 addition & 0 deletions src/test/resources/bags/v1_0/bag/data/foo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
1 change: 1 addition & 0 deletions src/test/resources/bags/v1_0/bag/manifest-sha512.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e7c22b994c59d9cf2b48e549b1e24666636045930d3da7c1acb299d1c3b7f931f94aae41edda2c2b207a36e10f8bcb8d45223e54878f5b316e7ce3b6bc019629 data/foo.txt
3 changes: 3 additions & 0 deletions src/test/resources/bags/v1_0/bag/tagmanifest-sha512.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
f5bdbc7f273dd8b95d30b77b3d6f727d999ecbe9be06a7656388e7a3a46d963881563d779a2a99265b0c2785de2a7b72ac05fa7bc5b66b471d3f4e80fe9bb370 bag-info.txt
1d73ae108d4109b61f56698a5e19ee1f8947bdf8940bbce6adbe5e0940c2363caace6a547b4f1b3ec6a4fd2b7fa845e9cb9d28823bc72c59971718bb26f2fbd8 bagit.txt
35d40e38f5e2eb7261a1cc0c0ccf9c6c50d2e07e39a9460ec4f99046048f939d82647c68d8f744c653c7a37c05cc9d71153c8028786dfeba4322a3be5fe81af0 manifest-sha512.txt