2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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 * ============LICENSE_END====================================================
21 package org.onap.aaf.auth.cmd.test.role;
23 import static org.junit.Assert.*;
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.Mock;
29 import org.mockito.Mockito;
30 import org.onap.aaf.auth.cmd.AAFcli;
31 import org.onap.aaf.auth.cmd.role.List;
32 import org.onap.aaf.auth.cmd.role.Role;
33 import org.onap.aaf.auth.cmd.test.JU_AAFCli;
34 import org.onap.aaf.auth.cmd.Cmd;
35 import org.onap.aaf.auth.cmd.Param;
36 import org.onap.aaf.auth.env.AuthzEnv;
37 import org.onap.aaf.auth.env.AuthzTrans;
38 import org.onap.aaf.cadi.CadiException;
39 import org.onap.aaf.cadi.Locator;
40 import org.onap.aaf.cadi.LocatorException;
41 import org.onap.aaf.cadi.PropAccess;
42 import org.onap.aaf.cadi.SecuritySetter;
43 import org.onap.aaf.cadi.client.Future;
44 import org.onap.aaf.cadi.client.Rcli;
45 import org.onap.aaf.cadi.http.HMangr;
46 import org.onap.aaf.misc.env.APIException;
48 import aaf.v2_0.Perms;
49 import aaf.v2_0.Roles;
50 import aaf.v2_0.UserRoles;
52 import static org.mockito.Mockito.*;
54 import java.io.IOException;
55 import java.io.Writer;
56 import java.lang.reflect.InvocationTargetException;
57 import java.lang.reflect.Method;
58 import java.net.HttpURLConnection;
60 import java.security.GeneralSecurityException;
61 import java.security.Principal;
63 import org.junit.Test;
65 public class JU_List {
77 private class ListRolesStub extends List {
79 public ListRolesStub(Role parent) {
81 // TODO Auto-generated constructor stub
88 public void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException{
89 prop = new PropAccess();
90 aEnv = new AuthzEnv();
91 wtr = mock(Writer.class);
92 loc = mock(Locator.class);
93 SecuritySetter<HttpURLConnection> secSet = mock(SecuritySetter.class);
94 hman = new HMangr(aEnv, loc);
95 aafcli = new AAFcli(prop, aEnv, wtr, hman, null, secSet);
96 role = new Role(aafcli);
97 list = new List(role);
101 public void testRoles() throws APIException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
102 Role role = new Role(aafcli);
103 ListRolesStub listStub = new ListRolesStub(role);
104 Future future = mock(Future.class);
105 Rcli rcli = mock(Rcli.class);
107 Class c = listStub.getClass();
108 Class[] cArg = new Class[3];
109 cArg[0] = Future.class;
110 cArg[1] = Rcli.class;
111 cArg[2] = String.class;//Steps to test a protected method
112 //Method listMethod = c.getDeclaredMethod("list", cArg);
113 //listMethod.setAccessible(true);
114 //listMethod.invoke(listStub, future, rcli, "test");
119 public void testReport() throws Exception {
120 UserRoles urs = new UserRoles();
121 Perms perms = new Perms();
122 Roles roles = mock(Roles.class);
123 list.report(roles, perms , urs , "test");
124 AAFcli cli = JU_AAFCli.getAAfCli();
125 cli.eval("DETAILS @[ 123");
126 list.report(roles, perms , urs , "test");