WrapperEncryptionTool sonar fixes
[appc.git] / appc-config / appc-encryption-tool / provider / src / test / java / org / onap / appc / encryptiontool / TestEncryptionTool.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.encryptiontool;
26
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.Map;
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;
36
37 public class TestEncryptionTool {
38
39     //@Test
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);
43
44     }
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);
53     }
54     @Test(expected=Exception.class)
55     public void testgetData() throws Exception
56     {
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);
64     }
65     @Test(expected=Exception.class)
66     public void testupdateDB() throws Exception
67     {
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);
75     }
76     @Test
77     public void decrypt() throws Exception{
78         EncryptionTool et = EncryptionTool.getInstance();
79         System.out.println(et.decrypt("enc:Ai8KLw==").toString());
80     }
81         
82         
83     //@Test(expected=Exception.class)
84     public void testupdateProperties() throws Exception{
85         WrapperEncryptionTool.updateProperties("testuser2", "", "abc3", "", "22", "testhost1", "Ansible");
86             
87     }
88         
89     //@Test(expected=Exception.class)
90     public void testgetProperties() throws Exception{
91         EncryptionToolDGWrapper et =  new EncryptionToolDGWrapper();
92         Map<String, String> inParams = new HashMap<String,String>();
93         SvcLogicContext ctx = new SvcLogicContext();
94         ctx.setAttribute("vnf-type", "test2");
95         ctx.setAttribute("input.action", "Configure");
96         ctx.setAttribute("APPC.protocol.PROTOCOL", "Ansible");
97         inParams.put("propertyName", "user");
98         inParams.put("prefix", "user");
99         et.getProperty(inParams, ctx);
100             
101     }
102         
103 }