1 /*******************************************************************************
2 * ============LICENSE_START====================================================
4 * * ===========================================================================
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * * ===========================================================================
7 * * Licensed under the Apache License, Version 2.0 (the "License");
8 * * you may not use this file except in compliance with the License.
9 * * You may obtain a copy of the License at
11 * * http://www.apache.org/licenses/LICENSE-2.0
13 * * Unless required by applicable law or agreed to in writing, software
14 * * distributed under the License is distributed on an "AS IS" BASIS,
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * * See the License for the specific language governing permissions and
17 * * limitations under the License.
18 * * ============LICENSE_END====================================================
21 ******************************************************************************/
22 package org.onap.aaf.auth.cmd.test;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
26 import static org.junit.Assert.fail;
27 import static org.mockito.Mockito.mock;
29 import java.io.IOException;
30 import java.io.OutputStreamWriter;
31 import java.net.HttpURLConnection;
32 import java.security.GeneralSecurityException;
34 import org.junit.BeforeClass;
35 import org.junit.Test;
36 import org.junit.runner.RunWith;
37 import org.mockito.runners.MockitoJUnitRunner;
38 import org.onap.aaf.auth.cmd.AAFcli;
39 import org.onap.aaf.auth.env.AuthzEnv;
40 import org.onap.aaf.cadi.CadiException;
41 import org.onap.aaf.cadi.Locator;
42 import org.onap.aaf.cadi.LocatorException;
43 import org.onap.aaf.cadi.config.Config;
44 import org.onap.aaf.cadi.config.SecurityInfo;
45 import org.onap.aaf.cadi.http.HBasicAuthSS;
46 import org.onap.aaf.cadi.http.HMangr;
47 import org.onap.aaf.cadi.locator.PropertyLocator;
48 import org.onap.aaf.misc.env.APIException;
49 @RunWith(MockitoJUnitRunner.class)
50 public class JU_AAFCli {
52 private static AAFcli cli;
53 private static int TIMEOUT = Integer.parseInt(Config.AAF_CONN_TIMEOUT_DEF);
56 // public static void setUp() throws Exception, Exception {
61 // public void eval() throws Exception {
62 // assertTrue(cli.eval("#startswith"));
66 // public void eval_empty() throws Exception {
67 // assertTrue(cli.eval(""));
71 // public void eval1() throws Exception {
72 // assertTrue(cli.eval("@[123"));
76 // public void eval2() throws Exception {
77 // assertFalse(cli.eval("as @[ 123"));
81 // public void eval3() throws Exception {
83 // cli.eval("expect @[ 123");
84 // } catch (Exception e) {
85 // // TODO Auto-generated catch block
86 // assertTrue(e instanceof CadiException);
90 // public void eval31() throws Exception {
92 // cli.eval("expect 1 @[ 123");
93 // } catch (Exception e) {
94 // // TODO Auto-generated catch block
95 // assertTrue(e instanceof CadiException);
100 // public void eval4() throws Exception {
102 // cli.eval("sleep @[ 123");
103 // } catch (Exception e) {
104 // assertTrue(e instanceof NumberFormatException);
109 // public void eval41() throws Exception {
110 // assertTrue(cli.eval("sleep 1 @[ 123"));
114 // public void eval5() throws Exception {
116 // cli.eval("delay @[ 123");
117 // } catch (Exception e) {
118 // assertTrue(e instanceof NumberFormatException);
123 // public void eval51() throws Exception {
124 // assertTrue(cli.eval("delay 1 @[ 123"));
128 // public void eval7() throws Exception {
129 // assertFalse(cli.eval("exit @[ 123"));
133 // public void eval8() throws Exception {
134 // assertTrue(cli.eval("REQUEST @[ 123"));
138 // public void eval9() throws Exception {
139 // assertTrue(cli.eval("FORCE @[ 123"));
143 // public void eval10() throws Exception {
144 // assertTrue(cli.eval("set @[ 123"));
148 // public void keyboardHelp() throws Exception {
149 // boolean noError=true;
151 // cli.keyboardHelp();
152 // } catch (Exception e) {
155 // assertTrue(noError);
161 // public void setProp() throws Exception {
162 // boolean noError=true;
164 // cli.keyboardHelp();
165 // } catch (Exception e) {
168 // assertTrue(noError);
172 // public void eval_randomString() throws Exception {
173 // assertTrue(cli.eval("Some random string @#&*& to check complete 100 coverage"));
176 // public static AAFcli getAAfCli() throws APIException, LocatorException, GeneralSecurityException, IOException {
177 // final AuthzEnv env = new AuthzEnv(System.getProperties());
178 // String aafUrl = "https://DME2RESOLVE";
179 // SecurityInfo si = new SecurityInfo(env);
180 // env.loadToSystemPropsStartsWith("AAF", "DME2");
182 // loc = new PropertyLocator(aafUrl);
183 // TIMEOUT = Integer.parseInt(env.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF));
184 // HMangr hman = new HMangr(env, loc).readTimeout(TIMEOUT).apiVersion("2.0");
186 // // TODO: Consider requiring a default in properties
187 // env.setProperty(Config.AAF_DEFAULT_REALM,
188 // System.getProperty(Config.AAF_DEFAULT_REALM, Config.getDefaultRealm()));
189 // HBasicAuthSS ss = mock(HBasicAuthSS.class);
190 // //TODO: Gabe[JUnit] constructor issue
191 // return new AAFcli(env, new OutputStreamWriter(System.out), hman, si, ss);
194 @Test //TODO: Temporary fix AAF-111
195 public void netYetTested() {