Update aaf client module
[aaf/authz.git] / authz-cass / src / test / java / com / att / dao / aaf / test / JU_Bytification.java
diff --git a/authz-cass/src/test/java/com/att/dao/aaf/test/JU_Bytification.java b/authz-cass/src/test/java/com/att/dao/aaf/test/JU_Bytification.java
deleted file mode 100644 (file)
index 76f9077..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- *  *      http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- *  * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package com.att.dao.aaf.test;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import java.io.IOException;\r
-import java.nio.ByteBuffer;\r
-import java.util.Date;\r
-\r
-import org.junit.Test;\r
-\r
-import com.att.dao.aaf.cass.CredDAO;\r
-import com.att.dao.aaf.cass.NsDAO;\r
-import com.att.dao.aaf.cass.NsType;\r
-import com.att.dao.aaf.cass.PermDAO;\r
-import com.att.dao.aaf.cass.RoleDAO;\r
-import com.att.dao.aaf.cass.UserRoleDAO;\r
-\r
-public class JU_Bytification {\r
-\r
-       @Test\r
-       public void testNS() throws IOException {\r
-               \r
-               // Normal\r
-               NsDAO.Data ns = new NsDAO.Data();\r
-               ns.name = "com.att.<pass>";\r
-               ns.type = NsType.APP.type;\r
-\r
-               ByteBuffer bb = ns.bytify();\r
-               \r
-               NsDAO.Data nsr = new NsDAO.Data();\r
-               nsr.reconstitute(bb);\r
-               check(ns,nsr);\r
-               \r
-               // Empty admin\r
-//             ns.admin(true).clear();\r
-               bb = ns.bytify();\r
-               nsr = new NsDAO.Data();\r
-               nsr.reconstitute(bb);\r
-               check(ns,nsr);\r
-               \r
-               // Empty responsible\r
-//             ns.responsible(true).clear();\r
-               bb = ns.bytify();\r
-               nsr = new NsDAO.Data();\r
-               nsr.reconstitute(bb);\r
-               check(ns,nsr);\r
-\r
-               bb = ns.bytify();\r
-               nsr = new NsDAO.Data();\r
-               nsr.reconstitute(bb);\r
-               check(ns,nsr);\r
-       }\r
-       \r
-       private void check(NsDAO.Data a, NsDAO.Data b) {\r
-               assertEquals(a.name,b.name);\r
-               assertEquals(a.type,b.type);\r
-//             assertEquals(a.admin.size(),b.admin.size());\r
-               \r
-//             for(String s: a.admin) {\r
-//                     assertTrue(b.admin.contains(s));\r
-//             }\r
-//             \r
-//             assertEquals(a.responsible.size(),b.responsible.size());\r
-//             for(String s: a.responsible) {\r
-//                     assertTrue(b.responsible.contains(s));\r
-//             }\r
-       }\r
-\r
-       @Test\r
-       public void testRole() throws IOException {\r
-               RoleDAO.Data rd1 = new RoleDAO.Data();\r
-               rd1.ns = "com.att.<pass>";\r
-               rd1.name = "my.role";\r
-               rd1.perms(true).add("com.att.<pass>.my.Perm|myInstance|myAction");\r
-               rd1.perms(true).add("com.att.<pass>.my.Perm|myInstance|myAction2");\r
-\r
-               // Normal\r
-               ByteBuffer bb = rd1.bytify();\r
-               RoleDAO.Data rd2 = new RoleDAO.Data();\r
-               rd2.reconstitute(bb);\r
-               check(rd1,rd2);\r
-               \r
-               // Overshoot Buffer\r
-               StringBuilder sb = new StringBuilder(300);\r
-               sb.append("role|instance|veryLongAction...");\r
-               for(int i=0;i<280;++i) {\r
-                       sb.append('a');\r
-               }\r
-               rd1.perms(true).add(sb.toString());\r
-               bb = rd1.bytify();\r
-               rd2 = new RoleDAO.Data();\r
-               rd2.reconstitute(bb);\r
-               check(rd1,rd2);\r
-               \r
-               // No Perms\r
-               rd1.perms.clear();\r
-               \r
-               bb = rd1.bytify();\r
-               rd2 = new RoleDAO.Data();\r
-               rd2.reconstitute(bb);\r
-               check(rd1,rd2);\r
-               \r
-               // 1000 Perms\r
-               for(int i=0;i<1000;++i) {\r
-                       rd1.perms(true).add("com|inst|action"+ i);\r
-               }\r
-\r
-               bb = rd1.bytify();\r
-               rd2 = new RoleDAO.Data();\r
-               rd2.reconstitute(bb);\r
-               check(rd1,rd2);\r
-\r
-       }\r
-       \r
-       private void check(RoleDAO.Data a, RoleDAO.Data b) {\r
-               assertEquals(a.ns,b.ns);\r
-               assertEquals(a.name,b.name);\r
-               \r
-               assertEquals(a.perms.size(),b.perms.size());\r
-               for(String s: a.perms) {\r
-                       assertTrue(b.perms.contains(s));\r
-               }\r
-       }\r
-\r
-       @Test\r
-       public void testPerm() throws IOException {\r
-               PermDAO.Data pd1 = new PermDAO.Data();\r
-               pd1.ns = "com.att.<pass>";\r
-               pd1.type = "my.perm";\r
-               pd1.instance = "instance";\r
-               pd1.action = "read";\r
-               pd1.roles(true).add("com.att.<pass>.my.Role");\r
-               pd1.roles(true).add("com.att.<pass>.my.Role2");\r
-\r
-               // Normal\r
-               ByteBuffer bb = pd1.bytify();\r
-               PermDAO.Data rd2 = new PermDAO.Data();\r
-               rd2.reconstitute(bb);\r
-               check(pd1,rd2);\r
-               \r
-               // No Perms\r
-               pd1.roles.clear();\r
-               \r
-               bb = pd1.bytify();\r
-               rd2 = new PermDAO.Data();\r
-               rd2.reconstitute(bb);\r
-               check(pd1,rd2);\r
-               \r
-               // 1000 Perms\r
-               for(int i=0;i<1000;++i) {\r
-                       pd1.roles(true).add("com.att.<pass>.my.Role"+ i);\r
-               }\r
-\r
-               bb = pd1.bytify();\r
-               rd2 = new PermDAO.Data();\r
-               rd2.reconstitute(bb);\r
-               check(pd1,rd2);\r
-\r
-       }\r
-       \r
-       private void check(PermDAO.Data a, PermDAO.Data b) {\r
-               assertEquals(a.ns,b.ns);\r
-               assertEquals(a.type,b.type);\r
-               assertEquals(a.instance,b.instance);\r
-               assertEquals(a.action,b.action);\r
-               \r
-               assertEquals(a.roles.size(),b.roles.size());\r
-               for(String s: a.roles) {\r
-                       assertTrue(b.roles.contains(s));\r
-               }\r
-       }\r
-\r
-       @Test\r
-       public void testUserRole() throws IOException {\r
-               UserRoleDAO.Data urd1 = new UserRoleDAO.Data();\r
-               urd1.user = "myname@abc.att.com";\r
-               urd1.role("com.att.<pass>","my.role");\r
-               urd1.expires = new Date();\r
-\r
-               // Normal\r
-               ByteBuffer bb = urd1.bytify();\r
-               UserRoleDAO.Data urd2 = new UserRoleDAO.Data();\r
-               urd2.reconstitute(bb);\r
-               check(urd1,urd2);\r
-               \r
-               // A null\r
-               urd1.expires = null; \r
-               urd1.role = null;\r
-               \r
-               bb = urd1.bytify();\r
-               urd2 = new UserRoleDAO.Data();\r
-               urd2.reconstitute(bb);\r
-               check(urd1,urd2);\r
-       }\r
-\r
-       private void check(UserRoleDAO.Data a, UserRoleDAO.Data b) {\r
-               assertEquals(a.user,b.user);\r
-               assertEquals(a.role,b.role);\r
-               assertEquals(a.expires,b.expires);\r
-       }\r
-\r
-       \r
-       @Test\r
-       public void testCred() throws IOException {\r
-               CredDAO.Data cd = new CredDAO.Data();\r
-               cd.id = "m55555@abc.att.com";\r
-               cd.ns = "com.att.abc";\r
-               cd.type = 2;\r
-               cd.cred = ByteBuffer.wrap(new byte[]{1,34,5,3,25,0,2,5,3,4});\r
-               cd.expires = new Date();\r
-\r
-               // Normal\r
-               ByteBuffer bb = cd.bytify();\r
-               CredDAO.Data cd2 = new CredDAO.Data();\r
-               cd2.reconstitute(bb);\r
-               check(cd,cd2);\r
-               \r
-               // nulls\r
-               cd.expires = null;\r
-               cd.cred = null;\r
-               \r
-               bb = cd.bytify();\r
-               cd2 = new CredDAO.Data();\r
-               cd2.reconstitute(bb);\r
-               check(cd,cd2);\r
-\r
-       }\r
-\r
-       private void check(CredDAO.Data a, CredDAO.Data b) {\r
-               assertEquals(a.id,b.id);\r
-               assertEquals(a.ns,b.ns);\r
-               assertEquals(a.type,b.type);\r
-               if(a.cred==null) {\r
-                       assertEquals(a.cred,b.cred); \r
-               } else {\r
-                       int l = a.cred.limit();\r
-                       assertEquals(l,b.cred.limit());\r
-                       for (int i=0;i<l;++i) {\r
-                               assertEquals(a.cred.get(),b.cred.get());\r
-                       }\r
-               }\r
-       }\r
-\r
-}\r