diff options
Diffstat (limited to 'core/src')
10 files changed, 632 insertions, 0 deletions
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), "");
|