bael-4604: add data, key, algorithm, and hash value as local variable in each method
This commit is contained in:
parent
28845d038e
commit
efeb4fec3f
|
@ -9,20 +9,16 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class HMACUtilUnitTest {
|
||||
|
||||
private static String hmacSHA256Value = "5b50d80c7dc7ae8bb1b1433cc0b99ecd2ac8397a555c6f75cb8a619ae35a0c35";
|
||||
private static String hmacMD5Value = "621dc816b3bf670212e0c261dc9bcdb6";
|
||||
private static String hmacSHA512Value = "b313a21908df55c9e322e3c65a4b0b7561ab1594ca806b3affbc0d769a1290c1922aa6622587bea3c0c4d871470a6d06f54dbd20dbda84250e2741eb01f08e33";
|
||||
|
||||
//given
|
||||
String hmacSHA256Algorithm = "HmacSHA256";
|
||||
String hmacSHA512Algorithm = "HmacSHA512";
|
||||
String hmacMD5Algorithm = "HmacMD5";
|
||||
String data = "baeldung";
|
||||
String key = "123456";
|
||||
|
||||
@Test
|
||||
public void givenDataAndKeyAndAlgorithm_whenHmacWithJava_thenSuccess()
|
||||
throws NoSuchAlgorithmException, InvalidKeyException {
|
||||
|
||||
//given
|
||||
String hmacSHA256Value = "5b50d80c7dc7ae8bb1b1433cc0b99ecd2ac8397a555c6f75cb8a619ae35a0c35";
|
||||
String hmacSHA256Algorithm = "HmacSHA256";
|
||||
String data = "baeldung";
|
||||
String key = "123456";
|
||||
|
||||
//when
|
||||
String result = HMACUtil.hmacWithJava(hmacSHA256Algorithm, data, key);
|
||||
|
||||
|
@ -32,6 +28,13 @@ public class HMACUtilUnitTest {
|
|||
|
||||
@Test
|
||||
public void givenDataAndKeyAndAlgorithm_whenHmacWithApacheCommons_thenSuccess() {
|
||||
|
||||
//given
|
||||
String hmacMD5Value = "621dc816b3bf670212e0c261dc9bcdb6";
|
||||
String hmacMD5Algorithm = "HmacMD5";
|
||||
String data = "baeldung";
|
||||
String key = "123456";
|
||||
|
||||
//when
|
||||
String result = HMACUtil.hmacWithApacheCommons(hmacMD5Algorithm, data, key);
|
||||
|
||||
|
@ -41,6 +44,14 @@ public class HMACUtilUnitTest {
|
|||
|
||||
@Test
|
||||
public void givenDataAndKeyAndAlgorithm_whenHmacWithBouncyCastle_thenSuccess() {
|
||||
|
||||
//given
|
||||
String hmacSHA512Value = "b313a21908df55c9e322e3c65a4b0b7561ab1594ca806b3affbc0d769a1" +
|
||||
"290c1922aa6622587bea3c0c4d871470a6d06f54dbd20dbda84250e2741eb01f08e33";
|
||||
String hmacSHA512Algorithm = "HmacSHA512";
|
||||
String data = "baeldung";
|
||||
String key = "123456";
|
||||
|
||||
//when
|
||||
String result = HMACUtil.hmacWithBouncyCastle(hmacSHA512Algorithm, data, key);
|
||||
|
||||
|
|
Loading…
Reference in New Issue