2 * Copyright 2018 Intel Corporation, Inc
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.aaf.sms;
19 import javax.net.ssl.SSLSocketFactory;
21 import javax.net.ssl.HttpsURLConnection;
22 import org.onap.aaf.sms.SmsResponse;
23 import org.onap.aaf.sms.SmsClient;
24 import java.io.InputStream;
25 import java.io.OutputStream;
26 import java.io.InputStreamReader;
27 import java.io.BufferedReader;
28 import java.io.OutputStreamWriter;
30 import java.util.HashMap;
31 import java.util.Iterator;
32 import java.util.List;
33 import java.util.ArrayList;
34 import org.json.JSONArray;
35 import org.json.JSONException;
36 import org.json.JSONObject;
38 public class SmsTest extends SmsClient {
40 public SmsTest(String host, int port, SSLSocketFactory s) {
43 public SmsTest(String host, int port, String version, SSLSocketFactory s) {
44 super(host, port, version, s);
46 public SmsResponse execute(String reqtype, String t, String ins, boolean input, boolean output) {
47 Map<String, Object> m;
48 SmsResponse resp = new SmsResponse();
49 System.out.println(t);
53 if ( t.matches("(.*)/v1/sms/domain")) {
54 resp.setSuccess(true);
55 resp.setResponseCode(201);
58 } catch ( Exception e ) {
59 resp.setResponse(null);
64 if ( t.matches("(.*)/v1/sms/(.*)/secret") ) {
65 resp.setSuccess(true);
66 resp.setResponseCode(201);
71 if ( t.matches("(.*)/v1/sms/(.*)/secret") ) {
72 resp.setSuccess(true);
73 resp.setResponseCode(200);
74 String jstr = "{\"secretnames\":[\"testsec1\",\"newtest\"]}";
77 } catch ( Exception e ) {
78 resp.setResponse(null);
83 if ( t.matches("(.*)/v1/sms/(.*)/secret/testsec1")) {
84 resp.setSuccess(true);
85 resp.setResponseCode(200);
86 String js = "{\"name\":\"testsec1\",\"values\":{\"username\":\"dbuser\",\"passwd\":\"jdX784i-5k\"}}";
89 Map<String, Object> sm = (Map<String, Object>)m.get("values");
90 } catch ( Exception e ) {
91 resp.setResponse(null);
99 if ( t.matches("(.*)/v1/sms/domain/(.*)") ) {
100 // for both delete domain & secret case
101 resp.setSuccess(true);
102 resp.setResponseCode(204);
103 resp.setResponse(null);