1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.authz.cm.cert;
\r
25 import static org.junit.Assert.*;
\r
26 import static org.mockito.Mockito.mock;
\r
28 import java.io.IOException;
\r
29 import java.security.cert.CertificateException;
\r
30 import java.security.cert.X509Certificate;
\r
32 import org.bouncycastle.asn1.x500.X500Name;
\r
33 import org.bouncycastle.operator.OperatorCreationException;
\r
34 import org.bouncycastle.pkcs.PKCS10CertificationRequest;
\r
35 import org.junit.BeforeClass;
\r
36 import org.junit.Rule;
\r
37 import org.junit.Test;
\r
38 import org.junit.rules.ExpectedException;
\r
39 import org.junit.runner.RunWith;
\r
40 import org.mockito.runners.MockitoJUnitRunner;
\r
41 import org.onap.aaf.authz.cm.cert.CSRMeta;
\r
43 import org.onap.aaf.cadi.cm.CertException;
\r
44 import org.onap.aaf.inno.env.Trans;
\r
46 @RunWith(MockitoJUnitRunner.class)
\r
47 public class JU_CSRMeta {
\r
49 private static CSRMeta csrmeta;
\r
50 private static Trans trans;
\r
51 private static PKCS10CertificationRequest req;
\r
54 public static void setUp() {
\r
55 trans = mock(Trans.class);
\r
56 csrmeta = new CSRMeta();
\r
58 csrmeta.email("pupleti@ht.com");
\r
59 csrmeta.mechID("HAKJH787");
\r
64 csrmeta.challenge("Challenge");
\r
69 public void x500Name() throws IOException {
\r
71 X500Name x500 = csrmeta.x500Name();
\r
72 assertEquals(x500.toString(),"CN=CN,E=pupleti@ht.com,OU=HAKJH787,O=O,L=L,ST=ST,C=C");
\r
76 public void initialConversationCert() throws CertificateException, OperatorCreationException, IOException {
\r
77 X509Certificate cert = csrmeta.initialConversationCert(trans);
\r
78 assertEquals(cert.getBasicConstraints(),-1);
\r
82 public void generateCSR() throws IOException, CertException {
\r
83 req = csrmeta.generateCSR(trans);
\r
88 public ExpectedException thrown= ExpectedException.none();
\r
91 public void dump() throws IOException, CertException {
\r
92 req = csrmeta.generateCSR(trans);
\r