diff --git a/src/test/java/helpers/TestScryptHelper.java b/src/test/java/helpers/TestScryptHelper.java index 01d1942..6d6b212 100644 --- a/src/test/java/helpers/TestScryptHelper.java +++ b/src/test/java/helpers/TestScryptHelper.java @@ -120,6 +120,18 @@ assertThat(result, is(true)); } + @Test(expected = Exception.class) + public void testMalformedBase64() { + String badB64 = "$2097160$!!!$!!!$"; // Invalid Base64 characters + ScryptHelper.check(badB64, "password"); + } + + @Test(expected = IllegalArgumentException.class) + public void testMissingParts() { + String missingParts = "$2097160$salt$"; // Missing the hash part + ScryptHelper.check(missingParts, "password"); + } + @Test public void testHashTiming() throws Exception { final int REPS = 100; @@ -128,7 +140,7 @@ ScryptHelper.hash("wibble" + i); } long endTime = System.currentTimeMillis(); - System.out.println("Mean time per hash(): " + (endTime - startTime) / (float)REPS + " ms"); + System.out.println("Mean time per hash(): " + (endTime - startTime) / (float) REPS + " ms"); } @Test @@ -140,7 +152,7 @@ ScryptHelper.check(hash, "wibble" + i); } long endTime = System.currentTimeMillis(); - System.out.println("Mean time per check(): " + (endTime - startTime) / (float)REPS + " ms"); + System.out.println("Mean time per check(): " + (endTime - startTime) / (float) REPS + " ms"); } }