2 * ============LICENSE_START=======================================================
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
15 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * ============LICENSE_END=========================================================
26 package org.onap.appc.encryptiontool;
28 import java.sql.SQLException;
29 import java.util.ArrayList;
30 import java.util.HashMap;
31 import java.util.List;
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;
41 public class TestEncryptionTool {
44 public void testEncryptionTool() throws Exception {
45 String[] input = new String[]{"testVnf_Type", "testUser", "testPassword11", "testAction1", "8080",
46 "http://localhost:8080/restconf/healthcheck"};
47 WrapperEncryptionTool.main(input);
51 @Test(expected = Exception.class)
52 public void testgetPropertyDG() throws Exception {
53 EncryptionToolDGWrapper et = new EncryptionToolDGWrapper();
54 SvcLogicContext ctx = new SvcLogicContext();
55 Map<String, String> inParams = new HashMap<>();
56 inParams.put("prefix", "test");
57 inParams.put("propertyName", "testVnf_Type.testAction1.url");
58 et.getProperty(inParams, ctx);
61 @Test(expected = Exception.class)
62 public void testgetData() throws Exception {
63 List<String> argList = null;
64 String schema = "sdnctl";
65 String tableName = "dual";
66 String getselectData = "123";
67 String getDataClasue = "123='123'";
68 DbServiceUtil.getData(tableName, argList, schema, getselectData, getDataClasue);
71 @Test(expected = Exception.class)
72 public void testupdateDB() throws Exception {
73 String setClause = null;
74 String tableName = "dual";
75 List<String> inputArgs = null;
76 String whereClause = "123='123'";
77 DbServiceUtil.updateDB(tableName, inputArgs, whereClause, setClause);
81 public void decrypt() throws Exception {
82 EncryptionTool et = EncryptionTool.getInstance();
83 System.out.println(et.decrypt("enc:Ai8KLw=="));
86 //@Test(expected=Exception.class)
87 public void testupdateProperties() throws Exception {
88 WrapperEncryptionTool.updateProperties(
89 "testuser2", "", "abc3", "", "22", "testhost1", "Ansible");
92 //@Test(expected=Exception.class)
93 public void testgetProperties() throws Exception {
94 EncryptionToolDGWrapper et = new EncryptionToolDGWrapper();
95 Map<String, String> inParams = new HashMap<>();
96 SvcLogicContext ctx = new SvcLogicContext();
97 ctx.setAttribute("vnf-type", "test2");
98 ctx.setAttribute("input.action", "Configure");
99 ctx.setAttribute("APPC.protocol.PROTOCOL", "Ansible");
100 inParams.put("propertyName", "user");
101 inParams.put("prefix", "user");
102 et.getProperty(inParams, ctx);
106 public void testEncrypt() throws Exception {
107 EncryptionTool et = EncryptionTool.getInstance();
108 String s1=et.encrypt("sampleText");
109 assertEquals("enc:MD4XHE0udVFHOw==", s1);