summaryrefslogtreecommitdiffstats
path: root/authz-cass/src/test
diff options
context:
space:
mode:
authorInstrumental <jcgmisc@stl.gathman.org>2018-03-26 14:09:21 -0700
committerInstrumental <jcgmisc@stl.gathman.org>2018-03-26 14:09:26 -0700
commit0ed473b17619d749bbdf56ad17199e71fb04c2be (patch)
tree190e4d83bffbc386eb7b8dd670f14809343dd664 /authz-cass/src/test
parent10027f3cd15afd2c8ef341e5cd92de911e07965e (diff)
AT&T 2.0.19 Code drop, stage 5
Issue-ID: AAF-197 Change-Id: I81dd2a8fd8cd4d4771e390609909c86ac09b7dac Signed-off-by: Instrumental <jcgmisc@stl.gathman.org>
Diffstat (limited to 'authz-cass/src/test')
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/authz/cass/hl/JU_Question.java500
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/JU_Cached.java127
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/JU_CachedDAO.java66
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/JU_CassAccess.java74
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/JU_CassDAOImpl.java97
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/JU_DAOException.java50
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/AbsJUCass.java200
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_ApprovalDAO.java147
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_ArtiDAO.java137
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_Bytification.java266
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CacheInfoDAO.java65
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CertDAO.java105
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CredDAO.java252
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_DelegateDAO.java107
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_FastCalling.java91
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_HistoryDAO.java154
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_NsDAO.java187
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_NsType.java59
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_PermDAO.java176
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_RoleDAO.java139
-rw-r--r--authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/NS_ChildUpdate.java74
-rw-r--r--authz-cass/src/test/resources/cadi.properties52
22 files changed, 0 insertions, 3125 deletions
diff --git a/authz-cass/src/test/java/org/onap/aaf/authz/cass/hl/JU_Question.java b/authz-cass/src/test/java/org/onap/aaf/authz/cass/hl/JU_Question.java
deleted file mode 100644
index 86bc1ab3..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/authz/cass/hl/JU_Question.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.authz.cass.hl;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
-
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.aaf.authz.env.AuthzTrans;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.NsDAO;
-import org.onap.aaf.dao.aaf.cass.PermDAO;
-import org.onap.aaf.dao.aaf.cass.RoleDAO;
-import org.onap.aaf.dao.aaf.cass.UserRoleDAO;
-import org.onap.aaf.dao.aaf.cass.NsDAO.Data;
-import org.onap.aaf.dao.aaf.hl.Question;
-import org.onap.aaf.dao.aaf.hl.Question.Access;
-import org.onap.aaf.dao.aaf.test.AbsJUCass;
-
-import org.onap.aaf.inno.env.Env;
-import org.onap.aaf.inno.env.TimeTaken;
-
-public class JU_Question extends AbsJUCass {
-
- private static final int EXPIRES_IN = 60000000;
- private static final String COM_TEST_JU = "com.test.ju_question";
- private static final String JU9999_JU_TEST_COM = "ju9999@ju.test.com";
- private static final String JU9998_JU_TEST_COM = "ju9998@ju.test.com";
- private static final String READ = "read";
- private static final int NFR_1 = 80;
- private static final int NFR_2 = 4000;
- private static final int ROLE_LEVEL1 = 1000;
- private static final int PERM_LEVEL1 = 1000;
-// private static final int PERM_LEVEL2 = 20;
- private static Question q;
- private static NsDAO.Data ndd;
-
- @BeforeClass
- public static void startupBeforeClass() throws Exception {
- details=false;
- AuthzTrans trans = env.newTransNoAvg();
- q = new Question(trans,cluster,AUTHZ, false);
- ndd = new NsDAO.Data();
- ndd.name=COM_TEST_JU;
- ndd.type=3; // app
- ndd.parent="com.test";
- ndd.description="Temporary Namespace for JU_Question";
- q.nsDAO.create(trans, ndd);
- }
-
- @AfterClass
- public static void endAfterClass() throws Exception {
- q.nsDAO.delete(trans, ndd,false);
- }
-// @Test
- public void mayUserRead_EmptyPerm() {
- PermDAO.Data pdd = new PermDAO.Data();
- Result<NsDAO.Data> result = q.mayUser(trans,JU9999_JU_TEST_COM,pdd,Access.read);
- assertFalse(result.isOK());
- }
-
-// @Test
- public void mayUserRead_OnePermNotExist() {
- Result<NsDAO.Data> result = q.mayUser(trans,JU9999_JU_TEST_COM,newPerm(0,0,READ),Access.read);
- assertFalse(result.isOK());
- assertEquals("Denied - ["+ JU9999_JU_TEST_COM +"] may not read Perm [" + COM_TEST_JU + ".myPerm0|myInstance0|read]",result.errorString());
- }
-
-// @Test
- public void mayUserRead_OnePermExistDenied() {
- PermDAO.Data perm = newPerm(0,0,READ);
- q.permDAO.create(trans,perm);
- try {
- Result<NsDAO.Data> result;
- TimeTaken tt = trans.start("q.mayUser...", Env.SUB);
- try {
- result = q.mayUser(trans,JU9999_JU_TEST_COM,perm,Access.read);
- } finally {
- tt.done();
- assertTrue("NFR time < "+ NFR_1 + "ms",tt.millis()<NFR_1);
- }
- assertFalse(result.isOK());
- assertEquals("Denied - ["+ JU9999_JU_TEST_COM +"] may not read Perm ["+COM_TEST_JU + ".myPerm0|myInstance0|read]",result.errorString());
- } finally {
- q.permDAO.delete(trans, perm, false);
- }
- }
-
-// @Test
- public void mayUserRead_OnePermOneRoleExistOK() {
- PermDAO.Data perm = newPerm(0,0,READ);
- RoleDAO.Data role = newRole(0,perm);
- UserRoleDAO.Data ur = newUserRole(role,JU9999_JU_TEST_COM,EXPIRES_IN);
- try {
- q.permDAO.create(trans,perm);
- q.roleDAO.create(trans,role);
- q.userRoleDAO.create(trans,ur);
-
- Result<NsDAO.Data> result;
- TimeTaken tt = trans.start("q.mayUser...", Env.SUB);
- try {
- result = q.mayUser(trans,JU9999_JU_TEST_COM,perm,Access.read);
- } finally {
- tt.done();
- assertTrue("NFR time < "+ NFR_1 + "ms",tt.millis()<NFR_1);
- }
- assertTrue(result.isOK());
- } finally {
- q.permDAO.delete(trans, perm, false);
- q.roleDAO.delete(trans, role, false);
- q.userRoleDAO.delete(trans, ur, false);
- }
- }
-
-// @Test
- public void filter_OnePermOneRoleExistOK() {
- PermDAO.Data perm = newPerm(0,0,READ);
- RoleDAO.Data role = newRole(0,perm);
- UserRoleDAO.Data ur1 = newUserRole(role,JU9998_JU_TEST_COM,EXPIRES_IN);
- UserRoleDAO.Data ur2 = newUserRole(role,JU9999_JU_TEST_COM,EXPIRES_IN);
- try {
- q.permDAO.create(trans,perm);
- q.roleDAO.create(trans,role);
- q.userRoleDAO.create(trans,ur1);
- q.userRoleDAO.create(trans,ur2);
-
- Result<List<PermDAO.Data>> pres;
- TimeTaken tt = trans.start("q.getPerms...", Env.SUB);
- try {
- pres = q.getPermsByUserFromRolesFilter(trans, JU9999_JU_TEST_COM, JU9999_JU_TEST_COM);
- } finally {
- tt.done();
- trans.info().log("filter_OnePermOneRleExistOK",tt);
- assertTrue("NFR time < "+ NFR_1 + "ms",tt.millis()<NFR_1);
- }
- assertTrue(pres.isOK());
-
- try {
- pres = q.getPermsByUserFromRolesFilter(trans, JU9999_JU_TEST_COM, JU9998_JU_TEST_COM);
- } finally {
- tt.done();
- trans.info().log("filter_OnePermOneRleExistOK No Value",tt);
- assertTrue("NFR time < "+ NFR_1 + "ms",tt.millis()<NFR_1);
- }
- assertFalse(pres.isOKhasData());
-
- } finally {
- q.permDAO.delete(trans, perm, false);
- q.roleDAO.delete(trans, role, false);
- q.userRoleDAO.delete(trans, ur1, false);
- q.userRoleDAO.delete(trans, ur2, false);
- }
- }
-
-// @Test
- public void mayUserRead_OnePermMultiRoleExistOK() {
- PermDAO.Data perm = newPerm(0,0,READ);
- List<RoleDAO.Data> lrole = new ArrayList<RoleDAO.Data>();
- List<UserRoleDAO.Data> lur = new ArrayList<UserRoleDAO.Data>();
- try {
- q.permDAO.create(trans,perm);
- for(int i=0;i<ROLE_LEVEL1;++i) {
- RoleDAO.Data role = newRole(i,perm);
- lrole.add(role);
- q.roleDAO.create(trans,role);
-
- UserRoleDAO.Data ur = newUserRole(role,JU9999_JU_TEST_COM,60000000);
- lur.add(ur);
- q.userRoleDAO.create(trans,ur);
- }
-
- Result<NsDAO.Data> result;
- TimeTaken tt = trans.start("mayUserRead_OnePermMultiRoleExistOK", Env.SUB);
- try {
- result = q.mayUser(trans,JU9999_JU_TEST_COM,perm,Access.read);
- } finally {
- tt.done();
- env.info().log(tt,ROLE_LEVEL1,"iterations");
- assertTrue("NFR time < "+ NFR_2 + "ms",tt.millis()<NFR_2);
- }
- assertTrue(result.isOK());
- } finally {
- q.permDAO.delete(trans, perm, false);
- for(RoleDAO.Data role : lrole) {
- q.roleDAO.delete(trans, role, false);
- }
- for(UserRoleDAO.Data ur : lur) {
- q.userRoleDAO.delete(trans, ur, false);
- }
- }
- }
-
- @Test
- public void mayUserRead_MultiPermOneRoleExistOK() {
- RoleDAO.Data role = newRole(0);
- UserRoleDAO.Data ur = newUserRole(role,JU9999_JU_TEST_COM,EXPIRES_IN);
- List<PermDAO.Data> lperm = new ArrayList<PermDAO.Data>();
- try {
- for(int i=0;i<PERM_LEVEL1;++i) {
- lperm.add(newPerm(i,i,READ,role));
- }
- q.roleDAO.create(trans, role);
- q.userRoleDAO.create(trans, ur);
-
- Result<NsDAO.Data> result;
- TimeTaken tt = trans.start("mayUserRead_MultiPermOneRoleExistOK", Env.SUB);
- try {
- result = q.mayUser(trans,JU9999_JU_TEST_COM,lperm.get(PERM_LEVEL1-1),Access.read);
- } finally {
- tt.done();
- env.info().log(tt,PERM_LEVEL1,"iterations");
- assertTrue("NFR time < "+ NFR_2 + "ms",tt.millis()<NFR_2);
- }
- assertTrue(result.isOK());
- } finally {
- for(PermDAO.Data perm : lperm) {
- q.permDAO.delete(trans, perm, false);
- }
- q.roleDAO.delete(trans, role, false);
- q.userRoleDAO.delete(trans, ur, false);
- }
- }
-
-//// @Test
-// public void mayUserRead_MultiPermMultiRoleExistOK() {
-// List<PermDAO.Data> lperm = new ArrayList<PermDAO.Data>();
-// List<RoleDAO.Data> lrole = new ArrayList<RoleDAO.Data>();
-// List<UserRoleDAO.Data> lur = new ArrayList<UserRoleDAO.Data>();
-//
-// try {
-// RoleDAO.Data role;
-// UserRoleDAO.Data ur;
-// for(int i=0;i<ROLE_LEVEL1;++i) {
-// lrole.add(role=newRole(i));
-// q.roleDAO.create(trans, role);
-// lur.add(ur=newUserRole(role, JU9999_JU_TEST_COM, EXPIRES_IN));
-// q.userRoleDAO.create(trans, ur);
-// for(int j=0;j<PERM_LEVEL2;++j) {
-// lperm.add(newPerm(i,j,READ,role));
-// }
-// }
-//
-// Result<NsDAO.Data> result;
-// TimeTaken tt = trans.start("mayUserRead_MultiPermMultiRoleExistOK", Env.SUB);
-// try {
-// result = q.mayUser(trans,JU9999_JU_TEST_COM,lperm.get(ROLE_LEVEL1*PERM_LEVEL2-1),Access.read);
-// } finally {
-// tt.done();
-// env.info().log(tt,lperm.size(),"perms",", ",lrole.size(),"role");
-// assertTrue("NFR time < "+ NFR_2 + "ms",tt.millis()<NFR_2);
-// }
-// assertTrue(result.isOK());
-// } finally {
-// for(PermDAO.Data perm : lperm) {
-// q.permDAO.delete(trans, perm, false);
-// }
-// for(RoleDAO.Data role : lrole) {
-// q.roleDAO.delete(trans, role, false);
-// }
-// for(UserRoleDAO.Data ur : lur) {
-// q.userRoleDAO.delete(trans, ur, false);
-// }
-// }
-// }
-
- @Test
- public void mayUserRead_MultiPermMultiRoleExist_10x10() {
- env.info().log("Original Filter Method 10x10");
- mayUserRead_MultiPermMultiRoleExist(10,10);
- env.info().log("New Filter Method 10x10");
- mayUserRead_MultiPermMultiRoleExist_NewOK(10,10);
- }
-
-// @Test
- public void mayUserRead_MultiPermMultiRoleExist_20x10() {
- env.info().log("mayUserRead_MultiPermMultiRoleExist_20x10");
- mayUserRead_MultiPermMultiRoleExist_NewOK(20,10);
- }
-
-// @Test
- public void mayUserRead_MultiPermMultiRoleExist_100x10() {
- env.info().log("mayUserRead_MultiPermMultiRoleExist_100x10");
- mayUserRead_MultiPermMultiRoleExist_NewOK(100,10);
- }
-
-// @Test
- public void mayUserRead_MultiPermMultiRoleExist_100x20() {
- env.info().log("mayUserRead_MultiPermMultiRoleExist_100x20");
- mayUserRead_MultiPermMultiRoleExist_NewOK(100,20);
- }
-
-// @Test
- public void mayUserRead_MultiPermMultiRoleExist_1000x20() {
- env.info().log("mayUserRead_MultiPermMultiRoleExist_1000x20");
- mayUserRead_MultiPermMultiRoleExist_NewOK(1000,20);
- }
-
- private void mayUserRead_MultiPermMultiRoleExist(int roleLevel, int permLevel) {
- List<PermDAO.Data> lperm = new ArrayList<PermDAO.Data>();
- List<RoleDAO.Data> lrole = new ArrayList<RoleDAO.Data>();
- List<UserRoleDAO.Data> lur = new ArrayList<UserRoleDAO.Data>();
- load(roleLevel, permLevel, lperm,lrole,lur);
-
-
- Result<List<PermDAO.Data>> pres;
- trans.setUser(new Principal() {
- @Override
- public String getName() {
- return JU9999_JU_TEST_COM;
- }
- });
-
- try {
- TimeTaken group = trans.start(" Original Security Method (1st time)", Env.SUB);
- try {
- TimeTaken tt = trans.start(" Get User Perms for "+JU9998_JU_TEST_COM, Env.SUB);
- try {
- pres = q.getPermsByUser(trans,JU9998_JU_TEST_COM,true);
- } finally {
- tt.done();
- env.info().log(tt," Looked up (full) getPermsByUser for",JU9998_JU_TEST_COM);
- }
- assertTrue(pres.isOK());
- tt = trans.start(" q.mayUser", Env.SUB);
- List<PermDAO.Data> reduced = new ArrayList<PermDAO.Data>();
-
- try {
- for(PermDAO.Data p : pres.value) {
- Result<Data> r = q.mayUser(trans,JU9999_JU_TEST_COM,p,Access.read);
- if(r.isOK()) {
- reduced.add(p);
- }
- }
- } finally {
- tt.done();
- env.info().log(tt," reduced" + pres.value.size(),"perms","to",reduced.size());
- // assertTrue("NFR time < "+ NFR_2 + "ms",tt.millis()<NFR_2);
- }
- // assertFalse(result.isOK());
- } finally {
- group.done();
- env.info().log(group," Original Validation Method (1st pass)");
- }
-
-
- } finally {
- unload(lperm, lrole, lur);
- }
- }
-
- private void mayUserRead_MultiPermMultiRoleExist_NewOK(int roleLevel, int permLevel) {
- List<PermDAO.Data> lperm = new ArrayList<PermDAO.Data>();
- List<RoleDAO.Data> lrole = new ArrayList<RoleDAO.Data>();
- List<UserRoleDAO.Data> lur = new ArrayList<UserRoleDAO.Data>();
- load(roleLevel, permLevel, lperm,lrole,lur);
-
- try {
-
- Result<List<PermDAO.Data>> pres;
- TimeTaken tt = trans.start(" mayUserRead_MultiPermMultiRoleExist_New New Filter", Env.SUB);
- try {
- pres = q.getPermsByUserFromRolesFilter(trans, JU9999_JU_TEST_COM, JU9998_JU_TEST_COM);
- } finally {
- tt.done();
- env.info().log(tt,lperm.size(),"perms",", ",lrole.size(),"role", lur.size(), "UserRoles");
-// assertTrue("NFR time < "+ NFR_2 + "ms",tt.millis()<NFR_2);
- }
-// assertTrue(pres.isOKhasData());
-
- tt = trans.start(" mayUserRead_MultiPermMultiRoleExist_New New Filter (2nd time)", Env.SUB);
- try {
- pres = q.getPermsByUserFromRolesFilter(trans, JU9999_JU_TEST_COM, JU9998_JU_TEST_COM);
- } finally {
- tt.done();
- env.info().log(tt,lperm.size(),"perms",", ",lrole.size(),"role", lur.size(), "UserRoles");
- assertTrue("NFR time < "+ NFR_2 + "ms",tt.millis()<NFR_2);
- }
-// assertTrue(pres.isOKhasData());
-
- } finally {
- unload(lperm, lrole, lur);
- }
- }
-
-
- private void load(int roleLevel, int permLevel, List<PermDAO.Data> lperm , List<RoleDAO.Data> lrole, List<UserRoleDAO.Data> lur) {
- RoleDAO.Data role;
- UserRoleDAO.Data ur;
- PermDAO.Data perm;
-
- int onethirdR=roleLevel/3;
- int twothirdR=onethirdR*2;
- int onethirdP=permLevel/3;
- int twothirdP=onethirdP*2;
-
- for(int i=0;i<roleLevel;++i) {
- lrole.add(role=newRole(i));
- if(i<onethirdR) { // one has
- lur.add(ur=newUserRole(role, JU9998_JU_TEST_COM, EXPIRES_IN));
- q.userRoleDAO.create(trans, ur);
- for(int j=0;j<onethirdP;++j) {
- lperm.add(perm=newPerm(i,j,READ,role));
- q.permDAO.create(trans, perm);
- }
- } else if(i<twothirdR) { // both have
- lur.add(ur=newUserRole(role, JU9998_JU_TEST_COM, EXPIRES_IN));
- q.userRoleDAO.create(trans, ur);
- lur.add(ur=newUserRole(role, JU9999_JU_TEST_COM, EXPIRES_IN));
- q.userRoleDAO.create(trans, ur);
- for(int j=onethirdP;j<twothirdP;++j) {
- lperm.add(perm=newPerm(i,j,READ,role));
- q.permDAO.create(trans, perm);
- }
- } else { // other has
- lur.add(ur=newUserRole(role, JU9999_JU_TEST_COM, EXPIRES_IN));
- q.userRoleDAO.create(trans, ur);
- for(int j=twothirdP;j<permLevel;++j) {
- lperm.add(perm=newPerm(i,j,READ,role));
- q.permDAO.create(trans, perm);
- }
- }
- q.roleDAO.create(trans, role);
- }
-
- }
-
- private void unload(List<PermDAO.Data> lperm , List<RoleDAO.Data> lrole, List<UserRoleDAO.Data> lur) {
- for(PermDAO.Data perm : lperm) {
- q.permDAO.delete(trans, perm, false);
- }
- for(RoleDAO.Data role : lrole) {
- q.roleDAO.delete(trans, role, false);
- }
- for(UserRoleDAO.Data ur : lur) {
- q.userRoleDAO.delete(trans, ur, false);
- }
-
- }
- private PermDAO.Data newPerm(int permNum, int instNum, String action, RoleDAO.Data ... grant) {
- PermDAO.Data pdd = new PermDAO.Data();
- pdd.ns=COM_TEST_JU;
- pdd.type="myPerm"+permNum;
- pdd.instance="myInstance"+instNum;
- pdd.action=action;
- for(RoleDAO.Data r : grant) {
- pdd.roles(true).add(r.fullName());
- r.perms(true).add(pdd.encode());
- }
- return pdd;
- }
-
- private RoleDAO.Data newRole(int roleNum, PermDAO.Data ... grant) {
- RoleDAO.Data rdd = new RoleDAO.Data();
- rdd.ns = COM_TEST_JU+roleNum;
- rdd.name = "myRole"+roleNum;
- for(PermDAO.Data p : grant) {
- rdd.perms(true).add(p.encode());
- p.roles(true).add(rdd.fullName());
- }
- return rdd;
- }
-
- private UserRoleDAO.Data newUserRole(RoleDAO.Data role,String user, long offset) {
- UserRoleDAO.Data urd = new UserRoleDAO.Data();
- urd.user=user;
- urd.role(role);
- urd.expires=new Date(System.currentTimeMillis()+offset);
- return urd;
- }
-
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/JU_Cached.java b/authz-cass/src/test/java/org/onap/aaf/dao/JU_Cached.java
deleted file mode 100644
index aa0785a4..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/JU_Cached.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao;
-
-import static org.junit.Assert.*;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Timer;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.onap.aaf.authz.env.AuthzEnv;
-import org.onap.aaf.authz.env.AuthzTrans;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.cache.Cache;
-import org.onap.aaf.cache.Cache.Dated;
-import org.onap.aaf.dao.CIDAO;
-import org.onap.aaf.dao.Cached;
-import org.onap.aaf.dao.Cached.Getter;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-//import org.onap.aaf.dao.Cached.Refresh;
-import org.onap.aaf.inno.env.Trans;
-
-@RunWith(PowerMockRunner.class)
-public class JU_Cached {
- Cached cached;
- @Mock
- CIDAO<Trans> ciDaoMock;
- @Mock
- AuthzEnv authzEnvMock;
- @Mock
- CIDAO<AuthzTrans> cidaoATMock;
-
- String name = "nameString";
-
- @Before
- public void setUp(){
- cached = new Cached(ciDaoMock, name, 0);
- }
-
- @Test(expected=ArithmeticException.class)
- public void testCachedIdx(){
- int Result = cached.cacheIdx("1234567890");
- }
-
- @Test(expected=ArithmeticException.class)
- public void testInvalidate(){
- int Res = cached.invalidate(name);
- }
-
- @SuppressWarnings("static-access")
- @Test
- public void testStopTimer(){
- cached.stopTimer();
- assertTrue(true);
- }
-
- @SuppressWarnings("static-access")
- @Test
- public void testStartRefresh(){
- cached.startRefresh(authzEnvMock, cidaoATMock);
- assertTrue(true);
- }
-// @Mock
-// Trans transMock;
-// @Mock
-// Getter<DAO> getterMock;
-//
-// @Test
-// public void testGet(){
-// cached.get(transMock, name, getterMock);
-// fail("not implemented");
-// }
-//
-// @SuppressWarnings("unchecked")
-// public Result<List<DATA>> get(TRANS trans, String key, Getter<DATA> getter) {
-// List<DATA> ld = null;
-// Result<List<DATA>> rld = null;
-//
-// int cacheIdx = cacheIdx(key);
-// Map<String, Dated> map = ((Map<String,Dated>)cache[cacheIdx]);
-//
-// // Check for saved element in cache
-// Dated cached = map.get(key);
-// // Note: These Segment Timestamps are kept up to date with DB
-// Date dbStamp = info.get(trans, name,cacheIdx);
-//
-// // Check for cache Entry and whether it is still good (a good Cache Entry is same or after DBEntry, so we use "before" syntax)
-// if(cached!=null && dbStamp.before(cached.timestamp)) {
-// ld = (List<DATA>)cached.data;
-// rld = Result.ok(ld);
-// } else {
-// rld = getter.get();
-// if(rld.isOK()) { // only store valid lists
-// map.put(key, new Dated(rld.value)); // successful item found gets put in cache
-//// } else if(rld.status == Result.ERR_Backend){
-//// map.remove(key);
-// }
-// }
-// return rld;
-// }
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/JU_CachedDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/JU_CachedDAO.java
deleted file mode 100644
index 3bb78d29..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/JU_CachedDAO.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.onap.aaf.dao.CIDAO;
-import org.onap.aaf.dao.CachedDAO;
-import org.onap.aaf.dao.DAO;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import org.onap.aaf.inno.env.Trans;
-
-@RunWith(PowerMockRunner.class)
-public class JU_CachedDAO {
- CachedDAO cachedDAO;
- @Mock
- DAO daoMock;
- @Mock
- CIDAO<Trans> ciDAOMock;
- int segsize=1;
- Object[ ] objs = new Object[2];
-
- @Before
- public void setUp(){
- objs[0] = "helo";
- objs[1] = "polo";
- cachedDAO = new CachedDAO(daoMock, ciDAOMock, segsize);
- }
-
- @Test
- public void testKeyFromObjs(){
- String result = cachedDAO.keyFromObjs(objs);
- System.out.println("value of resut " +result);
- assertTrue(true);
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/JU_CassAccess.java b/authz-cass/src/test/java/org/onap/aaf/dao/JU_CassAccess.java
deleted file mode 100644
index 41443fb3..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/JU_CassAccess.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.onap.aaf.dao.CassAccess;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import org.onap.aaf.inno.env.APIException;
-import org.onap.aaf.inno.env.Env;
-//import org.onap.aaf.dao.CassAccess.Resettable;
-import com.datastax.driver.core.Cluster.Builder;
-
-@RunWith(PowerMockRunner.class)
-public class JU_CassAccess {
- CassAccess cassAccess;
-
- public static final String KEYSPACE = "authz";
- public static final String CASSANDRA_CLUSTERS = "cassandra.clusters";
- public static final String CASSANDRA_CLUSTERS_PORT = "cassandra.clusters.port";
- public static final String CASSANDRA_CLUSTERS_USER_NAME = "cassandra.clusters.user";
- public static final String CASSANDRA_CLUSTERS_PASSWORD = "cassandra.clusters.password";
- public static final String CASSANDRA_RESET_EXCEPTIONS = "cassandra.reset.exceptions";
- public static final String LATITUDE = "LATITUDE";
- public static final String LONGITUDE = "LONGITUDE";
- //private static final List<Resettable> resetExceptions = new ArrayList<Resettable>();
- public static final String ERR_ACCESS_MSG = "Accessing Backend";
- private static Builder cb = null;
- @Mock
- Env envMock;
- String prefix=null;
-
- @Before
- public void setUp(){
- cassAccess = new CassAccess();
- }
-
-
- @Test(expected=APIException.class)
- public void testCluster() throws APIException, IOException {
- cassAccess.cluster(envMock, prefix);
-
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/JU_CassDAOImpl.java b/authz-cass/src/test/java/org/onap/aaf/dao/JU_CassDAOImpl.java
deleted file mode 100644
index 34106e26..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/JU_CassDAOImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao;
-
-import static org.junit.Assert.*;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.onap.aaf.authz.env.AuthzTrans;
-import org.onap.aaf.dao.CassDAOImpl;
-import org.onap.aaf.dao.Loader;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import org.onap.aaf.inno.env.Data;
-import org.onap.aaf.inno.env.Trans;
-import org.onap.aaf.inno.env.TransStore;
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ConsistencyLevel;
-
-@RunWith(PowerMockRunner.class)
-public class JU_CassDAOImpl {
-
-public static final String CASS_READ_CONSISTENCY="cassandra.readConsistency";
-public static final String CASS_WRITE_CONSISTENCY="cassandra.writeConsistency";
-
-CassDAOImpl cassDAOImpl;
-
-
-@Mock
-TransStore transStoreMock;
-@SuppressWarnings("rawtypes")
-Class dcMock;
-@SuppressWarnings("rawtypes")
-Loader loaderMock;
-Cluster clusterMock;
-Class<Data> classDataMock;
-ConsistencyLevel consistencyLevelMock;
-Trans transMock;
-
-@Mock
-AuthzTrans authzTransMock;
-
-
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Before
- public void setUp()
- {
- String name = "name";
- String keySpace = "keySpace";
- String table = "table";
- cassDAOImpl = new CassDAOImpl(transStoreMock, name, clusterMock, keySpace, classDataMock, table, consistencyLevelMock, consistencyLevelMock);
- }
-
-
- @Test
- public void testReadConsistency() {
- String table = "users";
- PowerMockito.when(authzTransMock.getProperty(CASS_READ_CONSISTENCY+'.'+table)).thenReturn("TWO");
- ConsistencyLevel consistencyLevel = cassDAOImpl.readConsistency(authzTransMock, table);
- System.out.println("Consistency level" + consistencyLevel.name());
- assertEquals("TWO", consistencyLevel.name());
- }
-
- @Test
- public void testWriteConsistency() {
- String table = "users";
- PowerMockito.when(authzTransMock.getProperty(CASS_WRITE_CONSISTENCY+'.'+table)).thenReturn(null);
- ConsistencyLevel consistencyLevel = cassDAOImpl.writeConsistency(authzTransMock, table);
- System.out.println("Consistency level" + consistencyLevel.name());
- assertEquals("ONE", consistencyLevel.name());
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/JU_DAOException.java b/authz-cass/src/test/java/org/onap/aaf/dao/JU_DAOException.java
deleted file mode 100644
index 4c3b11c7..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/JU_DAOException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao;
-
-import static org.junit.Assert.*;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.aaf.dao.DAOException;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-@RunWith(PowerMockRunner.class)
-public class JU_DAOException {
-DAOException daoException;
-
- //DAOException daoException = new DAOException();
- String message = "message";
- Throwable cause;
- @Before
- public void setUp(){
- daoException = new DAOException();
- }
-
- @Test
- public void test(){
- assertTrue(true);
- }
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/AbsJUCass.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/AbsJUCass.java
deleted file mode 100644
index 887f88b2..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/AbsJUCass.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.security.NoSuchAlgorithmException;
-import java.util.Properties;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.onap.aaf.authz.env.AuthzEnv;
-import org.onap.aaf.authz.env.AuthzTrans;
-import org.onap.aaf.dao.CassAccess;
-import org.onap.aaf.dao.CassDAOImpl;
-
-import org.onap.aaf.cadi.Hash;
-import org.onap.aaf.cadi.Symm;
-import org.onap.aaf.inno.env.APIException;
-import org.onap.aaf.inno.env.Env;
-import org.onap.aaf.inno.env.Trans.Metric;
-import com.datastax.driver.core.Cluster;
-
-import junit.framework.Assert;
-
-/**
- * Do Setup of Cassandra for Cassandra JUnit Testing
- *
- *
- */
-public class AbsJUCass {
- protected static final String AUTHZ = "authz";
- protected static Cluster cluster;
- protected static AuthzEnv env;
- protected static int iterations = 0;
- protected static float totals=0.0f;
- protected static float remote = 0.0f;
- protected static float json = 0.0f;
- protected static AuthzTrans trans;
- protected static boolean details = true;
-
- @BeforeClass
- public static void startup() throws APIException, IOException {
- synchronized(AUTHZ) {
- if(env==null) {
- final String resource = "cadi.properties";
- File f = new File("etc" + resource);
- InputStream is=null;
- Properties props = new Properties();
- try {
- if(f.exists()) {
- is = new FileInputStream(f);
- } else {
- URL rsrc = ClassLoader.getSystemResource(resource);
- is = rsrc.openStream();
- }
- props.load(is);
- } finally {
- if(is==null) {
- env= new AuthzEnv();
- Assert.fail(resource + " must exist in etc dir, or in Classpath");
- }
- is.close();
- }
- env = new AuthzEnv(props);
- }
- }
- cluster = CassAccess.cluster(env,"LOCAL");
-
- env.info().log("Connecting to Cluster");
- try {
- cluster.connect(AUTHZ);
- } catch(Exception e) {
- cluster=null;
- env.error().log(e);
- Assert.fail("Not able to connect to DB: " + e.getLocalizedMessage());
- }
- env.info().log("Connected");
-
- // Load special data here
-
- // WebPhone
- env.setProperty("java.naming.provider.url","ldap://ldap.webphone.att.com:389");
- env.setProperty("com.sun.jndi.ldap.connect.pool","true");
-
- iterations = 0;
-
- }
-
- @AfterClass
- public static void shutdown() {
- if(cluster!=null) {
- cluster.close();
- cluster = null;
- }
- }
-
- @Before
- public void newTrans() {
- trans = env.newTrans();
-
- trans.setProperty(CassDAOImpl.USER_NAME, System.getProperty("user.name"));
- }
-
- @After
- public void auditTrail() {
- if(totals==0) { // "updateTotals()" was not called... just do one Trans
- StringBuilder sb = new StringBuilder();
- Metric metric = trans.auditTrail(4, sb, Env.JSON, Env.REMOTE);
- if(details) {
- env.info().log(
- sb,
- "Total time:",
- totals += metric.total,
- "JSON time: ",
- metric.buckets[0],
- "REMOTE time: ",
- metric.buckets[1]
- );
- } else {
- totals += metric.total;
- }
- }
- }
-
- protected void updateTotals() {
- Metric metric = trans.auditTrail(0, null, Env.JSON, Env.REMOTE);
- totals+=metric.total;
- json +=metric.buckets[0];
- remote+=metric.buckets[1];
- }
-
-
- @AfterClass
- public static void print() {
- float transTime;
- if(iterations==0) {
- transTime=totals;
- } else {
- transTime=totals/iterations;
- }
- env.info().log(
- "Total time:",
- totals,
- "JSON time:",
- json,
- "REMOTE time:",
- remote,
- "Iterations:",
- iterations,
- "Transaction time:",
- transTime
- );
- }
-
- /**
- * Take a User/Pass and turn into an MD5 Hashed BasicAuth
- *
- * @param user
- * @param pass
- * @return
- * @throws IOException
- * @throws NoSuchAlgorithmException
- */
- public static byte[] userPassToBytes(String user, String pass)
- throws IOException, NoSuchAlgorithmException {
- // Take the form of BasicAuth, so as to allow any character in Password
- // (this is an issue in 1.0)
- // Also, it makes it quicker to evaluate Basic Auth direct questions
- String ba = Symm.base64url.encode(user + ':' + pass);
- // Take MD5 Hash, so that data in DB can't be reversed out.
- return Hash.encryptMD5(ba.getBytes());
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_ApprovalDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_ApprovalDAO.java
deleted file mode 100644
index 46720c37..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_ApprovalDAO.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-
-import org.junit.Test;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.ApprovalDAO;
-import org.onap.aaf.dao.aaf.cass.ApprovalDAO.Data;
-
-public class JU_ApprovalDAO extends AbsJUCass {
- @Test
- public void testCRUD() throws Exception {
- ApprovalDAO rrDAO = new ApprovalDAO(trans, cluster, AUTHZ);
- ApprovalDAO.Data data = new ApprovalDAO.Data();
-
- data.ticket = UUID.randomUUID(); // normally, read from Future object
- data.user = "testid@test.com";
- data.approver = "mySuper@att.com";
- data.type = "supervisor";
- data.status = "pending";
- data.operation = "C";
- data.updated = new Date();
-
- try {
- // Test create
- rrDAO.create(trans, data);
-
- // Test Read by Ticket
- Result<List<ApprovalDAO.Data>> rlad;
- rlad = rrDAO.readByTicket(trans, data.ticket);
- assertTrue(rlad.isOK());
- assertEquals(1,rlad.value.size());
- compare(data,rlad.value.get(0));
-
- // Hold onto original ID for deletion, and read tests
- UUID id = rlad.value.get(0).id;
-
- try {
- // Test Read by User
- rlad = rrDAO.readByUser(trans, data.user);
- assertTrue(rlad.isOKhasData());
- boolean ok = false;
- for(ApprovalDAO.Data a : rlad.value) {
- if(a.id.equals(id)) {
- ok = true;
- compare(data,a);
- }
- }
- assertTrue(ok);
-
- // Test Read by Approver
- rlad = rrDAO.readByApprover(trans, data.approver);
- assertTrue(rlad.isOKhasData());
- ok = false;
- for(ApprovalDAO.Data a : rlad.value) {
- if(a.id.equals(id)) {
- ok = true;
- compare(data,a);
- }
- }
- assertTrue(ok);
-
- // Test Read by ID
- rlad = rrDAO.read(trans, id);
- assertTrue(rlad.isOKhasData());
- ok = false;
- for(ApprovalDAO.Data a : rlad.value) {
- if(a.id.equals(id)) {
- ok = true;
- compare(data,a);
- }
- }
- assertTrue(ok);
-
- // Test Update
- data.status = "approved";
- data.id = id;
- assertTrue(rrDAO.update(trans, data).isOK());
-
- rlad = rrDAO.read(trans, id);
- assertTrue(rlad.isOKhasData());
- ok = false;
- for(ApprovalDAO.Data a : rlad.value) {
- if(a.id.equals(id)) {
- ok = true;
- compare(data,a);
- }
- }
- assertTrue(ok);
-
- } finally {
- // Delete
- data.id = id;
- rrDAO.delete(trans, data, true);
- rlad = rrDAO.read(trans, id);
- assertTrue(rlad.isOK());
- assertTrue(rlad.isEmpty());
- }
-
- } finally {
- rrDAO.close(trans);
- }
- }
-
- private void compare(Data d1, Data d2) {
- assertNotSame(d1.id,d2.id);
- assertEquals(d1.ticket,d2.ticket);
- assertEquals(d1.user,d2.user);
- assertEquals(d1.approver,d2.approver);
- assertEquals(d1.type,d2.type);
- assertEquals(d1.status,d2.status);
- assertEquals(d1.operation,d2.operation);
- assertNotSame(d1.updated,d2.updated);
- }
-
-
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_ArtiDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_ArtiDAO.java
deleted file mode 100644
index 0c92dc75..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_ArtiDAO.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.security.NoSuchAlgorithmException;
-import java.util.Date;
-import java.util.List;
-
-import org.junit.Test;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.ArtiDAO;
-import org.onap.aaf.dao.aaf.cass.ArtiDAO.Data;
-
-/**
- * UserDAO unit test.
- * User: tp007s
- * Date: 7/19/13
- */
-public class JU_ArtiDAO extends AbsJUCass {
- @Test
- public void test() throws IOException, NoSuchAlgorithmException {
- ArtiDAO adao = new ArtiDAO(trans,cluster,"authz");
- try {
- // Create
- ArtiDAO.Data data = new ArtiDAO.Data();
- data.mechid="m55555@perturbed.att.com";
- data.machine="perturbed1232.att.com";
- data.type(false).add("file");
- data.type(false).add("jks");
- data.sponsor="Fred Flintstone";
- data.ca="devl";
- data.dir="/opt/app/aft/keys";
- data.appName="kumquat";
- data.os_user="aft";
- data.notify="email:myname@bogus.email.com";
- data.expires=new Date();
-
-// Bytification
- ByteBuffer bb = data.bytify();
- Data bdata = new ArtiDAO.Data();
- bdata.reconstitute(bb);
- checkData1(data, bdata);
-
-
-// DB work
- adao.create(trans,data);
- try {
- // Validate Read with key fields in Data
- Result<List<ArtiDAO.Data>> rlcd = adao.read(trans,data);
- assertTrue(rlcd.isOKhasData());
- for(ArtiDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- // Validate Read with key fields in Data
- rlcd = adao.read(trans,data.mechid, data.machine);
- assertTrue(rlcd.isOKhasData());
- for(ArtiDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- // By Machine
- rlcd = adao.readByMachine(trans,data.machine);
- assertTrue(rlcd.isOKhasData());
- for(ArtiDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- // By MechID
- rlcd = adao.readByMechID(trans,data.mechid);
- assertTrue(rlcd.isOKhasData());
- for(ArtiDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- // Update
- data.sponsor = "Wilma Flintstone";
- adao.update(trans,data);
- rlcd = adao.read(trans,data);
- assertTrue(rlcd.isOKhasData());
- for(ArtiDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- } finally {
- // Always delete data, even if failure.
- adao.delete(trans,data, true);
- }
- } finally {
- adao.close(trans);
- }
-
-
- }
-
- private void checkData1(Data data, Data d) {
- assertEquals(data.mechid,d.mechid);
- assertEquals(data.machine,d.machine);
- assertEquals(data.type(false).size(),d.type(false).size());
- for(String s: data.type(false)) {
- assertTrue(d.type(false).contains(s));
- }
- assertEquals(data.sponsor,d.sponsor);
- assertEquals(data.ca,d.ca);
- assertEquals(data.dir,d.dir);
- assertEquals(data.appName,d.appName);
- assertEquals(data.os_user,d.os_user);
- assertEquals(data.notify,d.notify);
- assertEquals(data.expires,d.expires);
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_Bytification.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_Bytification.java
deleted file mode 100644
index 65efef40..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_Bytification.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Date;
-
-import org.junit.Test;
-import org.onap.aaf.dao.aaf.cass.CredDAO;
-import org.onap.aaf.dao.aaf.cass.NsDAO;
-import org.onap.aaf.dao.aaf.cass.NsType;
-import org.onap.aaf.dao.aaf.cass.PermDAO;
-import org.onap.aaf.dao.aaf.cass.RoleDAO;
-import org.onap.aaf.dao.aaf.cass.UserRoleDAO;
-
-public class JU_Bytification {
-
- @Test
- public void testNS() throws IOException {
-
- // Normal
- NsDAO.Data ns = new NsDAO.Data();
- ns.name = "com.att.<pass>";
- ns.type = NsType.APP.type;
-
- ByteBuffer bb = ns.bytify();
-
- NsDAO.Data nsr = new NsDAO.Data();
- nsr.reconstitute(bb);
- check(ns,nsr);
-
- // Empty admin
-// ns.admin(true).clear();
- bb = ns.bytify();
- nsr = new NsDAO.Data();
- nsr.reconstitute(bb);
- check(ns,nsr);
-
- // Empty responsible
-// ns.responsible(true).clear();
- bb = ns.bytify();
- nsr = new NsDAO.Data();
- nsr.reconstitute(bb);
- check(ns,nsr);
-
- bb = ns.bytify();
- nsr = new NsDAO.Data();
- nsr.reconstitute(bb);
- check(ns,nsr);
- }
-
- private void check(NsDAO.Data a, NsDAO.Data b) {
- assertEquals(a.name,b.name);
- assertEquals(a.type,b.type);
-// assertEquals(a.admin.size(),b.admin.size());
-
-// for(String s: a.admin) {
-// assertTrue(b.admin.contains(s));
-// }
-//
-// assertEquals(a.responsible.size(),b.responsible.size());
-// for(String s: a.responsible) {
-// assertTrue(b.responsible.contains(s));
-// }
- }
-
- @Test
- public void testRole() throws IOException {
- RoleDAO.Data rd1 = new RoleDAO.Data();
- rd1.ns = "com.att.<pass>";
- rd1.name = "my.role";
- rd1.perms(true).add("com.att.<pass>.my.Perm|myInstance|myAction");
- rd1.perms(true).add("com.att.<pass>.my.Perm|myInstance|myAction2");
-
- // Normal
- ByteBuffer bb = rd1.bytify();
- RoleDAO.Data rd2 = new RoleDAO.Data();
- rd2.reconstitute(bb);
- check(rd1,rd2);
-
- // Overshoot Buffer
- StringBuilder sb = new StringBuilder(300);
- sb.append("role|instance|veryLongAction...");
- for(int i=0;i<280;++i) {
- sb.append('a');
- }
- rd1.perms(true).add(sb.toString());
- bb = rd1.bytify();
- rd2 = new RoleDAO.Data();
- rd2.reconstitute(bb);
- check(rd1,rd2);
-
- // No Perms
- rd1.perms.clear();
-
- bb = rd1.bytify();
- rd2 = new RoleDAO.Data();
- rd2.reconstitute(bb);
- check(rd1,rd2);
-
- // 1000 Perms
- for(int i=0;i<1000;++i) {
- rd1.perms(true).add("com|inst|action"+ i);
- }
-
- bb = rd1.bytify();
- rd2 = new RoleDAO.Data();
- rd2.reconstitute(bb);
- check(rd1,rd2);
-
- }
-
- private void check(RoleDAO.Data a, RoleDAO.Data b) {
- assertEquals(a.ns,b.ns);
- assertEquals(a.name,b.name);
-
- assertEquals(a.perms.size(),b.perms.size());
- for(String s: a.perms) {
- assertTrue(b.perms.contains(s));
- }
- }
-
- @Test
- public void testPerm() throws IOException {
- PermDAO.Data pd1 = new PermDAO.Data();
- pd1.ns = "com.att.<pass>";
- pd1.type = "my.perm";
- pd1.instance = "instance";
- pd1.action = "read";
- pd1.roles(true).add("com.att.<pass>.my.Role");
- pd1.roles(true).add("com.att.<pass>.my.Role2");
-
- // Normal
- ByteBuffer bb = pd1.bytify();
- PermDAO.Data rd2 = new PermDAO.Data();
- rd2.reconstitute(bb);
- check(pd1,rd2);
-
- // No Perms
- pd1.roles.clear();
-
- bb = pd1.bytify();
- rd2 = new PermDAO.Data();
- rd2.reconstitute(bb);
- check(pd1,rd2);
-
- // 1000 Perms
- for(int i=0;i<1000;++i) {
- pd1.roles(true).add("com.att.<pass>.my.Role"+ i);
- }
-
- bb = pd1.bytify();
- rd2 = new PermDAO.Data();
- rd2.reconstitute(bb);
- check(pd1,rd2);
-
- }
-
- private void check(PermDAO.Data a, PermDAO.Data b) {
- assertEquals(a.ns,b.ns);
- assertEquals(a.type,b.type);
- assertEquals(a.instance,b.instance);
- assertEquals(a.action,b.action);
-
- assertEquals(a.roles.size(),b.roles.size());
- for(String s: a.roles) {
- assertTrue(b.roles.contains(s));
- }
- }
-
- @Test
- public void testUserRole() throws IOException {
- UserRoleDAO.Data urd1 = new UserRoleDAO.Data();
- urd1.user = "myname@abc.att.com";
- urd1.role("com.att.<pass>","my.role");
- urd1.expires = new Date();
-
- // Normal
- ByteBuffer bb = urd1.bytify();
- UserRoleDAO.Data urd2 = new UserRoleDAO.Data();
- urd2.reconstitute(bb);
- check(urd1,urd2);
-
- // A null
- urd1.expires = null;
- urd1.role = null;
-
- bb = urd1.bytify();
- urd2 = new UserRoleDAO.Data();
- urd2.reconstitute(bb);
- check(urd1,urd2);
- }
-
- private void check(UserRoleDAO.Data a, UserRoleDAO.Data b) {
- assertEquals(a.user,b.user);
- assertEquals(a.role,b.role);
- assertEquals(a.expires,b.expires);
- }
-
-
- @Test
- public void testCred() throws IOException {
- CredDAO.Data cd = new CredDAO.Data();
- cd.id = "m55555@abc.att.com";
- cd.ns = "com.att.abc";
- cd.type = 2;
- cd.cred = ByteBuffer.wrap(new byte[]{1,34,5,3,25,0,2,5,3,4});
- cd.expires = new Date();
-
- // Normal
- ByteBuffer bb = cd.bytify();
- CredDAO.Data cd2 = new CredDAO.Data();
- cd2.reconstitute(bb);
- check(cd,cd2);
-
- // nulls
- cd.expires = null;
- cd.cred = null;
-
- bb = cd.bytify();
- cd2 = new CredDAO.Data();
- cd2.reconstitute(bb);
- check(cd,cd2);
-
- }
-
- private void check(CredDAO.Data a, CredDAO.Data b) {
- assertEquals(a.id,b.id);
- assertEquals(a.ns,b.ns);
- assertEquals(a.type,b.type);
- if(a.cred==null) {
- assertEquals(a.cred,b.cred);
- } else {
- int l = a.cred.limit();
- assertEquals(l,b.cred.limit());
- for (int i=0;i<l;++i) {
- assertEquals(a.cred.get(),b.cred.get());
- }
- }
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CacheInfoDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CacheInfoDAO.java
deleted file mode 100644
index a2e96f2e..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CacheInfoDAO.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import java.io.IOException;
-import java.util.Date;
-
-import org.junit.Test;
-import org.onap.aaf.authz.env.AuthzTrans;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.CIDAO;
-import org.onap.aaf.dao.DAOException;
-import org.onap.aaf.dao.aaf.cass.CacheInfoDAO;
-import org.onap.aaf.dao.aaf.cass.RoleDAO;
-import org.onap.aaf.dao.aaf.cass.Status;
-
-import org.onap.aaf.inno.env.APIException;
-import org.onap.aaf.inno.env.util.Chrono;
-
-import junit.framework.Assert;
-
-
-public class JU_CacheInfoDAO extends AbsJUCass {
-
- @Test
- public void test() throws DAOException, APIException, IOException {
- CIDAO<AuthzTrans> id = new CacheInfoDAO(trans, cluster, AUTHZ);
- Date date = new Date();
-
- id.touch(trans, RoleDAO.TABLE,1);
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- }
- Result<Void> rid = id.check(trans);
- Assert.assertEquals(rid.status,Status.OK);
- Date[] dates = CacheInfoDAO.info.get(RoleDAO.TABLE);
- if(dates.length>0 && dates[1]!=null) {
- System.out.println(Chrono.dateStamp(dates[1]));
- System.out.println(Chrono.dateStamp(date));
- Assert.assertTrue(Math.abs(dates[1].getTime() - date.getTime())<20000); // allow for 4 seconds, given Remote DB
- }
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CertDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CertDAO.java
deleted file mode 100644
index 498f8ce6..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CertDAO.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.security.NoSuchAlgorithmException;
-import java.util.List;
-
-import org.junit.Test;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.CertDAO;
-import org.onap.aaf.dao.aaf.cass.CertDAO.Data;
-
-import org.onap.aaf.inno.env.APIException;
-
-/**
- * UserDAO unit test.
- * User: tp007s
- * Date: 7/19/13
- */
-public class JU_CertDAO extends AbsJUCass {
- @Test
- public void test() throws IOException, NoSuchAlgorithmException, APIException {
- CertDAO cdao = new CertDAO(trans,cluster,"authz");
- try {
- // Create
- CertDAO.Data data = new CertDAO.Data();
- data.serial=new BigInteger("11839383");
- data.id = "m55555@tguard.att.com";
- data.x500="CN=ju_cert.dao.att.com, OU=AAF, O=\"ATT Services, Inc.\", L=Southfield, ST=Michigan, C=US";
- data.x509="I'm a cert";
- data.ca = "aaf";
- cdao.create(trans,data);
-
-// Bytification
- ByteBuffer bb = data.bytify();
- Data bdata = new CertDAO.Data();
- bdata.reconstitute(bb);
- checkData1(data, bdata);
-
- // Validate Read with key fields in Data
- Result<List<CertDAO.Data>> rlcd = cdao.read(trans,data);
- assertTrue(rlcd.isOKhasData());
- for(CertDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- // Validate Read with key fields in Data
- rlcd = cdao.read(trans,data.ca,data.serial);
- assertTrue(rlcd.isOKhasData());
- for(CertDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- // Update
- data.id = "m66666.tguard.att.com";
- cdao.update(trans,data);
- rlcd = cdao.read(trans,data);
- assertTrue(rlcd.isOKhasData());
- for(CertDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- cdao.delete(trans,data, true);
- } finally {
- cdao.close(trans);
- }
-
-
- }
-
- private void checkData1(Data data, Data d) {
- assertEquals(data.ca,d.ca);
- assertEquals(data.serial,d.serial);
- assertEquals(data.id,d.id);
- assertEquals(data.x500,d.x500);
- assertEquals(data.x509,d.x509);
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CredDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CredDAO.java
deleted file mode 100644
index 3cf860ae..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_CredDAO.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.security.NoSuchAlgorithmException;
-import java.util.Date;
-import java.util.List;
-
-import org.junit.Test;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.CredDAO;
-import org.onap.aaf.dao.aaf.cass.CredDAO.Data;
-
-import org.onap.aaf.inno.env.APIException;
-
-/**
- * UserDAO unit test.
- * User: tp007s
- * Date: 7/19/13
- */
-public class JU_CredDAO extends AbsJUCass {
- @Test
- public void test() throws IOException, NoSuchAlgorithmException, APIException {
- CredDAO udao = new CredDAO(trans,cluster,"authz");
- try {
- // Create
- CredDAO.Data data = new CredDAO.Data();
- data.id = "m55555@aaf.att.com";
- data.type = CredDAO.BASIC_AUTH;
- data.notes = "temp pass";
- data.cred = ByteBuffer.wrap(userPassToBytes("m55555","mypass"));
- data.other = 12;
- data.expires = new Date(System.currentTimeMillis() + 60000*60*24*90);
- udao.create(trans,data);
-
-// Bytification
- ByteBuffer bb = data.bytify();
- Data bdata = new CredDAO.Data();
- bdata.reconstitute(bb);
- checkData1(data, bdata);
-
- // Validate Read with key fields in Data
- Result<List<CredDAO.Data>> rlcd = udao.read(trans,data);
- assertTrue(rlcd.isOKhasData());
- for(CredDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- // Update
- data.cred = ByteBuffer.wrap(userPassToBytes("m55555","mynewpass"));
- udao.update(trans,data);
- rlcd = udao.read(trans,data);
- assertTrue(rlcd.isOKhasData());
- for(CredDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- udao.delete(trans,data, true);
- } finally {
- udao.close(trans);
- }
-
-
- }
-
- private void checkData1(Data data, Data d) {
- assertEquals(data.id,d.id);
- assertEquals(data.type,d.type);
- assertEquals(data.ns,d.ns);
- assertEquals(data.notes,d.notes);
- assertEquals(data.cred,d.cred);
- assertEquals(data.other,d.other);
- assertEquals(data.expires,d.expires);
- }
-
-// private String CONST_myName = "MyName";
-// public static final java.nio.ByteBuffer CONST_MY_CRED = get_CONST_MY_CRED();
-// public static final int CONST_CRED_TYPE = 11;
-//
-// public static final Date CONST_UPDATE_DATE = new Date(System.currentTimeMillis()+60000*24);
-// @Test
-// public void test() {
-// UserDAO ud = new UserDAO(trans, cluster,"authz");
-// try {
-// UserDAO.Data data = createPrototypeUserData();
-// ud.create(trans, data);
-//
-// // Validate Read with key fields in Data
-// for(UserDAO.Data d : ud.read(trans, data)) {
-// checkData1(data,d);
-// }
-//
-// // Validate readByName
-// for(UserDAO.Data d : ud.read(trans, CONST_myName)) {
-// checkData1(data,d);
-// }
-//
-// ud.delete(trans, data);
-// List<UserDAO.Data> d_2 = ud.read(trans, CONST_myName);
-//
-// // Validate that data was deleted
-// assertEquals("User should not be found after deleted", 0, d_2.size() );
-//
-// data = new UserDAO.Data();
-// data.name = CONST_myName;
-// data.cred = CONST_MY_CRED;
-// data.cred_type= CONST_CRED_TYPE;
-// data.expires = new Date(System.currentTimeMillis()+60000*24);
-// final Result<UserDAO.Data> user = ud.r_create(trans, data);
-// assertEquals("ud.createUser should work", Result.Status.OK, user.status);
-//
-// checkDataIgnoreDateDiff(data, user.value);
-//
-// // finally leave system in consistent state by deleting user again
-// ud.delete(trans,data);
-//
-// } catch (DAOException e) {
-// e.printStackTrace();
-// fail("Fail due to Exception");
-// } finally {
-// ud.close(trans);
-// }
-// }
-//
-// private UserDAO.Data createPrototypeUserData() {
-// UserDAO.Data data = new UserDAO.Data();
-// data.name = CONST_myName;
-//
-// data.cred_type = CONST_CRED_TYPE;
-// data.cred = CONST_MY_CRED;
-// data.expires = CONST_UPDATE_DATE;
-// return data;
-// }
-//
-// // @Test
-// // public void testReadByUser() throws Exception {
-// // // this test was done above in our super test, since it uses the same setup
-// // }
-//
-// @Test
-// public void testFunctionCreateUser() throws Exception {
-// String name = "roger_rabbit";
-// Integer credType = CONST_CRED_TYPE;
-// java.nio.ByteBuffer cred = CONST_MY_CRED;
-// final UserDAO ud = new UserDAO(trans, cluster,"authz");
-// final UserDAO.Data data = createPrototypeUserData();
-// Result<UserDAO.Data> ret = ud.r_create(trans, data);
-// Result<List<Data>> byUserNameLookup = ud.r_read(trans, name);
-//
-// assertEquals("sanity test w/ different username (different than other test cases) failed", name, byUserNameLookup.value.get(0).name);
-// assertEquals("delete roger_rabbit failed", true, ud.delete(trans, byUserNameLookup.value.get(0)));
-// }
-//
-// @Test
-// public void testLowLevelCassandraCreateData_Given_UserAlreadyPresent_ShouldPass() throws Exception {
-// UserDAO ud = new UserDAO(trans, cluster,"authz");
-//
-// final UserDAO.Data data = createPrototypeUserData();
-// final UserDAO.Data data1 = ud.create(trans, data);
-// final UserDAO.Data data2 = ud.create(trans, data);
-//
-// assertNotNull(data1);
-// assertNotNull(data2);
-//
-// assertEquals(CONST_myName, data1.name);
-// assertEquals(CONST_myName, data2.name);
-// }
-//
-// @Test
-// public void testCreateUser_Given_UserAlreadyPresent_ShouldFail() throws Exception {
-// UserDAO ud = new UserDAO(trans, cluster,"authz");
-//
-// final UserDAO.Data data = createPrototypeUserData();
-//
-// // make sure that some prev test did not leave the user in the DB
-// ud.delete(trans, data);
-//
-// // attempt to create same user twice !!!
-//
-// final Result<UserDAO.Data> data1 = ud.r_create(trans, data);
-// final Result<UserDAO.Data> data2 = ud.r_create(trans, data);
-//
-// assertNotNull(data1);
-// assertNotNull(data2);
-//
-// assertEquals(true, Result.Status.OK == data1.status);
-// assertEquals(false, Result.Status.OK == data2.status);
-// }
-//
-// private void checkData1(UserDAO.Data data, UserDAO.Data d) {
-// data.name = CONST_myName;
-//
-// data.cred_type = CONST_CRED_TYPE;
-// data.cred = CONST_MY_CRED;
-// data.expires = CONST_UPDATE_DATE;
-//
-// assertEquals(data.name, d.name);
-// assertEquals(data.cred_type, d.cred_type);
-// assertEquals(data.cred, d.cred);
-// assertEquals(data.expires, d.expires);
-//
-// }
-//
-// private void checkDataIgnoreDateDiff(UserDAO.Data data, UserDAO.Data d) {
-// data.name = CONST_myName;
-//
-// data.cred_type = CONST_CRED_TYPE;
-// data.cred = CONST_MY_CRED;
-// data.expires = CONST_UPDATE_DATE;
-//
-// assertEquals(data.name, d.name);
-// assertEquals(data.cred_type, d.cred_type);
-// assertEquals(data.cred, d.cred);
-// // we allow dates to be different, e.g. high level calls e.g. createUser sets the date itself.
-// //assertEquals(data.updated, d.updated);
-//
-// }
-//
-// /**
-// * Get a CONST_MY_CRED ByteBuffer, which is the java type for a cass blob.
-// * @return
-// */
-// private static java.nio.ByteBuffer get_CONST_MY_CRED() {
-// return ByteBuffer.wrap("Hello".getBytes());
-// }
-//
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_DelegateDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_DelegateDAO.java
deleted file mode 100644
index d93ec399..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_DelegateDAO.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.ByteBuffer;
-import java.util.Date;
-import java.util.List;
-
-import org.junit.Test;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.DelegateDAO;
-import org.onap.aaf.dao.aaf.cass.DelegateDAO.Data;
-
-
-public class JU_DelegateDAO extends AbsJUCass {
- @Test
- public void testCRUD() throws Exception {
- DelegateDAO dao = new DelegateDAO(trans, cluster, AUTHZ);
- DelegateDAO.Data data = new DelegateDAO.Data();
- data.user = "myname";
- data.delegate = "yourname";
- data.expires = new Date();
-
-// Bytification
- ByteBuffer bb = data.bytify();
- Data bdata = new DelegateDAO.Data();
- bdata.reconstitute(bb);
- compare(data, bdata);
-
- try {
- // Test create
- Result<Data> ddcr = dao.create(trans,data);
- assertTrue(ddcr.isOK());
-
-
- // Read by User
- Result<List<DelegateDAO.Data>> records = dao.read(trans,data.user);
- assertTrue(records.isOKhasData());
- for(DelegateDAO.Data rdata : records.value)
- compare(data,rdata);
-
- // Read by Delegate
- records = dao.readByDelegate(trans,data.delegate);
- assertTrue(records.isOKhasData());
- for(DelegateDAO.Data rdata : records.value)
- compare(data,rdata);
-
- // Update
- data.delegate = "hisname";
- data.expires = new Date();
- assertTrue(dao.update(trans, data).isOK());
-
- // Read by User
- records = dao.read(trans,data.user);
- assertTrue(records.isOKhasData());
- for(DelegateDAO.Data rdata : records.value)
- compare(data,rdata);
-
- // Read by Delegate
- records = dao.readByDelegate(trans,data.delegate);
- assertTrue(records.isOKhasData());
- for(DelegateDAO.Data rdata : records.value)
- compare(data,rdata);
-
- // Test delete
- dao.delete(trans,data, true);
- records = dao.read(trans,data.user);
- assertTrue(records.isEmpty());
-
-
- } finally {
- dao.close(trans);
- }
- }
-
- private void compare(Data d1, Data d2) {
- assertEquals(d1.user, d2.user);
- assertEquals(d1.delegate, d2.delegate);
- assertEquals(d1.expires,d2.expires);
- }
-
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_FastCalling.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_FastCalling.java
deleted file mode 100644
index 9b0fa2ed..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_FastCalling.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.security.NoSuchAlgorithmException;
-import java.util.Date;
-import java.util.List;
-
-import org.junit.Test;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.CredDAO;
-import org.onap.aaf.dao.aaf.cass.CredDAO.Data;
-
-import org.onap.aaf.inno.env.APIException;
-
-public class JU_FastCalling extends AbsJUCass {
-
- @Test
- public void test() throws IOException, NoSuchAlgorithmException, APIException {
- trans.setProperty("cassandra.writeConsistency.cred","ONE");
-
- CredDAO udao = new CredDAO(env.newTransNoAvg(),cluster,"authz");
- System.out.println("Starting calls");
- for(iterations=0;iterations<8;++iterations) {
- try {
- // Create
- CredDAO.Data data = new CredDAO.Data();
- data.id = "m55555@aaf.att.com";
- data.type = CredDAO.BASIC_AUTH;
- data.cred = ByteBuffer.wrap(userPassToBytes("m55555","mypass"));
- data.expires = new Date(System.currentTimeMillis() + 60000*60*24*90);
- udao.create(trans,data);
-
- // Validate Read with key fields in Data
- Result<List<CredDAO.Data>> rlcd = udao.read(trans,data);
- assertTrue(rlcd.isOKhasData());
- for(CredDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- // Update
- data.cred = ByteBuffer.wrap(userPassToBytes("m55555","mynewpass"));
- udao.update(trans,data);
- rlcd = udao.read(trans,data);
- assertTrue(rlcd.isOKhasData());
- for(CredDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- udao.delete(trans,data, true);
- } finally {
- updateTotals();
- newTrans();
- }
- }
-
- }
-
- private void checkData1(Data data, Data d) {
- assertEquals(data.id,d.id);
- assertEquals(data.type,d.type);
- assertEquals(data.cred,d.cred);
- assertEquals(data.expires,d.expires);
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_HistoryDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_HistoryDAO.java
deleted file mode 100644
index 29ce5d4b..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_HistoryDAO.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.Random;
-
-import org.junit.Test;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.HistoryDAO;
-
-public class JU_HistoryDAO extends AbsJUCass {
-
- @Test
- public void testCreate() throws Exception {
- HistoryDAO historyDAO = new HistoryDAO(trans, cluster, AUTHZ);
- HistoryDAO.Data data = createHistoryData();
-
- try {
- historyDAO.create(trans,data);
- Thread.sleep(200);// History Create is Async
- Result<List<HistoryDAO.Data>> records = historyDAO.readByUser(trans,data.user,data.yr_mon);
- assertTrue(records.isOKhasData());
- for(HistoryDAO.Data d : records.value) {
- assertHistory(data, d);
- }
- } finally {
- historyDAO.close(trans);
- }
- }
-
- @Test
- public void tesReadByUser() throws Exception {
- HistoryDAO historyDAO = new HistoryDAO(trans,cluster, AUTHZ);
- HistoryDAO.Data data = createHistoryData();
-
- try {
- historyDAO.create(trans,data);
- Thread.sleep(200);// History Create is Async
- Result<List<HistoryDAO.Data>> records = historyDAO.readByUser(trans, data.user,data.yr_mon);
- assertTrue(records.isOKhasData());
- for(HistoryDAO.Data d : records.value) {
- assertHistory(data, d);
- }
- } finally {
- historyDAO.close(trans);
- }
- }
-
-/*
- @Test
- public void readByUserAndMonth() throws Exception {
- HistoryDAO historyDAO = new HistoryDAO(trans,cluster, AUTHZ);
- HistoryDAO.Data data = createHistoryData();
-
- try {
- historyDAO.create(trans,data);
- Thread.sleep(200);// History Create is Async
- Result<List<HistoryDAO.Data>> records = historyDAO.readByUserAndMonth(trans,
- data.user, Integer.valueOf(String.valueOf(data.yr_mon).substring(0, 4)),
- Integer.valueOf(String.valueOf(data.yr_mon).substring(4, 6)));
- assertTrue(records.isOKhasData());
- for(HistoryDAO.Data d : records.value) {
- assertHistory(data, d);
- }
- } finally {
- historyDAO.close(trans);
- }
- }
-*/
- //TODO readadd this
-// @Test
-// public void readByUserAndDay() throws Exception {
-// HistoryDAO historyDAO = new HistoryDAO(trans, cluster, AUTHZ);
-// HistoryDAO.Data data = createHistoryData();
-//
-// try {
-// historyDAO.create(trans, data);
-// Thread.sleep(200);// History Create is Async
-//
-// String dayTime = String.valueOf(data.day_time);
-// String day = null;
-// if (dayTime.length() < 8)
-// day = dayTime.substring(0, 1);
-// else
-// day = dayTime.substring(0, 2);
-//
-// List<HistoryDAO.Data> records = historyDAO.readByUserBetweenDates(trans,
-// data.user, Integer.valueOf(String.valueOf(data.yr_mon).substring(0, 4)),
-// Integer.valueOf(String.valueOf(data.yr_mon).substring(4, 6)),
-// Integer.valueOf(day), 0);
-// assertEquals(1,records.size());
-// for(HistoryDAO.Data d : records) {
-// assertHistory(data, d);
-// }
-// } finally {
-// historyDAO.close(trans);
-// }
-// }
- private HistoryDAO.Data createHistoryData() {
- HistoryDAO.Data data = HistoryDAO.newInitedData();
- Random random = new Random();
- data.user = "test" + random.nextInt();
- data.action = "add";
- data.target = "history";
- data.memo = "adding a row into history table";
-// data.detail().put("id", "test");
-// data.detail().put("name", "test");
- //String temp = "Test Blob Message";
- data.reconstruct = ByteBuffer.wrap("Temp Blob Message".getBytes());
- return data;
- }
-
- private void assertHistory(HistoryDAO.Data ip, HistoryDAO.Data op) {
- assertEquals(ip.yr_mon, op.yr_mon);
-// assertEquals(ip.day_time, op.day_time);
- assertEquals(ip.user, op.user);
- assertEquals(ip.action, op.action);
- assertEquals(ip.target, op.target);
- assertEquals(ip.memo, op.memo);
- //TODO : have to see if third party assert utility can be used
-// assertTrue(CollectionUtils.isEqualCollection(ip.detail, op.detail));
-// for (String key : ip.detail().keySet()) {
-// assertNotNull(op.detail().get(key));
-// }
- assertNotNull(op.reconstruct);
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_NsDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_NsDAO.java
deleted file mode 100644
index ad9ed287..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_NsDAO.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.junit.Test;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.NsDAO;
-import org.onap.aaf.dao.aaf.cass.NsType;
-import org.onap.aaf.dao.aaf.cass.NsDAO.Data;
-
-import org.onap.aaf.inno.env.APIException;
-
-
-public class JU_NsDAO extends AbsJUCass {
- private static final String CRM = "ju_crm";
- private static final String SWM = "ju_swm";
-
- @Test
- public void test() throws APIException, IOException {
- NsDAO nsd = new NsDAO(trans, cluster, AUTHZ);
- try {
- final String nsparent = "com.test";
- final String ns1 = nsparent +".ju_ns";
- final String ns2 = nsparent + ".ju_ns2";
-
- Map<String,String> oAttribs = new HashMap<String,String>();
- oAttribs.put(SWM, "swm_data");
- oAttribs.put(CRM, "crm_data");
- Data data = new NsDAO.Data();
- data.name = ns1;
- data.type = NsType.APP.type;
- data.attrib(true).putAll(oAttribs);
-
-
- Result<List<Data>> rdrr;
-
- // CREATE
- Result<Data> rdc = nsd.create(trans, data);
- assertTrue(rdc.isOK());
-
- try {
-// Bytification
- ByteBuffer bb = data.bytify();
- Data bdata = new NsDAO.Data();
- bdata.reconstitute(bb);
- compare(data, bdata);
-
- // Test READ by Object
- rdrr = nsd.read(trans, data);
- assertTrue(rdrr.isOKhasData());
- assertEquals(rdrr.value.size(),1);
- Data d = rdrr.value.get(0);
- assertEquals(d.name,data.name);
- assertEquals(d.type,data.type);
- attribsEqual(d.attrib(false),data.attrib(false));
- attribsEqual(oAttribs,data.attrib(false));
-
- // Test Read by Key
- rdrr = nsd.read(trans, data.name);
- assertTrue(rdrr.isOKhasData());
- assertEquals(rdrr.value.size(),1);
- d = rdrr.value.get(0);
- assertEquals(d.name,data.name);
- assertEquals(d.type,data.type);
- attribsEqual(d.attrib(false),data.attrib(false));
- attribsEqual(oAttribs,data.attrib(false));
-
- // Read NS by Type
- Result<Set<String>> rtypes = nsd.readNsByAttrib(trans, SWM);
- Set<String> types;
- if(rtypes.notOK()) {
- throw new IOException(rtypes.errorString());
- } else {
- types = rtypes.value;
- }
- assertEquals(1,types.size());
- assertEquals(true,types.contains(ns1));
-
- // Add second NS to test list of data returned
- Data data2 = new NsDAO.Data();
- data2.name = ns2;
- data2.type = 3; // app
- Result<Data> rdc2 = nsd.create(trans, data2);
- assertTrue(rdc2.isOK());
-
- // Interrupt - test PARENT
- Result<List<Data>> rdchildren = nsd.getChildren(trans, "com.test");
- assertTrue(rdchildren.isOKhasData());
- boolean child1 = false;
- boolean child2 = false;
- for(Data dchild : rdchildren.value) {
- if(ns1.equals(dchild.name))child1=true;
- if(ns2.equals(dchild.name))child2=true;
- }
- assertTrue(child1);
- assertTrue(child2);
-
- // FINISH DATA 2 by deleting
- Result<Void> rddr = nsd.delete(trans, data2, true);
- assertTrue(rddr.isOK());
-
- // ADD DESCRIPTION
- String description = "This is my test Namespace";
- assertFalse(description.equalsIgnoreCase(data.description));
-
- Result<Void> addDesc = nsd.addDescription(trans, data.name, description);
- assertTrue(addDesc.isOK());
- rdrr = nsd.read(trans, data);
- assertTrue(rdrr.isOKhasData());
- assertEquals(rdrr.value.size(),1);
- assertEquals(rdrr.value.get(0).description,description);
-
- // UPDATE
- String newDescription = "zz1234 Owns This Namespace Now";
- oAttribs.put("mso", "mso_data");
- data.attrib(true).put("mso", "mso_data");
- data.description = newDescription;
- Result<Void> update = nsd.update(trans, data);
- assertTrue(update.isOK());
- rdrr = nsd.read(trans, data);
- assertTrue(rdrr.isOKhasData());
- assertEquals(rdrr.value.size(),1);
- assertEquals(rdrr.value.get(0).description,newDescription);
- attribsEqual(oAttribs, rdrr.value.get(0).attrib);
-
-
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- // DELETE
- Result<Void> rddr = nsd.delete(trans, data, true);
- assertTrue(rddr.isOK());
- rdrr = nsd.read(trans, data);
- assertTrue(rdrr.isOK() && rdrr.isEmpty());
- assertEquals(rdrr.value.size(),0);
- }
- } finally {
- nsd.close(trans);
- }
- }
-
- private void compare(NsDAO.Data d, NsDAO.Data data) {
- assertEquals(d.name,data.name);
- assertEquals(d.type,data.type);
- attribsEqual(d.attrib(false),data.attrib(false));
- attribsEqual(d.attrib(false),data.attrib(false));
- }
-
- private void attribsEqual(Map<String,String> aa, Map<String,String> ba) {
- assertEquals(aa.size(),ba.size());
- for(Entry<String, String> es : aa.entrySet()) {
- assertEquals(es.getValue(),ba.get(es.getKey()));
- }
- }
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_NsType.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_NsType.java
deleted file mode 100644
index 92152695..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_NsType.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.AfterClass;
-import org.junit.Test;
-import org.onap.aaf.dao.aaf.cass.NsType;
-
-public class JU_NsType {
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Test
- public void test() {
- NsType nt,nt2;
- String[] tests = new String[] {"DOT","ROOT","COMPANY","APP","STACKED_APP","STACK"};
- for(String s : tests) {
- nt = NsType.valueOf(s);
- assertEquals(s,nt.name());
-
- nt2 = NsType.fromString(s);
- assertEquals(nt,nt2);
-
- int t = nt.type;
- nt2 = NsType.fromType(t);
- assertEquals(nt,nt2);
- }
-
- nt = NsType.fromType(Integer.MIN_VALUE);
- assertEquals(nt,NsType.UNKNOWN);
- nt = NsType.fromString("Garbage");
- assertEquals(nt,NsType.UNKNOWN);
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_PermDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_PermDAO.java
deleted file mode 100644
index 582ce185..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_PermDAO.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.Test;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.PermDAO;
-import org.onap.aaf.dao.aaf.cass.RoleDAO;
-import org.onap.aaf.dao.aaf.cass.PermDAO.Data;
-
-import org.onap.aaf.inno.env.APIException;
-
-/**
- * Test the PermissionDAO
- *
- * Utilize AbsJUCass to initialize and pre-load Cass
- *
- *
- */
-public class JU_PermDAO extends AbsJUCass{
-
- @Test
- public void test() throws APIException, IOException {
- PermDAO pd = new PermDAO(trans,cluster,"authz");
- try {
- PermDAO.Data data = new PermDAO.Data();
- data.ns = "com.test.ju_perm";
- data.type = "MyType";
- data.instance = "MyInstance";
- data.action = "MyAction";
- data.roles(true).add(data.ns + ".dev");
-
-
-
- // CREATE
- Result<Data> rpdc = pd.create(trans,data);
- assertTrue(rpdc.isOK());
-
- Result<List<PermDAO.Data>> rlpd;
- try {
-// Bytification
- ByteBuffer bb = data.bytify();
- Data bdata = new PermDAO.Data();
- bdata.reconstitute(bb);
- compare(data, bdata);
-
- // Validate Read with key fields in Data
- if((rlpd = pd.read(trans,data)).isOK())
- for(PermDAO.Data d : rlpd.value) {
- checkData1(data,d);
- }
-
- // Validate readByName
- if((rlpd = pd.readByType(trans,data.ns, data.type)).isOK())
- for(PermDAO.Data d : rlpd.value) {
- checkData1(data,d);
- }
-
- // Add Role
- RoleDAO.Data role = new RoleDAO.Data();
- role.ns = data.ns;
- role.name = "test";
-
- Result<Void> rvpd = pd.addRole(trans, data, role.fullName());
- assertTrue(rvpd.isOK());
- // Validate Read with key fields in Data
- if((rlpd = pd.read(trans,data)).isOK())
- for(PermDAO.Data d : rlpd.value) {
- checkData2(data,d);
- }
-
- // Remove Role
- rvpd = pd.delRole(trans, data, role.fullName());
- assertTrue(rvpd.isOK());
- if((rlpd = pd.read(trans,data)).isOK())
- for(PermDAO.Data d : rlpd.value) {
- checkData1(data,d);
- }
-
- // Add Child
- Data data2 = new Data();
- data2.ns = data.ns;
- data2.type = data.type + ".2";
- data2.instance = data.instance;
- data2.action = data.action;
-
- rpdc = pd.create(trans, data2);
- assertTrue(rpdc.isOK());
- try {
- rlpd = pd.readChildren(trans, data.ns,data.type);
- assertTrue(rlpd.isOKhasData());
- assertEquals(rlpd.value.size(),1);
- assertEquals(rlpd.value.get(0).fullType(),data2.fullType());
- } finally {
- // Delete Child
- pd.delete(trans, data2,true);
-
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- // DELETE
- Result<Void> rpdd = pd.delete(trans,data,true);
- assertTrue(rpdd.isOK());
- rlpd = pd.read(trans, data);
- assertTrue(rlpd.isOK() && rlpd.isEmpty());
- assertEquals(rlpd.value.size(),0);
- }
- } finally {
- pd.close(trans);
- }
- }
-
- private void compare(Data a, Data b) {
- assertEquals(a.ns,b.ns);
- assertEquals(a.type,b.type);
- assertEquals(a.instance,b.instance);
- assertEquals(a.action,b.action);
- assertEquals(a.roles(false).size(),b.roles(false).size());
- for(String s: a.roles(false)) {
- assertTrue(b.roles(false).contains(s));
- }
- }
- private void checkData1(Data data, Data d) {
- assertEquals(data.ns,d.ns);
- assertEquals(data.type,d.type);
- assertEquals(data.instance,d.instance);
- assertEquals(data.action,d.action);
-
- Set<String> ss = d.roles(true);
- assertEquals(1,ss.size());
- assertTrue(ss.contains(data.ns+".dev"));
- }
-
- private void checkData2(Data data, Data d) {
- assertEquals(data.ns,d.ns);
- assertEquals(data.type,d.type);
- assertEquals(data.instance,d.instance);
- assertEquals(data.action,d.action);
-
- Set<String> ss = d.roles(true);
- assertEquals(2,ss.size());
- assertTrue(ss.contains(data.ns+".dev"));
- assertTrue(ss.contains(data.ns+".test"));
- }
-
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_RoleDAO.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_RoleDAO.java
deleted file mode 100644
index ba61c61e..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/JU_RoleDAO.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.List;
-
-import org.junit.Test;
-import org.onap.aaf.authz.layer.Result;
-import org.onap.aaf.dao.aaf.cass.PermDAO;
-import org.onap.aaf.dao.aaf.cass.RoleDAO;
-import org.onap.aaf.dao.aaf.cass.RoleDAO.Data;
-
-import org.onap.aaf.inno.env.APIException;
-
-
-public class JU_RoleDAO extends AbsJUCass {
-
- @Test
- public void test() throws IOException, APIException {
- RoleDAO rd = new RoleDAO(trans, cluster, AUTHZ);
- try {
- Data data = new RoleDAO.Data();
- data.ns = "com.test.ju_role";
- data.name = "role1";
-
-// Bytification
- ByteBuffer bb = data.bytify();
- Data bdata = new RoleDAO.Data();
- bdata.reconstitute(bb);
- compare(data, bdata);
-
- // CREATE
- Result<Data> rdc = rd.create(trans, data);
- assertTrue(rdc.isOK());
- Result<List<Data>> rdrr;
- try {
- // READ
- rdrr = rd.read(trans, data);
- assertTrue(rdrr.isOKhasData());
- assertEquals(rdrr.value.size(),1);
- Data d = rdrr.value.get(0);
- assertEquals(d.perms.size(),0);
- assertEquals(d.name,data.name);
- assertEquals(d.ns,data.ns);
-
- PermDAO.Data perm = new PermDAO.Data();
- perm.ns = data.ns;
- perm.type = "Perm";
- perm.instance = "perm1";
- perm.action = "write";
-
- // ADD Perm
- Result<Void> rdar = rd.addPerm(trans, data, perm);
- assertTrue(rdar.isOK());
- rdrr = rd.read(trans, data);
- assertTrue(rdrr.isOKhasData());
- assertEquals(rdrr.value.size(),1);
- assertEquals(rdrr.value.get(0).perms.size(),1);
- assertTrue(rdrr.value.get(0).perms.contains(perm.encode()));
-
- // DEL Perm
- rdar = rd.delPerm(trans, data,perm);
- assertTrue(rdar.isOK());
- rdrr = rd.read(trans, data);
- assertTrue(rdrr.isOKhasData());
- assertEquals(rdrr.value.size(),1);
- assertEquals(rdrr.value.get(0).perms.size(),0);
-
- // Add Child
- Data data2 = new Data();
- data2.ns = data.ns;
- data2.name = data.name + ".2";
-
- rdc = rd.create(trans, data2);
- assertTrue(rdc.isOK());
- try {
- rdrr = rd.readChildren(trans, data.ns,data.name);
- assertTrue(rdrr.isOKhasData());
- assertEquals(rdrr.value.size(),1);
- assertEquals(rdrr.value.get(0).name,data.name + ".2");
-
- rdrr = rd.readChildren(trans, data.ns,"*");
- assertTrue(rdrr.isOKhasData());
- assertEquals(rdrr.value.size(),2);
-
- } finally {
- // Delete Child
- rd.delete(trans, data2, true);
- }
-
- } finally {
- // DELETE
- Result<Void> rddr = rd.delete(trans, data, true);
- assertTrue(rddr.isOK());
- rdrr = rd.read(trans, data);
- assertTrue(rdrr.isOK() && rdrr.isEmpty());
- assertEquals(rdrr.value.size(),0);
- }
- } finally {
- rd.close(trans);
- }
- }
-
- private void compare(Data a, Data b) {
- assertEquals(a.name,b.name);
- assertEquals(a.description, b.description);
- assertEquals(a.ns,b.ns);
- assertEquals(a.perms(false).size(),b.perms(false).size());
- for(String p : a.perms(false)) {
- assertTrue(b.perms(false).contains(p));
- }
- }
-
-}
diff --git a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/NS_ChildUpdate.java b/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/NS_ChildUpdate.java
deleted file mode 100644
index 379eb5e4..00000000
--- a/authz-cass/src/test/java/org/onap/aaf/dao/aaf/test/NS_ChildUpdate.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.dao.aaf.test;
-
-import org.onap.aaf.authz.env.AuthzEnv;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
-import com.datastax.driver.core.Session;
-
-public class NS_ChildUpdate {
-
- public static void main(String[] args) {
- if(args.length < 3 ) {
- System.out.println("usage: NS_ChildUpdate machine mechid (encrypted)passwd");
- } else {
- try {
- AuthzEnv env = new AuthzEnv();
- env.setLog4JNames("log.properties","authz","authz","audit","init","trace");
-
- Cluster cluster = Cluster.builder()
- .addContactPoint(args[0])
- .withCredentials(args[1],env.decrypt(args[2], false))
- .build();
-
- Session session = cluster.connect("authz");
- try {
- ResultSet result = session.execute("SELECT name,parent FROM ns");
- int count = 0;
- for(Row r : result.all()) {
- ++count;
- String name = r.getString(0);
- String parent = r.getString(1);
- if(parent==null) {
- int idx = name.lastIndexOf('.');
-
- parent = idx>0?name.substring(0, idx):".";
- System.out.println("UPDATE " + name + " to " + parent);
- session.execute("UPDATE ns SET parent='" + parent + "' WHERE name='" + name + "';");
- }
- }
- System.out.println("Processed " + count + " records");
- } finally {
- session.close();
- cluster.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
-}
diff --git a/authz-cass/src/test/resources/cadi.properties b/authz-cass/src/test/resources/cadi.properties
deleted file mode 100644
index 8f1209a9..00000000
--- a/authz-cass/src/test/resources/cadi.properties
+++ /dev/null
@@ -1,52 +0,0 @@
-#-------------------------------------------------------------------------------
-# ============LICENSE_START====================================================
-# * org.onap.aaf
-# * ===========================================================================
-# * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# * ===========================================================================
-# * Licensed under the Apache License, Version 2.0 (the "License");
-# * you may not use this file except in compliance with the License.
-# * You may obtain a copy of the License at
-# *
-# * http://www.apache.org/licenses/LICENSE-2.0
-# *
-# * Unless required by applicable law or agreed to in writing, software
-# * distributed under the License is distributed on an "AS IS" BASIS,
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# * See the License for the specific language governing permissions and
-# * limitations under the License.
-# * ============LICENSE_END====================================================
-# *
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# *
-#-------------------------------------------------------------------------------
-###############################################################################
-# Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.
-###############################################################################
-##
-## AUTHZ API (authz-service) Properties
-##
-
-cadi_prop_file=com.att.aaf.props;com.att.aaf.common.props
-
-#cadi_trust_all_x509=true
-#cadi_alias=aaf.att
-https.protocols=TLSv1.1,TLSv1.2
-
-cm_url=https://XXX:8150
-
-basic_realm=localized
-basic_warn=false
-localhost_deny=false
-
-cass_group_name=com.att.aaf
-cass_cluster_name=mithrilcsp.sbc.com
-aaf_default_realm=com.att.csp
-
-aaf_url=https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=2.0/envContext=DEV/routeOffer=BAU_SE
-aaf_id=???
-aaf_password=enc:XXX
-
-aaf_user_expires=3000
-aaf_clean_interval=4000
-