1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package com.att.cmd;
\r
25 import static org.junit.Assert.assertTrue;
\r
26 import static org.mockito.Mockito.mock;
\r
28 import java.io.IOException;
\r
29 import java.io.OutputStreamWriter;
\r
30 import java.net.HttpURLConnection;
\r
31 import java.security.GeneralSecurityException;
\r
33 import org.junit.BeforeClass;
\r
34 import org.junit.Test;
\r
35 import org.junit.runner.RunWith;
\r
36 import org.mockito.runners.MockitoJUnitRunner;
\r
38 import com.att.authz.env.AuthzEnv;
\r
39 import com.att.cadi.Locator;
\r
40 import com.att.cadi.LocatorException;
\r
41 import com.att.cadi.client.PropertyLocator;
\r
42 import com.att.cadi.config.Config;
\r
43 import com.att.cadi.config.SecurityInfo;
\r
44 import com.att.cadi.http.HBasicAuthSS;
\r
45 import com.att.cadi.http.HMangr;
\r
46 import com.att.inno.env.APIException;
\r
48 @RunWith(MockitoJUnitRunner.class)
\r
49 public class JU_AAFCli {
\r
51 private static AAFcli cli;
\r
52 private static int TIMEOUT = Integer.parseInt(Config.AAF_CONN_TIMEOUT_DEF);
\r
55 public static void setUp() throws Exception, Exception {
\r
60 public void eval() throws Exception {
\r
61 assertTrue(cli.eval("#startswith"));
\r
65 public void eval_empty() throws Exception{
\r
66 assertTrue(cli.eval(""));
\r
70 public void eval_randomString() throws Exception {
\r
71 assertTrue(cli.eval("Some random string @#&*& to check complete 100 coverage"));
\r
74 public static AAFcli getAAfCli() throws APIException, LocatorException, GeneralSecurityException, IOException {
\r
75 final AuthzEnv env = new AuthzEnv(System.getProperties());
\r
76 String aafUrl = "https://DME2RESOLVE";
\r
77 SecurityInfo si = new SecurityInfo(env);
\r
78 env.loadToSystemPropsStartsWith("AAF", "DME2");
\r
80 loc = new PropertyLocator(aafUrl);
\r
81 TIMEOUT = Integer.parseInt(env.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF));
\r
82 HMangr hman = new HMangr(env, loc).readTimeout(TIMEOUT).apiVersion("2.0");
\r
84 //TODO: Consider requiring a default in properties
\r
85 env.setProperty(Config.AAF_DEFAULT_REALM, System.getProperty(Config.AAF_DEFAULT_REALM,Config.getDefaultRealm()));
\r
86 HBasicAuthSS ss = mock(HBasicAuthSS.class);
\r
87 return new AAFcli(env, new OutputStreamWriter(System.out), hman, si, ss);
\r