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