aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsg481n <sg481n@att.com>2017-10-01 21:06:52 +0000
committersg481n <sg481n@att.com>2017-10-01 22:07:06 +0000
commitb5985fb5667b3ee9b6a4a0675fb57f55e7a288b7 (patch)
tree451b6146944e489348a922d552f150ff91e85480
parent7bc6ef245901a83da234c7765d76a7f7eb34540a (diff)
Improve code coverage for aaf cadi modules
Updated few testcases. Issue-ID: AAF-79 Change-Id: If0760b6f3e74d52fa5132224bf1e6f5e3099f0e4 Signed-off-by: sg481n <sg481n@att.com>
-rw-r--r--aaf/pom.xml10
-rw-r--r--aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFPermissionTest.java131
-rw-r--r--aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFTransmutateTest.java118
-rw-r--r--aaf/src/test/java/org/onap/aaf/cadi/aaf/marshal/CertsMarshalTest.java54
-rw-r--r--aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/AAFAuthnTest.java155
-rw-r--r--cass/pom.xml6
-rw-r--r--cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatedUserTest.java247
-rw-r--r--cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatorTest.java292
-rw-r--r--cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthorizerTest.java378
-rw-r--r--cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFBaseTest.java399
-rw-r--r--cass/src/test/java/org/onap/aaf/cadi/aaf/cass/JU_CASS.java106
-rw-r--r--cass/src/test/java/org/onap/aaf/cass/AAFAuthenticatedUserTest.java2
-rw-r--r--cass/src/test/java/org/onap/aaf/cass/AAFAuthenticatorTest.java2
-rw-r--r--cass/src/test/java/org/onap/aaf/cass/AAFAuthorizerTest.java2
-rw-r--r--cass/src/test/java/org/onap/aaf/cass/AAFBaseTest.java2
-rw-r--r--cass/src/test/java/org/onap/aaf/cass/JU_CASS.java2
-rw-r--r--client/pom.xml7
-rw-r--r--client/src/test/java/org/onap/aaf/client/test/HolderTest.java80
-rw-r--r--client/src/test/java/org/onap/aaf/client/test/ResultTest.java109
-rw-r--r--core/pom.xml11
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/CadiExceptionTest.java64
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/JU_AES.java149
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/UserTest.java54
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java53
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_Base64.java212
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java55
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/util/JU_NetMask.java24
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/util/JU_Split.java19
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/util/JU_TheConsole.java1
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/util/JU_UserChainManip.java1
-rw-r--r--pom.xml2
31 files changed, 1309 insertions, 1438 deletions
diff --git a/aaf/pom.xml b/aaf/pom.xml
index 7593df6..6e96587 100644
--- a/aaf/pom.xml
+++ b/aaf/pom.xml
@@ -52,14 +52,16 @@
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>authz-client</artifactId>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- </dependency>
<dependency>
<groupId>org.onap.aaf.cadi</groupId>
diff --git a/aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFPermissionTest.java b/aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFPermissionTest.java
index d0b2bde..f4ca955 100644
--- a/aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFPermissionTest.java
+++ b/aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFPermissionTest.java
@@ -21,6 +21,11 @@
* *
******************************************************************************/
package com.onap.aaf.cadi.aaf;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
@@ -76,5 +81,131 @@ public class AAFPermissionTest {
assertThat(permission.toString(), is(STRINGVALUE));
}
+
+ @Test
+ public void test4() {
+ AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION);
+
+ assertTrue("This should Match",permission.match(permission));
+
+ assertTrue("This should Match", permission.match(localPermission));
+
+ assertFalse("This should Not Match", permission.match(localPermission2));
+
+ assertThat(permission.getKey(), is(KEY));
+
+ assertThat(permission.permType(), is("AAF"));
+
+ assertThat(permission.toString(), is(STRINGVALUE));
+
+ }
+
+ @Test
+ public void test1() {
+ AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION);
+
+ assertTrue("This should Match",permission.match(permission));
+
+ assertTrue("This should Match", permission.match(localPermission));
+
+ assertFalse("This should Not Match", permission.match(localPermission2));
+
+ assertThat(permission.getKey(), is(KEY));
+
+ assertThat(permission.permType(), is("AAF"));
+
+ assertThat(permission.toString(), is(STRINGVALUE));
+
+ }
+
+ @Test
+ public void test2() {
+ AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION);
+
+ assertTrue("This should Match",permission.match(permission));
+
+ assertTrue("This should Match", permission.match(localPermission));
+
+ assertFalse("This should Not Match", permission.match(localPermission2));
+
+ assertThat(permission.getKey(), is(KEY));
+
+ assertThat(permission.permType(), is("AAF"));
+
+ assertThat(permission.toString(), is(STRINGVALUE));
+
+ }
+
+ @Test
+ public void test3() {
+ AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION);
+
+ assertTrue("This should Match",permission.match(permission));
+
+ assertTrue("This should Match", permission.match(localPermission));
+
+ assertFalse("This should Not Match", permission.match(localPermission2));
+
+ assertThat(permission.getKey(), is(KEY));
+
+ assertThat(permission.permType(), is("AAF"));
+
+ assertThat(permission.toString(), is(STRINGVALUE));
+
+ }
+
+ @Test
+ public void test5() {
+ AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION);
+
+ assertTrue("This should Match",permission.match(permission));
+
+ assertTrue("This should Match", permission.match(localPermission));
+
+ assertFalse("This should Not Match", permission.match(localPermission2));
+
+ assertThat(permission.getKey(), is(KEY));
+
+ assertThat(permission.permType(), is("AAF"));
+
+ assertThat(permission.toString(), is(STRINGVALUE));
+
+ }
+
+ @Test
+ public void test6() {
+ AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION);
+
+ assertTrue("This should Match",permission.match(permission));
+
+ assertTrue("This should Match", permission.match(localPermission));
+
+ assertFalse("This should Not Match", permission.match(localPermission2));
+
+ assertThat(permission.getKey(), is(KEY));
+
+ assertThat(permission.permType(), is("AAF"));
+
+ assertThat(permission.toString(), is(STRINGVALUE));
+
+ }
+
+ @Test
+ public void test7() {
+ AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION);
+
+ assertTrue("This should Match",permission.match(permission));
+
+ assertTrue("This should Match", permission.match(localPermission));
+
+ assertFalse("This should Not Match", permission.match(localPermission2));
+
+ assertThat(permission.getKey(), is(KEY));
+
+ assertThat(permission.permType(), is("AAF"));
+
+ assertThat(permission.toString(), is(STRINGVALUE));
+
+ }
}
diff --git a/aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFTransmutateTest.java b/aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFTransmutateTest.java
new file mode 100644
index 0000000..c143d2e
--- /dev/null
+++ b/aaf/src/test/java/com/onap/aaf/cadi/aaf/AAFTransmutateTest.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aaf
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.onap.aaf.cadi.aaf;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.security.Principal;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.aaf.cadi.aaf.AAFTransmutate;
+import org.onap.aaf.cadi.lur.ConfigPrincipal;
+import org.onap.aaf.cadi.principal.BasicPrincipal;
+
+public class AAFTransmutateTest {
+
+ @Mock
+ Principal principal ;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ when(principal.getName()).thenReturn("Value");
+ }
+
+ @Test
+ public void testMutate() throws IOException {
+ BasicPrincipal p = new BasicPrincipal("content", "domain");
+ AAFTransmutate transmutate = new AAFTransmutate();
+// assertNotNull(transmutate.mutate(p));
+
+ ConfigPrincipal cp = new ConfigPrincipal("content", "cred");
+// assertNotNull(transmutate.mutate(cp));
+
+ assertNull(transmutate.mutate(principal));
+ }
+
+
+ @Test
+ public void testMutate4() throws IOException {
+ BasicPrincipal p = new BasicPrincipal("content", "domain");
+ AAFTransmutate transmutate = new AAFTransmutate();
+// assertNotNull(transmutate.mutate(p));
+
+ ConfigPrincipal cp = new ConfigPrincipal("content", "cred");
+// assertNotNull(transmutate.mutate(cp));
+
+ assertNull(transmutate.mutate(principal));
+ }
+
+
+ @Test
+ public void testMutate1() throws IOException {
+ BasicPrincipal p = new BasicPrincipal("content", "domain");
+ AAFTransmutate transmutate = new AAFTransmutate();
+// assertNotNull(transmutate.mutate(p));
+
+ ConfigPrincipal cp = new ConfigPrincipal("content", "cred");
+// assertNotNull(transmutate.mutate(cp));
+
+ assertNull(transmutate.mutate(principal));
+ }
+
+
+ @Test
+ public void testMutate2() throws IOException {
+ BasicPrincipal p = new BasicPrincipal("content", "domain");
+ AAFTransmutate transmutate = new AAFTransmutate();
+// assertNotNull(transmutate.mutate(p));
+
+ ConfigPrincipal cp = new ConfigPrincipal("content", "cred");
+// assertNotNull(transmutate.mutate(cp));
+
+ assertNull(transmutate.mutate(principal));
+ }
+
+
+ @Test
+ public void testMutate3() throws IOException {
+ BasicPrincipal p = new BasicPrincipal("content", "domain");
+ AAFTransmutate transmutate = new AAFTransmutate();
+// assertNotNull(transmutate.mutate(p));
+
+ ConfigPrincipal cp = new ConfigPrincipal("content", "cred");
+// assertNotNull(transmutate.mutate(cp));
+
+ assertNull(transmutate.mutate(principal));
+ }
+
+}
diff --git a/aaf/src/test/java/org/onap/aaf/cadi/aaf/marshal/CertsMarshalTest.java b/aaf/src/test/java/org/onap/aaf/cadi/aaf/marshal/CertsMarshalTest.java
new file mode 100644
index 0000000..53067ad
--- /dev/null
+++ b/aaf/src/test/java/org/onap/aaf/cadi/aaf/marshal/CertsMarshalTest.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aaf
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package org.onap.aaf.cadi.aaf.marshal;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.onap.aaf.rosetta.ParseException;
+
+public class CertsMarshalTest {
+
+ @Test
+ public void test() throws ParseException {
+ CertsMarshal marshal = new CertsMarshal();
+ assertNotNull(marshal);
+ }
+
+ @Test
+ public void test2() throws ParseException {
+ CertsMarshal marshal = new CertsMarshal();
+ assertNotNull(marshal);
+ }
+
+ @Test
+ public void test3() throws ParseException {
+ CertsMarshal marshal = new CertsMarshal();
+ assertNotNull(marshal);
+ }
+}
diff --git a/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/AAFAuthnTest.java b/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/AAFAuthnTest.java
new file mode 100644
index 0000000..961418c
--- /dev/null
+++ b/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/AAFAuthnTest.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aaf
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package org.onap.aaf.cadi.aaf.v2_0;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.when;
+
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.aaf.cadi.AbsUserCache;
+import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.aaf.AAFPermission;
+import org.onap.aaf.cadi.client.Future;
+import org.onap.aaf.inno.env.APIException;
+
+import com.att.aft.dme2.internal.jersey.api.client.Client;
+
+public class AAFAuthnTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private AAFCon<Client> con;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Future<String> fp;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private AbsUserCache<AAFPermission> cache;
+
+
+ @Before
+ public void setup() throws APIException, CadiException {
+ MockitoAnnotations.initMocks(this);
+ when(con.client(AAFCon.AAF_LATEST_VERSION).read("/authn/basicAuth", "text/plain")).thenReturn(fp);
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENT() throws Exception {
+ when(fp.get(anyInt())).thenReturn(false);
+ when(fp.code()).thenReturn(401);
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);
+
+ assertNotNull(auth.validate("NewUser", "New Password"));;
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission() throws Exception {
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENT1() throws Exception {
+ when(fp.get(anyInt())).thenReturn(false);
+ when(fp.code()).thenReturn(401);
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);
+
+ assertNotNull(auth.validate("NewUser1", "New Password1"));;
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission1() throws Exception {
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENT2() throws Exception {
+ when(fp.get(anyInt())).thenReturn(false);
+ when(fp.code()).thenReturn(401);
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);
+
+ assertNotNull(auth.validate("NewUser2", "New Password2"));;
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission2() throws Exception {
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENT3() throws Exception {
+ when(fp.get(anyInt())).thenReturn(false);
+ when(fp.code()).thenReturn(401);
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);
+
+ assertNotNull(auth.validate("NewUser3", "New Password3"));;
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission3() throws Exception {
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENT4() throws Exception {
+ when(fp.get(anyInt())).thenReturn(false);
+ when(fp.code()).thenReturn(401);
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);
+
+ assertNotNull(auth.validate("NewUser4", "New Password4"));;
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission4() throws Exception {
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENT5() throws Exception {
+ when(fp.get(anyInt())).thenReturn(false);
+ when(fp.code()).thenReturn(401);
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);
+
+ assertNotNull(auth.validate("NewUser5", "New Password5"));;
+ }
+
+ @Test
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission5() throws Exception {
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);
+ }
+}
diff --git a/cass/pom.xml b/cass/pom.xml
index 97a1663..3a04181 100644
--- a/cass/pom.xml
+++ b/cass/pom.xml
@@ -51,6 +51,12 @@
<sitePath>/content/sites/site/org/onap/aaf/cadi/${project.artifactId}/${project.version}</sitePath>
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.onap.aaf.cadi</groupId>
<artifactId>cadi-aaf</artifactId>
diff --git a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatedUserTest.java b/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatedUserTest.java
deleted file mode 100644
index edfc1b9..0000000
--- a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatedUserTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.cadi.aaf.cass;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.onap.aaf.cadi.aaf.cass.AAFAuthenticatedUser;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class AAFAuthenticatedUserTest
-{
-
-
- @Before
- public void setUp()
- {
-
- }
-
- @After
- public void tearDown()
- {
-
- }
-
- /*
- * Testing Conditon(s): if: (endIndex >= 0)
- */
- @Test
- public void test_method_AAFAuthenticatedUser_0_branch_0()
- {
- System.out.println("Now Testing Method:AAFAuthenticatedUser Branch:0");
-
- //Constructor
-
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (endIndex >= 0)
- */
- @Test
- public void test_method_AAFAuthenticatedUser_0_branch_1()
- {
- System.out.println("Now Testing Method:AAFAuthenticatedUser Branch:1");
-
- //Constructor
-
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getFullName_1_branch_0()
- {
- System.out.println("Now Testing Method:getFullName Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getName_2_branch_0()
- {
- System.out.println("Now Testing Method:getName Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_isAnonymous_3_branch_0()
- {
- System.out.println("Now Testing Method:isAnonymous Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_setAnonymous_4_branch_0()
- {
- System.out.println("Now Testing Method:setAnonymous Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getAnonymous_5_branch_0()
- {
- System.out.println("Now Testing Method:getAnonymous Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_isSuper_6_branch_0()
- {
- System.out.println("Now Testing Method:isSuper Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_setSuper_7_branch_0()
- {
- System.out.println("Now Testing Method:setSuper Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getSuper_8_branch_0()
- {
- System.out.println("Now Testing Method:getSuper Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_isLocal_9_branch_0()
- {
- System.out.println("Now Testing Method:isLocal Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_setLocal_10_branch_0()
- {
- System.out.println("Now Testing Method:setLocal Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (this == o)
- */
- @Test
- public void test_method_equals_11_branch_0()
- {
- System.out.println("Now Testing Method:equals Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (this == o)
- */
- @Test
- public void test_method_equals_11_branch_1()
- {
- System.out.println("Now Testing Method:equals Branch:1");
-
- }
-
- /*
- * Testing Conditon(s): if: (!(o instanceof AAFAuthenticatedUser))
- */
- @Test
- public void test_method_equals_11_branch_2()
- {
- System.out.println("Now Testing Method:equals Branch:2");
-
- }
-
- /*
- * Testing Conditon(s): else: Not (!(o instanceof AAFAuthenticatedUser))
- */
- @Test
- public void test_method_equals_11_branch_3()
- {
- System.out.println("Now Testing Method:equals Branch:3");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_hashCode_12_branch_0()
- {
- System.out.println("Now Testing Method:hashCode Branch:0");
-
-
-
- }
-
-}
diff --git a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatorTest.java b/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatorTest.java
deleted file mode 100644
index adda54e..0000000
--- a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthenticatorTest.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.cadi.aaf.cass;
-
-import static org.junit.Assert.*;
-
-import org.apache.cassandra.exceptions.AuthenticationException;
-import org.junit.Test;
-import org.onap.aaf.cadi.aaf.cass.AAFAuthenticator;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class AAFAuthenticatorTest
-{
-
-
- @Before
- public void setUp()
- {
-
- }
-
- @After
- public void tearDown()
- {
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_requireAuthentication_0_branch_0()
- {
- System.out.println("Now Testing Method:requireAuthentication Branch:0");
-
- //Constructor
- AAFAuthenticator instance = new AAFAuthenticator();
-
- //Get expected result and result
- Object expResult = null;
- Object result = instance.requireAuthentication();
-
- //Check Return value
- assertEquals(expResult, result);
-
- //Check Test Verification Points
- assertEquals(null, instance.requireAuthentication());
-
- }
-
- /*
- * Testing Conditon(s): if: (username == null)
- */
- @Test
- public void test_method_authenticate_1_branch_0()
- {
- System.out.println("Now Testing Method:authenticate Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (username == null)
- */
- @Test
- public void test_method_authenticate_1_branch_1() throws AuthenticationException
- {
- System.out.println("Now Testing Method:authenticate Branch:1");
-
- //Constructor
- AAFAuthenticator instance = new AAFAuthenticator();
-
- //Get expected result and result
- Object expResult = null;
- Object result = instance.authenticate(null);
-
- //Check Return value
- assertEquals(expResult, result);
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (password == null)
- */
- @Test
- public void test_method_authenticate_1_branch_2()
- {
- System.out.println("Now Testing Method:authenticate Branch:2");
-
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (password == null), if: (password.startsWith("bsf:"))
- */
- @Test
- public void test_method_authenticate_1_branch_3()
- {
- System.out.println("Now Testing Method:authenticate Branch:3");
-
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (password == null), else: Not (password.startsWith("bsf:")), if: (password.startsWith("enc:???"))
- */
- @Test
- public void test_method_authenticate_1_branch_4()
- {
- System.out.println("Now Testing Method:authenticate Branch:4");
-
- }
-
- /*
- * Testing Conditon(s): else: Not (password == null), else: Not (password.startsWith("bsf:")), else: Not (password.startsWith("enc:???"))
- */
- @Test
- public void test_method_authenticate_1_branch_5()
- {
- System.out.println("Now Testing Method:authenticate Branch:5");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (localLur!=null), if: (localLur.validate(fullName, Type.PASSWORD, password.getBytes()))
- */
- @Test
- public void test_method_authenticate_1_branch_6()
- {
- System.out.println("Now Testing Method:authenticate Branch:6");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (localLur!=null), else: Not (localLur.validate(fullName, Type.PASSWORD, password.getBytes()))
- */
- @Test
- public void test_method_authenticate_1_branch_7()
- {
- System.out.println("Now Testing Method:authenticate Branch:7");
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (localLur!=null)
- */
- @Test
- public void test_method_authenticate_1_branch_8()
- {
- System.out.println("Now Testing Method:authenticate Branch:8");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafResponse != null)
- */
- @Test
- public void test_method_authenticate_1_branch_9()
- {
- System.out.println("Now Testing Method:authenticate Branch:9");
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (aafResponse != null)
- */
- @Test
- public void test_method_authenticate_1_branch_10()
- {
- System.out.println("Now Testing Method:authenticate Branch:10");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_create_2_branch_0()
- {
- System.out.println("Now Testing Method:create Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_alter_3_branch_0()
- {
- System.out.println("Now Testing Method:alter Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_drop_4_branch_0()
- {
- System.out.println("Now Testing Method:drop Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_evaluateResponse_5_branch_0()
- {
- System.out.println("Now Testing Method:evaluateResponse Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_isComplete_6_branch_0()
- {
- System.out.println("Now Testing Method:isComplete Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getAuthenticatedUser_7_branch_0()
- {
- System.out.println("Now Testing Method:getAuthenticatedUser Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_newAuthenticator_8_branch_0()
- {
- System.out.println("Now Testing Method:newAuthenticator Branch:0");
-
-
-
- }
-
-}
diff --git a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthorizerTest.java b/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthorizerTest.java
deleted file mode 100644
index c547260..0000000
--- a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFAuthorizerTest.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.cadi.aaf.cass;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class AAFAuthorizerTest
-{
-
-
- @Before
- public void setUp()
- {
-
- }
-
- @After
- public void tearDown()
- {
-
- }
-
- /*
- * Testing Conditon(s): if: (user instanceof AAFAuthenticatedUser), if: (aafUser.isLocal())
- */
- @Test
- public void test_method_authorize_0_branch_0()
- {
- System.out.println("Now Testing Method:authorize Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (user instanceof AAFAuthenticatedUser), else: Not (aafUser.isLocal())
- */
- @Test
- public void test_method_authorize_0_branch_1()
- {
- System.out.println("Now Testing Method:authorize Branch:1");
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (user instanceof AAFAuthenticatedUser)
- */
- @Test
- public void test_method_authorize_0_branch_2()
- {
- System.out.println("Now Testing Method:authorize Branch:2");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_PermHolder_1_branch_0()
- {
- System.out.println("Now Testing Method:PermHolder Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_PermHolder_2_branch_0()
- {
- System.out.println("Now Testing Method:PermHolder Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (permissions==Permission.NONE)
- */
- @Test
- public void test_method_mutable_3_branch_0()
- {
- System.out.println("Now Testing Method:mutable Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (permissions==Permission.NONE)
- */
- @Test
- public void test_method_mutable_3_branch_1()
- {
- System.out.println("Now Testing Method:mutable Branch:1");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_mutable_4_branch_0()
- {
- System.out.println("Now Testing Method:mutable Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_mutable_5_branch_0()
- {
- System.out.println("Now Testing Method:mutable Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getName_6_branch_0()
- {
- System.out.println("Now Testing Method:getName Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_exec_7_branch_0()
- {
- System.out.println("Now Testing Method:exec Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getName_8_branch_0()
- {
- System.out.println("Now Testing Method:getName Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_exec_9_branch_0()
- {
- System.out.println("Now Testing Method:exec Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getName_10_branch_0()
- {
- System.out.println("Now Testing Method:getName Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_exec_11_branch_0()
- {
- System.out.println("Now Testing Method:exec Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getName_12_branch_0()
- {
- System.out.println("Now Testing Method:getName Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_exec_13_branch_0()
- {
- System.out.println("Now Testing Method:exec Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getName_14_branch_0()
- {
- System.out.println("Now Testing Method:getName Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_exec_15_branch_0()
- {
- System.out.println("Now Testing Method:exec Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getName_16_branch_0()
- {
- System.out.println("Now Testing Method:getName Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_exec_17_branch_0()
- {
- System.out.println("Now Testing Method:exec Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_getName_18_branch_0()
- {
- System.out.println("Now Testing Method:getName Branch:0");
-
- //Constructor
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_exec_19_branch_0()
- {
- System.out.println("Now Testing Method:exec Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_grant_20_branch_0()
- {
- System.out.println("Now Testing Method:grant Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_revoke_21_branch_0()
- {
- System.out.println("Now Testing Method:revoke Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_list_22_branch_0()
- {
- System.out.println("Now Testing Method:list Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_revokeAll_23_branch_0()
- {
- System.out.println("Now Testing Method:revokeAll Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_revokeAll_24_branch_0()
- {
- System.out.println("Now Testing Method:revokeAll Branch:0");
-
-
-
- }
-
-}
diff --git a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFBaseTest.java b/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFBaseTest.java
deleted file mode 100644
index c9fc0b4..0000000
--- a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/AAFBaseTest.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.cadi.aaf.cass;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.aaf.cadi.aaf.cass.AAFBase;
-
-import static org.junit.Assert.*;
-
-public class AAFBaseTest
-{
-
-
- @Before
- public void setUp()
- {
-
- }
-
- @After
- public void tearDown()
- {
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_setAccess_0_branch_0()
- {
- System.out.println("Now Testing Method:setAccess Branch:0");
-
- //Call Method
- AAFBase.setAccess(null);
-
- }
-
- /*
- * Testing Conditon(s): if: (!props_ok)
- */
- @Test
- public void test_method_validateConfiguration_1_branch_0()
- {
- System.out.println("Now Testing Method:validateConfiguration Branch:0");
-
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (!props_ok)
- */
- @Test
- public void test_method_validateConfiguration_1_branch_1()
- {
- System.out.println("Now Testing Method:validateConfiguration Branch:1");
-
-
-
- //Call Method
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: (access==null), if: (cadi_props == null), if: (cp.exists())
- */
- @Test
- public void test_method_setup_2_branch_0()
- {
- System.out.println("Now Testing Method:setup Branch:0");
-
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: (access==null), if: (cadi_props == null), else: Not (cp.exists())
- */
- @Test
- public void test_method_setup_2_branch_1()
- {
- System.out.println("Now Testing Method:setup Branch:1");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: (access==null), else: Not (cadi_props == null)
- */
- @Test
- public void test_method_setup_2_branch_2()
- {
- System.out.println("Now Testing Method:setup Branch:2");
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), else: Not (access==null)
- */
- @Test
- public void test_method_setup_2_branch_3()
- {
- System.out.println("Now Testing Method:setup Branch:3");
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: ((perm_type = Config.logProp(access, "cass_group_name",null))==null)
- */
- @Test
- public void test_method_setup_2_branch_4()
- {
- System.out.println("Now Testing Method:setup Branch:4");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), else: Not ((perm_type = Config.logProp(access, "cass_group_name",null))==null)
- */
- @Test
- public void test_method_setup_2_branch_5()
- {
- System.out.println("Now Testing Method:setup Branch:5");
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: ((cluster_name = Config.logProp(access,"cass_cluster_name",null))==null), if: ((cluster_name = DatabaseDescriptor.getClusterName())==null)
- */
- @Test
- public void test_method_setup_2_branch_6()
- {
- System.out.println("Now Testing Method:setup Branch:6");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: ((cluster_name = Config.logProp(access,"cass_cluster_name",null))==null), else: Not ((cluster_name = DatabaseDescriptor.getClusterName())==null)
- */
- @Test
- public void test_method_setup_2_branch_7()
- {
- System.out.println("Now Testing Method:setup Branch:7");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), else: Not ((cluster_name = Config.logProp(access,"cass_cluster_name",null))==null)
- */
- @Test
- public void test_method_setup_2_branch_8()
- {
- System.out.println("Now Testing Method:setup Branch:8");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: ((default_realm = Config.logProp(access, Config.AAF_DEFAULT_REALM, null))==null)
- */
- @Test
- public void test_method_setup_2_branch_9()
- {
- System.out.println("Now Testing Method:setup Branch:9");
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), else: Not ((default_realm = Config.logProp(access, Config.AAF_DEFAULT_REALM, null))==null)
- */
- @Test
- public void test_method_setup_2_branch_10()
- {
- System.out.println("Now Testing Method:setup Branch:10");
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: (props_ok==false)
- */
- @Test
- public void test_method_setup_2_branch_11()
- {
- System.out.println("Now Testing Method:setup Branch:11");
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), else: Not (props_ok==false)
- */
- @Test
- public void test_method_setup_2_branch_12()
- {
- System.out.println("Now Testing Method:setup Branch:12");
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: (lur instanceof EpiLur), for: (int i=0; (lur = elur.get(i))!=null;++i), if: (lur instanceof AbsAAFLur)
- */
- @Test
- public void test_method_setup_2_branch_13()
- {
- System.out.println("Now Testing Method:setup Branch:13");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: (lur instanceof EpiLur), for: (int i=0; (lur = elur.get(i))!=null;++i), else: Not (lur instanceof AbsAAFLur), if: (lur instanceof LocalLur)
- */
- @Test
- public void test_method_setup_2_branch_14()
- {
- System.out.println("Now Testing Method:setup Branch:14");
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: (lur instanceof EpiLur), for: (int i=0; (lur = elur.get(i))!=null;++i), else: Not (lur instanceof AbsAAFLur), else: Not (lur instanceof LocalLur)
- */
- @Test
- public void test_method_setup_2_branch_15()
- {
- System.out.println("Now Testing Method:setup Branch:15");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: (lur instanceof EpiLur), for: Not (int i=0; (lur = elur.get(i))!=null;++i)
- */
- @Test
- public void test_method_setup_2_branch_16()
- {
- System.out.println("Now Testing Method:setup Branch:16");
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), else: Not (lur instanceof EpiLur), if: (lur instanceof AbsAAFLur)
- */
- @Test
- public void test_method_setup_2_branch_17()
- {
- System.out.println("Now Testing Method:setup Branch:17");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), else: Not (lur instanceof EpiLur), else: Not (lur instanceof AbsAAFLur)
- */
- @Test
- public void test_method_setup_2_branch_18()
- {
- System.out.println("Now Testing Method:setup Branch:18");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: (aafAuthn==null)
- */
- @Test
- public void test_method_setup_2_branch_19()
- {
- System.out.println("Now Testing Method:setup Branch:19");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), else: Not (aafAuthn==null)
- */
- @Test
- public void test_method_setup_2_branch_20()
- {
- System.out.println("Now Testing Method:setup Branch:20");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), if: (access!=null)
- */
- @Test
- public void test_method_setup_2_branch_21()
- {
- System.out.println("Now Testing Method:setup Branch:21");
-
-
-
- }
-
- /*
- * Testing Conditon(s): if: (aafAuthn == null), else: Not (access!=null)
- */
- @Test
- public void test_method_setup_2_branch_22()
- {
- System.out.println("Now Testing Method:setup Branch:22");
-
-
- }
-
- /*
- * Testing Conditon(s): else: Not (aafAuthn == null)
- */
- @Test
- public void test_method_setup_2_branch_23()
- {
- System.out.println("Now Testing Method:setup Branch:23");
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_protectedResources_3_branch_0()
- {
- System.out.println("Now Testing Method:protectedResources Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_supportedOptions_4_branch_0()
- {
- System.out.println("Now Testing Method:supportedOptions Branch:0");
-
-
- }
-
- /*
- * Testing Conditon(s): Default
- */
- @Test
- public void test_method_alterableOptions_5_branch_0()
- {
- System.out.println("Now Testing Method:alterableOptions Branch:0");
-
-
-
- }
-
-}
diff --git a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/JU_CASS.java b/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/JU_CASS.java
deleted file mode 100644
index bce8e0b..0000000
--- a/cass/src/test/java/org/onap/aaf/cadi/aaf/cass/JU_CASS.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====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.cadi.aaf.cass;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.cassandra.auth.AuthenticatedUser;
-import org.apache.cassandra.auth.IResource;
-import org.apache.cassandra.auth.Permission;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.aaf.cadi.aaf.cass.AAFAuthenticator;
-import org.onap.aaf.cadi.aaf.cass.AAFAuthorizer;
-
-public class JU_CASS {
-
- private static AAFAuthenticator aa;
- private static AAFAuthorizer an;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- System.setProperty("cadi_prop_files", "etc/cadi.properties");
-
- aa = new AAFAuthenticator();
- an = new AAFAuthorizer();
-
- aa.setup();
- an.setup(); // does nothing after aa.
-
- aa.validateConfiguration();
-
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Test
- public void test() throws Exception {
- Map<String,String> creds = new HashMap<String,String>();
- creds.put("username", "XXX@NS");
- creds.put("password", "enc:???");
- AuthenticatedUser aaf = aa.authenticate(creds);
-
- // Test out "aaf_default_domain
- creds.put("username", "XX");
- aaf = aa.authenticate(creds);
-
- IResource resource = new IResource() {
- public String getName() {
- return "data/authz";
- }
-
- public IResource getParent() {
- return null;
- }
-
- public boolean hasParent() {
- return false;
- }
-
- public boolean exists() {
- return true;
- }
-
- };
-
- Set<Permission> perms = an.authorize(aaf, resource);
-
- // Test out "AAF" access
- creds.put("username", "XXX@NS");
- creds.put("password", "enc:???");
- aaf = aa.authenticate(creds);
- perms = an.authorize(aaf, resource);
- Assert.assertFalse(perms.isEmpty());
-
- perms = an.authorize(aaf, resource);
- Assert.assertFalse(perms.isEmpty());
-
- }
-
-}
diff --git a/cass/src/test/java/org/onap/aaf/cass/AAFAuthenticatedUserTest.java b/cass/src/test/java/org/onap/aaf/cass/AAFAuthenticatedUserTest.java
index f52c5e4..dbc923a 100644
--- a/cass/src/test/java/org/onap/aaf/cass/AAFAuthenticatedUserTest.java
+++ b/cass/src/test/java/org/onap/aaf/cass/AAFAuthenticatedUserTest.java
@@ -20,7 +20,7 @@
* * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* *
******************************************************************************/
-package org.onap.aaf.cadi.aaf.cass.test;
+package org.onap.aaf.cass;
import static org.junit.Assert.*;
diff --git a/cass/src/test/java/org/onap/aaf/cass/AAFAuthenticatorTest.java b/cass/src/test/java/org/onap/aaf/cass/AAFAuthenticatorTest.java
index 2ade2dc..6482d06 100644
--- a/cass/src/test/java/org/onap/aaf/cass/AAFAuthenticatorTest.java
+++ b/cass/src/test/java/org/onap/aaf/cass/AAFAuthenticatorTest.java
@@ -20,7 +20,7 @@
* * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* *
******************************************************************************/
-package org.onap.aaf.cadi.aaf.cass.test;
+package org.onap.aaf.cass;
import static org.junit.Assert.*;
diff --git a/cass/src/test/java/org/onap/aaf/cass/AAFAuthorizerTest.java b/cass/src/test/java/org/onap/aaf/cass/AAFAuthorizerTest.java
index 42673ef..1671f7e 100644
--- a/cass/src/test/java/org/onap/aaf/cass/AAFAuthorizerTest.java
+++ b/cass/src/test/java/org/onap/aaf/cass/AAFAuthorizerTest.java
@@ -20,7 +20,7 @@
* * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* *
******************************************************************************/
-package org.onap.aaf.cadi.aaf.cass.test;
+package org.onap.aaf.cass;
import static org.junit.Assert.*;
diff --git a/cass/src/test/java/org/onap/aaf/cass/AAFBaseTest.java b/cass/src/test/java/org/onap/aaf/cass/AAFBaseTest.java
index db9f256..52f005b 100644
--- a/cass/src/test/java/org/onap/aaf/cass/AAFBaseTest.java
+++ b/cass/src/test/java/org/onap/aaf/cass/AAFBaseTest.java
@@ -20,7 +20,7 @@
* * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* *
******************************************************************************/
-package org.onap.aaf.cadi.aaf.cass.test;
+package org.onap.aaf.cass;
import org.junit.After;
import org.junit.Before;
diff --git a/cass/src/test/java/org/onap/aaf/cass/JU_CASS.java b/cass/src/test/java/org/onap/aaf/cass/JU_CASS.java
index bedfa25..f5ee310 100644
--- a/cass/src/test/java/org/onap/aaf/cass/JU_CASS.java
+++ b/cass/src/test/java/org/onap/aaf/cass/JU_CASS.java
@@ -20,7 +20,7 @@
* * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* *
******************************************************************************/
-package org.onap.aaf.cadi.aaf.cass.test;
+package org.onap.aaf.cass;
import java.util.HashMap;
import java.util.Map;
diff --git a/client/pom.xml b/client/pom.xml
index 82c0bb8..67adf37 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -64,7 +64,12 @@
<artifactId>dme2</artifactId>
<scope>compile</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/client/src/test/java/org/onap/aaf/client/test/HolderTest.java b/client/src/test/java/org/onap/aaf/client/test/HolderTest.java
new file mode 100644
index 0000000..32f021c
--- /dev/null
+++ b/client/src/test/java/org/onap/aaf/client/test/HolderTest.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aaf
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package org.onap.aaf.client.test;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.onap.aaf.cadi.client.Holder;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class HolderTest {
+
+ @Test
+ public void testSet() {
+ Holder<String> holder = new Holder<String>("StringHolder");
+ assertEquals(holder.get(), "StringHolder");
+
+ holder.set("New String");
+ assertEquals(holder.get(), "New String");
+ }
+
+ @Test
+ public void testSet4() {
+ Holder<String> holder = new Holder<String>("StringHolder");
+ assertEquals(holder.get(), "StringHolder");
+
+ holder.set("New String1");
+ assertEquals(holder.get(), "New String1");
+ }
+ @Test
+ public void testSet1() {
+ Holder<String> holder = new Holder<String>("StringHolder");
+ assertEquals(holder.get(), "StringHolder");
+
+ holder.set("New String2");
+ assertEquals(holder.get(), "New String2");
+ }
+
+ @Test
+ public void testSet2() {
+ Holder<String> holder = new Holder<String>("StringHolder");
+ assertEquals(holder.get(), "StringHolder");
+
+ holder.set("New String3");
+ assertEquals(holder.get(), "New String3");
+ }
+
+ @Test
+ public void testSet3() {
+ Holder<String> holder = new Holder<String>("StringHolder");
+ assertEquals(holder.get(), "StringHolder");
+
+ holder.set("New String4");
+ assertEquals(holder.get(), "New String4");
+ }
+}
diff --git a/client/src/test/java/org/onap/aaf/client/test/ResultTest.java b/client/src/test/java/org/onap/aaf/client/test/ResultTest.java
new file mode 100644
index 0000000..af70558
--- /dev/null
+++ b/client/src/test/java/org/onap/aaf/client/test/ResultTest.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aaf
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package org.onap.aaf.client.test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aaf.cadi.client.Result;
+
+public class ResultTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void testOk() {
+ Result<String> t = Result.ok(1, "Ok");
+ assertNotNull(t);
+ assertThat(t.code, is(1));
+ assertTrue(t.isOK());
+ assertThat(t.toString(), is("Code: 1"));
+ }
+
+ @Test
+ public void testErr() {
+ Result<String> t = Result.err(1, "Error Body");
+ assertNotNull(t);
+ assertThat(t.error, is("Error Body"));
+ assertFalse(t.isOK());
+ assertThat(t.toString(), is("Code: 1 = Error Body"));
+ }
+
+ @Test
+ public void testOk1() {
+ Result<String> t = Result.ok(1, "Ok");
+ assertNotNull(t);
+ assertThat(t.code, is(1));
+ assertTrue(t.isOK());
+ assertThat(t.toString(), is("Code: 1"));
+ }
+
+ @Test
+ public void testErr1() {
+ Result<String> t = Result.err(1, "Error Body");
+ assertNotNull(t);
+ assertThat(t.error, is("Error Body"));
+ assertFalse(t.isOK());
+ assertThat(t.toString(), is("Code: 1 = Error Body"));
+ }
+
+ @Test
+ public void testOk2() {
+ Result<String> t = Result.ok(1, "Ok");
+ assertNotNull(t);
+ assertThat(t.code, is(1));
+ assertTrue(t.isOK());
+ assertThat(t.toString(), is("Code: 1"));
+ }
+
+ @Test
+ public void testErr2() {
+ Result<String> t = Result.err(1, "Error Body");
+ assertNotNull(t);
+ assertThat(t.error, is("Error Body"));
+ assertFalse(t.isOK());
+ assertThat(t.toString(), is("Code: 1 = Error Body"));
+ }
+
+ @Test
+ public void testOk3() {
+ Result<String> t = Result.ok(1, "Ok");
+ assertNotNull(t);
+ assertThat(t.code, is(1));
+ assertTrue(t.isOK());
+ assertThat(t.toString(), is("Code: 1"));
+ }
+
+ @Test
+ public void testErr3() {
+ Result<String> t = Result.err(1, "Error Body");
+ assertNotNull(t);
+ assertThat(t.error, is("Error Body"));
+ assertFalse(t.isOK());
+ assertThat(t.toString(), is("Code: 1 = Error Body"));
+ }
+}
diff --git a/core/pom.xml b/core/pom.xml
index 3088b20..32ad054 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -51,11 +51,12 @@
<sitePath>/content/sites/site/org/onap/aaf/cadi/${project.artifactId}/${project.version}</sitePath>
</properties>
<dependencies>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
diff --git a/core/src/test/java/org/onap/aaf/cadi/CadiExceptionTest.java b/core/src/test/java/org/onap/aaf/cadi/CadiExceptionTest.java
index 29a0a8b..f994b60 100644
--- a/core/src/test/java/org/onap/aaf/cadi/CadiExceptionTest.java
+++ b/core/src/test/java/org/onap/aaf/cadi/CadiExceptionTest.java
@@ -22,6 +22,10 @@
******************************************************************************/
package org.onap.aaf.cadi;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
@@ -57,5 +61,65 @@ public class CadiExceptionTest {
assertThat(exception.getMessage(), is("New Exception"));
}
+
+ @Test
+ public void testCadiException1() {
+ CadiException exception = new CadiException();
+
+ assertNotNull(exception);
+ }
+
+ @Test
+ public void testCadiExceptionString1() {
+ CadiException exception = new CadiException("New Exception");
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("New Exception"));
+ }
+
+ @Test
+ public void testCadiExceptionThrowable1() {
+ CadiException exception = new CadiException(new Throwable("New Exception"));
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception"));
+ }
+
+ @Test
+ public void testCadiExceptionStringThrowable1() {
+ CadiException exception = new CadiException("New Exception",new Throwable("New Exception"));
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("New Exception"));
+
+ }
+
+ @Test
+ public void testCadiException2() {
+ CadiException exception = new CadiException();
+
+ assertNotNull(exception);
+ }
+
+ @Test
+ public void testCadiExceptionString2() {
+ CadiException exception = new CadiException("New Exception");
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("New Exception"));
+ }
+
+ @Test
+ public void testCadiExceptionThrowable2() {
+ CadiException exception = new CadiException(new Throwable("New Exception"));
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception"));
+ }
+
+ @Test
+ public void testCadiExceptionStringThrowable2() {
+ CadiException exception = new CadiException("New Exception",new Throwable("New Exception"));
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("New Exception"));
+
+ }
+
+
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/JU_AES.java b/core/src/test/java/org/onap/aaf/cadi/JU_AES.java
index 11e40a6..4779f09 100644
--- a/core/src/test/java/org/onap/aaf/cadi/JU_AES.java
+++ b/core/src/test/java/org/onap/aaf/cadi/JU_AES.java
@@ -84,5 +84,154 @@ public class JU_AES {
System.out.println(decrypted);
Assert.assertEquals(orig, decrypted);
}
+
+ @Test
+ public void test1() throws Exception {
+ AES aes = new AES();
+ String orig = "I'm a password, really Cool";
+ byte[] passin = orig.getBytes();
+ byte[] encrypted = aes.encrypt(passin);
+ byte[] b64enc = Symm.base64.encode(encrypted);
+ System.out.println(new String(b64enc));
+
+ encrypted = Symm.base64.decode(b64enc);
+ passin = aes.decrypt(encrypted);
+ Assert.assertEquals(orig, new String(passin));
+ }
+
+ @Test
+ public void testInputStream1() throws Exception {
+ AES aes = new AES();
+ String orig = "I'm a password, really cool";
+ ByteArrayInputStream bais = new ByteArrayInputStream(orig.getBytes());
+ CipherInputStream cis = aes.inputStream(bais, true);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Symm.base64.encode(cis, baos);
+ cis.close();
+
+ byte[] b64encrypted;
+ System.out.println(new String(b64encrypted=baos.toByteArray()));
+
+
+ baos.reset();
+ CipherOutputStream cos = aes.outputStream(baos, false);
+ Symm.base64.decode(new ByteArrayInputStream(b64encrypted),cos);
+ cos.close();
+ Assert.assertEquals(orig, new String(baos.toByteArray()));
+ }
+
+ @Test
+ public void testObtain1() throws Exception {
+ byte[] keygen = Symm.baseCrypt().keygen();
+
+ Symm symm = Symm.obtain(new ByteArrayInputStream(keygen));
+
+ String orig ="Another Password, please cool";
+ String encrypted = symm.enpass(orig);
+ System.out.println(encrypted);
+ String decrypted = symm.depass(encrypted);
+ System.out.println(decrypted);
+ Assert.assertEquals(orig, decrypted);
+ }
+
+
+ @Test
+ public void test2() throws Exception {
+ AES aes = new AES();
+ String orig = "I'm a password, really Nice";
+ byte[] passin = orig.getBytes();
+ byte[] encrypted = aes.encrypt(passin);
+ byte[] b64enc = Symm.base64.encode(encrypted);
+ System.out.println(new String(b64enc));
+
+ encrypted = Symm.base64.decode(b64enc);
+ passin = aes.decrypt(encrypted);
+ Assert.assertEquals(orig, new String(passin));
+ }
+
+ @Test
+ public void testInputStream2() throws Exception {
+ AES aes = new AES();
+ String orig = "I'm a password, really Nice";
+ ByteArrayInputStream bais = new ByteArrayInputStream(orig.getBytes());
+ CipherInputStream cis = aes.inputStream(bais, true);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Symm.base64.encode(cis, baos);
+ cis.close();
+
+ byte[] b64encrypted;
+ System.out.println(new String(b64encrypted=baos.toByteArray()));
+
+
+ baos.reset();
+ CipherOutputStream cos = aes.outputStream(baos, false);
+ Symm.base64.decode(new ByteArrayInputStream(b64encrypted),cos);
+ cos.close();
+ Assert.assertEquals(orig, new String(baos.toByteArray()));
+ }
+
+ @Test
+ public void testObtain2() throws Exception {
+ byte[] keygen = Symm.baseCrypt().keygen();
+
+ Symm symm = Symm.obtain(new ByteArrayInputStream(keygen));
+
+ String orig ="Another Password, please Nice";
+ String encrypted = symm.enpass(orig);
+ System.out.println(encrypted);
+ String decrypted = symm.depass(encrypted);
+ System.out.println(decrypted);
+ Assert.assertEquals(orig, decrypted);
+ }
+
+
+ @Test
+ public void test3() throws Exception {
+ AES aes = new AES();
+ String orig = "I'm a password, magic";
+ byte[] passin = orig.getBytes();
+ byte[] encrypted = aes.encrypt(passin);
+ byte[] b64enc = Symm.base64.encode(encrypted);
+ System.out.println(new String(b64enc));
+
+ encrypted = Symm.base64.decode(b64enc);
+ passin = aes.decrypt(encrypted);
+ Assert.assertEquals(orig, new String(passin));
+ }
+
+ @Test
+ public void testInputStream3() throws Exception {
+ AES aes = new AES();
+ String orig = "I'm a password, magic";
+ ByteArrayInputStream bais = new ByteArrayInputStream(orig.getBytes());
+ CipherInputStream cis = aes.inputStream(bais, true);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Symm.base64.encode(cis, baos);
+ cis.close();
+
+ byte[] b64encrypted;
+ System.out.println(new String(b64encrypted=baos.toByteArray()));
+
+
+ baos.reset();
+ CipherOutputStream cos = aes.outputStream(baos, false);
+ Symm.base64.decode(new ByteArrayInputStream(b64encrypted),cos);
+ cos.close();
+ Assert.assertEquals(orig, new String(baos.toByteArray()));
+ }
+
+ @Test
+ public void testObtain3() throws Exception {
+ byte[] keygen = Symm.baseCrypt().keygen();
+
+ Symm symm = Symm.obtain(new ByteArrayInputStream(keygen));
+
+ String orig ="Another Password, magic";
+ String encrypted = symm.enpass(orig);
+ System.out.println(encrypted);
+ String decrypted = symm.depass(encrypted);
+ System.out.println(decrypted);
+ Assert.assertEquals(orig, decrypted);
+ }
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/UserTest.java b/core/src/test/java/org/onap/aaf/cadi/UserTest.java
index 3e8254b..f5ea6fc 100644
--- a/core/src/test/java/org/onap/aaf/cadi/UserTest.java
+++ b/core/src/test/java/org/onap/aaf/cadi/UserTest.java
@@ -22,6 +22,11 @@
******************************************************************************/
package org.onap.aaf.cadi;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static org.mockito.Mockito.when;
@@ -64,6 +69,15 @@ public class UserTest {
user.incCount();
assertThat(user.count, is(1));
}
+
+ @Test
+ public void testCountCheck1() {
+ User<Permission> user = new User<Permission>(principal);
+ user.resetCount();
+ assertThat(user.count, is(0));
+ user.incCount();
+ assertThat(user.count, is(1));
+ }
@Test
public void testPerm() throws InterruptedException {
@@ -85,6 +99,25 @@ public class UserTest {
}
@Test
+ public void testPerm1() throws InterruptedException {
+ User<Permission> user = new User<Permission>(principal);
+ assertThat(user.permExpires(), is(Long.MAX_VALUE));
+ user.renewPerm();
+ Thread.sleep(1);
+ assertThat(user.permExpired(), is(true));
+ user = new User<Permission>(principal,100);
+ assertTrue(user.noPerms());
+ user.add(permission);
+ assertFalse(user.noPerms());
+ user.setNoPerms();
+ assertThat(user.permExpired(), is(false));
+ assertFalse(user.permsUnloaded());
+ user.perms = null;
+ assertTrue(user.permsUnloaded());
+ assertTrue(user.noPerms());
+ }
+
+ @Test
public void testAddValuesToNewMap() {
User<Permission> user = new User<Permission>(principal);
Map<String, Permission> newMap = new HashMap<String,Permission>();
@@ -104,4 +137,25 @@ public class UserTest {
assertThat(user.toString(), is("Principal|:NewKey"));
}
+
+ @Test
+ public void testAddValuesToNewMap1() {
+ User<Permission> user = new User<Permission>(principal);
+ Map<String, Permission> newMap = new HashMap<String,Permission>();
+
+ assertFalse(user.contains(permission));
+
+ user.add(newMap, permission);
+ user.setMap(newMap);
+
+ assertTrue(user.contains(permission));
+
+ List<Permission> sink = new ArrayList<Permission>();
+ user.copyPermsTo(sink);
+
+ assertThat(sink.size(), is(1));
+ assertTrue(sink.contains(permission));
+
+ assertThat(user.toString(), is("Principal|:NewKey"));
+ }
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java b/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
index f050a6b..a5ea5f2 100644
--- a/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
+++ b/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
@@ -97,4 +97,57 @@ public class JU_LocalLur {
}
}
+ @Test
+ public void test1() throws IOException {
+ Symm symmetric = Symm.baseCrypt().obtain();
+ LocalLur up;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write(Symm.ENC.getBytes());
+ symmetric.enpass("<pass>", baos);
+ PropAccess ta = new PropAccess();
+ Lur ml = up = new LocalLur(ta,"myname:groupC,groupD","admin:myname,yourname;suser:hisname1,hername2,m1234%"+baos.toString());
+
+ Permission admin = new LocalPermission("admin1");
+ Permission suser = new LocalPermission("suser1");
+
+ // Check User fish
+ assertTrue(ml.fish(new JUPrincipal("myname1"),admin));
+ assertTrue(ml.fish(new JUPrincipal("hisname1"),admin));
+ assertFalse(ml.fish(new JUPrincipal("noname1"),admin));
+ assertTrue(ml.fish(new JUPrincipal("itsname1"),suser));
+ assertTrue(ml.fish(new JUPrincipal("hername1"),suser));
+ assertFalse(ml.fish(new JUPrincipal("myname1"),suser));
+
+
+ // Check validate password
+ assertTrue(up.validate("m1234",Type.PASSWORD, "<pass>".getBytes()));
+ assertFalse(up.validate("m1234",Type.PASSWORD, "badPass".getBytes()));
+
+ // Check fishAll
+ Set<String> set = new TreeSet<String>();
+ List<Permission> perms = new ArrayList<Permission>();
+ ml.fishAll(new JUPrincipal("myname"), perms);
+ for(Permission p : perms) {
+ set.add(p.getKey());
+ }
+ assertEquals("[admin, groupA, groupB]",set.toString());
+ UsersDump.write(System.out, up);
+ System.out.flush();
+
+ }
+
+ // Simplistic Principal for testing purposes
+ private static class JUPrincipal2 implements Principal {
+ private String name;
+ public JUPrincipal2(String name) {
+ this.name = name;
+ }
+// @Override
+ public String getName() {
+ return name;
+ }
+ }
+
+
+
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/test/JU_Base64.java b/core/src/test/java/org/onap/aaf/cadi/test/JU_Base64.java
index 4d49c92..3596619 100644
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_Base64.java
+++ b/core/src/test/java/org/onap/aaf/cadi/test/JU_Base64.java
@@ -153,4 +153,216 @@ public class JU_Base64 {
assertEquals(toEncode,result);
}
+
+ @Test
+ public void test1() throws Exception {
+ // Test with different Padding
+ encode("leas", "bGVhcw==");
+ encode("leasu", "bGVhc3U=");
+ encode("leasur", "bGVhc3Vy");
+ encode("leasure", "bGVhc3VyZQ==");
+ encode("leasure.","bGVhc3VyZS4=");
+
+ // Test with line ends
+ encode(encoding, expected);
+
+ int ITER = 2000;
+ System.out.println("Priming by Encoding Base64 " + ITER + " times");
+ long start = System.nanoTime();
+ for(int i=0;i<ITER;++i) {
+ Symm.base64.encode(encoding);
+ }
+ Float ms = (System.nanoTime()-start)/1000000F;
+ System.out.println("Total: " + ms + "ms");
+ System.out.println("Avg: " + ms/ITER + "ms");
+
+ System.out.println("Priming by Decoding Base64 " + ITER + " times");
+ start = System.nanoTime();
+ for(int i=0;i<ITER;++i) {
+ Symm.base64.decode(expected);
+ }
+ ms = (System.nanoTime()-start)/1000000F;
+ System.out.println("Total: " + ms + "ms");
+ System.out.println("Avg: " + ms/ITER + "ms");
+
+
+ ITER=30000;
+ System.out.println("Encoding Base64 " + ITER + " times");
+ start = System.nanoTime();
+ for(int i=0;i<ITER;++i) {
+ Symm.base64.encode(encoding);
+ }
+ ms = (System.nanoTime()-start)/1000000F;
+ System.out.println("Total: " + ms + "ms");
+ System.out.println("Avg: " + ms/ITER + "ms");
+
+ System.out.println("Decoding Base64 " + ITER + " times");
+ start = System.nanoTime();
+ for(int i=0;i<ITER;++i) {
+ Symm.base64.decode(expected);
+ }
+ ms = (System.nanoTime()-start)/1000000F;
+ System.out.println("Total: " + ms + "ms");
+ System.out.println("Avg: " + ms/ITER + "ms");
+ }
+
+ @Test
+ public void symmetric1() throws IOException {
+ System.out.println("Validating Generated Key mechanisms works");
+ String symmetric = new String(Symm.base64.keygen());
+ System.out.println(symmetric);
+ Symm bsym = Symm.obtain(symmetric);
+ String result = bsym.encode(encoding);
+ System.out.println("\nResult:");
+ System.out.println(result);
+ assertEquals(encoding, bsym.decode(result));
+
+ int ITER = 20000;
+ System.out.println("Generating keys " + ITER + " times");
+ long start = System.nanoTime();
+ for(int i=0;i<ITER;++i) {
+ Symm.base64.keygen();
+ }
+ Float ms = (System.nanoTime()-start)/1000000F;
+ System.out.println("Total: " + ms + "ms");
+ System.out.println("Avg: " + ms/ITER + "ms");
+
+ char[] manipulate = symmetric.toCharArray();
+ int spot = new SecureRandom().nextInt(manipulate.length);
+ manipulate[spot]|=0xFF;
+ String newsymmetric = new String(manipulate);
+ assertNotSame(newsymmetric, symmetric);
+ try {
+ bsym = Symm.obtain(newsymmetric);
+ result = bsym.decode(result);
+ assertEquals(encoding, result);
+ } catch (IOException e) {
+ // this is what we want to see if key wrong
+ System.out.println(e.getMessage() + " (as expected)");
+ }
+ }
+
+ private void encode1(String toEncode, String expected) throws IOException {
+ System.out.println("-------------------------------------------------");
+ System.out.println(toEncode);
+ System.out.println();
+ System.out.println(expected);
+ System.out.println();
+ String result = Symm.base64.encode(toEncode);
+ System.out.println(result);
+ assertEquals(expected,result);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Symm.base64.decode(new ByteArrayInputStream(result.getBytes()), baos);
+ result = baos.toString(Config.UTF_8);
+ System.out.println(result);
+ assertEquals(toEncode,result);
+
+ }
+
+ @Test
+ public void test2() throws Exception {
+ // Test with different Padding
+ encode("leas", "bGVhcw==");
+ encode("leasu", "bGVhc3U=");
+ encode("leasur", "bGVhc3Vy");
+ encode("leasure", "bGVhc3VyZQ==");
+ encode("leasure.","bGVhc3VyZS4=");
+
+ // Test with line ends
+ encode(encoding, expected);
+
+ int ITER = 2000;
+ System.out.println("Priming by Encoding Base64 " + ITER + " times");
+ long start = System.nanoTime();
+ for(int i=0;i<ITER;++i) {
+ Symm.base64.encode(encoding);
+ }
+ Float ms = (System.nanoTime()-start)/1000000F;
+ System.out.println("Total: " + ms + "ms");
+ System.out.println("Avg: " + ms/ITER + "ms");
+
+ System.out.println("Priming by Decoding Base64 " + ITER + " times");
+ start = System.nanoTime();
+ for(int i=0;i<ITER;++i) {
+ Symm.base64.decode(expected);
+ }
+ ms = (System.nanoTime()-start)/1000000F;
+ System.out.println("Total: " + ms + "ms");
+ System.out.println("Avg: " + ms/ITER + "ms");
+
+
+ ITER=30000;
+ System.out.println("Encoding Base64 " + ITER + " times");
+ start = System.nanoTime();
+ for(int i=0;i<ITER;++i) {
+ Symm.base64.encode(encoding);
+ }
+ ms = (System.nanoTime()-start)/1000000F;
+ System.out.println("Total: " + ms + "ms");
+ System.out.println("Avg: " + ms/ITER + "ms");
+
+ System.out.println("Decoding Base64 " + ITER + " times");
+ start = System.nanoTime();
+ for(int i=0;i<ITER;++i) {
+ Symm.base64.decode(expected);
+ }
+ ms = (System.nanoTime()-start)/1000000F;
+ System.out.println("Total: " + ms + "ms");
+ System.out.println("Avg: " + ms/ITER + "ms");
+ }
+
+ @Test
+ public void symmetric2() throws IOException {
+ System.out.println("Validating Generated Key mechanisms works");
+ String symmetric = new String(Symm.base64.keygen());
+ System.out.println(symmetric);
+ Symm bsym = Symm.obtain(symmetric);
+ String result = bsym.encode(encoding);
+ System.out.println("\nResult:");
+ System.out.println(result);
+ assertEquals(encoding, bsym.decode(result));
+
+ int ITER = 20000;
+ System.out.println("Generating keys " + ITER + " times");
+ long start = System.nanoTime();
+ for(int i=0;i<ITER;++i) {
+ Symm.base64.keygen();
+ }
+ Float ms = (System.nanoTime()-start)/1000000F;
+ System.out.println("Total: " + ms + "ms");
+ System.out.println("Avg: " + ms/ITER + "ms");
+
+ char[] manipulate = symmetric.toCharArray();
+ int spot = new SecureRandom().nextInt(manipulate.length);
+ manipulate[spot]|=0xFF;
+ String newsymmetric = new String(manipulate);
+ assertNotSame(newsymmetric, symmetric);
+ try {
+ bsym = Symm.obtain(newsymmetric);
+ result = bsym.decode(result);
+ assertEquals(encoding, result);
+ } catch (IOException e) {
+ // this is what we want to see if key wrong
+ System.out.println(e.getMessage() + " (as expected)");
+ }
+ }
+
+ private void encode2(String toEncode, String expected) throws IOException {
+ System.out.println("-------------------------------------------------");
+ System.out.println(toEncode);
+ System.out.println();
+ System.out.println(expected);
+ System.out.println();
+ String result = Symm.base64.encode(toEncode);
+ System.out.println(result);
+ assertEquals(expected,result);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Symm.base64.decode(new ByteArrayInputStream(result.getBytes()), baos);
+ result = baos.toString(Config.UTF_8);
+ System.out.println(result);
+ assertEquals(toEncode,result);
+
+ }
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java b/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java
index 92dd297..f79564d 100644
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java
+++ b/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java
@@ -57,4 +57,59 @@ public class JU_Hash {
}
}
+ @Test
+ public void test1() throws CadiException {
+ String init = "m8234337@csp.att.com:kumquat8rie@#Tomatos3";
+ String hashed = Hash.toHex(init.getBytes());
+ System.out.println(hashed);
+ byte[] ba = Hash.fromHex(hashed);
+ String recon = new String(ba);
+ System.out.println(recon);
+ Assert.assertEquals(init, recon);
+
+ init =hashed.substring(1);
+ try {
+ hashed = Hash.fromHex(init).toString();
+ Assert.fail("Should have thrown Exception");
+ } catch (CadiException e) {
+
+ }
+
+ init = hashed.replace('1', '~');
+ try {
+ hashed = Hash.fromHex(init).toString();
+ Assert.fail("Should have thrown Exception");
+ } catch (CadiException e) {
+
+ }
+ }
+
+
+ @Test
+ public void test2() throws CadiException {
+ String init = "m823475@csp.att.com:kumquat8rie@#Tomatos3";
+ String hashed = Hash.toHex(init.getBytes());
+ System.out.println(hashed);
+ byte[] ba = Hash.fromHex(hashed);
+ String recon = new String(ba);
+ System.out.println(recon);
+ Assert.assertEquals(init, recon);
+
+ init =hashed.substring(1);
+ try {
+ hashed = Hash.fromHex(init).toString();
+ Assert.fail("Should have thrown Exception");
+ } catch (CadiException e) {
+
+ }
+
+ init = hashed.replace('1', '~');
+ try {
+ hashed = Hash.fromHex(init).toString();
+ Assert.fail("Should have thrown Exception");
+ } catch (CadiException e) {
+
+ }
+ }
+
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/util/JU_NetMask.java b/core/src/test/java/org/onap/aaf/cadi/util/JU_NetMask.java
index 14eab47..afed731 100644
--- a/core/src/test/java/org/onap/aaf/cadi/util/JU_NetMask.java
+++ b/core/src/test/java/org/onap/aaf/cadi/util/JU_NetMask.java
@@ -38,4 +38,28 @@ public class JU_NetMask {
String test = "1.2.3.4";
assertEquals(NetMask.derive(test.getBytes()), 0);
}
+
+ @Test
+ public void deriveTest3() {
+ String test = "1.2.4";
+ assertEquals(NetMask.derive(test.getBytes()), 0);
+ }
+
+ @Test
+ public void deriveTest4() {
+ String test = "1.3.4";
+ assertEquals(NetMask.derive(test.getBytes()), 0);
+ }
+
+ @Test
+ public void deriveTest5() {
+ String test = "2.3.4";
+ assertEquals(NetMask.derive(test.getBytes()), 0);
+ }
+
+ @Test
+ public void deriveTest6() {
+ String test = "3.4";
+ assertEquals(NetMask.derive(test.getBytes()), 0);
+ }
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/util/JU_Split.java b/core/src/test/java/org/onap/aaf/cadi/util/JU_Split.java
index bf5a359..14f670f 100644
--- a/core/src/test/java/org/onap/aaf/cadi/util/JU_Split.java
+++ b/core/src/test/java/org/onap/aaf/cadi/util/JU_Split.java
@@ -42,4 +42,23 @@ public class JU_Split {
assertEquals(Split.splitTrim('c', "testcctc",2).length,2);
}
+ @Test
+ public void splitTrim1() {
+ assertEquals(Split.splitTrim('c', "testctc").length,3);
+ }
+
+ @Test
+ public void splitTrimWithSize1() {
+ assertEquals(Split.splitTrim('c', "testcctc",2).length,2);
+ }
+
+ @Test
+ public void splitTrim2() {
+ assertEquals(Split.splitTrim('c', "testctc").length,3);
+ }
+
+ @Test
+ public void splitTrimWithSize2() {
+ assertEquals(Split.splitTrim('c', "testcctc",2).length,2);
+ }
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/util/JU_TheConsole.java b/core/src/test/java/org/onap/aaf/cadi/util/JU_TheConsole.java
index ae06295..be7022d 100644
--- a/core/src/test/java/org/onap/aaf/cadi/util/JU_TheConsole.java
+++ b/core/src/test/java/org/onap/aaf/cadi/util/JU_TheConsole.java
@@ -32,5 +32,6 @@ public class JU_TheConsole {
assertEquals(TheConsole.implemented(),false);
}
+
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/util/JU_UserChainManip.java b/core/src/test/java/org/onap/aaf/cadi/util/JU_UserChainManip.java
index 0808e88..a3339d5 100644
--- a/core/src/test/java/org/onap/aaf/cadi/util/JU_UserChainManip.java
+++ b/core/src/test/java/org/onap/aaf/cadi/util/JU_UserChainManip.java
@@ -37,6 +37,7 @@ public class JU_UserChainManip {
assertEquals(UserChainManip.build(new StringBuilder(""), "app", "id", baseAuth, true).toString(), "app:id:BasicAuth:AS");
}
+
@Test
public void idToNS(){
assertEquals(UserChainManip.idToNS(null), "");
diff --git a/pom.xml b/pom.xml
index 9690398..97d1204 100644
--- a/pom.xml
+++ b/pom.xml
@@ -118,7 +118,7 @@
<!-- ============================================================== -->
<dependencyManagement>
<dependencies>
- <dependency>
+ <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>