summaryrefslogtreecommitdiffstats
path: root/auth/auth-cass/src/test/java
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-09-07 12:21:34 -0500
committerInstrumental <jonathan.gathman@att.com>2018-09-07 12:22:50 -0500
commit4b5a7d721d994a49057e9bfb403c7bff1b376660 (patch)
treea36d03227b63a3e60346d6c3ca87b061087dae85 /auth/auth-cass/src/test/java
parent824dc7b5fc0e1ccdf7f460479aff344727f0f01e (diff)
Mass removal of all Tabs (Style Warnings)
Issue-ID: AAF-473 Change-Id: Iaf0ef8120882937959bb0065f2f6ba74a021940f Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-cass/src/test/java')
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java164
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CachedDAO.java44
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassAccess.java52
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassDAOImpl.java56
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_DAOException.java22
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/AbsJUCass.java278
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_Bytification.java412
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsType.java48
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectCertIdentity.java52
9 files changed, 564 insertions, 564 deletions
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java
index 31a93723..47723e6b 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java
@@ -50,91 +50,91 @@ import org.onap.aaf.misc.env.Trans;
// @RunWith(PowerMockRunner.class)
public class JU_Cached {
- @Mock
- CIDAO<Trans> ciDaoMock;
+ @Mock
+ CIDAO<Trans> ciDaoMock;
- @Mock
- AuthzEnv authzEnvMock;
+ @Mock
+ AuthzEnv authzEnvMock;
- @Mock
- CIDAO<AuthzTrans> cidaoATMock;
-
- String name = "nameString";
+ @Mock
+ CIDAO<AuthzTrans> cidaoATMock;
+
+ String name = "nameString";
- @Before
- public void setUp(){
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testCachedIdx(){
- Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 1, 30000L);
- assertThat(cached.cacheIdx("1234567890"), is(0));
- }
-
- @Test
- public void testInvalidate(){
- Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 5, 30000L);
- cached.add("test", new ArrayList<>());
- cached.invalidate("test");
- cached.invalidate("test1");
- }
-
- @SuppressWarnings("static-access")
- @Test
- public void testStopTimer(){
- Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 1, 30000L);
- cached.stopTimer();
- assertTrue(true);
- }
+ @Before
+ public void setUp(){
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testCachedIdx(){
+ Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 1, 30000L);
+ assertThat(cached.cacheIdx("1234567890"), is(0));
+ }
+
+ @Test
+ public void testInvalidate(){
+ Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 5, 30000L);
+ cached.add("test", new ArrayList<>());
+ cached.invalidate("test");
+ cached.invalidate("test1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void testStopTimer(){
+ Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 1, 30000L);
+ cached.stopTimer();
+ assertTrue(true);
+ }
- @SuppressWarnings("static-access")
- @Test
- public void testStartRefresh(){
- Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 1, 30000L);
- cached.startRefresh(authzEnvMock, cidaoATMock);
- assertTrue(true);
- }
-// @Mock
-// Trans transMock;
-// @Mock
-// Getter<DAO> getterMock;
-//
-// @Test
-// public void testGet(){
-// cached.get(transMock, name, getterMock);
-// fail("not implemented");
-// }
-//
-// @SuppressWarnings("unchecked")
-// public Result<List<DATA>> get(TRANS trans, String key, Getter<DATA> getter) {
-// List<DATA> ld = null;
-// Result<List<DATA>> rld = null;
-//
-// int cacheIdx = cacheIdx(key);
-// Map<String, Dated> map = ((Map<String,Dated>)cache[cacheIdx]);
-//
-// // Check for saved element in cache
-// Dated cached = map.get(key);
-// // Note: These Segment Timestamps are kept up to date with DB
-// Date dbStamp = info.get(trans, name,cacheIdx);
-//
-// // Check for cache Entry and whether it is still good (a good Cache Entry is same or after DBEntry, so we use "before" syntax)
-// if(cached!=null && dbStamp.before(cached.timestamp)) {
-// ld = (List<DATA>)cached.data;
-// rld = Result.ok(ld);
-// } else {
-// rld = getter.get();
-// if(rld.isOK()) { // only store valid lists
-// map.put(key, new Dated(rld.value)); // successful item found gets put in cache
-//// } else if(rld.status == Result.ERR_Backend){
-//// map.remove(key);
-// }
-// }
-// return rld;
-// }
+ @SuppressWarnings("static-access")
+ @Test
+ public void testStartRefresh(){
+ Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 1, 30000L);
+ cached.startRefresh(authzEnvMock, cidaoATMock);
+ assertTrue(true);
+ }
+// @Mock
+// Trans transMock;
+// @Mock
+// Getter<DAO> getterMock;
+//
+// @Test
+// public void testGet(){
+// cached.get(transMock, name, getterMock);
+// fail("not implemented");
+// }
+//
+// @SuppressWarnings("unchecked")
+// public Result<List<DATA>> get(TRANS trans, String key, Getter<DATA> getter) {
+// List<DATA> ld = null;
+// Result<List<DATA>> rld = null;
+//
+// int cacheIdx = cacheIdx(key);
+// Map<String, Dated> map = ((Map<String,Dated>)cache[cacheIdx]);
+//
+// // Check for saved element in cache
+// Dated cached = map.get(key);
+// // Note: These Segment Timestamps are kept up to date with DB
+// Date dbStamp = info.get(trans, name,cacheIdx);
+//
+// // Check for cache Entry and whether it is still good (a good Cache Entry is same or after DBEntry, so we use "before" syntax)
+// if(cached!=null && dbStamp.before(cached.timestamp)) {
+// ld = (List<DATA>)cached.data;
+// rld = Result.ok(ld);
+// } else {
+// rld = getter.get();
+// if(rld.isOK()) { // only store valid lists
+// map.put(key, new Dated(rld.value)); // successful item found gets put in cache
+//// } else if(rld.status == Result.ERR_Backend){
+//// map.remove(key);
+// }
+// }
+// return rld;
+// }
- class DataStub extends CacheableData {
- @Override public int[] invalidate(Cached<?, ?> cache) { return null; }
- }
+ class DataStub extends CacheableData {
+ @Override public int[] invalidate(Cached<?, ?> cache) { return null; }
+ }
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CachedDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CachedDAO.java
index 14612a1f..8ffc5c2f 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CachedDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CachedDAO.java
@@ -39,26 +39,26 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class JU_CachedDAO {
- CachedDAO cachedDAO;
- @Mock
- DAO daoMock;
- @Mock
- CIDAO<Trans> ciDAOMock;
- int segsize=1;
- Object[ ] objs = new Object[2];
-
- @Before
- public void setUp(){
- objs[0] = "helo";
- objs[1] = "polo";
- cachedDAO = new CachedDAO(daoMock, ciDAOMock, segsize, segsize);
- }
-
- @Test
- public void testKeyFromObjs(){
- String result = cachedDAO.keyFromObjs(objs);
- System.out.println("value of resut " +result);
- assertTrue(true);
- }
-
+ CachedDAO cachedDAO;
+ @Mock
+ DAO daoMock;
+ @Mock
+ CIDAO<Trans> ciDAOMock;
+ int segsize=1;
+ Object[ ] objs = new Object[2];
+
+ @Before
+ public void setUp(){
+ objs[0] = "helo";
+ objs[1] = "polo";
+ cachedDAO = new CachedDAO(daoMock, ciDAOMock, segsize, segsize);
+ }
+
+ @Test
+ public void testKeyFromObjs(){
+ String result = cachedDAO.keyFromObjs(objs);
+ System.out.println("value of resut " +result);
+ assertTrue(true);
+ }
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassAccess.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassAccess.java
index 525450a6..722011b0 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassAccess.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassAccess.java
@@ -41,33 +41,33 @@ import com.datastax.driver.core.Cluster.Builder;
@RunWith(PowerMockRunner.class)
public class JU_CassAccess {
- CassAccess cassAccess;
-
- public static final String KEYSPACE = "authz";
- public static final String CASSANDRA_CLUSTERS = "cassandra.clusters";
- public static final String CASSANDRA_CLUSTERS_PORT = "cassandra.clusters.port";
- public static final String CASSANDRA_CLUSTERS_USER_NAME = "cassandra.clusters.user";
- public static final String CASSANDRA_CLUSTERS_PASSWORD = "cassandra.clusters.password";
- public static final String CASSANDRA_RESET_EXCEPTIONS = "cassandra.reset.exceptions";
- public static final String LATITUDE = "LATITUDE";
- public static final String LONGITUDE = "LONGITUDE";
- //private static final List<Resettable> resetExceptions = new ArrayList<>();
- public static final String ERR_ACCESS_MSG = "Accessing Backend";
- private static Builder cb = null;
- @Mock
- Env envMock;
- String prefix=null;
-
- @Before
- public void setUp(){
- cassAccess = new CassAccess();
- }
+ CassAccess cassAccess;
+
+ public static final String KEYSPACE = "authz";
+ public static final String CASSANDRA_CLUSTERS = "cassandra.clusters";
+ public static final String CASSANDRA_CLUSTERS_PORT = "cassandra.clusters.port";
+ public static final String CASSANDRA_CLUSTERS_USER_NAME = "cassandra.clusters.user";
+ public static final String CASSANDRA_CLUSTERS_PASSWORD = "cassandra.clusters.password";
+ public static final String CASSANDRA_RESET_EXCEPTIONS = "cassandra.reset.exceptions";
+ public static final String LATITUDE = "LATITUDE";
+ public static final String LONGITUDE = "LONGITUDE";
+ //private static final List<Resettable> resetExceptions = new ArrayList<>();
+ public static final String ERR_ACCESS_MSG = "Accessing Backend";
+ private static Builder cb = null;
+ @Mock
+ Env envMock;
+ String prefix=null;
+
+ @Before
+ public void setUp(){
+ cassAccess = new CassAccess();
+ }
- @Test(expected=APIException.class)
- public void testCluster() throws APIException, IOException {
- cassAccess.cluster(envMock, prefix);
-
- }
+ @Test(expected=APIException.class)
+ public void testCluster() throws APIException, IOException {
+ cassAccess.cluster(envMock, prefix);
+
+ }
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassDAOImpl.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassDAOImpl.java
index d06e38f7..b5749747 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassDAOImpl.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassDAOImpl.java
@@ -64,33 +64,33 @@ AuthzTrans authzTransMock;
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Before
- public void setUp()
- {
- String name = "name";
- String keySpace = "keySpace";
- String table = "table";
- cassDAOImpl = new CassDAOImpl(transStoreMock, name, clusterMock, keySpace, classDataMock, table, consistencyLevelMock, consistencyLevelMock);
- }
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Before
+ public void setUp()
+ {
+ String name = "name";
+ String keySpace = "keySpace";
+ String table = "table";
+ cassDAOImpl = new CassDAOImpl(transStoreMock, name, clusterMock, keySpace, classDataMock, table, consistencyLevelMock, consistencyLevelMock);
+ }
- //TODO: Gabe [JUnit] Visibility issue
- @Test
- public void testReadConsistency() {
- String table = "users";
- PowerMockito.when(authzTransMock.getProperty(CASS_READ_CONSISTENCY+'.'+table)).thenReturn("TWO");
- ConsistencyLevel consistencyLevel = cassDAOImpl.readConsistency(authzTransMock, table);
- System.out.println("Consistency level" + consistencyLevel.name());
- assertEquals("TWO", consistencyLevel.name());
- }
-
- @Test
- public void testWriteConsistency() {
- String table = "users";
- PowerMockito.when(authzTransMock.getProperty(CASS_WRITE_CONSISTENCY+'.'+table)).thenReturn(null);
- ConsistencyLevel consistencyLevel = cassDAOImpl.writeConsistency(authzTransMock, table);
- System.out.println("Consistency level" + consistencyLevel.name());
- assertEquals("ONE", consistencyLevel.name());
- }
-
+ //TODO: Gabe [JUnit] Visibility issue
+ @Test
+ public void testReadConsistency() {
+ String table = "users";
+ PowerMockito.when(authzTransMock.getProperty(CASS_READ_CONSISTENCY+'.'+table)).thenReturn("TWO");
+ ConsistencyLevel consistencyLevel = cassDAOImpl.readConsistency(authzTransMock, table);
+ System.out.println("Consistency level" + consistencyLevel.name());
+ assertEquals("TWO", consistencyLevel.name());
+ }
+
+ @Test
+ public void testWriteConsistency() {
+ String table = "users";
+ PowerMockito.when(authzTransMock.getProperty(CASS_WRITE_CONSISTENCY+'.'+table)).thenReturn(null);
+ ConsistencyLevel consistencyLevel = cassDAOImpl.writeConsistency(authzTransMock, table);
+ System.out.println("Consistency level" + consistencyLevel.name());
+ assertEquals("ONE", consistencyLevel.name());
+ }
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_DAOException.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_DAOException.java
index 8cfb8520..8cd412d2 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_DAOException.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_DAOException.java
@@ -34,16 +34,16 @@ import org.powermock.modules.junit4.PowerMockRunner;
public class JU_DAOException {
DAOException daoException;
- //DAOException daoException = new DAOException();
- String message = "message";
- Throwable cause;
- @Before
- public void setUp(){
- daoException = new DAOException();
- }
+ //DAOException daoException = new DAOException();
+ String message = "message";
+ Throwable cause;
+ @Before
+ public void setUp(){
+ daoException = new DAOException();
+ }
- @Test
- public void test(){
- assertTrue(true);
- }
+ @Test
+ public void test(){
+ assertTrue(true);
+ }
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/AbsJUCass.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/AbsJUCass.java
index 3064de55..331e4c8b 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/AbsJUCass.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/AbsJUCass.java
@@ -53,148 +53,148 @@ import junit.framework.Assert;
*
*/
public class AbsJUCass {
- protected static final String AUTHZ = "authz";
- protected static Cluster cluster;
- protected static AuthzEnv env;
- protected static int iterations = 0;
- protected static float totals=0.0f;
- protected static float remote = 0.0f;
- protected static float json = 0.0f;
- protected static AuthzTrans trans;
- protected static boolean details = true;
-
- @BeforeClass
- public static void startup() throws APIException, IOException {
- synchronized(AUTHZ) {
- if(env==null) {
- final String resource = "cadi.properties";
- File f = new File("etc" + resource);
- InputStream is=null;
- Properties props = new Properties();
- try {
- if(f.exists()) {
- is = new FileInputStream(f);
- } else {
- URL rsrc = ClassLoader.getSystemResource(resource);
- is = rsrc.openStream();
- }
- props.load(is);
- } finally {
- if(is==null) {
- env= new AuthzEnv();
- Assert.fail(resource + " must exist in etc dir, or in Classpath");
- }
- is.close();
- }
- env = new AuthzEnv(props);
- }
- }
- cluster = CassAccess.cluster(env,"LOCAL");
+ protected static final String AUTHZ = "authz";
+ protected static Cluster cluster;
+ protected static AuthzEnv env;
+ protected static int iterations = 0;
+ protected static float totals=0.0f;
+ protected static float remote = 0.0f;
+ protected static float json = 0.0f;
+ protected static AuthzTrans trans;
+ protected static boolean details = true;
+
+ @BeforeClass
+ public static void startup() throws APIException, IOException {
+ synchronized(AUTHZ) {
+ if(env==null) {
+ final String resource = "cadi.properties";
+ File f = new File("etc" + resource);
+ InputStream is=null;
+ Properties props = new Properties();
+ try {
+ if(f.exists()) {
+ is = new FileInputStream(f);
+ } else {
+ URL rsrc = ClassLoader.getSystemResource(resource);
+ is = rsrc.openStream();
+ }
+ props.load(is);
+ } finally {
+ if(is==null) {
+ env= new AuthzEnv();
+ Assert.fail(resource + " must exist in etc dir, or in Classpath");
+ }
+ is.close();
+ }
+ env = new AuthzEnv(props);
+ }
+ }
+ cluster = CassAccess.cluster(env,"LOCAL");
- env.info().log("Connecting to Cluster");
- try {
- cluster.connect(AUTHZ);
- } catch(Exception e) {
- cluster=null;
- env.error().log(e);
- Assert.fail("Not able to connect to DB: " + e.getLocalizedMessage());
- }
- env.info().log("Connected");
-
- // Load special data here
-
- // WebPhone
- env.setProperty("java.naming.provider.url","ldap://ldap.webphone.att.com:389");
- env.setProperty("com.sun.jndi.ldap.connect.pool","true");
-
- iterations = 0;
-
- }
-
- @AfterClass
- public static void shutdown() {
- if(cluster!=null) {
- cluster.close();
- cluster = null;
- }
- }
+ env.info().log("Connecting to Cluster");
+ try {
+ cluster.connect(AUTHZ);
+ } catch(Exception e) {
+ cluster=null;
+ env.error().log(e);
+ Assert.fail("Not able to connect to DB: " + e.getLocalizedMessage());
+ }
+ env.info().log("Connected");
+
+ // Load special data here
+
+ // WebPhone
+ env.setProperty("java.naming.provider.url","ldap://ldap.webphone.att.com:389");
+ env.setProperty("com.sun.jndi.ldap.connect.pool","true");
+
+ iterations = 0;
+
+ }
+
+ @AfterClass
+ public static void shutdown() {
+ if(cluster!=null) {
+ cluster.close();
+ cluster = null;
+ }
+ }
- @Before
- public void newTrans() {
- trans = env.newTrans();
-
- trans.setProperty(CassDAOImpl.USER_NAME, System.getProperty("user.name"));
- }
-
- @After
- public void auditTrail() {
- if(totals==0) { // "updateTotals()" was not called... just do one Trans
- StringBuilder sb = new StringBuilder();
- Metric metric = trans.auditTrail(4, sb, Env.JSON, Env.REMOTE);
- if(details) {
- env.info().log(
- sb,
- "Total time:",
- totals += metric.total,
- "JSON time: ",
- metric.buckets[0],
- "REMOTE time: ",
- metric.buckets[1]
- );
- } else {
- totals += metric.total;
- }
- }
- }
-
- protected void updateTotals() {
- Metric metric = trans.auditTrail(0, null, Env.JSON, Env.REMOTE);
- totals+=metric.total;
- json +=metric.buckets[0];
- remote+=metric.buckets[1];
- }
+ @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
- */
- //TODO: Gabe [JUnit] Issue
- 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());
- }
+ @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
+ */
+ //TODO: Gabe [JUnit] Issue
+ 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/org/onap/aaf/auth/dao/aaf/test/JU_Bytification.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_Bytification.java
index e316ac7e..4ffa946f 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_Bytification.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_Bytification.java
@@ -38,228 +38,228 @@ 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.<pass>";
- ns.type = NsType.APP.type;
+ @Test
+ public void testNS() throws IOException {
+
+ // Normal
+ NsDAO.Data ns = new NsDAO.Data();
+ ns.name = "org.osaaf.<pass>";
+ ns.type = NsType.APP.type;
- ByteBuffer bb = ns.bytify();
-
- NsDAO.Data nsr = new NsDAO.Data();
- nsr.reconstitute(bb);
- check(ns,nsr);
-
- // Empty admin
-// ns.admin(true).clear();
- bb = ns.bytify();
- nsr = new NsDAO.Data();
- nsr.reconstitute(bb);
- check(ns,nsr);
-
- // Empty responsible
-// ns.responsible(true).clear();
- bb = ns.bytify();
- nsr = new NsDAO.Data();
- nsr.reconstitute(bb);
- check(ns,nsr);
+ 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));
-// }
- }
+ 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.<pass>";
- rd1.name = "my.role";
- rd1.perms(true).add("org.osaaf.<pass>.my.Perm|myInstance|myAction");
- rd1.perms(true).add("org.osaaf.<pass>.my.Perm|myInstance|myAction2");
+ @Test
+ public void testRole() throws IOException {
+ RoleDAO.Data rd1 = new RoleDAO.Data();
+ rd1.ns = "org.osaaf.<pass>";
+ rd1.name = "my.role";
+ rd1.perms(true).add("org.osaaf.<pass>.my.Perm|myInstance|myAction");
+ rd1.perms(true).add("org.osaaf.<pass>.my.Perm|myInstance|myAction2");
- // Normal
- ByteBuffer bb = rd1.bytify();
- RoleDAO.Data rd2 = new RoleDAO.Data();
- rd2.reconstitute(bb);
- check(rd1,rd2);
-
- // Overshoot Buffer
- StringBuilder sb = new StringBuilder(300);
- sb.append("role|instance|veryLongAction...");
- for(int i=0;i<280;++i) {
- sb.append('a');
- }
- rd1.perms(true).add(sb.toString());
- bb = rd1.bytify();
- rd2 = new RoleDAO.Data();
- rd2.reconstitute(bb);
- check(rd1,rd2);
-
- // No Perms
- rd1.perms.clear();
-
- bb = rd1.bytify();
- rd2 = new RoleDAO.Data();
- rd2.reconstitute(bb);
- check(rd1,rd2);
-
- // 1000 Perms
- for(int i=0;i<1000;++i) {
- rd1.perms(true).add("com|inst|action"+ i);
- }
+ // 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);
+ 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));
- }
- }
+ }
+
+ 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.<pass>";
- pd1.type = "my.perm";
- pd1.instance = "instance";
- pd1.action = "read";
- pd1.roles(true).add("org.osaaf.<pass>.my.Role");
- pd1.roles(true).add("org.osaaf.<pass>.my.Role2");
+ @Test
+ public void testPerm() throws IOException {
+ PermDAO.Data pd1 = new PermDAO.Data();
+ pd1.ns = "org.osaaf.<pass>";
+ pd1.type = "my.perm";
+ pd1.instance = "instance";
+ pd1.action = "read";
+ pd1.roles(true).add("org.osaaf.<pass>.my.Role");
+ pd1.roles(true).add("org.osaaf.<pass>.my.Role2");
- // Normal
- ByteBuffer bb = pd1.bytify();
- PermDAO.Data rd2 = new PermDAO.Data();
- rd2.reconstitute(bb);
- check(pd1,rd2);
-
- // No Perms
- pd1.roles.clear();
-
- bb = pd1.bytify();
- rd2 = new PermDAO.Data();
- rd2.reconstitute(bb);
- check(pd1,rd2);
-
- // 1000 Perms
- for(int i=0;i<1000;++i) {
- pd1.roles(true).add("org.osaaf.<pass>.my.Role"+ i);
- }
+ // 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.<pass>.my.Role"+ i);
+ }
- bb = pd1.bytify();
- rd2 = new PermDAO.Data();
- rd2.reconstitute(bb);
- check(pd1,rd2);
+ 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));
- }
- }
+ }
+
+ private void check(PermDAO.Data a, PermDAO.Data b) {
+ assertEquals(a.ns,b.ns);
+ assertEquals(a.type,b.type);
+ assertEquals(a.instance,b.instance);
+ assertEquals(a.action,b.action);
+
+ assertEquals(a.roles.size(),b.roles.size());
+ for(String s: a.roles) {
+ assertTrue(b.roles.contains(s));
+ }
+ }
- @Test
- public void testUserRole() throws IOException {
- UserRoleDAO.Data urd1 = new UserRoleDAO.Data();
- urd1.user = "myname@abc.att.com";
- urd1.role("org.osaaf.<pass>","my.role");
- urd1.expires = new Date();
+ @Test
+ public void testUserRole() throws IOException {
+ UserRoleDAO.Data urd1 = new UserRoleDAO.Data();
+ urd1.user = "myname@abc.att.com";
+ urd1.role("org.osaaf.<pass>","my.role");
+ urd1.expires = new Date();
- // Normal
- ByteBuffer bb = urd1.bytify();
- UserRoleDAO.Data urd2 = new UserRoleDAO.Data();
- urd2.reconstitute(bb);
- check(urd1,urd2);
-
- // A null
- urd1.expires = null;
- urd1.role = null;
-
- bb = urd1.bytify();
- urd2 = new UserRoleDAO.Data();
- urd2.reconstitute(bb);
- check(urd1,urd2);
- }
+ // 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);
- }
+ 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();
+
+ @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);
+ // 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());
- }
- }
- }
+ 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/org/onap/aaf/auth/dao/aaf/test/JU_NsType.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsType.java
index 06e5f0ed..38d0fbfd 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsType.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsType.java
@@ -29,30 +29,30 @@ import org.onap.aaf.auth.dao.cass.NsType;
public class JU_NsType {
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
+ @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);
- }
+ @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/org/onap/aaf/auth/direct/test/JU_DirectCertIdentity.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectCertIdentity.java
index 07cd7ae9..f9ad5a9e 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectCertIdentity.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectCertIdentity.java
@@ -39,33 +39,33 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class JU_DirectCertIdentity {
-
- public DirectCertIdentity directCertIdentity;
-
- @Before
- public void setUp(){
- directCertIdentity = new DirectCertIdentity();
- }
+
+ public DirectCertIdentity directCertIdentity;
+
+ @Before
+ public void setUp(){
+ directCertIdentity = new DirectCertIdentity();
+ }
- @Mock
- HttpServletRequest req;
- X509Certificate cert;
- byte[] _certBytes;
-
- @Test
- public void testidentity(){
-
- try {
- Principal p = directCertIdentity.identity(req, cert, _certBytes);
- assertEquals(( (p) == null),true);
-
- } catch (CertificateException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- //assertTrue(true);
-
- }
+ @Mock
+ HttpServletRequest req;
+ X509Certificate cert;
+ byte[] _certBytes;
+
+ @Test
+ public void testidentity(){
+
+ try {
+ Principal p = directCertIdentity.identity(req, cert, _certBytes);
+ assertEquals(( (p) == null),true);
+
+ } catch (CertificateException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //assertTrue(true);
+
+ }
}