2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 * ============LICENSE_END=========================================================
24 package org.onap.appc.encryptiontool;
26 import java.sql.SQLException;
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
31 import org.junit.Test;
32 import org.onap.appc.encryptiontool.wrapper.DbServiceUtil;
33 import org.onap.appc.encryptiontool.wrapper.EncryptionTool;
34 import org.onap.appc.encryptiontool.wrapper.EncryptionToolDGWrapper;
35 import org.onap.appc.encryptiontool.wrapper.WrapperEncryptionTool;
36 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
38 public class TestEncryptionTool {
41 public void testEncryptionTool() throws Exception {
42 String[] input = new String[]{"testVnf_Type", "testUser", "testPassword11", "testAction1", "8080",
43 "http://localhost:8080/restconf/healthcheck"};
44 WrapperEncryptionTool.main(input);
48 @Test(expected = Exception.class)
49 public void testgetPropertyDG() throws Exception {
50 EncryptionToolDGWrapper et = new EncryptionToolDGWrapper();
51 SvcLogicContext ctx = new SvcLogicContext();
52 Map<String, String> inParams = new HashMap<>();
53 inParams.put("prefix", "test");
54 inParams.put("propertyName", "testVnf_Type.testAction1.url");
55 et.getProperty(inParams, ctx);
58 @Test(expected = Exception.class)
59 public void testgetData() throws Exception {
60 List<String> argList = null;
61 String schema = "sdnctl";
62 String tableName = "dual";
63 String getselectData = "123";
64 String getDataClasue = "123='123'";
65 DbServiceUtil.getData(tableName, argList, schema, getselectData, getDataClasue);
68 @Test(expected = Exception.class)
69 public void testupdateDB() throws Exception {
70 String setClause = null;
71 String tableName = "dual";
72 List<String> inputArgs = null;
73 String whereClause = "123='123'";
74 DbServiceUtil.updateDB(tableName, inputArgs, whereClause, setClause);
78 public void decrypt() throws Exception {
79 EncryptionTool et = EncryptionTool.getInstance();
80 System.out.println(et.decrypt("enc:Ai8KLw=="));
83 //@Test(expected=Exception.class)
84 public void testupdateProperties() throws Exception {
85 WrapperEncryptionTool.updateProperties(
86 "testuser2", "", "abc3", "", "22", "testhost1", "Ansible");
89 //@Test(expected=Exception.class)
90 public void testgetProperties() throws Exception {
91 EncryptionToolDGWrapper et = new EncryptionToolDGWrapper();
92 Map<String, String> inParams = new HashMap<>();
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);