summaryrefslogtreecommitdiffstats
path: root/auth/auth-cass
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-cass')
-rw-r--r--auth/auth-cass/pom.xml2
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/.gitignore5
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/AbsJUCass.java200
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_ApprovalDAO.java153
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_ArtiDAO.java137
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_Bytification.java266
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CacheInfoDAO.java64
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CertDAO.java103
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CredDAO.java250
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_DelegateDAO.java108
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_FastCalling.java90
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_HistoryDAO.java153
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_LocateDAO.java146
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_LocationContent.java93
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_NsDAO.java187
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_NsType.java58
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_OAuthTokenDAO.java134
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_PermDAO.java176
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_RoleDAO.java138
-rw-r--r--auth/auth-cass/src/test/java/com/att/dao/aaf/test/NS_ChildUpdate.java74
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/cass/hl/JU_Question.java509
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/cass/hl/JU_Question2.java73
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_ApprovalDAO.java146
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_ArtiDAO.java136
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CacheInfoDAO.java63
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CertDAO.java103
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CredDAO.java250
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_DelegateDAO.java106
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_FastCalling.java89
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_HistoryDAO.java153
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsDAO.java185
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_PermDAO.java174
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_RoleDAO.java137
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java63
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFUserPass.java84
35 files changed, 1 insertions, 4807 deletions
diff --git a/auth/auth-cass/pom.xml b/auth/auth-cass/pom.xml
index 429a1220..41540887 100644
--- a/auth/auth-cass/pom.xml
+++ b/auth/auth-cass/pom.xml
@@ -71,7 +71,7 @@
</developers>
<properties>
- <skipTests>true</skipTests>
+
<!-- SONAR -->
diff --git a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/.gitignore b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/.gitignore
deleted file mode 100644
index 1871693c..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/JU_OAuthAppDAO.java
-/.settings/
-/.project
-/target/
-/.classpath
diff --git a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/AbsJUCass.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/AbsJUCass.java
deleted file mode 100644
index 5b6a08c5..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/AbsJUCass.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.auth.dao.CassAccess;
-import org.onap.aaf.auth.dao.CassDAOImpl;
-import org.onap.aaf.auth.env.AuthzEnv;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.cadi.Hash;
-import org.onap.aaf.cadi.Symm;
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.env.Env;
-import org.onap.aaf.misc.env.Trans.Metric;
-
-import com.datastax.driver.core.Cluster;
-
-import junit.framework.Assert;
-
-/**
- * Do Setup of Cassandra for Cassandra JUnit Testing
- *
- * @author Jonathan
- *
- */
-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 {
- try {
- 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
-
- iterations = 0;
- } catch (Throwable t) {
- t.printStackTrace();
- throw t;
- }
- }
-
- @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.hashMD5(ba.getBytes());
- }
-
-}
diff --git a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_ApprovalDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_ApprovalDAO.java
deleted file mode 100644
index bc860d0a..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_ApprovalDAO.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.dao.aaf.test;
-
-
-import static org.junit.Assert.assertEquals;
-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.auth.dao.cass.ApprovalDAO;
-import org.onap.aaf.auth.dao.cass.ApprovalDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-
-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();
-
- // Note, Create creates the time id
- 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();
- data.memo = "Sing Hey for the break of day";
- data.last_notified = null;
-
- try {
- // Test create
- Result<Data> rc = rrDAO.create(trans, data);
- if(rc.isOKhasData()) { // Create creates the TIMEID.
- data = rc.value;
- }
-
- // 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) {
- assertEquals(d1.id.toString(),d2.id.toString());
- assertEquals(d1.ticket.toString(),d2.ticket.toString());
- 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);
- //assertEquals(d1.updated,d2.updated);
- assertEquals(d1.memo,d2.memo);
- assertEquals(d1.last_notified,d2.last_notified);
- }
-
-
-
-}
diff --git a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_ArtiDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_ArtiDAO.java
deleted file mode 100644
index e104cbe5..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_ArtiDAO.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.auth.dao.CassAccess;
-import org.onap.aaf.auth.dao.cass.ArtiDAO;
-import org.onap.aaf.auth.dao.cass.ArtiDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-
-/**
- * UserDAO unit test.
- * Date: 7/19/13
- */
-public class JU_ArtiDAO extends AbsJUCass {
- @Test
- public void test() throws IOException, NoSuchAlgorithmException {
- ArtiDAO adao = new ArtiDAO(trans,cluster,CassAccess.KEYSPACE);
- try {
- // TODO: Clean out AT&T specific data
- // Create
- ArtiDAO.Data data = new ArtiDAO.Data();
- data.mechid="m553j5@perturbed.onap.org";
- data.machine="perturbed1232.onap.org";
- data.type(false).add("file");
- data.type(false).add("jks");
- data.sponsor="Fred Flintstone";
- data.ca="devl";
- data.dir="/opt/app/aft/keys";
- data.ns="kumquat";
- data.os_user="aft";
- data.notify="email:fred@bogus.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.ns,d.ns);
- assertEquals(data.os_user,d.os_user);
- assertEquals(data.notify,d.notify);
- assertEquals(data.expires,d.expires);
- }
-
-}
diff --git a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_Bytification.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_Bytification.java
deleted file mode 100644
index 206c52a7..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_Bytification.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.auth.dao.cass.CredDAO;
-import org.onap.aaf.auth.dao.cass.NsDAO;
-import org.onap.aaf.auth.dao.cass.NsType;
-import org.onap.aaf.auth.dao.cass.PermDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO;
-import org.onap.aaf.auth.dao.cass.UserRoleDAO;
-
-public class JU_Bytification {
-
- @Test
- public void testNS() throws IOException {
-
- // Normal
- NsDAO.Data ns = new NsDAO.Data();
- ns.name = "org.osaaf.whatever";
- 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 = "org.osaaf.whatever";
- rd1.name = "my.role";
- rd1.perms(true).add("org.osaaf.whatever.my.Perm|myInstance|myAction");
- rd1.perms(true).add("org.osaaf.whatever.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 = "org.osaaf.whatever";
- pd1.type = "my.perm";
- pd1.instance = "instance";
- pd1.action = "read";
- pd1.roles(true).add("org.osaaf.whatever.my.Role");
- pd1.roles(true).add("org.osaaf.whatever.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("org.osaaf.whatever.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();
-// TODO: Clean out AT&T specific data
- urd1.user = "jg1555@abc.att.com";
- urd1.role("org.osaaf.whatever","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 = "org.osaaf.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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CacheInfoDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CacheInfoDAO.java
deleted file mode 100644
index 87b88482..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CacheInfoDAO.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-
-package com.att.dao.aaf.test;
-
-import java.io.IOException;
-import java.util.Date;
-
-import org.junit.Test;
-import org.onap.aaf.auth.dao.CIDAO;
-import org.onap.aaf.auth.dao.DAOException;
-import org.onap.aaf.auth.dao.cass.CacheInfoDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO;
-import org.onap.aaf.auth.dao.cass.Status;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CertDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CertDAO.java
deleted file mode 100644
index cd3fb8d0..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CertDAO.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.auth.dao.CassAccess;
-import org.onap.aaf.auth.dao.cass.CertDAO;
-import org.onap.aaf.auth.dao.cass.CertDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.env.APIException;
-
-/**
- * UserDAO unit test.
- * Date: 7/19/13
- */
-public class JU_CertDAO extends AbsJUCass {
- @Test
- public void test() throws IOException, NoSuchAlgorithmException, APIException {
- CertDAO cdao = new CertDAO(trans,cluster,CassAccess.KEYSPACE);
- 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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CredDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CredDAO.java
deleted file mode 100644
index 3ccc4320..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_CredDAO.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.auth.dao.CassAccess;
-import org.onap.aaf.auth.dao.cass.CredDAO;
-import org.onap.aaf.auth.dao.cass.CredDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.env.APIException;
-
-/**
- * UserDAO unit test.
- * Date: 7/19/13
- */
-public class JU_CredDAO extends AbsJUCass {
- @Test
- public void test() throws IOException, NoSuchAlgorithmException, APIException {
- CredDAO udao = new CredDAO(trans,cluster,CassAccess.KEYSPACE);
- 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,CassAccess.KEYSPACE);
-// 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,CassAccess.KEYSPACE);
-// 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,CassAccess.KEYSPACE);
-//
-// 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,CassAccess.KEYSPACE);
-//
-// 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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_DelegateDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_DelegateDAO.java
deleted file mode 100644
index 1a4d21c4..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_DelegateDAO.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.auth.dao.cass.DelegateDAO;
-import org.onap.aaf.auth.dao.cass.DelegateDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-
-
-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();
-// TODO: Clean out AT&T specific data
- data.user = "jg1555";
- data.delegate = "rd8227";
- 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
- // TODO: Clean out AT&T specific data
- data.delegate = "pf2819";
- 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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_FastCalling.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_FastCalling.java
deleted file mode 100644
index 9d3ff5db..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_FastCalling.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.auth.dao.CassAccess;
-import org.onap.aaf.auth.dao.cass.CredDAO;
-import org.onap.aaf.auth.dao.cass.CredDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.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,CassAccess.KEYSPACE);
- 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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_HistoryDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_HistoryDAO.java
deleted file mode 100644
index 11d88358..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_HistoryDAO.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.security.SecureRandom;
-import java.util.List;
-
-import org.junit.Test;
-import org.onap.aaf.auth.dao.cass.HistoryDAO;
-import org.onap.aaf.auth.layer.Result;
-
-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();
- SecureRandom random = new SecureRandom();
- 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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_LocateDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_LocateDAO.java
deleted file mode 100644
index 283a3563..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_LocateDAO.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.auth.dao.CassAccess;
-import org.onap.aaf.auth.dao.cass.LocateDAO;
-import org.onap.aaf.auth.dao.cass.LocateDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.env.APIException;
-
-/**
- * Test the LocateDAO
- *
- * Utilize AbsJUCass to initialize and pre-load Cass
- *
- * @author Jonathan
- *
- */
-public class JU_LocateDAO extends AbsJUCass{
-
- @Test
- public void test() throws APIException, IOException {
- LocateDAO pd = new LocateDAO(trans,cluster,CassAccess.KEYSPACE);
- try {
- LocateDAO.Data data = new LocateDAO.Data();
- data.name="org.osaaf.aaf.locateTester";
- data.hostname="mithrilcsp.sbc.com";
- data.port=19999;
- data.latitude=32.780140f;
- data.longitude=-96.800451f;
- data.major=2;
- data.minor=0;
- data.patch=19;
- data.pkg=23;
- data.protocol="https";
- Set<String> sp = data.subprotocol(true);
- sp.add("TLS1.1");
- sp.add("TLS1.2");
-
-
-
- // CREATE
- Result<Data> rpdc = pd.create(trans,data);
- assertTrue(rpdc.isOK());
-
- Result<List<LocateDAO.Data>> rlpd;
- try {
-// Bytification
- ByteBuffer bb = data.bytify();
- Data bdata = new LocateDAO.Data();
- bdata.reconstitute(bb);
- compare(data, bdata);
-
- // Validate Read with key fields in Data
- rlpd = pd.read(trans,data);
- assertTrue(rlpd.isOK());
- if(rlpd.isOK()) {
- for(LocateDAO.Data d : rlpd.value) {
- compare(data,d);
- }
- }
-
- // Validate Read by Name
- rlpd = pd.readByName(trans,data.name);
- assertTrue(rlpd.isOK());
- if(rlpd.isOK()) {
- for(LocateDAO.Data d : rlpd.value) {
- compare(data,d);
- }
- }
-
- // Modify
- data.latitude = -31.0000f;
-
- Result<Void> rupd = pd.update(trans, data);
- assertTrue(rupd.isOK());
- rlpd = pd.read(trans,data);
- assertTrue(rlpd.isOK());
- if(rlpd.isOK()) {
- for(LocateDAO.Data d : rlpd.value) {
- compare(data,d);
- }
- }
-
- } 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.name,b.name);
- assertEquals(a.hostname,b.hostname);
- assertEquals(a.port,b.port);
- assertEquals(a.major,b.major);
- assertEquals(a.minor,b.minor);
- assertEquals(a.patch,b.patch);
- assertEquals(a.pkg,b.pkg);
- assertEquals(a.latitude,b.latitude);
- assertEquals(a.longitude,b.longitude);
- assertEquals(a.protocol,b.protocol);
- Set<String> spa = a.subprotocol(false);
- Set<String> spb = b.subprotocol(false);
- assertEquals(spa.size(),spb.size());
- for(String s : spa) {
- assertTrue(spb.contains(s));
- }
- }
-}
diff --git a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_LocationContent.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_LocationContent.java
deleted file mode 100644
index 39f096c1..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_LocationContent.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.dao.aaf.test;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.aaf.cadi.PropAccess;
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.env.Data;
-import org.onap.aaf.misc.env.Data.TYPE;
-import org.onap.aaf.misc.rosetta.env.RosettaDF;
-import org.onap.aaf.misc.rosetta.env.RosettaEnv;
-
-import locate.v1_0.MgmtEndpoint;
-import locate.v1_0.MgmtEndpoint.SpecialPorts;
-import locate.v1_0.MgmtEndpoints;
-
-public class JU_LocationContent {
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void test() {
- PropAccess access = new PropAccess();
- RosettaEnv env = new RosettaEnv(access.getProperties());
- try {
- RosettaDF<MgmtEndpoints> medf = env.newDataFactory(MgmtEndpoints.class);
- medf.out(TYPE.JSON);
- medf.option(Data.PRETTY);
- MgmtEndpoint me = new MgmtEndpoint();
- me.setHostname("mithrilcsp.sbc.com");
- me.setLatitude(32);
- me.setLongitude(-90);
- me.setMajor(2);
- me.setMinor(0);
- me.setPatch(19);
- me.setPort(3312);
- me.setProtocol("http");
- me.getSubprotocol().add("TLS1.1");
-
- SpecialPorts sp = new SpecialPorts();
- sp.setName("debug");
- sp.setPort(9000);
- sp.setProtocol("java");
- me.getSpecialPorts().add(sp);
-
- MgmtEndpoints mes = new MgmtEndpoints();
- mes.getMgmtEndpoint().add(me);
- System.out.println(medf.newData().load(mes).asString());
-
- } catch (APIException e) {
- e.printStackTrace();
- }
-
- }
-
-}
diff --git a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_NsDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_NsDAO.java
deleted file mode 100644
index 5b313419..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_NsDAO.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.auth.dao.cass.NsDAO;
-import org.onap.aaf.auth.dao.cass.NsType;
-import org.onap.aaf.auth.dao.cass.NsDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.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.parent = nsparent;
- 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
- data2.parent = nsparent;
- 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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_NsType.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_NsType.java
deleted file mode 100644
index 2644fedd..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_NsType.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.dao.aaf.test;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.AfterClass;
-import org.junit.Test;
-import org.onap.aaf.auth.dao.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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_OAuthTokenDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_OAuthTokenDAO.java
deleted file mode 100644
index f3f91d00..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_OAuthTokenDAO.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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 java.util.UUID;
-
-import org.junit.Test;
-import org.onap.aaf.auth.dao.CassAccess;
-import org.onap.aaf.auth.dao.cass.OAuthTokenDAO;
-import org.onap.aaf.auth.dao.cass.OAuthTokenDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.cadi.oauth.AAFToken;
-
-/**
- * UserDAO unit test.
- * Date: 7/19/13
- */
-public class JU_OAuthTokenDAO extends AbsJUCass {
- @Test
- public void test() throws IOException, NoSuchAlgorithmException {
- OAuthTokenDAO adao = new OAuthTokenDAO(trans,cluster,CassAccess.KEYSPACE);
- UUID uuid = UUID.randomUUID();
- try {
- // Create
- Data data = new OAuthTokenDAO.Data();
- data.id=AAFToken.toToken(uuid);
- data.client_id="zClient";
- data.user = "xy1255@csp.att.com";
- data.active = true;
- data.type=1;
- data.refresh = AAFToken.toToken(UUID.randomUUID());
- data.expires=new Date();
- data.scopes(false).add("org.osaaf.aaf");
- data.scopes(false).add("org.osaaf.grid");
- data.content="{darth:\"I am your content\"}";
- data.req_ip="::1";
-
-// Bytification
- ByteBuffer bb = data.bytify();
- Data bdata = new OAuthTokenDAO.Data();
-// System.out.println(new String(Symm.base64noSplit.encode(bb.array())));
- bdata.reconstitute(bb);
- checkData1(data, bdata);
-
-// DB work
- adao.create(trans,data);
- try {
- // Validate Read with Data Object
- Result<List<OAuthTokenDAO.Data>> rlcd = adao.read(trans,data);
- assertTrue(rlcd.isOKhasData());
- for(OAuthTokenDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
- // Validate Read with key fields in Data
- rlcd = adao.read(trans,data.id);
- assertTrue(rlcd.isOKhasData());
- for(OAuthTokenDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- // Validate Read by User
- rlcd = adao.readByUser(trans,data.user);
- assertTrue(rlcd.isOKhasData());
- for(OAuthTokenDAO.Data d : rlcd.value) {
- checkData1(data,d);
- }
-
- // Update
- data.content = "{darth:\"I am your content\", luke:\"Noooooooo!\"}";
- data.active = false;
- adao.update(trans,data);
- rlcd = adao.read(trans,data);
- assertTrue(rlcd.isOKhasData());
- for(OAuthTokenDAO.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.id,d.id);
- assertEquals(data.client_id,d.client_id);
- assertEquals(data.user,d.user);
- assertEquals(data.active,d.active);
- assertEquals(data.type,d.type);
- assertEquals(data.refresh,d.refresh);
- assertEquals(data.expires,d.expires);
- for(String s: data.scopes(false)) {
- assertTrue(d.scopes(false).contains(s));
- }
- for(String s: d.scopes(false)) {
- assertTrue(data.scopes(false).contains(s));
- }
- assertEquals(data.content,d.content);
- assertEquals(data.state,d.state);
- assertEquals(data.req_ip,d.req_ip);
- }
-
-}
diff --git a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_PermDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_PermDAO.java
deleted file mode 100644
index 0a506db1..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_PermDAO.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.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.auth.dao.CassAccess;
-import org.onap.aaf.auth.dao.cass.PermDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO;
-import org.onap.aaf.auth.dao.cass.PermDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.env.APIException;
-
-/**
- * Test the PermissionDAO
- *
- * Utilize AbsJUCass to initialize and pre-load Cass
- *
- * @author Jonathan
- *
- */
-public class JU_PermDAO extends AbsJUCass{
-
- @Test
- public void test() throws APIException, IOException {
- PermDAO pd = new PermDAO(trans,cluster,CassAccess.KEYSPACE);
- 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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_RoleDAO.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_RoleDAO.java
deleted file mode 100644
index 56875bdd..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/JU_RoleDAO.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-
-package com.att.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.auth.dao.cass.PermDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.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/auth/auth-cass/src/test/java/com/att/dao/aaf/test/NS_ChildUpdate.java b/auth/auth-cass/src/test/java/com/att/dao/aaf/test/NS_ChildUpdate.java
deleted file mode 100644
index 8e2f78b6..00000000
--- a/auth/auth-cass/src/test/java/com/att/dao/aaf/test/NS_ChildUpdate.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package com.att.dao.aaf.test;
-
-import org.onap.aaf.auth.dao.CassAccess;
-import org.onap.aaf.auth.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(CassAccess.KEYSPACE);
- 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/auth/auth-cass/src/test/java/org/onap/aaf/auth/cass/hl/JU_Question.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/cass/hl/JU_Question.java
deleted file mode 100644
index e06a8c57..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/cass/hl/JU_Question.java
+++ /dev/null
@@ -1,509 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.cass.hl;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
-
-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.auth.dao.cass.NsDAO;
-import org.onap.aaf.auth.dao.cass.PermDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO;
-import org.onap.aaf.auth.dao.cass.UserRoleDAO;
-import org.onap.aaf.auth.dao.cass.NsDAO.Data;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.dao.hl.Question.Access;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.cadi.principal.TaggedPrincipal;
-import org.onap.aaf.misc.env.Env;
-import org.onap.aaf.misc.env.TimeTaken;
-
-import com.att.dao.aaf.test.AbsJUCass;
-
-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 TaggedPrincipal() {
- @Override
- public String getName() {
- return JU9999_JU_TEST_COM;
- }
-
- @Override
- public String tag() {
- return "JUnit";
- }
-
- @Override
- public String personalName() {
- return JU9998_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/auth/auth-cass/src/test/java/org/onap/aaf/auth/cass/hl/JU_Question2.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/cass/hl/JU_Question2.java
deleted file mode 100644
index bfb6fd4e..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/cass/hl/JU_Question2.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package org.onap.aaf.auth.cass.hl;
-
-import java.io.IOException;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.aaf.auth.dao.hl.Question;
-
-public class JU_Question2 {
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void test() throws IOException {
- String s,u;
- System.out.println((s="com") + '=' + (u=Question.toUnique(s)));
- System.out.println(u+'='+(Question.fromUnique(u)));
- System.out.println((s="org.osaaf.cdp.Tenant32_what-a-joy") + '=' + (u=Question.toUnique(s)));
- System.out.println(u+'='+(Question.fromUnique(u)));
- System.out.println((s="org.osaaf.cdp") + '=' + (u=Question.toUnique(s)));
- System.out.println(u+'='+(Question.fromUnique(u)));
-
-// Assert.assertSame(s="com", Question.toUnique(s));
-// Assert.assertSame(s="", Question.toUnique(s));
-// Assert.assertSame(s="com.aa", Question.toUnique(s));
-// Assert.assertNotSame(s="com.Aa", Question.toUnique(s));
-// Assert.assertEquals("com.aa", Question.toUnique(s));
-// Assert.assertNotSame(s="com.Aa.1", Question.toUnique(s));
-// Assert.assertEquals("com.aa.1", Question.toUnique(s));
-// Assert.assertNotSame(s="com.Aa.1-3", Question.toUnique(s));
-// Assert.assertEquals("com.aa.13", Question.toUnique(s));
-// Assert.assertEquals("com.aa.13", Question.toUnique("com.aA.1_3"));
- }
-
-}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_ApprovalDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_ApprovalDAO.java
deleted file mode 100644
index 13a13edf..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_ApprovalDAO.java
+++ /dev/null
@@ -1,146 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.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.auth.dao.cass.ApprovalDAO;
-import org.onap.aaf.auth.dao.cass.ApprovalDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-
-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/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_ArtiDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_ArtiDAO.java
deleted file mode 100644
index f095e32f..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_ArtiDAO.java
+++ /dev/null
@@ -1,136 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.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.auth.dao.cass.ArtiDAO;
-import org.onap.aaf.auth.dao.cass.ArtiDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-
-/**
- * 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.ns="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.ns,d.ns);
- assertEquals(data.os_user,d.os_user);
- assertEquals(data.notify,d.notify);
- assertEquals(data.expires,d.expires);
- }
-
-}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CacheInfoDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CacheInfoDAO.java
deleted file mode 100644
index 7a1bd58c..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CacheInfoDAO.java
+++ /dev/null
@@ -1,63 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.dao.aaf.test;
-
-import java.io.IOException;
-import java.util.Date;
-
-import org.junit.Test;
-import org.onap.aaf.auth.dao.CIDAO;
-import org.onap.aaf.auth.dao.DAOException;
-import org.onap.aaf.auth.dao.cass.CacheInfoDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO;
-import org.onap.aaf.auth.dao.cass.Status;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.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/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CertDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CertDAO.java
deleted file mode 100644
index 8e8ed6ea..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CertDAO.java
+++ /dev/null
@@ -1,103 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.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.auth.dao.cass.CertDAO;
-import org.onap.aaf.auth.dao.cass.CertDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.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/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CredDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CredDAO.java
deleted file mode 100644
index bb88a2aa..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_CredDAO.java
+++ /dev/null
@@ -1,250 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.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.auth.dao.cass.CredDAO;
-import org.onap.aaf.auth.dao.cass.CredDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.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/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_DelegateDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_DelegateDAO.java
deleted file mode 100644
index a518e509..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_DelegateDAO.java
+++ /dev/null
@@ -1,106 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.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.auth.dao.cass.DelegateDAO;
-import org.onap.aaf.auth.dao.cass.DelegateDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-
-
-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/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_FastCalling.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_FastCalling.java
deleted file mode 100644
index d7886d3c..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_FastCalling.java
+++ /dev/null
@@ -1,89 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.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.auth.dao.cass.CredDAO;
-import org.onap.aaf.auth.dao.cass.CredDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.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/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_HistoryDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_HistoryDAO.java
deleted file mode 100644
index 0b552a49..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_HistoryDAO.java
+++ /dev/null
@@ -1,153 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.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.auth.dao.cass.HistoryDAO;
-import org.onap.aaf.auth.layer.Result;
-
-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/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsDAO.java
deleted file mode 100644
index eb064959..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsDAO.java
+++ /dev/null
@@ -1,185 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.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.auth.dao.cass.NsDAO;
-import org.onap.aaf.auth.dao.cass.NsType;
-import org.onap.aaf.auth.dao.cass.NsDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.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/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_PermDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_PermDAO.java
deleted file mode 100644
index 1a407af7..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_PermDAO.java
+++ /dev/null
@@ -1,174 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.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.auth.dao.cass.PermDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO;
-import org.onap.aaf.auth.dao.cass.PermDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.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/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_RoleDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_RoleDAO.java
deleted file mode 100644
index fda818fc..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_RoleDAO.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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.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.auth.dao.cass.PermDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO.Data;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.misc.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/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java
deleted file mode 100644
index 79d30c4c..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java
+++ /dev/null
@@ -1,63 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.direct.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.security.Principal;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.direct.DirectAAFLur;
-import org.onap.aaf.auth.env.AuthzEnv;
-import org.onap.aaf.cadi.Permission;
-import org.powermock.modules.junit4.PowerMockRunner;
-@RunWith(PowerMockRunner.class)
-public class JU_DirectAAFLur {
-
-public static AuthzEnv env;
-public static Question question;
-public DirectAAFLur directAAFLur;
-
-
-
- @Before
- public void setUp()
- {
- directAAFLur = new DirectAAFLur(env, question);
- }
-
- @Test
- public void testFish()
- {
-
- Principal bait = null;
- Permission pond=null;
- directAAFLur.fish(bait, pond);
-
- assertTrue(true);
-
- }
-
-}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFUserPass.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFUserPass.java
deleted file mode 100644
index 6a25d991..00000000
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFUserPass.java
+++ /dev/null
@@ -1,84 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.direct.test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.*;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.direct.DirectAAFUserPass;
-import org.onap.aaf.auth.env.AuthzEnv;
-import org.onap.aaf.cadi.CredVal.Type;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-@RunWith(PowerMockRunner.class)
-public class JU_DirectAAFUserPass {
-
- // TODO: Ian - This test is in shambles. fix it
-
- //public static AuthzEnv env;
- //public static Question question;
- public DirectAAFUserPass directAAFUserPass;
-
- @Mock
- AuthzEnv env;
-
- @Mock
- Question question;
-
- String user;
-
- Type type;
-
- byte[] pass;
-
- @Before
- public void setUp() {
- directAAFUserPass = new DirectAAFUserPass(env, question);
- }
-
- @Test
- public void testvalidate(){
-
- // Boolean bolVal = directAAFUserPass.validate(user, type, pass);
- // assertEquals((bolVal==null),true);
-
- assertTrue(true);
-
- }
-
- @Test
- public void notYetTested() {
- fail("Tests not yet implemented");
- }
-
-}