aboutsummaryrefslogtreecommitdiffstats
path: root/security-utils/src
diff options
context:
space:
mode:
Diffstat (limited to 'security-utils/src')
-rw-r--r--security-utils/src/main/java/org/openecomp/sdc/security/SecurityUtil.java3
-rw-r--r--security-utils/src/test/java/org/openecomp/sdc/security/PasswordsTest.java38
-rw-r--r--security-utils/src/test/java/org/openecomp/sdc/security/SecurityUtilTest.java5
3 files changed, 26 insertions, 20 deletions
diff --git a/security-utils/src/main/java/org/openecomp/sdc/security/SecurityUtil.java b/security-utils/src/main/java/org/openecomp/sdc/security/SecurityUtil.java
index 9500ab5c12..b9a5f7ab4b 100644
--- a/security-utils/src/main/java/org/openecomp/sdc/security/SecurityUtil.java
+++ b/security-utils/src/main/java/org/openecomp/sdc/security/SecurityUtil.java
@@ -1,7 +1,9 @@
package org.openecomp.sdc.security;
+import fj.data.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
@@ -13,7 +15,6 @@ import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
-import fj.data.*;
public class SecurityUtil {
diff --git a/security-utils/src/test/java/org/openecomp/sdc/security/PasswordsTest.java b/security-utils/src/test/java/org/openecomp/sdc/security/PasswordsTest.java
index 26f04735e5..6d6e3cea8a 100644
--- a/security-utils/src/test/java/org/openecomp/sdc/security/PasswordsTest.java
+++ b/security-utils/src/test/java/org/openecomp/sdc/security/PasswordsTest.java
@@ -2,53 +2,55 @@ package org.openecomp.sdc.security;
import org.junit.Test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public class PasswordsTest {
@Test
public void hashPassword() throws Exception {
String hash = Passwords.hashPassword("hello1234");
- assertEquals(true, Passwords.isExpectedPassword("hello1234", hash));
+ assertTrue(Passwords.isExpectedPassword("hello1234", hash));
//test different salt-> result in different hash
String hash2 = Passwords.hashPassword("hello1234");
- assertEquals(false, hash.equals(hash2));
+ assertFalse(hash.equals(hash2));
String hash3 = Passwords.hashPassword("");
- assertEquals(true, Passwords.isExpectedPassword("", hash3));
+ assertTrue(Passwords.isExpectedPassword("", hash3));
String hash4 = Passwords.hashPassword(null);
- assertEquals(true, hash4 == null );
+ assertTrue(hash4 == null);
}
@Test
public void isExpectedPassword() throws Exception {
//region isExpectedPassword(String password, String salt, String hash)
- assertEquals(true, Passwords.isExpectedPassword(null, null , null));
+ assertTrue(Passwords.isExpectedPassword(null, null, null));
//valid hash
- assertEquals(true, Passwords.isExpectedPassword("hello1234", "e0277df331f4ff8f74752ac4a8fbe03b","6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0"));
+ assertTrue(Passwords.isExpectedPassword("hello1234", "e0277df331f4ff8f74752ac4a8fbe03b", "6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0"));
//invalid salt
- assertEquals(false, Passwords.isExpectedPassword("hello1234", "c0000df331f4ff8f74752ac4a00be03c","6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0"));
- assertEquals(false, Passwords.isExpectedPassword("hello1234", null,"6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0"));
+ assertFalse(Passwords.isExpectedPassword("hello1234", "c0000df331f4ff8f74752ac4a00be03c", "6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0"));
+ assertFalse(Passwords.isExpectedPassword("hello1234", null, "6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0"));
//exacly 1 param uninitialized
- assertEquals(false,Passwords.isExpectedPassword("hello1234", "",null));
- assertEquals(false,Passwords.isExpectedPassword( null, "" , "hello1234"));
+ assertFalse(Passwords.isExpectedPassword("hello1234", "", null));
+ assertFalse(Passwords.isExpectedPassword(null, "", "hello1234"));
//no salt & no hash
- assertEquals(false, Passwords.isExpectedPassword("hello1234", null ,"hello1234"));
+ assertFalse(Passwords.isExpectedPassword("hello1234", null, "hello1234"));
//endregion
//region isExpectedPassword(String password, String expectedHash)
- assertEquals(true, Passwords.isExpectedPassword(null, null));
+ assertTrue(Passwords.isExpectedPassword(null, null));
//valid hash
- assertEquals(true, Passwords.isExpectedPassword("hello1234", "e0277df331f4ff8f74752ac4a8fbe03b:6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0"));
+ assertTrue(Passwords.isExpectedPassword("hello1234", "e0277df331f4ff8f74752ac4a8fbe03b:6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0"));
//invalid salt
- assertEquals(false, Passwords.isExpectedPassword("hello1234", "c0000df331f4ff8f74752ac4a00be03c:6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0"));
+ assertFalse(Passwords.isExpectedPassword("hello1234", "c0000df331f4ff8f74752ac4a00be03c:6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0"));
//exacly 1 param uninitialized
- assertEquals(false,Passwords.isExpectedPassword("hello1234", null));
- assertEquals(false,Passwords.isExpectedPassword( null,"hello1234"));
+ assertFalse(Passwords.isExpectedPassword("hello1234", null));
+ assertFalse(Passwords.isExpectedPassword(null, "hello1234"));
//no salt & no hash
- assertEquals(false, Passwords.isExpectedPassword("hello1234", "hello1234"));
+ assertFalse(Passwords.isExpectedPassword("hello1234", "hello1234"));
//endregion
}
diff --git a/security-utils/src/test/java/org/openecomp/sdc/security/SecurityUtilTest.java b/security-utils/src/test/java/org/openecomp/sdc/security/SecurityUtilTest.java
index e23c864b77..a5cdff7bc1 100644
--- a/security-utils/src/test/java/org/openecomp/sdc/security/SecurityUtilTest.java
+++ b/security-utils/src/test/java/org/openecomp/sdc/security/SecurityUtilTest.java
@@ -1,8 +1,11 @@
package org.openecomp.sdc.security;
import org.junit.Test;
+
import java.util.Base64;
-import static org.junit.Assert.*;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
public class SecurityUtilTest {