aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/test/java/com/att/cadi
diff options
context:
space:
mode:
authorsg481n <sg481n@att.com>2017-08-25 01:57:24 -0400
committersg481n <sg481n@att.com>2017-08-25 01:57:37 -0400
commit62c4eb45e157d502463d797c1353802ca8e1e307 (patch)
treef79566b55c2535fd4be51b52cb4e5cb258391114 /core/src/test/java/com/att/cadi
parenta623b7658783e9a66f6131821de9447d58951cfe (diff)
Update project structure for aaf/cadi
Update project structure from com.att to org.onap and add distribution management and staging plugin. Issue-id: AAF-22 Change-Id: Idf2b591139e38921ad28782a51486714a05dee92 Signed-off-by: sg481n <sg481n@att.com>
Diffstat (limited to 'core/src/test/java/com/att/cadi')
-rw-r--r--core/src/test/java/com/att/cadi/JU_AES.java86
-rw-r--r--core/src/test/java/com/att/cadi/lur/test/JU_LocalLur.java101
-rw-r--r--core/src/test/java/com/att/cadi/lur/test/TestAccess.java91
-rw-r--r--core/src/test/java/com/att/cadi/test/JU_Base64.java157
-rw-r--r--core/src/test/java/com/att/cadi/test/JU_BufferedServletInputStream.java191
-rw-r--r--core/src/test/java/com/att/cadi/test/JU_Capacitor.java144
-rw-r--r--core/src/test/java/com/att/cadi/test/JU_Hash.java61
-rw-r--r--core/src/test/java/com/att/cadi/test/JU_Passcode.java90
-rw-r--r--core/src/test/java/com/att/cadi/test/JU_UserChainManip.java48
-rw-r--r--core/src/test/java/com/att/cadi/test/JU_Vars.java126
-rw-r--r--core/src/test/java/com/att/cadi/test/Test.java70
-rw-r--r--core/src/test/java/com/att/cadi/wsse/test/JU_WSSE_Read.java191
-rw-r--r--core/src/test/java/com/att/cadi/wsse/test/JU_XReader.java66
13 files changed, 0 insertions, 1422 deletions
diff --git a/core/src/test/java/com/att/cadi/JU_AES.java b/core/src/test/java/com/att/cadi/JU_AES.java
deleted file mode 100644
index fb2482a..0000000
--- a/core/src/test/java/com/att/cadi/JU_AES.java
+++ /dev/null
@@ -1,86 +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 com.att.cadi;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
-import javax.crypto.CipherInputStream;
-import javax.crypto.CipherOutputStream;
-
-import org.junit.Test;
-
-import junit.framework.Assert;
-
-public class JU_AES {
-
- @Test
- public void test() throws Exception {
- AES aes = new AES();
- String orig = "I'm a password, really";
- 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 testInputStream() throws Exception {
- AES aes = new AES();
- String orig = "I'm a password, really";
- 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 testObtain() throws Exception {
- byte[] keygen = Symm.baseCrypt().keygen();
-
- Symm symm = Symm.obtain(new ByteArrayInputStream(keygen));
-
- String orig ="Another Password, please";
- 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/com/att/cadi/lur/test/JU_LocalLur.java b/core/src/test/java/com/att/cadi/lur/test/JU_LocalLur.java
deleted file mode 100644
index f11c74d..0000000
--- a/core/src/test/java/com/att/cadi/lur/test/JU_LocalLur.java
+++ /dev/null
@@ -1,101 +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 com.att.cadi.lur.test;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.junit.Test;
-
-import com.att.cadi.CredVal.Type;
-import com.att.cadi.Lur;
-import com.att.cadi.Permission;
-import com.att.cadi.PropAccess;
-import com.att.cadi.Symm;
-import com.att.cadi.config.UsersDump;
-import com.att.cadi.lur.LocalLur;
-import com.att.cadi.lur.LocalPermission;
-
-public class JU_LocalLur {
-
- @Test
- public void test() 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:groupA,groupB","admin:myname,yourname;suser:hisname,hername,m1234%"+baos.toString());
-
- Permission admin = new LocalPermission("admin");
- Permission suser = new LocalPermission("suser");
-
- // Check User fish
- assertTrue(ml.fish(new JUPrincipal("myname"),admin));
- assertTrue(ml.fish(new JUPrincipal("hisname"),admin));
- assertFalse(ml.fish(new JUPrincipal("noname"),admin));
- assertTrue(ml.fish(new JUPrincipal("itsname"),suser));
- assertTrue(ml.fish(new JUPrincipal("hername"),suser));
- assertFalse(ml.fish(new JUPrincipal("myname"),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 JUPrincipal implements Principal {
- private String name;
- public JUPrincipal(String name) {
- this.name = name;
- }
-// @Override
- public String getName() {
- return name;
- }
- }
-
-}
diff --git a/core/src/test/java/com/att/cadi/lur/test/TestAccess.java b/core/src/test/java/com/att/cadi/lur/test/TestAccess.java
deleted file mode 100644
index 81d5092..0000000
--- a/core/src/test/java/com/att/cadi/lur/test/TestAccess.java
+++ /dev/null
@@ -1,91 +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 com.att.cadi.lur.test;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import com.att.cadi.Access;
-import com.att.cadi.Symm;
-
-public class TestAccess implements Access {
- private Symm symm;
-
- public TestAccess() {
- symm = Symm.obtain(this);
- }
-
- public TestAccess(Symm symmetric) {
- symm = symmetric;
- }
-
- public void log(Level level, Object... elements) {
- boolean first = true;
- for(int i=0;i<elements.length;++i) {
- if(first)first = false;
- else System.out.print(' ');
- System.out.print(elements[i].toString());
- }
- System.out.println();
- }
-
- public void log(Exception e, Object... elements) {
- e.printStackTrace();
- log(Level.ERROR,elements);
- }
-
- public void setLogLevel(Level level) {
-
- }
-
- public ClassLoader classLoader() {
- return ClassLoader.getSystemClassLoader();
- }
-
- public String getProperty(String string, String def) {
- String rv = System.getProperty(string);
- return rv==null?def:rv;
- }
-
- public void load(InputStream is) throws IOException {
-
- }
-
- public String decrypt(String encrypted, boolean anytext) throws IOException {
- return (encrypted!=null && (anytext==true || encrypted.startsWith(Symm.ENC)))
- ? symm.depass(encrypted)
- : encrypted;
- }
-
- @Override
- public boolean willLog(Level level) {
- return true;
- }
-
- @Override
- public void printf(Level level, String fmt, Object[] elements) {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/core/src/test/java/com/att/cadi/test/JU_Base64.java b/core/src/test/java/com/att/cadi/test/JU_Base64.java
deleted file mode 100644
index 1a82298..0000000
--- a/core/src/test/java/com/att/cadi/test/JU_Base64.java
+++ /dev/null
@@ -1,157 +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 com.att.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 com.att.cadi.Symm;
-import com.att.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);
-
- }
-}
diff --git a/core/src/test/java/com/att/cadi/test/JU_BufferedServletInputStream.java b/core/src/test/java/com/att/cadi/test/JU_BufferedServletInputStream.java
deleted file mode 100644
index 5f299bb..0000000
--- a/core/src/test/java/com/att/cadi/test/JU_BufferedServletInputStream.java
+++ /dev/null
@@ -1,191 +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 com.att.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 com.att.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/com/att/cadi/test/JU_Capacitor.java b/core/src/test/java/com/att/cadi/test/JU_Capacitor.java
deleted file mode 100644
index 5584911..0000000
--- a/core/src/test/java/com/att/cadi/test/JU_Capacitor.java
+++ /dev/null
@@ -1,144 +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 com.att.cadi.test;
-
-import static junit.framework.Assert.assertEquals;
-
-import org.junit.Test;
-
-import com.att.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/com/att/cadi/test/JU_Hash.java b/core/src/test/java/com/att/cadi/test/JU_Hash.java
deleted file mode 100644
index e5d2d6b..0000000
--- a/core/src/test/java/com/att/cadi/test/JU_Hash.java
+++ /dev/null
@@ -1,61 +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 com.att.cadi.test;
-
-import org.junit.Test;
-
-import com.att.cadi.CadiException;
-import com.att.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) {
-
- }
- }
-
-}
diff --git a/core/src/test/java/com/att/cadi/test/JU_Passcode.java b/core/src/test/java/com/att/cadi/test/JU_Passcode.java
deleted file mode 100644
index 122ecf7..0000000
--- a/core/src/test/java/com/att/cadi/test/JU_Passcode.java
+++ /dev/null
@@ -1,90 +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 com.att.cadi.test;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-
-import org.junit.Test;
-
-import com.att.cadi.CmdLine;
-import com.att.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();
- }
- 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");
-
-
- }
-
-}
diff --git a/core/src/test/java/com/att/cadi/test/JU_UserChainManip.java b/core/src/test/java/com/att/cadi/test/JU_UserChainManip.java
deleted file mode 100644
index 65f5ebd..0000000
--- a/core/src/test/java/com/att/cadi/test/JU_UserChainManip.java
+++ /dev/null
@@ -1,48 +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 com.att.cadi.test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-import com.att.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/com/att/cadi/test/JU_Vars.java b/core/src/test/java/com/att/cadi/test/JU_Vars.java
deleted file mode 100644
index e681622..0000000
--- a/core/src/test/java/com/att/cadi/test/JU_Vars.java
+++ /dev/null
@@ -1,126 +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 com.att.cadi.test;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.AfterClass;
-import org.junit.Test;
-
-import com.att.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"));
-
- }
-
-}
diff --git a/core/src/test/java/com/att/cadi/test/Test.java b/core/src/test/java/com/att/cadi/test/Test.java
deleted file mode 100644
index 4fe9111..0000000
--- a/core/src/test/java/com/att/cadi/test/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 com.att.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 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/com/att/cadi/wsse/test/JU_WSSE_Read.java b/core/src/test/java/com/att/cadi/wsse/test/JU_WSSE_Read.java
deleted file mode 100644
index 65338ae..0000000
--- a/core/src/test/java/com/att/cadi/wsse/test/JU_WSSE_Read.java
+++ /dev/null
@@ -1,191 +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 com.att.cadi.wsse.test;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.junit.Test;
-
-import com.att.cadi.BasicCred;
-import com.att.cadi.BufferedServletInputStream;
-import com.att.cadi.wsse.WSSEParser;
-
-public class JU_WSSE_Read {
-
- @Test
- public void test() {
- try {
- final BasicCred bc = new BasicCred() {
-
- private String user;
- private byte[] password;
-
- public void setUser(String user) {
- this.user = user;
- }
-
- public void setCred(byte[] passwd) {
- this.password = passwd;
- }
-
- public String getUser() {
- return user;
- }
-
- public byte[] getCred() {
- return password;
- }
- };
-
- WSSEParser wp = new WSSEParser();
-
- FileInputStream fis;
- fis = new FileInputStream("test/example.xml");
- BufferedServletInputStream is = new BufferedServletInputStream(fis);
- try {
- is.mark(1536);
- try {
- assertNull(wp.parse(bc, is));
- } finally {
- is.reset();
- assertEquals(814,is.buffered());
- }
- String password = new String(bc.getCred());
- System.out.println("CadiWrap credentials are: " + bc.getUser() + ", " + password);
- assertEquals("some_user", bc.getUser());
- assertEquals("some_password", password);
-
- } finally {
- fis.close();
- }
-
- // CBUS (larger)
- fis = new FileInputStream("test/CBUSevent.xml");
- is = new BufferedServletInputStream(fis);
- try {
- is.mark(1536);
- try {
- assertNull(wp.parse(bc, is));
- } finally {
- is.reset();
- assertEquals(667,is.buffered());
- }
- String password = new String(bc.getCred());
- System.out.println("CadiWrap credentials are: " + bc.getUser() + ", " + password);
- assertEquals("none", bc.getUser());
- assertEquals("none", password);
-
- } finally {
- fis.close();
- }
-
- // Closed Stream
- fis = new FileInputStream("test/example.xml");
- fis.close();
- bc.setCred(null);
- bc.setUser(null);
- XMLStreamException ex = wp.parse(bc, fis);
- assertNotNull(ex);
- assertNull(bc.getUser());
- assertNull(bc.getCred());
-
-
- fis = new FileInputStream("test/exampleNoSecurity.xml");
- try {
- bc.setCred(null);
- bc.setUser(null);
- assertNull(wp.parse(bc, fis));
- assertNull(bc.getUser());
- assertNull(bc.getCred());
- } finally {
- fis.close();
- }
-
- fis = new FileInputStream("test/exampleBad1.xml");
- try {
- bc.setCred(null);
- bc.setUser(null);
- assertNull(wp.parse(bc, fis));
- assertNull(bc.getUser());
- assertNull(bc.getCred());
- } finally {
- fis.close();
- }
-
- XMLStreamException e = wp.parse(bc, new ByteArrayInputStream("Not XML".getBytes())); // empty
- assertNotNull(e);
-
- e = wp.parse(bc, new ByteArrayInputStream("".getBytes())); // empty
- assertNotNull(e);
-
-
- long start, count = 0L;
- int iter = 30000;
- File f = new File("test/CBUSevent.xml");
- fis = new FileInputStream(f);
- is = new BufferedServletInputStream(fis);
- is.mark(0);
- try {
- while(is.read()>=0);
- } finally {
- fis.close();
- }
-
- for(int i=0;i<iter;++i) {
- start = System.nanoTime();
- is.reset();
- try {
- assertNull(wp.parse(bc, is));
- } finally {
- count += System.nanoTime()-start;
- }
- }
- float ms = count/1000000f;
- System.out.println("Executed " + iter + " WSSE reads from Memory Stream in " + ms + "ms. " + ms/iter + "ms per trans");
-
- // SPECIFIC ISSUES
-
- fis = new FileInputStream("test/error2013_04_23.xml");
- try {
- bc.setCred(null);
- bc.setUser(null);
- assertNull(wp.parse(bc, fis));
- assertNull(bc.getUser());
- assertNull(bc.getCred());
- } finally {
- fis.close();
- }
- } catch(Exception e) {
- e.printStackTrace(System.err);
- }
- }
-
-}
diff --git a/core/src/test/java/com/att/cadi/wsse/test/JU_XReader.java b/core/src/test/java/com/att/cadi/wsse/test/JU_XReader.java
deleted file mode 100644
index ee69561..0000000
--- a/core/src/test/java/com/att/cadi/wsse/test/JU_XReader.java
+++ /dev/null
@@ -1,66 +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 com.att.cadi.wsse.test;
-
-import java.io.FileInputStream;
-
-import javax.xml.stream.events.XMLEvent;
-
-import org.junit.Test;
-
-import com.att.cadi.wsse.XEvent;
-import com.att.cadi.wsse.XReader;
-
-public class JU_XReader {
- @Test
- public void test() throws Exception {
- FileInputStream fis = new FileInputStream("test/CBUSevent.xml");
- try {
- XReader xr = new XReader(fis);
- while(xr.hasNext()) {
- XEvent xe = xr.nextEvent();
- switch(xe.getEventType()) {
- case XMLEvent.START_DOCUMENT:
- System.out.println("Start Document");
- break;
- case XMLEvent.START_ELEMENT:
- System.out.println("Start Event: " + xe.asStartElement().getName());
- break;
- case XMLEvent.END_ELEMENT:
- System.out.println("End Event: " + xe.asEndElement().getName());
- break;
- case XMLEvent.CHARACTERS:
- System.out.println("Characters: " + xe.asCharacters().getData());
- break;
- case XMLEvent.COMMENT:
- System.out.println("Comment: " + ((XEvent.Comment)xe).value);
- break;
- }
- }
- } finally {
- fis.close();
- }
-
- }
-
-}