From 6d469611d86642bc0b74ce51af72cc36d2af962d Mon Sep 17 00:00:00 2001 From: Instrumental Date: Mon, 26 Mar 2018 12:04:27 -0700 Subject: Remove Code from cadi, it is now in authz Issue-ID: AAF-193 Change-Id: Ib7abdb15ba8a7445a3875cf8c6bb48b7d563f424 Signed-off-by: Instrumental --- core/src/test/java/org/onap/aaf/cadi/JU_AES.java | 229 ------------- .../org/onap/aaf/cadi/JU_CadiExceptionTest.java | 125 ------- .../java/org/onap/aaf/cadi/JU_CadiWrapTest.java | 197 ----------- .../java/org/onap/aaf/cadi/JU_PropAccessTest.java | 75 ----- .../test/java/org/onap/aaf/cadi/JU_UserTest.java | 161 --------- .../org/onap/aaf/cadi/filter/JU_FCGetTest.java | 99 ------ .../onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java | 171 ---------- .../org/onap/aaf/cadi/lur/test/JU_LocalLur.java | 104 ------ .../org/onap/aaf/cadi/lur/test/JU_TestAccess.java | 91 ----- .../org/onap/aaf/cadi/taf/JU_NullTafRespTest.java | 62 ---- .../java/org/onap/aaf/cadi/test/JU_Base64.java | 368 --------------------- .../cadi/test/JU_BufferedServletInputStream.java | 190 ----------- .../java/org/onap/aaf/cadi/test/JU_Capacitor.java | 143 -------- .../test/java/org/onap/aaf/cadi/test/JU_Hash.java | 115 ------- .../java/org/onap/aaf/cadi/test/JU_Passcode.java | 106 ------ .../test/java/org/onap/aaf/cadi/test/JU_Test.java | 70 ---- .../org/onap/aaf/cadi/test/JU_UserChainManip.java | 47 --- .../test/java/org/onap/aaf/cadi/test/JU_Vars.java | 125 ------- .../java/org/onap/aaf/cadi/util/JU_NetMask.java | 65 ---- .../test/java/org/onap/aaf/cadi/util/JU_Split.java | 64 ---- .../java/org/onap/aaf/cadi/util/JU_TheConsole.java | 37 --- .../org/onap/aaf/cadi/util/JU_UserChainManip.java | 51 --- .../test/java/org/onap/aaf/cadi/util/JU_Vars.java | 57 ---- .../org/onap/aaf/cadi/wsse/test/JU_WSSE_Read.java | 190 ----------- .../org/onap/aaf/cadi/wsse/test/JU_XReader.java | 65 ---- 25 files changed, 3007 deletions(-) delete mode 100644 core/src/test/java/org/onap/aaf/cadi/JU_AES.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/JU_CadiExceptionTest.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/JU_CadiWrapTest.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/JU_PropAccessTest.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/JU_UserTest.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/filter/JU_FCGetTest.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/lur/test/JU_TestAccess.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/taf/JU_NullTafRespTest.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/test/JU_Base64.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/test/JU_BufferedServletInputStream.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/test/JU_Capacitor.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/test/JU_Passcode.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/test/JU_Test.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/test/JU_UserChainManip.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/test/JU_Vars.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/util/JU_NetMask.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/util/JU_Split.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/util/JU_TheConsole.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/util/JU_UserChainManip.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/util/JU_Vars.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/wsse/test/JU_WSSE_Read.java delete mode 100644 core/src/test/java/org/onap/aaf/cadi/wsse/test/JU_XReader.java (limited to 'core/src/test/java/org') diff --git a/core/src/test/java/org/onap/aaf/cadi/JU_AES.java b/core/src/test/java/org/onap/aaf/cadi/JU_AES.java deleted file mode 100644 index 50c4f27..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/JU_AES.java +++ /dev/null @@ -1,229 +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; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - -import javax.crypto.CipherInputStream; -import javax.crypto.CipherOutputStream; - -import org.junit.Test; -import org.onap.aaf.cadi.AES; -import org.onap.aaf.cadi.Symm; - -import junit.framework.Assert; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.OutputStream; - -import javax.crypto.CipherInputStream; -import javax.crypto.CipherOutputStream; - -import org.junit.Test; -import org.onap.aaf.cadi.AES; -import org.onap.aaf.cadi.Symm; - -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 testAESFileStream() throws Exception { - File fi = new File("test/AESKeyFile"); - AES aes = new AES(fi); - - 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)); - - File temp = new File("tempFile"); - try { - assertFalse(temp.exists()); - aes.save(temp); - assertTrue(temp.exists()); - } catch (Exception e) { - } finally { - temp.delete(); - } - - } - - @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())); - - CipherInputStream cis1 = aes.inputStream(bais, false); - ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); - Symm.base64.encode(cis1, baos1); - cis.close(); - - byte[] b64encrypted1; - System.out.println(new String(b64encrypted1=baos1.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())); - - OutputStream stream = aes.outputStream(System.out, true); - assertTrue(stream instanceof CipherOutputStream); - - } - - @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); - } - - @Test - public void test1() 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 testAESFileStream1() throws Exception { - File fi = new File("test/AESKeyFile"); - AES aes = new AES(fi); - - 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)); - - File temp = new File("tempFile"); - try { - assertFalse(temp.exists()); - aes.save(temp); - assertTrue(temp.exists()); - } catch (Exception e) { - } finally { - temp.delete(); - } - - } - - @Test - public void testInputStream1() 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())); - - CipherInputStream cis1 = aes.inputStream(bais, false); - ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); - Symm.base64.encode(cis1, baos1); - cis.close(); - - byte[] b64encrypted1; - System.out.println(new String(b64encrypted1=baos1.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())); - - OutputStream stream = aes.outputStream(System.out, true); - assertTrue(stream instanceof CipherOutputStream); - - } - - @Test - public void testObtain1() 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/org/onap/aaf/cadi/JU_CadiExceptionTest.java b/core/src/test/java/org/onap/aaf/cadi/JU_CadiExceptionTest.java deleted file mode 100644 index 2eae209..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/JU_CadiExceptionTest.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; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import org.junit.Test; - -public class JU_CadiExceptionTest { - - @Test - public void testCadiException() { - CadiException exception = new CadiException(); - - assertNotNull(exception); - } - - @Test - public void testCadiExceptionString() { - CadiException exception = new CadiException("New Exception"); - assertNotNull(exception); - assertThat(exception.getMessage(), is("New Exception")); - } - - @Test - public void testCadiExceptionThrowable() { - CadiException exception = new CadiException(new Throwable("New Exception")); - assertNotNull(exception); - assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception")); - } - - @Test - public void testCadiExceptionStringThrowable() { - CadiException exception = new CadiException("New Exception",new Throwable("New Exception")); - assertNotNull(exception); - assertThat(exception.getMessage(), is("New Exception")); - - } - - @Test - public void testCadiException1() { - CadiException exception = new CadiException(); - - assertNotNull(exception); - } - - @Test - public void testCadiExceptionString1() { - CadiException exception = new CadiException("New Exception"); - assertNotNull(exception); - assertThat(exception.getMessage(), is("New Exception")); - } - - @Test - public void testCadiExceptionThrowable1() { - CadiException exception = new CadiException(new Throwable("New Exception")); - assertNotNull(exception); - assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception")); - } - - @Test - public void testCadiExceptionStringThrowable1() { - CadiException exception = new CadiException("New Exception",new Throwable("New Exception")); - assertNotNull(exception); - assertThat(exception.getMessage(), is("New Exception")); - - } - - @Test - public void testCadiException2() { - CadiException exception = new CadiException(); - - assertNotNull(exception); - } - - @Test - public void testCadiExceptionString2() { - CadiException exception = new CadiException("New Exception"); - assertNotNull(exception); - assertThat(exception.getMessage(), is("New Exception")); - } - - @Test - public void testCadiExceptionThrowable2() { - CadiException exception = new CadiException(new Throwable("New Exception")); - assertNotNull(exception); - assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception")); - } - - @Test - public void testCadiExceptionStringThrowable2() { - CadiException exception = new CadiException("New Exception",new Throwable("New Exception")); - assertNotNull(exception); - assertThat(exception.getMessage(), is("New Exception")); - - } - - - -} diff --git a/core/src/test/java/org/onap/aaf/cadi/JU_CadiWrapTest.java b/core/src/test/java/org/onap/aaf/cadi/JU_CadiWrapTest.java deleted file mode 100644 index da81e0c..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/JU_CadiWrapTest.java +++ /dev/null @@ -1,197 +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; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import static org.junit.Assert.*; -import static org.mockito.Matchers.isA; -import static org.mockito.Mockito.when; - -import java.security.Principal; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.onap.aaf.cadi.CachedPrincipal.Resp; -import org.onap.aaf.cadi.filter.MapPermConverter; -import org.onap.aaf.cadi.lur.EpiLur; -import org.onap.aaf.cadi.taf.TafResp; - -public class JU_CadiWrapTest { - - @Mock - private HttpServletRequest request; - - @Mock - private TafResp tafResp; - - @Mock - private Principal principle; - - @Mock - private Lur lur; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testInstantiate() throws CadiException { - Access a = new PropAccess(); - when(tafResp.getAccess()).thenReturn(a); - - lur.fishAll(isA(Principal.class), isA(List.class)); - - EpiLur lur1 = new EpiLur(lur); - - CadiWrap wrap = new CadiWrap(request, tafResp, lur1); - - assertNull(wrap.getUserPrincipal()); - assertNull(wrap.getRemoteUser()); - assertNull(wrap.getUser()); - assertEquals(wrap.getPermissions(principle).size(), 0); - - byte[] arr = {'1','2'}; - wrap.setCred(arr); - - assertEquals(arr, wrap.getCred()); - - wrap.setUser("User1"); - assertEquals("User1", wrap.getUser()); - - wrap.invalidate("1"); - - assertFalse(wrap.isUserInRole(null)); - - wrap.set(tafResp, lur); - - wrap.invalidate("2"); - - wrap.isUserInRole("User1"); - } - - @Test - public void testInstantiateWithPermConverter() throws CadiException { - Access a = new PropAccess(); - when(tafResp.getAccess()).thenReturn(a); - when(tafResp.getPrincipal()).thenReturn(principle); - - - CachingLur lur1 = new CachingLur() { - - @Override - public Permission createPerm(String p) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean fish(Principal bait, Permission pond) { - // TODO Auto-generated method stub - return true; - } - - @Override - public void fishAll(Principal bait, List permissions) { - // TODO Auto-generated method stub - - } - - @Override - public void destroy() { - // TODO Auto-generated method stub - - } - - @Override - public boolean handlesExclusively(Permission pond) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean supports(String userName) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void remove(String user) { - // TODO Auto-generated method stub - - } - - @Override - public Resp reload(User user) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setDebug(String commaDelimIDsOrNull) { - // TODO Auto-generated method stub - - } - - @Override - public void clear(Principal p, StringBuilder sb) { - // TODO Auto-generated method stub - - } - }; - - MapPermConverter pc = new MapPermConverter(); - - CadiWrap wrap = new CadiWrap(request, tafResp, lur1, pc); - - assertNotNull(wrap.getUserPrincipal()); - assertNull(wrap.getRemoteUser()); - assertNull(wrap.getUser()); - - byte[] arr = {'1','2'}; - wrap.setCred(arr); - - assertEquals(arr, wrap.getCred()); - - wrap.setUser("User1"); - assertEquals("User1", wrap.getUser()); - - wrap.invalidate("1"); - wrap.setPermConverter(new MapPermConverter()); - - assertTrue(wrap.getLur() instanceof CachingLur); - assertTrue(wrap.isUserInRole("User1")); - - wrap.set(tafResp, lur); - assertFalse(wrap.isUserInRole("Perm1")); - } -} diff --git a/core/src/test/java/org/onap/aaf/cadi/JU_PropAccessTest.java b/core/src/test/java/org/onap/aaf/cadi/JU_PropAccessTest.java deleted file mode 100644 index 9b18aa6..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/JU_PropAccessTest.java +++ /dev/null @@ -1,75 +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; - - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.Properties; - -import org.junit.Before; -import org.junit.Test; -import org.onap.aaf.cadi.Access.Level; -import org.onap.aaf.cadi.config.Config; - -public class JU_PropAccessTest { - - @Test - public void test() { - PropAccess prop = new PropAccess(new Object()); - - prop = new PropAccess("cadi_name=user","cadi_loglevel=DEBUG","cadi_prop_files=test/cadi.properties"); - - assertTrue(prop.getProperties().keySet().contains("cadi_name")); - assertTrue(prop.getProperty("cadi_name").equals("user")); - - prop.setProperty("cadi_keyfile", "file"); - prop.setLogLevel(Level.DEBUG); - assertEquals(prop.getProperty("cadi_keyfile"),"file"); - prop.log(Level.DEBUG); - assertTrue(prop.getDME2Properties().keySet().contains("AFT_DME2_SSL_INCLUDE_PROTOCOLS")); - } - - @Test - public void testWithProperties() { - Properties p = new Properties(); - p.put("cadi_name", "user"); - p.put("cadi_loglevel", "DEBUG"); - - PropAccess prop = new PropAccess(p); - - assertTrue(prop.getProperties().keySet().contains("cadi_name")); - assertTrue(prop.getProperty("cadi_name").equals("user")); - - prop.setProperty("cadi_keyfile", "file"); - prop.setLogLevel(Level.DEBUG); - assertEquals(prop.getProperty("cadi_keyfile"),"file"); - prop.log(Level.DEBUG); - assertTrue(prop.getDME2Properties().keySet().contains("AFT_DME2_SSL_INCLUDE_PROTOCOLS")); - } -} diff --git a/core/src/test/java/org/onap/aaf/cadi/JU_UserTest.java b/core/src/test/java/org/onap/aaf/cadi/JU_UserTest.java deleted file mode 100644 index be2becd..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/JU_UserTest.java +++ /dev/null @@ -1,161 +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; - -import static org.junit.Assert.*; - -import org.junit.Test; - - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; - -import java.security.Principal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.onap.aaf.cadi.lur.LocalPermission; - -public class JU_UserTest { - - @Mock - private Principal principal; - - @Mock - private LocalPermission permission; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - - when(principal.getName()).thenReturn("Principal"); - - when(permission.getKey()).thenReturn("NewKey"); - when(permission.match(permission)).thenReturn(true); - } - - @Test - public void testCountCheck() { - User user = new User(principal); - user.resetCount(); - assertThat(user.count, is(0)); - user.incCount(); - assertThat(user.count, is(1)); - } - - @Test - public void testCountCheck1() { - User user = new User(principal); - user.resetCount(); - assertThat(user.count, is(0)); - user.incCount(); - assertThat(user.count, is(1)); - } - - @Test - public void testPerm() throws InterruptedException { - User user = new User(principal); - assertThat(user.permExpires(), is(Long.MAX_VALUE)); - user.renewPerm(); - Thread.sleep(1); - assertThat(user.permExpired(), is(true)); - user = new User(principal,100); - assertTrue(user.noPerms()); - user.add(permission); - assertFalse(user.noPerms()); - user.setNoPerms(); - assertThat(user.permExpired(), is(false)); - assertFalse(user.permsUnloaded()); - user.perms = null; - assertTrue(user.permsUnloaded()); - assertTrue(user.noPerms()); - } - - @Test - public void testPerm1() throws InterruptedException { - User user = new User(principal); - assertThat(user.permExpires(), is(Long.MAX_VALUE)); - user.renewPerm(); - Thread.sleep(1); - assertThat(user.permExpired(), is(true)); - user = new User(principal,100); - assertTrue(user.noPerms()); - user.add(permission); - assertFalse(user.noPerms()); - user.setNoPerms(); - assertThat(user.permExpired(), is(false)); - assertFalse(user.permsUnloaded()); - user.perms = null; - assertTrue(user.permsUnloaded()); - assertTrue(user.noPerms()); - } - - @Test - public void testAddValuesToNewMap() { - User user = new User(principal); - Map newMap = new HashMap(); - - assertFalse(user.contains(permission)); - - user.add(newMap, permission); - user.setMap(newMap); - - assertTrue(user.contains(permission)); - - List sink = new ArrayList(); - user.copyPermsTo(sink); - - assertThat(sink.size(), is(1)); - assertTrue(sink.contains(permission)); - - assertThat(user.toString(), is("Principal|:NewKey")); - } - - @Test - public void testAddValuesToNewMap1() { - User user = new User(principal); - Map newMap = new HashMap(); - - assertFalse(user.contains(permission)); - - user.add(newMap, permission); - user.setMap(newMap); - - assertTrue(user.contains(permission)); - - List sink = new ArrayList(); - user.copyPermsTo(sink); - - assertThat(sink.size(), is(1)); - assertTrue(sink.contains(permission)); - - assertThat(user.toString(), is("Principal|:NewKey")); - } -} diff --git a/core/src/test/java/org/onap/aaf/cadi/filter/JU_FCGetTest.java b/core/src/test/java/org/onap/aaf/cadi/filter/JU_FCGetTest.java deleted file mode 100644 index b0308a5..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/filter/JU_FCGetTest.java +++ /dev/null @@ -1,99 +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.filter; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletContext; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.onap.aaf.cadi.PropAccess; - -public class JU_FCGetTest { - - @Mock - private ServletContext context; - - @Mock - private FilterConfig config; - - @Mock - private PropAccess access = new PropAccess(); - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testGetStringFromDef() { - PropAccess access = new PropAccess(); - - FCGet fcGet = new FCGet(access, context, config); - - String user = fcGet.get("user", "DefaultUser", true); - - assertEquals(user, "DefaultUser"); - } - - @Test - public void testGetStringFromContext() { - PropAccess access = new PropAccess(); - when(context.getInitParameter("user")).thenReturn("ContextUser"); - - FCGet fcGet = new FCGet(access, context, null); - - String user = fcGet.get("user", "DefaultUser", true); - - assertEquals(user,"ContextUser"); - } - - @Test - public void testGetStringFromFilter() { - PropAccess access = new PropAccess(); - when(config.getInitParameter("user")).thenReturn("FilterUser"); - - FCGet fcGet = new FCGet(access, null, config); - - String user = fcGet.get("user", "DefaultUser", true); - - assertEquals(user,"FilterUser"); - } - - @Test - public void testGetStringWithNullContextFilter() { - - when(access.getProperty("user", "DefaultUser")).thenReturn(null); - - FCGet fcGet = new FCGet(access, null, null); - - String user = fcGet.get("user", "DefaultUser", true); - - assertEquals(user,"DefaultUser"); - } -} diff --git a/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java b/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java deleted file mode 100644 index ec5d0a8..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java +++ /dev/null @@ -1,171 +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.lur; - -import static org.junit.Assert.*; - -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; - -public class JU_ConfigPrincipalTest { - - @Before - public void setUp() throws Exception { - } - - @Test - public void testConfigPrincipalStringString() { - ConfigPrincipal p = new ConfigPrincipal("User", "pass"); - - assertEquals(p.getName(), "User"); - assertEquals(p.toString(), "User"); - - } - - @Test - public void testConfigPrincipalStringByteArray() throws IOException { - byte[] bytes = "pass".getBytes(); - ConfigPrincipal p = new ConfigPrincipal("User", bytes); - - assertEquals(p.getName(), "User"); - assertEquals(p.getCred(), bytes); - assertEquals(p.toString(), "User"); - assertTrue(p.getAsBasicAuthHeader().startsWith("Basic")); - } - - @Test - public void testConfigPrincipalStringString2() { - ConfigPrincipal p = new ConfigPrincipal("Demo", "password"); - - assertEquals(p.getName(), "Demo"); - assertEquals(p.toString(), "Demo"); - - } - - @Test - public void testConfigPrincipalStringByteArray2() throws IOException { - byte[] bytes = "password".getBytes(); - ConfigPrincipal p = new ConfigPrincipal("Demo", bytes); - - assertEquals(p.getName(), "Demo"); - assertEquals(p.getCred(), bytes); - assertEquals(p.toString(), "Demo"); - assertTrue(p.getAsBasicAuthHeader().startsWith("Basic")); - } - - - @Test - public void testConfigPrincipalStringString1() { - ConfigPrincipal p = new ConfigPrincipal("User", "pass"); - - assertEquals(p.getName(), "User"); - assertEquals(p.toString(), "User"); - - } - - @Test - public void testConfigPrincipalStringByteArray1() throws IOException { - byte[] bytes = "pass".getBytes(); - ConfigPrincipal p = new ConfigPrincipal("User", bytes); - - assertEquals(p.getName(), "User"); - assertEquals(p.getCred(), bytes); - assertEquals(p.toString(), "User"); - assertTrue(p.getAsBasicAuthHeader().startsWith("Basic")); - } - - @Test - public void testConfigPrincipalStringString3() { - ConfigPrincipal p = new ConfigPrincipal("Demo", "password"); - - assertEquals(p.getName(), "Demo"); - assertEquals(p.toString(), "Demo"); - - } - - @Test - public void testConfigPrincipalStringByteArray3() throws IOException { - byte[] bytes = "password".getBytes(); - ConfigPrincipal p = new ConfigPrincipal("Demo", bytes); - - assertEquals(p.getName(), "Demo"); - assertEquals(p.getCred(), bytes); - assertEquals(p.toString(), "Demo"); - assertTrue(p.getAsBasicAuthHeader().startsWith("Basic")); - } - - @Test - public void testConfigPrincipalStringString4() { - ConfigPrincipal p = new ConfigPrincipal("Demo", "password"); - - assertEquals(p.getName(), "Demo"); - assertEquals(p.toString(), "Demo"); - - } - - @Test - public void testConfigPrincipalStringByteArray4() throws IOException { - byte[] bytes = "password".getBytes(); - ConfigPrincipal p = new ConfigPrincipal("Demo", bytes); - - assertEquals(p.getName(), "Demo"); - assertEquals(p.getCred(), bytes); - assertEquals(p.toString(), "Demo"); - assertTrue(p.getAsBasicAuthHeader().startsWith("Basic")); - } - - @Test - public void testConfigPrincipalStringByteArray5() throws IOException { - byte[] bytes = "password".getBytes(); - ConfigPrincipal p = new ConfigPrincipal("Demo", bytes); - - assertEquals(p.getName(), "Demo"); - assertEquals(p.getCred(), bytes); - assertEquals(p.toString(), "Demo"); - assertTrue(p.getAsBasicAuthHeader().startsWith("Basic")); - } - - @Test - public void testConfigPrincipalStringByteArray6() throws IOException { - byte[] bytes = "password".getBytes(); - ConfigPrincipal p = new ConfigPrincipal("Demo", bytes); - - assertEquals(p.getName(), "Demo"); - assertEquals(p.getCred(), bytes); - assertEquals(p.toString(), "Demo"); - assertTrue(p.getAsBasicAuthHeader().startsWith("Basic")); - } - - @Test - public void testConfigPrincipalStringByteArray7() throws IOException { - byte[] bytes = "password".getBytes(); - ConfigPrincipal p = new ConfigPrincipal("Demo", bytes); - - assertEquals(p.getName(), "Demo"); - assertEquals(p.getCred(), bytes); - assertEquals(p.toString(), "Demo"); - assertTrue(p.getAsBasicAuthHeader().startsWith("Basic")); - } -} diff --git a/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java b/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java deleted file mode 100644 index b04d00d..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java +++ /dev/null @@ -1,104 +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.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 org.onap.aaf.cadi.Lur; -import org.onap.aaf.cadi.Permission; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.Symm; -import org.onap.aaf.cadi.CredVal.Type; -import org.onap.aaf.cadi.config.UsersDump; -import org.onap.aaf.cadi.lur.LocalLur; -import org.onap.aaf.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("", 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, "".getBytes())); -// assertFalse(up.validate("m1234",Type.PASSWORD, "badPass".getBytes())); -// - // Check fishAll - Set set = new TreeSet(); - List perms = new ArrayList(); - 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/org/onap/aaf/cadi/lur/test/JU_TestAccess.java b/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_TestAccess.java deleted file mode 100644 index 1bdf765..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_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 org.onap.aaf.cadi.lur.test; - -import java.io.IOException; -import java.io.InputStream; - -import org.onap.aaf.cadi.Access; -import org.onap.aaf.cadi.Symm; - -public class JU_TestAccess implements Access { - private Symm symm; - - public JU_TestAccess() { - symm = Symm.obtain(this); - } - - public JU_TestAccess(Symm symmetric) { - symm = symmetric; - } - - public void log(Level level, Object... elements) { - boolean first = true; - for(int i=0;i=0) { - aa[i]=(byte)c; - } - } - System.out.println(new String(aa)); - - bsis.reset(); - - byte bb[] = new byte[400]; - for(int i=0;i=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=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 list = new ArrayList(); - list.add("method"); - assertEquals(Vars.convert(test, list), test); - } - - @Test - public void convertTest1() { - String test = "te%t"; - List list = new ArrayList(); - list.add("method"); - assertEquals(Vars.convert("test", list), "test"); - } - - @Test - public void convertTest2() { - String test = "te%s%t"; - List list = new ArrayList(); - list.add("method"); - assertEquals(Vars.convert("test", list), "test"); - } - -} diff --git a/core/src/test/java/org/onap/aaf/cadi/wsse/test/JU_WSSE_Read.java b/core/src/test/java/org/onap/aaf/cadi/wsse/test/JU_WSSE_Read.java deleted file mode 100644 index af45f55..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/wsse/test/JU_WSSE_Read.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.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 org.onap.aaf.cadi.BasicCred; -import org.onap.aaf.cadi.BufferedServletInputStream; -import org.onap.aaf.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