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.sql.SQLException;
28 import java.util.ArrayList;
29 import java.util.HashMap;
30 import java.util.List;
32 import org.junit.Test;
33 import org.onap.appc.encryptiontool.wrapper.DbServiceUtil;
34 import org.onap.appc.encryptiontool.wrapper.EncryptionTool;
35 import org.onap.appc.encryptiontool.wrapper.EncryptionToolDGWrapper;
36 import org.onap.appc.encryptiontool.wrapper.WrapperEncryptionTool;
37 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
39 public class TestEncryptionTool {
42 public void testEncryptionTool() throws Exception {
43 String[] input = new String[]{"testVnf_Type", "testUser", "testPassword11", "testAction1", "8080",
44 "http://localhost:8080/restconf/healthcheck"};
45 WrapperEncryptionTool.main(input);
49 @Test(expected = Exception.class)
50 public void testgetPropertyDG() throws Exception {
51 EncryptionToolDGWrapper et = new EncryptionToolDGWrapper();
52 SvcLogicContext ctx = new SvcLogicContext();
53 Map<String, String> inParams = new HashMap<>();
54 inParams.put("prefix", "test");
55 inParams.put("propertyName", "testVnf_Type.testAction1.url");
56 et.getProperty(inParams, ctx);
59 @Test(expected = Exception.class)
60 public void testgetData() throws Exception {
61 List<String> argList = null;
62 String schema = "sdnctl";
63 String tableName = "dual";
64 String getselectData = "123";
65 String getDataClasue = "123='123'";
66 DbServiceUtil.getData(tableName, argList, schema, getselectData, getDataClasue);
69 @Test(expected = Exception.class)
70 public void testupdateDB() throws Exception {
71 String setClause = null;
72 String tableName = "dual";
73 List<String> inputArgs = null;
74 String whereClause = "123='123'";
75 DbServiceUtil.updateDB(tableName, inputArgs, whereClause, setClause);
79 public void decrypt() throws Exception {
80 EncryptionTool et = EncryptionTool.getInstance();
81 System.out.println(et.decrypt("enc:Ai8KLw=="));
84 //@Test(expected=Exception.class)
85 public void testupdateProperties() throws Exception {
86 WrapperEncryptionTool.updateProperties(
87 "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<>();
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);