X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-cmd%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fcmd%2Ftest%2Frole%2FJU_List.java;h=bbdb77e8ad196dfce64ff8abb1e8740cf5649449;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=0c85fc3cf442f5abf6d1c38f507e3dae08cd726c;hpb=a7024ad2f0df65a2005e29d24a5974304d2b58c6;p=aaf%2Fauthz.git diff --git a/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/role/JU_List.java b/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/role/JU_List.java index 0c85fc3c..bbdb77e8 100644 --- a/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/role/JU_List.java +++ b/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/role/JU_List.java @@ -16,6 +16,7 @@ * limitations under the License. * ============LICENSE_END============================================ */ + package org.onap.aaf.auth.cmd.test.role; import static org.junit.Assert.*; @@ -65,97 +66,97 @@ import java.util.ArrayList; import org.junit.Test; public class JU_List { - - AAFcli cli; - Role role; - List list; - PropAccess prop; - AuthzEnv aEnv; - Writer wtr; - Locator loc; - HMangr hman; - AAFcli aafcli; - - private class ListRolesStub extends List { - - public ListRolesStub(Role parent) { - super(parent); - // TODO Auto-generated constructor stub - } - } - - private class RolesStub extends Roles { - public void addRole(aaf.v2_0.Role role) { - if (this.role == null) { - this.role = new ArrayList(); - } - this.role.add(role); - } - } - - private class RoleStub extends aaf.v2_0.Role { - - public void addPerms(Pkey perms) { - if (this.perms == null) { - this.perms = new ArrayList(); - } - this.perms.add(perms); - } - } - - @Before - public void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException, CadiException{ - prop = new PropAccess(); - aEnv = new AuthzEnv(); - wtr = mock(Writer.class); - loc = mock(Locator.class); - SecuritySetter secSet = mock(SecuritySetter.class); - hman = new HMangr(aEnv, loc); - aafcli = new AAFcli(prop, aEnv, wtr, hman, null, secSet); - role = new Role(aafcli); - list = new List(role); - } - - @Test - public void testRoles() throws APIException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - Role role = new Role(aafcli); - ListRolesStub listStub = new ListRolesStub(role); - Future future = mock(Future.class); - Rcli rcli = mock(Rcli.class); - - Class c = listStub.getClass(); - Class[] cArg = new Class[3]; - cArg[0] = Future.class; - cArg[1] = Rcli.class; - cArg[2] = String.class;//Steps to test a protected method - //Method listMethod = c.getDeclaredMethod("list", cArg); - //listMethod.setAccessible(true); - //listMethod.invoke(listStub, future, rcli, "test"); - - } - - @Test - public void testReport() throws Exception { - UserRoles urs = new UserRoles(); - Perms perms = new Perms(); - RolesStub roles = new RolesStub(); - list.report(roles, perms , urs , "test"); - AAFcli cli = JU_AAFCli.getAAfCli(); - RoleStub role = new RoleStub(); - roles.addRole(role); - Pkey pkey = new Pkey(); - pkey.setInstance("test"); - pkey.setAction("test"); - pkey.setInstance("test"); - pkey.setType("test"); - role.addPerms(pkey); - list.report(roles, perms , null , "test"); - list.report(roles, perms , urs , "test"); - - aafcli.eval("DETAILS @[ 123"); - role.setName("test"); - - list.report(roles, perms , urs , "test"); - } + + AAFcli cli; + Role role; + List list; + PropAccess prop; + AuthzEnv aEnv; + Writer wtr; + Locator loc; + HMangr hman; + AAFcli aafcli; + + private class ListRolesStub extends List { + + public ListRolesStub(Role parent) { + super(parent); + // TODO Auto-generated constructor stub + } + } + + private class RolesStub extends Roles { + public void addRole(aaf.v2_0.Role role) { + if (this.role == null) { + this.role = new ArrayList<>(); + } + this.role.add(role); + } + } + + private class RoleStub extends aaf.v2_0.Role { + + public void addPerms(Pkey perms) { + if (this.perms == null) { + this.perms = new ArrayList<>(); + } + this.perms.add(perms); + } + } + + @Before + public void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException, CadiException{ + prop = new PropAccess(); + aEnv = new AuthzEnv(); + wtr = mock(Writer.class); + loc = mock(Locator.class); + SecuritySetter secSet = mock(SecuritySetter.class); + hman = new HMangr(aEnv, loc); + aafcli = new AAFcli(prop, aEnv, wtr, hman, null, secSet); + role = new Role(aafcli); + list = new List(role); + } + + @Test + public void testRoles() throws APIException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + Role role = new Role(aafcli); + ListRolesStub listStub = new ListRolesStub(role); + Future future = mock(Future.class); + Rcli rcli = mock(Rcli.class); + + Class c = listStub.getClass(); + Class[] cArg = new Class[3]; + cArg[0] = Future.class; + cArg[1] = Rcli.class; + cArg[2] = String.class;//Steps to test a protected method + //Method listMethod = c.getDeclaredMethod("list", cArg); + //listMethod.setAccessible(true); + //listMethod.invoke(listStub, future, rcli, "test"); + + } + + @Test + public void testReport() throws Exception { + UserRoles urs = new UserRoles(); + Perms perms = new Perms(); + RolesStub roles = new RolesStub(); + list.report(roles, perms , urs , "test"); + AAFcli cli = JU_AAFCli.getAAfCli(); + RoleStub role = new RoleStub(); + roles.addRole(role); + Pkey pkey = new Pkey(); + pkey.setInstance("test"); + pkey.setAction("test"); + pkey.setInstance("test"); + pkey.setType("test"); + role.addPerms(pkey); + list.report(roles, perms , null , "test"); + list.report(roles, perms , urs , "test"); + + aafcli.eval("DETAILS @[ 123"); + role.setName("test"); + + list.report(roles, perms , urs , "test"); + } }