@@ -32,8 +32,10 @@ public class DigestHelperTest {
3232 private final static String INPUT_STRING_NO2 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789b\n " ;
3333 private final static String INPUT_STRING_NO3 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789h\n " ;
3434 private final static String SHA256_CHECKSUM = "{SHA-256}c6ab15af7842d23d3c06c138b53a7d09c5e351a79c4eb3c8ca8d65e5ce8900ab" ;
35+ private final static String SHA256_NO_PREFIX_CHECKSUM = "c6ab15af7842d23d3c06c138b53a7d09c5e351a79c4eb3c8ca8d65e5ce8900ab" ;
3536 private final static String SHA1_CHECKSUM = "{SHA-1}49e4b2f4292b63e88597c127d11bc2cc0f2ca0ff" ;
3637 private final static String MD5_CHECKSUM = "{MD5}d141a8eeaf6bba779d1d1dc5102a81c5" ;
38+ private final static String MD5_NO_PREFIX_CHECKSUM = "d141a8eeaf6bba779d1d1dc5102a81c5" ;
3739 private final static String ZERO_PADDED_MD5_CHECKSUM = "{MD5}0e51dfa74b87f19dd5e0124d6a2195e3" ;
3840 private final static String ZERO_PADDED_SHA256_CHECKSUM = "{SHA-256}08b5ae0c7d7d45d8ed406d7c3c7da695b81187903694314d97f8a37752a6b241" ;
3941 private static final String MD5 = "MD5" ;
@@ -97,6 +99,34 @@ public static void init() throws UnsupportedEncodingException {
9799 public void reset () throws IOException {
98100 inputStream .reset ();
99101 }
102+
103+ @ Test (expected = IllegalArgumentException .class )
104+ public void testChecksumSanityNoPrefixWrongAlgorithm () {
105+ DigestHelper .validateChecksumString (SHA256_NO_PREFIX_CHECKSUM );
106+ }
107+
108+ @ Test
109+ public void testChecksumSanityNoPrefix () {
110+ DigestHelper .validateChecksumString (MD5_NO_PREFIX_CHECKSUM );
111+ }
112+
113+ @ Test
114+ public void testChecksumSanityPrefixEmptyAlgorithm () {
115+ String checksum = "{}" + MD5_NO_PREFIX_CHECKSUM ;
116+ DigestHelper .validateChecksumString (checksum );
117+ }
118+
119+ @ Test (expected = IllegalArgumentException .class )
120+ public void testChecksumSanityPrefixWrongAlgorithm () {
121+ String checksum = "{MD5}" + SHA256_NO_PREFIX_CHECKSUM ;
122+ DigestHelper .validateChecksumString (checksum );
123+ }
124+
125+ @ Test (expected = IllegalArgumentException .class )
126+ public void testChecksumSanityPrefixWrongChecksumLength () {
127+ String checksum = SHA256_CHECKSUM + "XXXXX" ;
128+ DigestHelper .validateChecksumString (checksum );
129+ }
100130}
101131
102132//Generated with love by TestMe :) Please report issues and submit feature requests at: http://weirddev.com/forum#!/testme
0 commit comments