1 package org.openecomp.sdc.security;
5 import java.util.Base64;
7 import static org.junit.Assert.assertEquals;
8 import static org.junit.Assert.assertNotEquals;
10 public class SecurityUtilTest {
13 public void encryptDecryptAES128() throws Exception {
14 String data = "decrypt SUCCESS!!";
15 String encrypted = SecurityUtil.INSTANCE.encrypt(data).left().value();
16 assertNotEquals( data, encrypted );
17 byte[] decryptMsg = Base64.getDecoder().decode(encrypted);
18 assertEquals( SecurityUtil.INSTANCE.decrypt( decryptMsg , false ).left().value() ,data );
19 assertEquals( SecurityUtil.INSTANCE.decrypt( encrypted.getBytes() , true ).left().value() ,data );
23 public void obfuscateKey() throws Exception {
24 String key = "abcdefghij123456";
25 String expectedkey = "********ij123456";
26 String obfuscated = SecurityUtil.INSTANCE.obfuscateKey( key );
27 System.out.println( obfuscated );
28 assertEquals( obfuscated , expectedkey );