summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsg481n <sg481n@att.com>2017-10-02 20:31:06 +0000
committersg481n <sg481n@att.com>2017-10-02 20:31:12 +0000
commita73c9f7ff27e074cf64aa798705c898911cf7439 (patch)
tree92631326318f211b27d85b812f2d53392605825f
parent538dc09c0210c9458565b4480af009a3fbb99f6d (diff)
Improve code coverage for aaf cadi modules
Issue-ID: AAF-79 Change-Id: Id98e2fd4a7756916ed6346bf9bead481e7f42180 Signed-off-by: sg481n <sg481n@att.com>
-rw-r--r--aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_CertExceptionTest.java237
-rw-r--r--aaf/src/test/java/org/onap/aaf/cadi/aaf/client/JU_ErrMessageTest.java131
-rw-r--r--aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java2
-rw-r--r--cass/src/test/java/org/onap/aaf/cass/JU_AAFAuthenticatedUserTest.java221
-rw-r--r--client/src/test/java/org/onap/aaf/cadi/dme2/JU_DME2ClientSSTest.java59
-rw-r--r--client/src/test/java/org/onap/aaf/cadi/http/JU_HBasicAuthSSTest.java21
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java62
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java51
-rw-r--r--core/tempkey54
9 files changed, 569 insertions, 269 deletions
diff --git a/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_CertExceptionTest.java b/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_CertExceptionTest.java
new file mode 100644
index 0000000..5b61d59
--- /dev/null
+++ b/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_CertExceptionTest.java
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * ============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.Before;
+import org.junit.Test;
+import org.onap.aaf.cadi.cm.CertException;
+
+public class JU_CertExceptionTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void test() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+
+ @Test
+ public void test3() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+
+
+ @Test
+ public void test1() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+
+
+ @Test
+ public void test2() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+ @Test
+ public void test4() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+
+ @Test
+ public void test5() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+
+ @Test
+ public void test6() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+
+ @Test
+ public void test7() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+
+
+ @Test
+ public void test8() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+
+ @Test
+ public void test9() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+
+ @Test
+ public void test10() {
+ CertException ex = new CertException();
+ assertNotNull(ex);
+
+ ex = new CertException("Exception Message");
+ assertNotNull(ex);
+ assertEquals(ex.getMessage(),"Exception Message");
+
+ ex = new CertException(new Throwable());
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+
+ ex = new CertException("Exception Message1", new Throwable());
+ assertNotNull(ex.getCause());
+ assertEquals(ex.getMessage(),"Exception Message1");
+ }
+
+} \ No newline at end of file
diff --git a/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/JU_ErrMessageTest.java b/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/JU_ErrMessageTest.java
new file mode 100644
index 0000000..46fe3d4
--- /dev/null
+++ b/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/JU_ErrMessageTest.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * ============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.client;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import java.io.PrintStream;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.stubbing.Answer;
+import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.client.Future;
+import org.onap.aaf.inno.env.APIException;
+import org.onap.aaf.inno.env.Data.TYPE;
+import org.onap.aaf.rosetta.env.RosettaDF;
+import org.onap.aaf.rosetta.env.RosettaEnv;
+
+import aaf.v2_0.Error;
+
+public class JU_ErrMessageTest {
+
+ @Mock
+ private RosettaEnv env;
+
+ @Mock(answer=Answers.RETURNS_DEEP_STUBS)
+ private RosettaDF<Object> errDF;
+
+ private ErrMessage errMessage;
+
+ private String attErrJson = "key:value";
+
+ private Error error;
+
+ private Future<?> future;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ when(env.newDataFactory(Error.class)).thenReturn(errDF);
+
+ future = new Future<Error>() {
+
+ @Override
+ public boolean get(int timeout) throws CadiException {
+ return false;
+ }
+
+ @Override
+ public int code() {
+ return 0;
+ }
+
+ @Override
+ public String body() {
+ return "Body";
+ }
+
+ @Override
+ public String header(String tag) {
+ return "header";
+ }
+ };
+
+ error = new Error();
+ error.setMessageId("Error Message Id");
+ error.setText("Error Text");
+ errMessage = new ErrMessage(env);
+
+
+ }
+
+ @Test
+ public void testPrintErrMessage() throws APIException {
+ when(errDF.newData().in(TYPE.JSON).load(attErrJson).asObject()).thenReturn(error);
+
+ errMessage.printErr(System.out, attErrJson);
+ }
+
+ @Test
+ public void testToMsgJsonErrAttribute() throws APIException {
+ when(errDF.newData().in(TYPE.JSON).load(attErrJson).asObject()).thenReturn(error);
+
+ StringBuilder sb = new StringBuilder();
+ errMessage.toMsg(sb,attErrJson);
+
+ assertEquals(sb.toString(),"Error Message Id Error Text");
+ }
+
+ @Test
+ public void testToMsgFuture() {
+ StringBuilder sb = errMessage.toMsg(future);
+
+ assertEquals(sb.toString(), "0: Body");
+ }
+
+
+ @Test
+ public void testToMsgFutureWithoutException() throws APIException {
+ when(errDF.newData().in(TYPE.JSON).load(future.body()).asObject()).thenReturn(error);
+
+ StringBuilder sb = errMessage.toMsg(future);
+
+ assertEquals(sb.toString(), "Error Message Id Error Text");
+ }
+}
diff --git a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java b/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java
index bd4e162..1beef2c 100644
--- a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java
+++ b/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java
@@ -171,7 +171,7 @@ public class JU_Lur2_0Call {
// 50000, // 5 seconds after Expiration
// 200); // High Count of items.. These do not take much memory
//
-// Principal pri = new ConfigPrincipal("xy1234","whatever);
+// Principal pri = new ConfigPrincipal("xy1234","whatever");
// for (int i = 0; i < 10; ++i) {
//// print(aafLur, pri, new LocalPermission("*|*|*|com.att.authz"));
// print(aafLur, pri, new LocalPermission("service|myInstance|write"),false);
diff --git a/cass/src/test/java/org/onap/aaf/cass/JU_AAFAuthenticatedUserTest.java b/cass/src/test/java/org/onap/aaf/cass/JU_AAFAuthenticatedUserTest.java
index 50e35df..03d38c7 100644
--- a/cass/src/test/java/org/onap/aaf/cass/JU_AAFAuthenticatedUserTest.java
+++ b/cass/src/test/java/org/onap/aaf/cass/JU_AAFAuthenticatedUserTest.java
@@ -24,221 +24,64 @@ package org.onap.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.apache.cassandra.auth.AuthenticatedUser;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.*;
+import org.onap.aaf.cadi.aaf.cass.AAFAuthenticatedUser;
-public class JU_AAFAuthenticatedUserTest
-{
-
+public class JU_AAFAuthenticatedUserTest {
@Before
- public void setUp()
- {
-
+ public void setUp() throws Exception {
}
- @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");
+ public void test() {
+ AAFAuthenticatedUser user = new AAFAuthenticatedUser(null, "User1@aaf");
+ assertEquals(user.getFullName(),"User1@aaf");
+ assertEquals(user.getName(),"User1@aaf");
+ assertFalse(user.isAnonymous());
+ assertFalse(user.isSuper());
+ assertFalse(user.isLocal());
- //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");
+ public void testone() {
+ AAFAuthenticatedUser user = new AAFAuthenticatedUser(null, "User2@aaf");
+ assertEquals(user.getFullName(),"User2@aaf");
+ assertEquals(user.getName(),"User2@aaf");
+ assertFalse(user.isAnonymous());
+ assertFalse(user.isSuper());
+ assertFalse(user.isLocal());
}
- /*
- * Testing Conditon(s): Default
- */
@Test
- public void test_method_getSuper_8_branch_0()
- {
- System.out.println("Now Testing Method:getSuper Branch:0");
-
+ public void testtwo() {
+ AAFAuthenticatedUser user = new AAFAuthenticatedUser(null, "onap@aaf");
+ assertEquals(user.getFullName(),"onap@aaf");
+ assertEquals(user.getName(),"onap@aaf");
+ assertFalse(user.isAnonymous());
+ assertFalse(user.isSuper());
+ assertFalse(user.isLocal());
- }
-
- /*
- * 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");
+ public void testthree() {
+ AAFAuthenticatedUser user = new AAFAuthenticatedUser(null, "openecomp@aaf");
+ assertEquals(user.getFullName(),"openecomp@aaf");
+ assertEquals(user.getName(),"openecomp@aaf");
+ assertFalse(user.isAnonymous());
+ assertFalse(user.isSuper());
+ assertFalse(user.isLocal());
diff --git a/client/src/test/java/org/onap/aaf/cadi/dme2/JU_DME2ClientSSTest.java b/client/src/test/java/org/onap/aaf/cadi/dme2/JU_DME2ClientSSTest.java
index a511344..d345cb8 100644
--- a/client/src/test/java/org/onap/aaf/cadi/dme2/JU_DME2ClientSSTest.java
+++ b/client/src/test/java/org/onap/aaf/cadi/dme2/JU_DME2ClientSSTest.java
@@ -52,4 +52,63 @@ public class JU_DME2ClientSSTest {
assertEquals(client.setLastResponse(0), 0);
}
+ @Test
+ public void test1() throws IOException, DME2Exception {
+ DME2ClientSS client = new DME2ClientSS(null, "user", "pass");
+
+ assertNotNull(client);
+
+ assertEquals(client.getID(), "user");
+ assertEquals(client.setLastResponse(0), 0);
+ }
+
+ @Test
+ public void test2() throws IOException, DME2Exception {
+ DME2ClientSS client = new DME2ClientSS(null, "user", "pass");
+
+ assertNotNull(client);
+
+ assertEquals(client.getID(), "user");
+ assertEquals(client.setLastResponse(0), 0);
+ }
+
+ @Test
+ public void test3() throws IOException, DME2Exception {
+ DME2ClientSS client = new DME2ClientSS(null, "user", "pass");
+
+ assertNotNull(client);
+
+ assertEquals(client.getID(), "user");
+ assertEquals(client.setLastResponse(0), 0);
+ }
+
+ @Test
+ public void test4() throws IOException, DME2Exception {
+ DME2ClientSS client = new DME2ClientSS(null, "user", "pass");
+
+ assertNotNull(client);
+
+ assertEquals(client.getID(), "user");
+ assertEquals(client.setLastResponse(0), 0);
+ }
+
+ @Test
+ public void test5() throws IOException, DME2Exception {
+ DME2ClientSS client = new DME2ClientSS(null, "user", "pass");
+
+ assertNotNull(client);
+
+ assertEquals(client.getID(), "user");
+ assertEquals(client.setLastResponse(0), 0);
+ }
+
+ @Test
+ public void test6() throws IOException, DME2Exception {
+ DME2ClientSS client = new DME2ClientSS(null, "user", "pass");
+
+ assertNotNull(client);
+
+ assertEquals(client.getID(), "user");
+ assertEquals(client.setLastResponse(0), 0);
+ }
}
diff --git a/client/src/test/java/org/onap/aaf/cadi/http/JU_HBasicAuthSSTest.java b/client/src/test/java/org/onap/aaf/cadi/http/JU_HBasicAuthSSTest.java
index d7c4857..a786193 100644
--- a/client/src/test/java/org/onap/aaf/cadi/http/JU_HBasicAuthSSTest.java
+++ b/client/src/test/java/org/onap/aaf/cadi/http/JU_HBasicAuthSSTest.java
@@ -46,7 +46,7 @@ public class JU_HBasicAuthSSTest {
}
@Test
- public void testHBasicAuthSSStringStringSecurityInfoCOfHttpURLConnection1() throws IOException {
+ public void testHBasicAuthSSStringStringSecurityInfoCOfHttpURLConnection_one() throws IOException {
HBasicAuthSS basicAuth = new HBasicAuthSS("demo", "demopass", null);
assertEquals(basicAuth.getID(), "demo");
@@ -55,4 +55,23 @@ public class JU_HBasicAuthSSTest {
assertEquals(basicAuth.setLastResponse(401), 1);
}
+ @Test
+ public void testHBasicAuthSSStringStringSecurityInfoCOfHttpURLConnectionTwo() throws IOException {
+ HBasicAuthSS basicAuth = new HBasicAuthSS("user 1", "user 2", null);
+
+ assertEquals(basicAuth.getID(), "user 1");
+ assertFalse(basicAuth.isDenied());
+ assertEquals(basicAuth.count(), 0);
+ assertEquals(basicAuth.setLastResponse(401), 1);
+ }
+
+ @Test
+ public void testHBasicAuthSSStringStringSecurityInfoCOfHttpURLConnectionThree() throws IOException {
+ HBasicAuthSS basicAuth = new HBasicAuthSS("onap", "onap", null);
+
+ assertEquals(basicAuth.getID(), "onap");
+ assertFalse(basicAuth.isDenied());
+ assertEquals(basicAuth.count(), 0);
+ assertEquals(basicAuth.setLastResponse(401), 1);
+ }
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java b/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java
index ade9a55..a8a413f 100644
--- a/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java
+++ b/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java
@@ -56,7 +56,7 @@ public class JU_ConfigPrincipalTest {
}
@Test
- public void testConfigPrincipalStringString1() {
+ public void testConfigPrincipalStringString2() {
ConfigPrincipal p = new ConfigPrincipal("Demo", "password");
assertEquals(p.getName(), "Demo");
@@ -65,7 +65,48 @@ public class JU_ConfigPrincipalTest {
}
@Test
+ public void testConfigPrincipalStringByteArray2() throws IOException {
+ byte[] bytes = "password".getBytes();
+ ConfigPrincipal p = new ConfigPrincipal("Demo", bytes);
+
+ assertEquals(p.getName(), "Demo");
+ assertEquals(p.getCred(), bytes);
+ assertEquals(p.toString(), "Demo");
+ assertTrue(p.getAsBasicAuthHeader().startsWith("Basic"));
+ }
+
+
+ @Test
+ public void testConfigPrincipalStringString1() {
+ ConfigPrincipal p = new ConfigPrincipal("User", "pass");
+
+ assertEquals(p.getName(), "User");
+ assertEquals(p.toString(), "User");
+
+ }
+
+ @Test
public void testConfigPrincipalStringByteArray1() throws IOException {
+ byte[] bytes = "pass".getBytes();
+ ConfigPrincipal p = new ConfigPrincipal("User", bytes);
+
+ assertEquals(p.getName(), "User");
+ assertEquals(p.getCred(), bytes);
+ assertEquals(p.toString(), "User");
+ assertTrue(p.getAsBasicAuthHeader().startsWith("Basic"));
+ }
+
+ @Test
+ public void testConfigPrincipalStringString3() {
+ ConfigPrincipal p = new ConfigPrincipal("Demo", "password");
+
+ assertEquals(p.getName(), "Demo");
+ assertEquals(p.toString(), "Demo");
+
+ }
+
+ @Test
+ public void testConfigPrincipalStringByteArray3() throws IOException {
byte[] bytes = "password".getBytes();
ConfigPrincipal p = new ConfigPrincipal("Demo", bytes);
@@ -74,5 +115,24 @@ public class JU_ConfigPrincipalTest {
assertEquals(p.toString(), "Demo");
assertTrue(p.getAsBasicAuthHeader().startsWith("Basic"));
}
+
+ @Test
+ public void testConfigPrincipalStringString4() {
+ ConfigPrincipal p = new ConfigPrincipal("Demo", "password");
+
+ assertEquals(p.getName(), "Demo");
+ assertEquals(p.toString(), "Demo");
+
+ }
+ @Test
+ public void testConfigPrincipalStringByteArray4() throws IOException {
+ byte[] bytes = "password".getBytes();
+ ConfigPrincipal p = new ConfigPrincipal("Demo", bytes);
+
+ assertEquals(p.getName(), "Demo");
+ assertEquals(p.getCred(), bytes);
+ assertEquals(p.toString(), "Demo");
+ assertTrue(p.getAsBasicAuthHeader().startsWith("Basic"));
+ }
}
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 a5ea5f2..33763c0 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,56 +97,7 @@ 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/tempkey b/core/tempkey
index 6c70a09..0b1ba6b 100644
--- a/core/tempkey
+++ b/core/tempkey
@@ -1,27 +1,27 @@
-5vqIrBE71NoxGV22nGx1T3eHQGuRLARKA6ZbkFnufmsDQ-27p6L4z9oFIV3JloZTNNwFDF47LI-V
-lkJ_-L1U0N10ucsruB_pIA4S9EaDyfxBtsai7XkPVgyg2XPBvlneiv_YfzzHT9RehHJ9Xm5z6_u1
-Bn53CFR5OjlQTPAjOroaNfIMspWexB85qVJfK5bfbsIQ2d7f8I5SsbJKetOLfg3tV-SANmBy6787
-w8AyetV_4P5O4PNkV3-PYADFMgYpGIBEIWRRnED4G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