2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.encryptiontool;
27 import java.util.ArrayList;
28 import java.util.HashMap;
30 import org.junit.Test;
31 import org.onap.appc.encryptiontool.wrapper.DbServiceUtil;
32 import org.onap.appc.encryptiontool.wrapper.EncryptionTool;
33 import org.onap.appc.encryptiontool.wrapper.EncryptionToolDGWrapper;
34 import org.onap.appc.encryptiontool.wrapper.WrapperEncryptionTool;
35 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
37 public class TestEncryptionTool {
40 public void testEncryptionTool() throws Exception{
41 String [] input = new String[] {"testVnf_Type","testUser","testPassword11", "testAction1", "8080", "http://localhost:8080/restconf/healthcheck"};
42 WrapperEncryptionTool.main(input);
45 @Test(expected=Exception.class)
46 public void testgetPropertyDG() throws Exception{
47 EncryptionToolDGWrapper et = new EncryptionToolDGWrapper();
48 SvcLogicContext ctx = new SvcLogicContext();
49 Map<String, String> inParams = new HashMap<String, String>();
50 inParams.put("prefix", "test");
51 inParams.put("propertyName", "testVnf_Type.testAction1.url");
52 et.getProperty(inParams, ctx);
54 @Test(expected=Exception.class)
55 public void testgetData() throws Exception
57 DbServiceUtil d = new DbServiceUtil();
58 ArrayList argList = null;
59 String schema ="sdnctl";
60 String tableName ="dual";
61 String getselectData ="123";
62 String getDataClasue="123='123'";
63 d.getData(tableName, argList, schema, getselectData, getDataClasue);
65 @Test(expected=Exception.class)
66 public void testupdateDB() throws Exception
68 DbServiceUtil d = new DbServiceUtil();
69 String setCluase = null;
70 String schema ="sdnctl";
71 String tableName ="dual";
72 ArrayList inputArgs = null;
73 String whereClause="123='123'";
74 d.updateDB(tableName, inputArgs, schema, whereClause, setCluase);
77 public void decrypt() throws Exception{
78 EncryptionTool et = EncryptionTool.getInstance();
79 System.out.println(et.decrypt("enc:Ai8KLw==").toString());
83 //@Test(expected=Exception.class)
84 public void testupdateProperties() throws Exception{
85 WrapperEncryptionTool et = new WrapperEncryptionTool();
86 et.updateProperties("testuser2", "", "abc3", "", "22", "testhost1", "Ansible");
90 //@Test(expected=Exception.class)
91 public void testgetProperties() throws Exception{
92 EncryptionToolDGWrapper et = new EncryptionToolDGWrapper();
93 Map<String, String> inParams = new HashMap<String,String>();
94 SvcLogicContext ctx = new SvcLogicContext();
95 ctx.setAttribute("vnf-type", "test2");
96 ctx.setAttribute("input.action", "Configure");
97 ctx.setAttribute("APPC.protocol.PROTOCOL", "Ansible");
98 inParams.put("propertyName", "user");
99 inParams.put("prefix", "user");
100 et.getProperty(inParams, ctx);