summaryrefslogtreecommitdiffstats
path: root/auth/auth-certman
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-certman')
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_DevlCA.java280
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/cert/JU_CSRMeta.java88
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertReq.java90
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/JU_KeyMarshaling.java80
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/JU_SignTest.java109
5 files changed, 0 insertions, 647 deletions
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_DevlCA.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_DevlCA.java
deleted file mode 100644
index 13bf6108..00000000
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_DevlCA.java
+++ /dev/null
@@ -1,280 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.cm.ca;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.CALLS_REAL_METHODS;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateExpiredException;
-import java.security.cert.CertificateNotYetValidException;
-import java.security.cert.X509Certificate;
-import java.util.Date;
-import java.util.Set;
-
-import javax.security.auth.x500.X500Principal;
-import javax.servlet.http.HttpServletRequest;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.aaf.auth.cm.cert.CSRMeta;
-import org.onap.aaf.auth.dao.cached.CachedCertDAO;
-import org.onap.aaf.cadi.cm.CertException;
-import org.onap.aaf.misc.env.Trans;
-
-//TODO: Gabe [JUnit] Missing class
-@RunWith(MockitoJUnitRunner.class)
-public class JU_DevlCA {
-
- @Mock
- private static CachedCertDAO certDAO;
-
- @Mock
- private static HttpServletRequest req;
-
- @Mock
- private static CSRMeta csrMeta;
-
- static Trans trans;
-
- static X509andChain cert1;
- static byte [] name = {1,23,4,54,6,56};
-
- private static CA devICA;
-
- @BeforeClass
- public static void setUp() throws CertificateException, CertException, IOException {
- String str = "core java api";
- byte[] b = str.getBytes();
- Principal prc = new X500Principal("CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US");
- req = mock(HttpServletRequest.class);
- devICA = mock(CA.class);
- X509Certificate cert = new X509Certificate() {
-
- @Override
- public boolean hasUnsupportedCriticalExtension() {
- return false;
- }
-
- @Override
- public Set<String> getNonCriticalExtensionOIDs() {
-
- return null;
- }
-
- @Override
- public byte[] getExtensionValue(String oid) {
-
- return null;
- }
-
- @Override
- public Set<String> getCriticalExtensionOIDs() {
-
- return null;
- }
-
- @Override
- public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException, SignatureException {
-
-
- }
-
- @Override
- public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException,
- NoSuchProviderException, SignatureException {
-
-
- }
-
- @Override
- public String toString() {
-
- return null;
- }
-
- @Override
- public PublicKey getPublicKey() {
-
- return null;
- }
-
- @Override
- public byte[] getEncoded() throws CertificateEncodingException {
-
- return null;
- }
-
- @Override
- public int getVersion() {
-
- return 0;
- }
-
- @Override
- public byte[] getTBSCertificate() throws CertificateEncodingException {
-
- return null;
- }
-
- @Override
- public boolean[] getSubjectUniqueID() {
-
- return null;
- }
-
- @Override
- public Principal getSubjectDN() {
-
- return null;
- }
-
- @Override
- public byte[] getSignature() {
-
- return null;
- }
-
- @Override
- public byte[] getSigAlgParams() {
-
- return null;
- }
-
- @Override
- public String getSigAlgOID() {
-
- return null;
- }
-
- @Override
- public String getSigAlgName() {
-
- return null;
- }
-
- @Override
- public BigInteger getSerialNumber() {
-
- return null;
- }
-
- @Override
- public Date getNotBefore() {
-
- return null;
- }
-
- @Override
- public Date getNotAfter() {
-
- return null;
- }
-
- @Override
- public boolean[] getKeyUsage() {
-
- return null;
- }
-
- @Override
- public boolean[] getIssuerUniqueID() {
-
- return null;
- }
-
- @Override
- public Principal getIssuerDN() {
-
- return null;
- }
-
- @Override
- public int getBasicConstraints() {
-
- return 0;
- }
-
- @Override
- public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException {
-
-
- }
-
- @Override
- public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException {
-
- }
- };
- when(devICA.sign(Mockito.any(Trans.class), Mockito.any(CSRMeta.class))).thenReturn(cert1);
- certDAO = mock(CachedCertDAO.class, CALLS_REAL_METHODS);
- }
-
- @Test
- public void identity_True() throws CertificateException, IOException, CertException {
- assertNotNull(devICA.sign(trans, csrMeta));
- }
-
-
- @Test
- public void identityNull() throws CertificateException {
- try {
- assertNotNull(devICA.sign(null, csrMeta));
- } catch (IOException e) {
-
- e.printStackTrace();
- } catch (CertException e) {
-
- e.printStackTrace();
- }
- }
-
- @Test
- public void identityBothNull() throws CertificateException {
- try {
- assertNotNull(devICA.sign(null, null));
- } catch (IOException e) {
-
- e.printStackTrace();
- } catch (CertException e) {
-
- e.printStackTrace();
- }
- }
-
-}
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/cert/JU_CSRMeta.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/cert/JU_CSRMeta.java
deleted file mode 100644
index acf028c6..00000000
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/cert/JU_CSRMeta.java
+++ /dev/null
@@ -1,88 +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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.cm.cert;
-
-import static org.mockito.Mockito.mock;
-
-import java.util.List;
-
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.aaf.cadi.cm.CertException;
-import org.onap.aaf.misc.env.Trans;
-
-import junit.framework.Assert;
-
-@RunWith(MockitoJUnitRunner.class)
-public class JU_CSRMeta {
-
- private static CSRMeta csrmeta;
- private static Trans trans;
- private static PKCS10CertificationRequest req;
-
- @BeforeClass
- public static void setUp() throws CertException {
- trans = mock(Trans.class);
- List<RDN> lrdn = RDN.parse('/',"o=ATT Services, Inc/l=St Louis/st=Missouri/c=US");
-
- csrmeta = new CSRMeta(lrdn);
- }
-
-// @Test
-// public void x500Name() throws IOException {
-//
-// X500Name x500 = csrmeta.x500Name();
-// assertEquals(x500.toString(),"CN=CN,E=pupleti@ht.com,OU=HAKJH787,O=O,L=L,ST=ST,C=C");
-// }
-//
-// @Test
-// public void initialConversationCert() throws CertificateException, OperatorCreationException, IOException {
-// X509Certificate cert = csrmeta.initialConversationCert(trans);
-// assertEquals(cert.getBasicConstraints(),-1);
-// }
-//
-// @Test
-// public void generateCSR() throws IOException, CertException {
-// req = csrmeta.generateCSR(trans);
-// assertNotNull(req);
-// }
-
- @Rule
- public ExpectedException thrown= ExpectedException.none();
-
-// @Test
-// public void dump() throws IOException, CertException {
-// req = csrmeta.generateCSR(trans);
-// csrmeta.dump(req);
-// }
-
- @Test //TODO: Temporary fix AAF-111
- public void netYetTested() {
- Assert.fail("Tests not yet implemented");
- }
-
-}
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertReq.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertReq.java
deleted file mode 100644
index f54e36e1..00000000
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertReq.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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.auth.cm.data;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.aaf.auth.cm.ca.CA;
-import org.onap.aaf.auth.cm.ca.X509andChain;
-import org.onap.aaf.auth.cm.cert.BCFactory;
-import org.onap.aaf.auth.cm.cert.CSRMeta;
-import org.onap.aaf.auth.cm.data.CertReq;
-import org.onap.aaf.cadi.cm.CertException;
-import org.onap.aaf.misc.env.Trans;
-
-@RunWith(MockitoJUnitRunner.class)
-public class JU_CertReq {
-
- private static BCFactory bcFact;
-
- private static CSRMeta value;
-
- private static CertReq req;
-
- @BeforeClass
- public static void setUp() {
- bcFact = mock(BCFactory.class);
- value = mock(CSRMeta.class);
- req = mock(CertReq.class);
-
- }
-
-// @Test
-// public void getCSRMeta() throws CertException, IOException {
-// //req = new CertReq();
-// req.mechid = "1213";
-// List<String> fqdnsas = new ArrayList<String>();
-// fqdnsas.add("String1");
-// List<String> emails = new ArrayList<String>();
-// emails.add("pupleti@hotmail.com");
-// req.emails = emails;
-// req.fqdns = fqdnsas;
-// req.certAuthority = new CA(null, "testName", "ALL") {
-// //TODO: Gabe [JUnit] REREVIEW
-// @Override
-// public X509andChain sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException {
-//
-// return null;
-// }
-// };
-// req.sponsor = "asa@df.co";
-// assertNull(req.getCSRMeta());
-// }
-
- @Test //TODO: Temporary fix AAF-111
- public void netYetTested() {
- fail("Tests not yet implemented");
- }
-}
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/JU_KeyMarshaling.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/JU_KeyMarshaling.java
deleted file mode 100644
index 7b69d286..00000000
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/JU_KeyMarshaling.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package org.onap.aaf.auth.cm.test;
-
-import java.io.IOException;
-import java.security.KeyPair;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-
-import org.junit.AfterClass;
-import org.junit.Test;
-import org.onap.aaf.auth.env.AuthzEnv;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.cadi.cm.CertException;
-import org.onap.aaf.cadi.cm.Factory;
-
-import junit.framework.Assert;
-
-public class JU_KeyMarshaling {
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Test
- public void test() {
- AuthzEnv env = new AuthzEnv();
- AuthzTrans trans = env.newTrans();
- try {
- KeyPair kpair = Factory.generateKeyPair(trans);
- String privateString = Factory.toString(trans, kpair.getPrivate());
- System.out.println("Private as base64 encoded as PKCS8 Spec");
- System.out.println(privateString);
-
- // Take String, and create Private Key
- PrivateKey pk = Factory.toPrivateKey(trans, privateString);
- Assert.assertEquals(kpair.getPrivate().getAlgorithm(), pk.getAlgorithm());
- Assert.assertEquals(kpair.getPrivate().getFormat(), pk.getFormat());
- Assert.assertEquals(kpair.getPrivate().getEncoded(), pk.getEncoded());
-
-
- String s = Factory.toString(trans, kpair.getPublic());
- System.out.println("Public as base64 encoded x509 Spec");
- System.out.println(s);
-
- PublicKey pub = Factory.toPublicKey(trans, s);
- Assert.assertEquals(kpair.getPublic().toString(), pub.toString());
-
-
- } catch (IOException e) {
- e.printStackTrace();
- } catch (CertException e) {
- e.printStackTrace();
- } finally {
- StringBuilder sb = new StringBuilder("=== Timings ===\n");
- trans.auditTrail(1, sb);
- System.out.println(sb);
- }
- }
-
-}
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/JU_SignTest.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/JU_SignTest.java
deleted file mode 100644
index 93013d3f..00000000
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/JU_SignTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 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====================================================
- *
- */
-
-package org.onap.aaf.auth.cm.test;
-
-import java.io.File;
-import java.math.BigInteger;
-import java.security.KeyPair;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.cert.Certificate;
-import java.security.cert.X509Certificate;
-import java.security.interfaces.RSAPrivateKey;
-import java.security.interfaces.RSAPublicKey;
-import java.util.Collection;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Test;
-import static org.junit.Assert.fail;
-import org.onap.aaf.auth.env.AuthzEnv;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.cadi.cm.Factory;
-
-public class JU_SignTest {
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Test
- public void test() throws Exception {
- AuthzEnv env = new AuthzEnv();
- AuthzTrans trans = env.newTrans();
- KeyPair kpair = Factory.generateKeyPair(trans);
- PrivateKey privateKey = kpair.getPrivate();
- String privateString = Factory.toString(trans, privateKey);
- System.out.println("Private as base64 encoded as PKCS8 Spec");
- System.out.println(privateString);
-
- PublicKey publicKey = kpair.getPublic();
- String publicString = Factory.toString(trans, publicKey);
- System.out.println("public as base64 encoded as PKCS8 Spec");
- System.out.println(publicString);
-
- byte data[] = "Sign this please.".getBytes();
- byte sig[] = Factory.sign(trans, data, privateKey);
- System.out.println("Signature");
- System.out.println(Factory.toSignatureString(sig));
-
- Assert.assertTrue(Factory.verify(trans, data, sig, publicKey));
- }
-
-// @Test
-// public void test2() throws Exception {
-// AuthzEnv env = new AuthzEnv();
-// AuthzTrans trans = env.newTrans();
-// File key = new File("/opt/app/aaf/common/com.att.aaf.key");
-// PrivateKey privKey = Factory.toPrivateKey(trans, key);
-// RSAPrivateKey rPrivKey = (RSAPrivateKey)privKey;
-// BigInteger privMod, pubMod;
-// System.out.println((privMod = rPrivKey.getModulus()).toString(16));
-//
-// byte data[] = "Sign this please.".getBytes();
-// byte sig[] = Factory.sign(trans, data, privKey);
-// System.out.println("Signature");
-// System.out.println(Factory.toSignatureString(sig));
-//
-//
-// File crt = new File("/opt/app/aaf/common/com.att.aaf.crt");
-// Collection<? extends Certificate> x509s = Factory.toX509Certificate(trans, crt);
-// X509Certificate cert = null;
-// for(Certificate c : x509s) {
-// cert = (X509Certificate)c;
-// break;
-// }
-// PublicKey pubKey = cert.getPublicKey();
-// RSAPublicKey rPubKey = (RSAPublicKey)pubKey;
-//
-// System.out.println((pubMod = rPubKey.getModulus()).toString(16));
-//
-// Assert.assertTrue(Factory.verify(trans, data, sig, pubKey));
-// Assert.assertEquals(privMod,pubMod);
-//
-// }
-
- @Test //TODO: Temporary fix AAF-111
- public void netYetTested() {
- fail("Tests not yet implemented");
- }
-}