summaryrefslogtreecommitdiffstats
path: root/core/src/test/java/org/onap/aaf/cadi/test
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/java/org/onap/aaf/cadi/test')
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_Base64.java368
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_BufferedServletInputStream.java190
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_Capacitor.java143
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java115
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_Passcode.java106
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_Test.java70
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_UserChainManip.java47
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_Vars.java125
8 files changed, 0 insertions, 1164 deletions
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
deleted file mode 100644
index 3596619..0000000
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_Base64.java
+++ /dev/null
@@ -1,368 +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.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.security.SecureRandom;
-import org.junit.Test;
-import org.onap.aaf.cadi.Symm;
-import org.onap.aaf.cadi.config.Config;
-
-
-public class JU_Base64 {
- private static final String encoding = "Man is distinguished, not only by his reason, but by this singular " +
- "passion from other animals, which is a lust of the mind, that by a " +
- "perseverance of delight in the continued and indefatigable generation of " +
- "knowledge, exceeds the short vehemence of any carnal pleasure.";
-
- private static final String expected =
- "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz\n" +
- "IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg\n" +
- "dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu\n" +
- "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo\n" +
- "ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
-
-
- @Test
- public void test() 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 symmetric() 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 encode(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 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_BufferedServletInputStream.java b/core/src/test/java/org/onap/aaf/cadi/test/JU_BufferedServletInputStream.java
deleted file mode 100644
index e496076..0000000
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_BufferedServletInputStream.java
+++ /dev/null
@@ -1,190 +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.test;
-
-import static junit.framework.Assert.assertEquals;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import org.junit.Test;
-import org.onap.aaf.cadi.BufferedServletInputStream;
-
-public class JU_BufferedServletInputStream {
-
- @Test
- public void testByteRead() throws Exception {
- FileInputStream fis = new FileInputStream("test/CBUSevent.xml");
- BufferedServletInputStream bsis = new BufferedServletInputStream(fis);
- try {
- bsis.mark(0);
- int c;
- byte aa[] = new byte[260];
- for(int i=0;i<aa.length;++i) {
- c = bsis.read();
- if(c>=0) {
- aa[i]=(byte)c;
- }
- }
- System.out.println(new String(aa));
-
- bsis.reset();
-
- byte bb[] = new byte[400];
- for(int i=0;i<bb.length;++i) {
- c = bsis.read();
- if(c>=0) {
- bb[i]=(byte)c;
- }
- }
- System.out.println(new String(bb));
-
- } finally {
- bsis.close();
- fis.close();
- }
- }
-
- @Test
- public void testByteArray() throws Exception {
- FileInputStream fis = new FileInputStream("test/CBUSevent.xml");
- BufferedServletInputStream bsis = new BufferedServletInputStream(fis);
- try {
- bsis.mark(0);
- byte aa[] = new byte[260];
- bsis.read(aa);
- System.out.println(new String(aa));
-
- bsis.reset();
-
- byte bb[] = new byte[400];
- bsis.read(bb);
- System.out.println(new String(bb));
-
- } finally {
- bsis.close();
- fis.close();
- }
- }
-
- @Test
- public void testDoubleRead() throws Exception {
- FileInputStream fis = new FileInputStream("test/CBUSevent.xml");
- BufferedServletInputStream bsis = new BufferedServletInputStream(fis);
- try {
- bsis.mark(0);
- byte aa[] = new byte[260];
- bsis.read(aa);
- System.out.println(new String(aa));
-
- bsis.reset();
-
- byte bb[] = new byte[400];
- bsis.read(bb);
- System.out.println(new String(bb));
-
- } finally {
- bsis.close();
- fis.close();
- }
- }
-
- @Test
- public void testByteArray2() throws Exception {
- FileInputStream fis = new FileInputStream("test/CBUSevent.xml");
- try {
- BufferedServletInputStream bsis = new BufferedServletInputStream(fis);
- byte[] content = null;
- byte aa[] = new byte[500];
- for(int i=0;i<2000;++i) {
- bsis.mark(0);
- bsis.read(aa,0,260);
- if(i==0)System.out.println(new String(aa));
-
- bsis.reset();
-
- bsis.read(aa,0,aa.length);
- if(i==0) {
- System.out.println(new String(aa));
- content = aa;
- aa = new byte[400];
- }
- bsis = new BufferedServletInputStream(new ByteArrayInputStream(content));
-
- }
-
- System.out.println(new String(aa));
-
- } finally {
- fis.close();
- }
- }
-
- // "Bug" 4/22/2013
- // Some XML code expects Buffered InputStream can never return 0... This isn't actually true, but we'll accommodate as far
- // as we can.
- // Here, we make sure we set and read the Buffered data, making sure the buffer is empty on the last test...
- @Test
- public void issue04_22_2013() throws IOException {
- String testString = "We want to read in and get out with a Buffered Stream seamlessly.";
- ByteArrayInputStream bais = new ByteArrayInputStream(testString.getBytes());
- BufferedServletInputStream bsis = new BufferedServletInputStream(bais);
- try {
- bsis.mark(0);
- byte aa[] = new byte[testString.length()]; // 65 count... important for our test (divisible by 5);
-
- int read;
- for(int i=0;i<aa.length;i+=5) {
- read = bsis.read(aa, i, 5);
- assertEquals(5,read);
- }
- System.out.println(new String(aa));
-
- bsis.reset();
-
- byte bb[] = new byte[aa.length];
- read = 0;
- for(int i=0;read>=0;i+=read) {
- read = bsis.read(bb,i,5);
- switch(i) {
- case 65:
- assertEquals(read,-1);
- break;
- default:
- assertEquals(read,5);
- }
- }
- System.out.println(new String(bb));
- assertEquals(testString,new String(aa));
- assertEquals(testString,new String(bb));
-
- } finally {
- bsis.close();
- bais.close();
- }
-
- }
-
-
-}
diff --git a/core/src/test/java/org/onap/aaf/cadi/test/JU_Capacitor.java b/core/src/test/java/org/onap/aaf/cadi/test/JU_Capacitor.java
deleted file mode 100644
index 9d11fe4..0000000
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_Capacitor.java
+++ /dev/null
@@ -1,143 +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.test;
-
-import static junit.framework.Assert.assertEquals;
-
-import org.junit.Test;
-import org.onap.aaf.cadi.Capacitor;
-
-public class JU_Capacitor {
- @Test
- public void testA() {
- Capacitor cap = new Capacitor();
-
- for(int iter=0;iter<200;++iter) {
- for(int i=0;i<20;++i) {
- cap.put((byte)('a'+i));
- }
- cap.setForRead();
- byte[] array = new byte[20];
- for(int i=0;i<20;++i) {
- array[i]=(byte)cap.read();
- }
- assertEquals("abcdefghijklmnopqrst",new String(array));
- assertEquals(-1,cap.read());
- cap.done();
- }
- }
-
- public final static String TEST_DATA =
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
- "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" +
- "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" +
- "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +
- "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" +
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
- @Test
- public void testB() {
- Capacitor cap = new Capacitor();
- byte[] arrayA = TEST_DATA.getBytes();
- System.out.println(arrayA.length);
- for(int iter=0;iter<200;++iter) {
- for(int i=0;i<arrayA.length;++i) {
- cap.put(arrayA[i]);
- }
- cap.setForRead();
- assertEquals(TEST_DATA.length(),cap.available());
- byte[] arrayB = new byte[arrayA.length];
- for(int i=0;i<arrayB.length;++i) {
- arrayB[i]=(byte)cap.read();
- }
- assertEquals(TEST_DATA,new String(arrayB));
- assertEquals(-1,cap.read());
- cap.done();
- }
- }
-
- @Test
- public void testC() {
- Capacitor cap = new Capacitor();
- byte[] arrayA = TEST_DATA.getBytes();
- System.out.println(arrayA.length);
- for(int iter=0;iter<200;++iter) {
- cap.put(arrayA,0,arrayA.length);
- cap.setForRead();
- assertEquals(TEST_DATA.length(),cap.available());
- byte[] arrayB = new byte[arrayA.length];
- assertEquals(arrayA.length,cap.read(arrayB,0,arrayB.length));
- assertEquals(TEST_DATA,new String(arrayB));
- assertEquals(-1,cap.read());
- cap.done();
- }
- }
-
-
- @Test
- public void testD() {
- StringBuffer sb = new StringBuffer();
- for(int i=0;i<300;++i) {
- sb.append(TEST_DATA);
- sb.append("###FILLER##");
- }
- String td = sb.toString();
- Capacitor cap = new Capacitor();
- byte[] arrayA = td.getBytes();
- System.out.println(arrayA.length);
- for(int iter=0;iter<200;++iter) {
- cap.put(arrayA,0,arrayA.length);
- cap.setForRead();
- assertEquals(td.length(),cap.available());
- byte[] arrayB = new byte[arrayA.length];
- assertEquals(arrayA.length,cap.read(arrayB,0,arrayB.length));
- assertEquals(td,new String(arrayB));
- assertEquals(-1,cap.read());
- cap.done();
- }
- }
-
- @Test
- public void testE() {
- Capacitor cap = new Capacitor();
-
- String b = "This is some content that we want to read";
- byte[] a = b.getBytes();
- byte[] c = new byte[b.length()]; // we want to use this to test reading offsets, etc
-
- for(int i=0;i<a.length;i+=11) {
- cap.put(a, i, Math.min(11,a.length-i));
- }
- cap.reset();
- int read;
- for(int i=0;i<c.length;i+=read) {
- read = cap.read(c, i, Math.min(3,c.length-i));
- if(read<0) break;
- }
-
- assertEquals(b, new String(c));
-
-
- }
-
-
-}
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
deleted file mode 100644
index f79564d..0000000
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java
+++ /dev/null
@@ -1,115 +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.test;
-
-import org.junit.Test;
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.Hash;
-
-import junit.framework.Assert;
-
-public class JU_Hash {
-
- @Test
- public void test() throws CadiException {
- String init = "m82347@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 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/test/JU_Passcode.java b/core/src/test/java/org/onap/aaf/cadi/test/JU_Passcode.java
deleted file mode 100644
index f51b131..0000000
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_Passcode.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.test;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-
-import org.junit.Test;
-import org.onap.aaf.cadi.CmdLine;
-import org.onap.aaf.cadi.Symm;
-
-import junit.framework.Assert;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-
-import org.junit.AfterClass;
-import org.junit.Test;
-import org.onap.aaf.cadi.CmdLine;
-import org.onap.aaf.cadi.Symm;
-
-import junit.framework.Assert;
-
-public class JU_Passcode {
- @Test
- public void test() throws Exception {
- int iterations = 0;
- long start = System.nanoTime();
- int gens= 800, en_de=2000;
- for(int j=0;j<gens;++j) {
- CmdLine.main(new String[] {"keygen","tempkey"});
-
- Symm symm;
- File fi = new File("tempkey");
- Assert.assertEquals(2074, fi.length());
- FileInputStream fis = new FileInputStream(fi);
-
- try {
- symm = Symm.obtain(fis);
- } finally {
- fis.close();
- fi.delete();
- }
- String samples[] = {"activevos","ThisIsATestPassword","I have spaces","I have 's, /s and &s and _s"};
- ByteArrayOutputStream baos;
- for(int i=0;i<en_de;++i) {
- String password = samples[i%samples.length];
- baos = new ByteArrayOutputStream();
- symm.enpass(password, baos);
- String pass = baos.toString();
- byte[] array = baos.toByteArray();
- for(int k=0;k<array.length;++k) {
- byte ch = array[k];
-// for(int k=0;k<pass.length();++k) {
-// char ch = pass.charAt(k);
- if(!(Character.isLetter(ch) || Character.isDigit(ch) || ch=='-' || ch=='_' || ch=='=')) {
- throw new Exception("Yikes, have a bad character..." + ch + '(' + (int)ch + ')');
- }
- }
- baos = new ByteArrayOutputStream();
- symm.depass(pass, baos);
- Assert.assertEquals(password,baos.toString());
- Assert.assertEquals(password,symm.depass(pass));
- ++iterations;
- }
- symm.enpass("activevos", System.out);
- System.out.println();
- }
- float ms = (System.nanoTime()-start)/1000000F;
- System.out.println("Ran " + iterations + " Encrypt/Decrypt cycles + " + gens + " keygens");
-
- System.out.println("Total: " + ms + "ms");
- System.out.println("Avg: " + ms/iterations + "ms");
- System.out.println("Avg Gen + " + en_de + " Encrypt/Decrypt cycles: " + ms/gens + "ms");
-
-
- }
-
- @AfterClass
- public static void tearDown() {
-
- }
-
-}
diff --git a/core/src/test/java/org/onap/aaf/cadi/test/JU_Test.java b/core/src/test/java/org/onap/aaf/cadi/test/JU_Test.java
deleted file mode 100644
index 38eefe4..0000000
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_Test.java
+++ /dev/null
@@ -1,70 +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.test;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * A Class to run on command line to determine suitability of environment for certain TAFs.
- *
- * For instance, CSP supports services only in certain domains, and while dynamic host
- * lookups on the machine work in most cases, sometimes, names and IPs are unexpected (and
- * invalid) for CSP because of multiple NetworkInterfaces, etc
- *
- *
- */
-public class JU_Test {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- try {
- System.out.println("CADI/TAF test");
-
- String hostName = InetAddress.getLocalHost().getCanonicalHostName();
-
- System.out.println(" Your automatic hostname is reported as \"" + hostName + "\"\n");
- String[] two;
-
- for(String str : args) {
- two = str.split("=");
- if(two.length==2) {
- if("hostname".equals(two[0])) {
- hostName = two[1];
- System.out.println(" You have overlaid the automatic hostname with \"" + hostName + "\"\n");
- }
- }
- }
- if(hostName.endsWith("vpn.cingular.net"))
- System.out.println(" This service appears to be an AT&T VPN address. These VPNs are typically\n" +
- " (and appropriately) firewalled against incoming traffic, and likely cannot be accessed.\n" +
- " For best results, choose a machine that is not firewalled on the ports you choose.\n");
-
- } catch (UnknownHostException e) {
- e.printStackTrace();
- }
-
- }
-
-}
diff --git a/core/src/test/java/org/onap/aaf/cadi/test/JU_UserChainManip.java b/core/src/test/java/org/onap/aaf/cadi/test/JU_UserChainManip.java
deleted file mode 100644
index 397b4b1..0000000
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_UserChainManip.java
+++ /dev/null
@@ -1,47 +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.test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.onap.aaf.cadi.util.UserChainManip;
-
-public class JU_UserChainManip {
-
- @Test
- public void test() {
- assertEquals("",UserChainManip.idToNS(null));
- assertEquals("",UserChainManip.idToNS(""));
- assertEquals("",UserChainManip.idToNS("something"));
- assertEquals("",UserChainManip.idToNS("something@@"));
- assertEquals("",UserChainManip.idToNS("something@@."));
- assertEquals("com",UserChainManip.idToNS("something@com"));
- assertEquals("com.random",UserChainManip.idToNS("something@random.com"));
- assertEquals("com.random",UserChainManip.idToNS("@random.com"));
- assertEquals("com.random",UserChainManip.idToNS("something@random.com."));
- assertEquals("com.random",UserChainManip.idToNS("something@..random...com..."));
- assertEquals("com.random.this",UserChainManip.idToNS("something@this.random.com"));
- }
-
-}
diff --git a/core/src/test/java/org/onap/aaf/cadi/test/JU_Vars.java b/core/src/test/java/org/onap/aaf/cadi/test/JU_Vars.java
deleted file mode 100644
index 47209cd..0000000
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_Vars.java
+++ /dev/null
@@ -1,125 +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.test;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.AfterClass;
-import org.junit.Test;
-import org.onap.aaf.cadi.util.Vars;
-
-public class JU_Vars {
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Test
- public void test() {
- StringBuilder holder = new StringBuilder();
- String str,bstr;
- assertEquals(str = "set %1 to %2",Vars.convert(holder,str, "a","b"));
- assertEquals("set a to b",holder.toString());
- assertEquals(str,Vars.convert(null,str, "a","b"));
- holder.setLength(0);
- assertEquals(str,Vars.convert(holder,bstr="set %s to %s", "a","b"));
- assertEquals("set a to b",holder.toString());
- assertEquals(str,Vars.convert(null,bstr, "a","b"));
-
- holder.setLength(0);
- assertEquals(str = "%1=%2",Vars.convert(holder,str, "a","b"));
- assertEquals("a=b",holder.toString());
- assertEquals(str,Vars.convert(null,str, "a","b"));
- holder.setLength(0);
- assertEquals(str,Vars.convert(holder,bstr="%s=%s", "a","b"));
- assertEquals("a=b",holder.toString());
- assertEquals(str,Vars.convert(null,bstr, "a","b"));
-
- holder.setLength(0);
- assertEquals(str = "%1%2",Vars.convert(holder,str, "a","b"));
- assertEquals("ab",holder.toString());
- assertEquals(str ,Vars.convert(null,str, "a","b"));
- holder.setLength(0);
- assertEquals(str,Vars.convert(holder,bstr="%s%s", "a","b"));
- assertEquals("ab",holder.toString());
- assertEquals(str ,Vars.convert(null,bstr, "a","b"));
-
-
- holder.setLength(0);
- assertEquals(str = " %1=%2 ",Vars.convert(holder,str, "a","b"));
- assertEquals(" a=b ",holder.toString());
- assertEquals(str ,Vars.convert(null,str, "a","b"));
- holder.setLength(0);
- assertEquals(str,Vars.convert(holder,bstr = " %s=%s ", "a","b"));
- assertEquals(" a=b ",holder.toString());
- assertEquals(str ,Vars.convert(null,bstr, "a","b"));
-
- holder.setLength(0);
- assertEquals(str = " %1%2%10 ",Vars.convert(holder,str, "a","b","c","d","e","f","g","h","i","j"));
- assertEquals(" abj ",holder.toString());
- assertEquals(str,Vars.convert(null,str, "a","b","c","d","e","f","g","h","i","j"));
- holder.setLength(0);
- assertEquals(str=" %1%2%3 ",Vars.convert(holder,bstr = " %s%s%s ", "a","b","c","d","e","f","g","h","i","j"));
- assertEquals(" abc ",holder.toString());
- assertEquals(str,Vars.convert(null,bstr, "a","b","c","d","e","f","g","h","i","j"));
-
-
- holder.setLength(0);
- assertEquals(str = "set %1 to %2",Vars.convert(holder,str, "Something much","larger"));
- assertEquals("set Something much to larger",holder.toString());
- assertEquals(str,Vars.convert(null,str,"Something much","larger"));
- holder.setLength(0);
- assertEquals(str,Vars.convert(holder,bstr="set %s to %s", "Something much","larger"));
- assertEquals("set Something much to larger",holder.toString());
- assertEquals(str,Vars.convert(null,bstr, "Something much","larger"));
-
- holder.setLength(0);
- assertEquals(str = "Text without Vars",Vars.convert(holder,str));
- assertEquals(str,holder.toString());
- assertEquals(str = "Text without Vars",Vars.convert(null,str));
-
-
- holder.setLength(0);
- assertEquals(str = "Not %1 Enough %2 Vars %3",Vars.convert(holder,str, "a","b"));
- assertEquals("Not a Enough b Vars ",holder.toString());
- assertEquals(str ,Vars.convert(null,str, "a","b"));
- holder.setLength(0);
- assertEquals(str,Vars.convert(holder,bstr="Not %s Enough %s Vars %s", "a","b"));
- assertEquals("Not a Enough b Vars ",holder.toString());
- assertEquals(str ,Vars.convert(null,bstr, "a","b"));
-
- holder.setLength(0);
- assertEquals(str = "!@#$%^*()-+?/,:;.",Vars.convert(holder,str, "a","b"));
- assertEquals(str,holder.toString());
- assertEquals(str ,Vars.convert(null,str, "a","b"));
-
- holder.setLength(0);
- bstr = "%s !@#$%^*()-+?/,:;.";
- str = "%1 !@#$%^*()-+?/,:;.";
- assertEquals(str,Vars.convert(holder,bstr, "Not Acceptable"));
- assertEquals("Not Acceptable !@#$%^*()-+?/,:;.",holder.toString());
- assertEquals(str ,Vars.convert(null,bstr, "Not Acceptable"));
-
- }
-
-}