Changed to unmaintained
[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-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Modification Copyright (C) 2018 IBM.
10  * =============================================================================
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  * 
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  * 
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  * 
23  * ============LICENSE_END=========================================================
24  */
25
26 package org.onap.appc.encryptiontool;
27
28 import java.sql.SQLException;
29 import java.util.ArrayList;
30 import java.util.HashMap;
31 import java.util.List;
32 import java.util.Map;
33 import org.junit.Test;
34 import org.onap.appc.encryptiontool.wrapper.DbServiceUtil;
35 import org.onap.appc.encryptiontool.wrapper.EncryptionTool;
36 import org.onap.appc.encryptiontool.wrapper.EncryptionToolDGWrapper;
37 import org.onap.appc.encryptiontool.wrapper.WrapperEncryptionTool;
38 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
39 import static org.junit.Assert.assertEquals;
40 import static org.junit.Assert.assertNotNull;
41
42 public class TestEncryptionTool {
43
44     //@Test
45     public void testEncryptionTool() throws Exception {
46         String[] input = new String[]{"testVnf_Type", "testUser", "testPassword11", "testAction1", "8080",
47             "http://localhost:8080/restconf/healthcheck"};
48         WrapperEncryptionTool.main(input);
49
50     }
51
52     @Test(expected = Exception.class)
53     public void testgetPropertyDG() throws Exception {
54         EncryptionToolDGWrapper et = new EncryptionToolDGWrapper();
55         SvcLogicContext ctx = new SvcLogicContext();
56         Map<String, String> inParams = new HashMap<>();
57         inParams.put("prefix", "test");
58         inParams.put("propertyName", "testVnf_Type.testAction1.url");
59         et.getProperty(inParams, ctx);
60     }
61
62     @Test(expected = Exception.class)
63     public void testgetData() throws Exception {
64         List<String> argList = null;
65         String schema = "sdnctl";
66         String tableName = "dual";
67         String getselectData = "123";
68         String getDataClasue = "123='123'";
69         DbServiceUtil.getData(tableName, argList, schema, getselectData, getDataClasue);
70     }
71
72     @Test(expected = Exception.class)
73     public void testupdateDB() throws Exception {
74         String setClause = null;
75         String tableName = "dual";
76         List<String> inputArgs = null;
77         String whereClause = "123='123'";
78         DbServiceUtil.updateDB(tableName, inputArgs, whereClause, setClause);
79     }
80
81     @Test
82     public void decrypt() throws Exception {
83         EncryptionTool et = EncryptionTool.getInstance();
84         System.out.println(et.decrypt("enc:Ai8KLw=="));
85         assertNotNull(et);
86     }
87
88     //@Test(expected=Exception.class)
89     public void testupdateProperties() throws Exception {
90         WrapperEncryptionTool.updateProperties(
91             "testuser2", "", "abc3", "", "22", "testhost1", "Ansible");
92     }
93
94     //@Test(expected=Exception.class)
95     public void testgetProperties() throws Exception {
96         EncryptionToolDGWrapper et = new EncryptionToolDGWrapper();
97         Map<String, String> inParams = new HashMap<>();
98         SvcLogicContext ctx = new SvcLogicContext();
99         ctx.setAttribute("vnf-type", "test2");
100         ctx.setAttribute("input.action", "Configure");
101         ctx.setAttribute("APPC.protocol.PROTOCOL", "Ansible");
102         inParams.put("propertyName", "user");
103         inParams.put("prefix", "user");
104         et.getProperty(inParams, ctx);
105     }
106     
107     @Test
108     public void testEncrypt() throws Exception {
109         EncryptionTool et = EncryptionTool.getInstance();
110         String s1=et.encrypt("sampleText");
111         assertEquals("enc:MD4XHE0udVFHOw==", s1);
112     }
113 }